]> git.mxchange.org Git - mailer.git/blobdiff - inc/http-functions.php
Rewrote else blocks (avoided them)
[mailer.git] / inc / http-functions.php
index 317ba55e83d1599c86c31cec6240d7e0496616d4..67a70435983f725096b859e352b7750c8fbbdb88 100644 (file)
@@ -551,7 +551,7 @@ function unchunkHttpResponse ($response) {
                //* DEBUG: */ die('tempResponse['.strlen($tempResponse).']=<pre>'.replaceReturnNewLine(htmlentities($tempResponse)).'</pre>');
 
                // Re-add the headers
-               $response = merge_array($GLOBALS['http_headers'], stringToArray(chr(10), $tempResponse));
+               $response = merge_array($GLOBALS['http_headers'], stringToArray(PHP_EOL, $tempResponse));
        } // END - if
 
        // Return the unchunked array
@@ -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, str_replace('%', '{PER}', 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_referrer`) VALUES('%s','%s', '%s', '%s')",
+                               array(
+                                       detectServerName(),
+                                       detectRemoteAddr(TRUE),
+                                       detectUserAgent(TRUE),
+                                       detectReferer(TRUE)
+                               ), __FUNCTION__, __LINE__);
+               }
        } // END - if
 }