- // Is ext-sql_patches at least version 0.9.1?
- if (isExtensionInstalledAndNewer('sql_patches', '0.9.1')) {
- // Then log it away
- SQL_QUERY("INSERT INTO `{?_MYSQL_PREFIX?}_server_name_log` (`server_name`) VALUES('{%pipe,detectServerName%}')",
- __FUNCTION__, __LINE__);
+ // Is ext-sql_patches at least version 0.9.2?
+ if (isExtensionInstalledAndNewer('sql_patches', '0.9.2')) {
+ // Is there an entry?
+ if (countSumTotalData(detectServerName(), 'server_name_log', 'server_name_id', 'server_name', TRUE, str_replace('%', '{PER}', sprintf(" AND `server_name_remote_addr`='%s' AND `server_name_ua`='%s' AND `server_name_referrer`='%s'", sqlEscapeString(detectRemoteAddr(TRUE)), sqlEscapeString(detectUserAgent(TRUE)), sqlEscapeString(detectReferer(TRUE))))) == 1) {
+ // Update counter, as all are the same
+ sqlQueryEscaped("UPDATE
+ `{?_MYSQL_PREFIX?}_server_name_log`
+SET
+ `server_name_counter`=`server_name_counter`+1
+WHERE
+ `server_name`='%s' AND
+ `server_name_remote_addr`='%s' AND
+ `server_name_ua`='%s' AND
+ `server_name_referrer`='%s'
+LIMIT 1",
+ array(
+ detectServerName(),
+ detectRemoteAddr(TRUE),
+ detectUserAgent(TRUE),
+ detectReferer(TRUE)
+ ), __FUNCTION__, __LINE__);
+ } else {
+ // Then log it away
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_server_name_log` (`server_name`, `server_name_remote_addr`, `server_name_ua`, `server_name_referrer`) VALUES('%s','%s', '%s', '%s')",
+ array(
+ detectServerName(),
+ detectRemoteAddr(TRUE),
+ detectUserAgent(TRUE),
+ detectReferer(TRUE)
+ ), __FUNCTION__, __LINE__);
+ }