]> git.mxchange.org Git - mailer.git/commitdiff
Addded more fields to server_name_log table, fixed out-dated ext-admins
authorRoland Häder <roland@mxchange.org>
Sat, 3 Nov 2012 22:15:03 +0000 (22:15 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 3 Nov 2012 22:15:03 +0000 (22:15 +0000)
inc/extensions/ext-sql_patches.php
inc/http-functions.php
inc/libs/admins_functions.php
inc/wrapper-functions.php

index 72fa99753d0fe7413bb5e9c8efb3b14fa34c0c8c..12fe7602de75008c7d70b8487d76186346d3269c 100644 (file)
@@ -940,12 +940,26 @@ INDEX (`history_last_used` DESC)",
 `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&auml;gen hinzugef&uuml;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&auml;hler vergessen.");
+                               break;
                } // END - switch
                break;
 
index 317ba55e83d1599c86c31cec6240d7e0496616d4..4085f73176083f64efbbb4d123720ef57ba91ec2 100644 (file)
@@ -859,11 +859,37 @@ function getContentType () {
 
 // 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
 }
 
index 955748eb9ae454f78e48e5a91bf0343edbfcc6a6..31cfefdd208bdf51e65d16d9a0b08b08e857bc15 100644 (file)
@@ -513,9 +513,12 @@ function sendAdminsEmails ($subject, $template, $content, $userid) {
 
        // 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',
@@ -551,6 +554,9 @@ function sendAdminsEmails ($subject, $template, $content, $userid) {
                                        $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',
index e0244d0af44eff72fd5a853b9fe60d872058e29d..ce8ad1099950f6b4eed1ddf32f921f1c9eac0dce 100644 (file)
@@ -214,12 +214,12 @@ function isDirectory ($FQFN) {
 }
 
 // "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
@@ -229,12 +229,12 @@ function detectRealIpAddress () {
 }
 
 // "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
@@ -244,12 +244,12 @@ function detectRemoteAddr () {
 }
 
 // "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
@@ -274,12 +274,12 @@ function detectUserAgent ($alwaysReal = FALSE) {
 }
 
 // "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