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 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作