Discuz教程网

[代码修改] 【DSU】打卡机 2.41加入限制IP段打卡功能

[复制链接]
authicon dly 发表于 2012-5-11 22:39:44 | 显示全部楼层 |阅读模式
语言包加入:

<item id="addresserr"><![CDATA[不在允许签到范围内]]></item>

pper.inc.php文件中
将下边这段代码:
  1. if(!empty($_G['gp_ajax']) && $_G['uid']){
  2. $_G['gp_formhash'] =strip_tags($_G['gp_formhash']);
  3. $formhash = 0;
  4. if($_G['gp_formhash'] == $_G['formhash']){$formhash = 1;}
  5. if($formhash){
  6. $dsu_amuppercked = dsu_amupper();
  7. if($dsu_amupperimage){
  8. $returnajax = $return_img;
  9. }else{
  10. $returnajax = $return_txt;
  11. }
  12. include template('dsu_amupper:ajax');
  13. }
  14. }
复制代码

改为:
  1. if(!mip()){
  2. $returnajax = lang("plugin/dsu_amupper","addresserr");
  3. include template('dsu_amupper:ajax');
  4. }else if(!empty($_G['gp_ajax']) && $_G['uid']){
  5. $_G['gp_formhash'] =strip_tags($_G['gp_formhash']);
  6. $formhash = 0;
  7. if($_G['gp_formhash'] == $_G['formhash']){$formhash = 1;}
  8. if($formhash){
  9. $dsu_amuppercked = dsu_amupper();
  10. if($dsu_amupperimage){
  11. $returnajax = $return_img;
  12. }else{
  13. $returnajax = $return_txt;
  14. }
  15. include template('dsu_amupper:ajax');
  16. }
  17. }

  18. function mip(){
  19. if (!empty($_SERVER['HTTP_CLIENT_IP']))
  20. $ip=$_SERVER['HTTP_CLIENT_IP'];
  21. else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
  22. $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  23. else
  24. $ip=$_SERVER['REMOTE_ADDR'];
  25. if(substr($ip,0,2)=="127")
  26. return true;
  27. else
  28. return false;
  29. }
复制代码

下边这段代码中“if(substr($ip,0,2)=="127")”为检验来访IP头两位是不是127,可以按照自己的需求修改



上一篇:【DSU】【免费插件】一键哀悼For Discuz X1.5-X2-X2.5
下一篇:用笨方法实现让游客参与活动--X2.5版本
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2024-5-15 16:26

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表