Mybb注册地域限制插件

阅读更多
上一篇文件关于Mybb注册地域限制的文章是在web前端实现,需要javascript的支持,如果用户限制javascript的运行就不可以了,特别是一些东欧国家所用浏览器非常古老,他们不自觉地就突破了web前端的限制,没有办法,只好办后台。代码如下:

Please make sure IN_MYBB is defined."); } $plugins->add_hook("datahandler_user_validate", "ipcheck_end"); function ipcheck_info() { return array( "name"=> "ipcheck", "description"=>"检测注册用户IP合法性", "website"=> "", "author"=>"cai21cn", "authorsite"=> "", "version"=> "1.0", "compatibility" =>"*", "guid"=>"", ); } function ipcheck_end(&$user) { global $mybb, $lang; // if we created the user registration detection, check it! if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } $file = iconv("GBK","UTF-8",file_get_contents("http://whois.pconline.com.cn/ip.jsp?ip=".$ip)); if (strpos($file,"湖北")===false){ //$user->set_error($file." * 1抱歉,仅限湖北省内用户注册!".$ip); $user->set_error("抱歉,仅限湖北省内用户注册!"); }else{ // $user->set_error($file." * 2抱歉,仅限湖北省内用户注册!".$ip); } } ?>


插件的安装使用请参阅www.mybb.com

你可能感兴趣的:(Mybb注册地域限制插件)