duangu9173 2015-11-09 10:08
浏览 42
已采纳

如何使用循环检查用户IP进行注册?

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)

  • 写回答

1条回答 默认 最新

  • dongmi1995 2015-11-11 07:56
    关注

    you can use ".table_user." and remove prefix_users in this code.

    and you can use || inside of if like this:

    if ($already_reg >= 1  || $already_reg2 >= 1) 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路