my web check users IP for registration with this part of code:
$userip=check_ip_behind_proxy();
//get today date
$today = date('Y-m-d',time());
//get yesterday date
$days_ago = date('Y-m-d', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));
//Get number of IP coincidences of registering user within logged in users YESTERDAY And TODAY
$already_reg=$db->get_var("SELECT COUNT(*) FROM `prefix_users` WHERE `user_lastlogin` like '%$today%' AND user_lastip = '$userip'");
$already_reg2=$db->get_var("SELECT COUNT(*) FROM `prefix_users` WHERE `user_lastlogin` like '%$days_ago%' AND user_lastip = '$userip'");
//if there is coincidence, no register allowed for that IP - he already has an account!
if ($already_reg >= 1){
$form_username_error[] = $main_smarty->get_config_vars('Register_Error_YourIpIsBanned');
$error = true;
}
//if there is coincidence, no register allowed for that IP - he already has an account!
if ($already_reg2 >= 1){
$form_username_error[] = $main_smarty->get_config_vars('Register_Error_YourIpIsBanned');
$error = true;
}
As you can see, we check user IP with two recent Day. how can I use LOOP to check users IP for N Days ago? (N=30 Days)
And how can I change 'prefix_users' to General Mode and not using directly "prefix" word? (user table)