I have on my PHP file a function that check if an IP is banned or not. For some reason my site is very slow and the problem is when I check if the IP is banned or not.
(I remove the code that checks and my site was fast again)
Here's my code:
// index.php - everything redirects to this file in the .htaccess
<?php
include('config.php');
if(isIpBanned($_SERVER['REMOTE_ADDR'])) {
die('access denied');
}
// rest of the code
here's my function
// config.php
<?php
function isIpBanned($db, $ip) { // $db is declared correctly
$goodIP = $db->getRecord("SELECT is_banned FROM security.ip WHERE ip = '$ip'"); // this function works and return 1 or 0
return (bool)$goodIP;
}
This query takes about 2 seconds to 3 seconds to run. Why? I don't have left join or other tables.
Thanks