`server_name_id` BIGINT (20) NOT NULL AUTO_INCREMENT,
`server_name` VARCHAR (255) NOT NULL DEFAULT 'invalid',
`server_name_added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+`server_name_remote_addr` VARCHAR (15) NOT NULL DEFAULT '0.0.0.0',
+`server_name_ua` TINYTEXT NULL DEFAULT NULL,
+`server_name_referrer` TINYTEXT NULL DEFAULT NULL,
+`server_name_counter` BIGINT (20) NOT NULL DEFAULT 0,
PRIMARY KEY (`server_name_id`)
", 'Logging of wrong SERVER_NAME');
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Loggen von falschen <strong>SERVER_NAME</strong> Einträgen hinzugefügt.");
break;
+
+ case '0.9.2': // SQL queries for v0.9.2
+ addExtensionAddTableColumnSql('server_name_log', 'server_name_remote_addr', "VARCHAR (15) NOT NULL DEFAULT '0.0.0.0'");
+ addExtensionAddTableColumnSql('server_name_log', 'server_name_counter', 'BIGINT (20) NOT NULL DEFAULT 0');
+ addExtensionAddTableColumnSql('server_name_log', 'server_name_ua', 'TINYTEXT NULL DEFAULT NULL');
+ addExtensionAddTableColumnSql('server_name_log', 'server_name_referrer', 'TINYTEXT NULL DEFAULT NULL');
+
+ // Update notes (these will be set as task text!)
+ setExtensionUpdateNotes("Sorry, hatte noch IP-Nummer, User-Agent, aufrufende Seite und Zähler vergessen.");
+ break;
} // END - switch
break;
// Logs wrong SERVER_NAME attempts
function logWrongServerNameRedirect () {
- // 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, sprintf(" AND `server_name_remote_addr`='%s' AND `server_name_ua`='%s' AND `server_name_referrer`='%s'", SQL_ESCAPE(detectRemoteAddr(TRUE)), SQL_ESCAPE(detectUserAgent(TRUE)), SQL_ESCAPE(detectReferer(TRUE)))) == 1) {
+ // Update counter, as all are the same
+ SQL_QUERY_ESC("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
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_server_name_log` (`server_name`, `server_name_remote_addr`, `server_name_ua`, `server_name_referral`) VALUES('%s','%s', '%s', '%s')",
+ array(
+ detectServerName(),
+ detectRemoteAddr(TRUE),
+ detectUserAgent(TRUE),
+ detectReferer(TRUE)
+ ), __FUNCTION__, __LINE__);
+ }
} // END - if
}
// No entries found?
if (SQL_HASZERONUMS($result)) {
- // Create new entry (to all admins)
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (`admin_id`, `mail_template`) VALUES (NULL, '%s')",
- array($template), __FUNCTION__, __LINE__);
+ // Is ext-admins' version at least 0.7.9?
+ if (isExtensionInstalledAndNewer('admins', '0.7.9')) {
+ // Create new entry (to all admins)
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_mails` (`admin_id`, `mail_template`) VALUES (NULL, '%s')",
+ array($template), __FUNCTION__, __LINE__);
+ } // END - if
// Select all email adresses (default)
$result = SQL_QUERY('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC',
$userid
));
}
+
+ // Abort here as below while() loop will cause problems
+ return;
} elseif (($adminId == '0') || (empty($adminId))) {
// Select all email adresses
$result = SQL_QUERY('SELECT `email` FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `id` ASC',
}
// "Getter" for the real remote IP number
-function detectRealIpAddress () {
+function detectRealIpAddress ($alwaysReal = FALSE) {
// Get remote ip from environment
$remoteAddr = determineRealRemoteAddress();
// Is removeip installed?
- if (isExtensionActive('removeip')) {
+ if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
// Then anonymize it
$remoteAddr = getAnonymousRemoteAddress($remoteAddr);
} // END - if
}
// "Getter" for remote IP number
-function detectRemoteAddr () {
+function detectRemoteAddr ($alwaysReal = FALSE) {
// Get remote ip from environment
$remoteAddr = determineRealRemoteAddress(TRUE);
// Is removeip installed?
- if (isExtensionActive('removeip')) {
+ if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
// Then anonymize it
$remoteAddr = getAnonymousRemoteAddress($remoteAddr);
} // END - if
}
// "Getter" for remote hostname
-function detectRemoteHostname () {
+function detectRemoteHostname ($alwaysReal = FALSE) {
// Get remote ip from environment
$remoteHost = getenv('REMOTE_HOST');
// Is removeip installed?
- if (isExtensionActive('removeip')) {
+ if ((isExtensionActive('removeip')) && ($alwaysReal === FALSE)) {
// Then anonymize it
$remoteHost = getAnonymousRemoteHost($remoteHost);
} // END - if
}
// "Getter" for referer
-function detectReferer () {
+function detectReferer ($alwaysReal = FALSE) {
// Get remote ip from environment
$referer = getenv('HTTP_REFERER');
// Is removeip installed?
- if (isExtensionActive('removeip')) {
+ if ((isExtensionActive('removeip')) && ($alwaysReal === TRUE)) {
// Then anonymize it
$referer = getAnonymousReferer($referer);
} // END - if