找回密码
 立即注册

QQ登录

只需一步,快速开始

UCenter防止恶意访问

uc_server/model/admin.php
搜索:
  1. $this->cookie_status = isset($_COOKIE['sid']) ? 1 : 0;
复制代码

添加:
  1. if(!$this->cookie_status){
  2.         include UC_ROOT.'../config/config_global.php';
  3.         $cookiepre = $_config['cookie']['cookiepre'].substr(md5($_config['cookie']['cookiepath'].'|'.$_config['cookie']['cookiedomain']), 0, 4).'_';
  4.         $auth = addslashes($_COOKIE[$cookiepre.'auth']);
  5.         if(empty($_config['cookie']['saltkey'])) {
  6.           $_config['cookie']['saltkey'] = addslashes($_COOKIE[$cookiepre.'saltkey']);
  7.         }
  8.         $authkey = md5($_config['security']['authkey'].$_config['cookie']['saltkey']);
  9.         $auth = daddslashes(explode("\t", $this->dauthcode($auth, 'DECODE',$authkey)));
  10.         list($discuz_pw, $discuz_uid) = empty($auth) || count($auth) < 2 ? array('', '') : $auth;
  11.         $discuz_uid = intval($discuz_uid);
  12.         $groupid = $this->db->result_first("SELECT groupid FROM ".$_config['db'][1]['tablepre']."common_member WHERE uid='$discuz_uid'");
  13.         if(!in_array($groupid,array('1','2'))){
  14.            header("HTTP/1.1 404 Not Found");header("Status: 404 Not Found");exit;
  15.         }
  16.       }
复制代码

  1. array('1','2')
复制代码
为指定可访问用户组
搜索:
  1. function __construct() {
  2.       $this->adminbase();
  3.   }
复制代码

加入:
  1. function dauthcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
  2.       $ckey_length = 4;
  3.       $key = md5($key );
  4.       $keya = md5(substr($key, 0, 16));
  5.       $keyb = md5(substr($key, 16, 16));
  6.       $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';

  7.       $cryptkey = $keya.md5($keya.$keyc);
  8.       $key_length = strlen($cryptkey);

  9.       $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;
  10.       $string_length = strlen($string);

  11.       $result = '';
  12.       $box = range(0, 255);

  13.       $rndkey = array();
  14.       for($i = 0; $i <= 255; $i++) {
  15.         $rndkey[$i] = ord($cryptkey[$i % $key_length]);
  16.       }

  17.       for($j = $i = 0; $i < 256; $i++) {
  18.         $j = ($j + $box[$i] + $rndkey[$i]) % 256;
  19.         $tmp = $box[$i];
  20.         $box[$i] = $box[$j];
  21.         $box[$j] = $tmp;
  22.       }

  23.       for($a = $j = $i = 0; $i < $string_length; $i++) {
  24.         $a = ($a + 1) % 256;
  25.         $j = ($j + $box[$a]) % 256;
  26.         $tmp = $box[$a];
  27.         $box[$a] = $box[$j];
  28.         $box[$j] = $tmp;
  29.         $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
  30.       }

  31.       if($operation == 'DECODE') {
  32.         if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) {
  33.           return substr($result, 26);
  34.         } else {
  35.           return '';
  36.         }
  37.       } else {
  38.         return $keyc.str_replace('=', '', base64_encode($result));
  39.       }

  40.   }
复制代码

本教程由无限星辰工作室CRX349独家整理和提供,转载请注明地址,谢谢。本文地址:https://www.xmspace.net/thread-782-1-1.html
无限星辰工作室  好集导航 Discuz全集下载  星辰站长网  集热爱361  一品文学  手机小游戏合集   海外空间网 星辰api  星辰支付二维码管理平台 阿里云服务器 腾讯云服务器
服务Discuz!建站|DiscuzQ配置|二开|小程序|APP|搬家|挂马清理|防护|Win/Linux环境搭建|优化|运维|
服务理念:专业 诚信 友好QQ842062626 服务项目 Q群315524225

发表于 2019-8-2 23:47:47 | 显示全部楼层 |阅读模式

回复 | 使用道具 举报

该帖共收到 0 条回复!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

美图秀

    • fastadmin 后台界面使用字段数组类型
    • Discuz!x3.5 修改标题高亮颜色
    • Discuz!x3.5 应用中心 下载应用一直下载中
    • 帖子定时显示
    • 论坛辅助审核
拖动客服框
Online Service
点击这里给我发消息
点击这里联系我们
微信扫一扫
在线客服
快速回复 返回顶部 返回列表