} return md5($hash . rand(1, 3000) . print_r($_SERVER, 1)); } // 目录不存在则创建 if (!is_dir($dir)) { mkdir($dir, 0777, true); } $iswafKey = iswaf_create_key(SITE_URL); $iswafConfig = array('iswaf_database' => $dir . '/', 'iswaf_connenct_key' => $iswafKey, 'iswaf_status' => 1, 'defences' => array('callback_xss' => 'On', 'upload' => 'On', 'inject' => 'On', 'filemode' => 'On', 'webshell' => 'On', 'server_args' => 'On', 'webserver' => 'On', 'hotfixs' => 'On')); //注册ts站点 $context = stream_context_create(array('http' => array('method' => "GET", 'timeout' => 10, 'user_agent' => "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"))); $url = 'http://www.fanghuyun.com/api.php?do=tsreg&IDKey=' . $iswafKey . '&url=' . SITE_URL . '&ip=' . get_client_ip(); $res = file_get_contents($url, false, $context); //dump($res);exit; file_put_contents($dir . '/config.php', "<?php\nreturn " . var_export($iswafConfig, true) . ";\n?>"); $menu['admin_menu']['index']['首页']['安全防护'] = 'http://www.fanghuyun.com/?do=simple&IDKey=' . md5($iswafKey); //2.如果防护云配置文件存在,但是没有关闭,启用防护云 } else { if (defined('iswaf_status') && iswaf_status != 0) { $context = stream_context_create(array('http' => array('method' => "GET", 'timeout' => 10, 'user_agent' => "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"))); $res = file_get_contents('http://www.fanghuyun.com/api.php?IDKey=' . iswaf_connenct_key . '&url=' . SITE_URL . '&ip=' . get_client_ip(), false, $context); //dump($res);exit; $menu['admin_menu']['index']['首页']['安全防护'] = 'http://www.fanghuyun.com/?do=simple&IDKey=' . md5(iswaf_connenct_key); } } $city_menu = array('admin_channel' => array('system' => L('PUBLIC_SYSTEM'), 'user' => L('PUBLIC_USER'), 'weiba' => '论坛'), 'admin_menu' => array('system' => array(L('PUBLIC_SYSTEM_SETTING') => array(L('PUBLIC_NAVIGATION_SETTING') => U('admin/Config/nav'))), 'user' => array(L('PUBLIC_USER') => array(L('PUBLIC_USER_MANAGEMENT') => U('admin/User/index'))), 'weiba' => array('版块列表' => array('版块列表' => U('weiba/Admin/index')), '增加版块' => array('增加版块' => U('weiba/Admin/addWeiba')), '版块分类' => array('版块分类' => U('weiba/Admin/weibaCate')), '帖子列表' => array('帖子列表' => U('weiba/Admin/postList')), '帖子回收站' => array('帖子回收站' => U('weiba/Admin/postRecycle')), '版主审核' => array('版主审核' => U('weiba/Admin/weibaAdminAudit')), '版块审核' => array('版块审核' => U('weiba/Admin/weibaAudit')), '首页帖子' => array('首页帖子' => U('weiba/Admin/indexPost'))))); $uid = $_SESSION['mid']; if ($uid != 1 && is_city_admin($uid)) { return $city_menu; } return $menu;
/** * 获取指定用户的权限集合 * @param integer $uid 用户ID * @return array 指定用户的权限集合 */ public function loadRule($uid) { if (empty($uid)) { return false; } if (empty(self::$permission[$uid])) { $permission = model('Cache')->get('perm_user_' . $uid); if (!$permission) { $userGroupids = model('UserGroupLink')->getUserGroup($uid); $userGroupids[$uid] && ($userGroup = model('UserGroup')->getUserGroup($userGroupids[$uid])); $permission = array(); // 先处理应用内的用户组 if (!empty($this->option['group'])) { $permission = $this->getGroupPermission($this->option['app'] . '_' . $this->option['group']); } foreach ($userGroup as $k => $v) { if ($v['user_group_type'] == 1) { // 特殊组 $permission = $this->getGroupPermission($v['user_group_id']); break; } $_p = $this->getGroupPermission($v['user_group_id']); // 追加到已有权限中 foreach ($_p as $app => $models) { foreach ($models as $model => $d) { if (isset($permission[$app][$model])) { $permission[$app][$model] = array_merge($permission[$app][$model], $d); } else { $permission[$app][$model] = $d; } } } } //增加城市管理员的登录权限 if (is_city_admin($uid)) { $permission['core']['admin']['admin_login'] = 1; } model('Cache')->set('perm_user_' . $uid, $permission, 600); } self::$permission[$uid] = $permission; } return self::$permission[$uid]; }