]> git.mxchange.org Git - ctracker.git/blobdiff - libs/lib_connect.php
Added index + optimized query
[ctracker.git] / libs / lib_connect.php
index c0476d4ef4575f40c985c23fea96db5258b5311d..0af17e8556ebc7b4fc9ef02231c8a1f52d83c977 100644 (file)
@@ -312,10 +312,13 @@ function isCrackerTrackerIpSuspicious () {
        } // END - if
 
        // We only need the very last attempt to get!
-       $result = runCrackerTrackerSql("SELECT * FROM `ctracker_data` WHERE `remote_addr`='" . determineCrackerTrackerRealRemoteAddress() . "' OR `proxy_addr`='" . getenv('REMOTE_ADDR') . "' ORDER BY `last_attempt` DESC LIMIT 1", __FUNCTION__, __LINE__);
+       $result = runCrackerTrackerSql("SELECT SQL_SMALL_RESULT COUNT(`id`) AS `cnt` FROM `ctracker_data` USE INDEX (`remote_proxy_last`) WHERE `remote_addr`='" . determineCrackerTrackerRealRemoteAddress() . "' OR `proxy_addr`='" . getenv('REMOTE_ADDR') . "' ORDER BY `last_attempt` DESC LIMIT 1", __FUNCTION__, __LINE__);
 
-       // Do we have entries?
-       $found = (mysql_num_rows($result) == 1);
+       // Get row count
+       list($rows) = mysql_fetch_row($result);
+
+       // Is there one entry?
+       $found = ($rows > 0);
 
        // And again?
        if ($found === TRUE) {