function __construct() { global $gCache; $this->db = hg_checkDB(); $this->cache = $gCache; $this->mNodedir = CACHE_DIR . 'program/node/'; }
function __construct() { global $_INPUT, $gUser; $this->queue = new queue(); $this->user = $gUser; $this->db = hg_checkDB(); }
function __construct($settings = array()) { global $gCache; $this->cache = $gCache; $this->db = hg_checkDB(); $this->settings = $settings; }
public function rebuild_prms($group_id) { $this->db = hg_checkDB(); //取出所有模块 $sql = 'SELECT id, application_id FROM ' . DB_PREFIX . 'modules'; $q = $this->db->query($sql); $modules = array(); $module_application = array(); while ($row = $this->db->fetch_array($q)) { $modules[$row['application_id']][] = $row['id']; $module_application[$row['id']] = $row['application_id']; //记录模块所属的系统id } //取权限设置 $sql = 'SELECT * FROM ' . DB_PREFIX . 'prms WHERE admin_group_id=' . $group_id; $prms = $this->db->query_first($sql); $sys_prms = unserialize($prms['sys_prms']); $module_prms = unserialize($prms['module_prms']); //重建权限格式 $re_prms = array(); $set_module_appid = array(); if ($module_prms) { foreach ($module_prms as $mid => $op) { foreach ($op as $k => $v) { if ($v) { $appid = $module_application[$mid]; $set_module_appid[$k][$appid] = $appid; //记录已经设置模块权限的系统 $re_prms[$k][] = $mid; } } } } if ($sys_prms) { foreach ($sys_prms as $appid => $op) { foreach ($op as $k => $v) { if ($v) { //设置模块权限的系统不合并权限 if ($set_module_appid[$k] && in_array($appid, $set_module_appid[$k])) { //do nothing } else { if ($re_prms[$k]) { $re_prms[$k] = @array_merge($re_prms[$k], $modules[$appid]); } else { $re_prms[$k] = $modules[$appid]; } } } } } } $prms_str = '<?php $hg_group_prms = ' . var_export($re_prms, TRUE) . '; ?>'; if (hg_mkdir(CACHE_DIR . 'prms/')) { hg_file_write(CACHE_DIR . 'prms/ag_' . $group_id . '.php', $prms_str); return $re_prms; } else { exit(CACHE_DIR . 'program/' . $type . '目录创建失败,请检查目录权限.'); } }
public function create() { if (!$this->input['reffer_a']) { return; } $this->db = hg_checkDB(); $data = array('content' => serialize($this->input), 'module_id' => $this->input['mid'], 'admin_id' => $this->user['id'], 'op' => $this->input['reffer_a'], 'ip' => hg_getip(), 'create_time' => TIMENOW); hg_fetch_query_sql($data, 'last_submit_data'); }
function __construct() { global $_INPUT; global $gGlobalConfig; global $gCache; $this->db = hg_checkDB(); $this->cache = $gCache; $this->input = $_INPUT; }
function __construct() { global $_INPUT; global $gGlobalConfig; $this->db = hg_checkDB(); $this->input = $_INPUT; if ($gGlobalConfig['App_publishcontent']) { $this->curl = new curl($gGlobalConfig['App_publishcontent']['host'], $gGlobalConfig['App_publishcontent']['dir'] . 'admin/'); } }
function __construct() { global $_INPUT; global $gGlobalConfig; $this->db = hg_checkDB(); $this->input = $_INPUT; if (!$gGlobalConfig['App_block']) { return false; } $this->curl = new curl($gGlobalConfig['App_block']['host'], $gGlobalConfig['App_block']['dir']); }
public function add_log($content, $type = 'login') { if ($this->settings['App_logs']) { $this->add2log($content, $type); } else { $this->db = hg_checkDB(); if ($this->input['id']) { $ids = '(' . $this->input['id'] . ')'; } $ip = hg_getip(); $ipaddr = hg_getIpInfo($ip, 5); if ($ipaddr) { $zone = $ipaddr[0]['zone']; $service = $ipaddr[0]['service']; } $data = array('content' => $content . $ids, 'type' => $type, 'admin_id' => intval($this->user['id']), 'user_name' => $this->user['user_name'], 'group_type' => $this->user['group_type'], 'ip' => $ip, 'ip_info' => $zone . ' ' . $service, 'create_time' => TIMENOW, 'script_name' => SCRIPT_NAME . '::' . REFERRER); hg_fetch_query_sql($data, 'log'); } }
private function _getApplication($mid) { $db = hg_checkDB(); $sql = "SELECT * FROM " . DB_PREFIX . "modules WHERE id=" . $mid; $module = $db->query_first($sql); if (!$module) { exit('运行模块不存在'); } $application = hg_check_application(intval($module['application_id'])); if (!$application) { exit('应用不存在或已被删除'); } return $application; }
function __construct() { global $gCache; $this->db = hg_checkDB(); $this->cache = $gCache; }
function __construct() { global $_INPUT; $this->db = hg_checkDB(); $this->input = $_INPUT; }
require ROOT_PATH . 'lib/templates/template.php'; @(include ROOT_PATH . 'conf/proxy.conf.php'); $_SERVER['HTTP_REFERER'] = hg_clean_value($_SERVER['HTTP_REFERER']); define('REFERRER', $_SERVER['HTTP_REFERER']); $gTpl = new Templates($gProxyConf); if (DEVELOP_MODE) { $gTpl->setTemplateVersion(''); } else { $gTpl->setTemplateVersion(SOFTVAR . '/' . $gGlobalConfig['version']); } $gTpl->addVar('gProxyConf', $gProxyConf); $gCache = new class_functions(); if (DEVELOP_MODE) { } if (defined('WITH_DB') && WITH_DB) { $gDB = hg_checkDB(); } $_INPUT = hg_init_input(); if (!defined('WITHOUT_LOGIN') || !WITHOUT_LOGIN) { include ROOT_PATH . 'lib/session.php'; //用户登录session信息 $session = new Session(); //获取用户登录信息,这里将会存有用户的基础信息和权限部分 $gUser = $session->LoadSession($_INPUT['access_token']); if (!$gUser['id'] && !in_array(SCRIPT_NAME, array('login', 'register'))) { if (!$_INPUT['ajax']) { /*if ($_SERVER['query_string']) { $query_string = '?' . $_SERVER['query_string']; }*/ if ($_SERVER['QUERY_STRING']) {
public function menu() { $sql = 'SELECT * FROM ' . DB_PREFIX . 'modules ORDER BY order_id ASC, id ASC'; $q = $this->db->query($sql); $menu = array(); while ($row = $this->db->fetch_array($q)) { echo $row['name'] . '<br />'; if ($row['target']) { $atarget = ''; } else { $atarget = 'a=frame&'; } if (!$row['class_id']) { $row['class_id'] = 7; } if ($row['menu_pos'] == -1) { $menu[$row['application_id']][-1] = array('name' => $row['name'], 'module_id' => $row['id'], 'app_uniqueid' => $row['app_uniqueid'], 'mod_uniqueid' => $row['mod_uniqueid'], 'url' => 'run.php?' . $atarget . 'mid=' . $row['id'], 'close' => 0, 'order_id' => $row['order_id'], 'father_id' => $row['class_id'], 'include_apps' => $row['app_uniqueid'], '`index`' => 0); } if ($row['app_uniqueid'] == $row['mod_uniqueid']) { if (!$menu[$row['application_id']][-1]) { $menu[$row['application_id']][-1] = array('name' => $row['name'], 'module_id' => $row['id'], 'app_uniqueid' => $row['app_uniqueid'], 'mod_uniqueid' => $row['mod_uniqueid'], 'url' => 'run.php?' . $atarget . 'mid=' . $row['id'], 'close' => 0, 'father_id' => $row['class_id'], 'order_id' => $row['order_id'], 'include_apps' => $row['app_uniqueid'], '`index`' => 0); } } else { if ($row['menu_pos'] == 0) { $menu[$row['application_id']][] = array('name' => $row['name'], 'module_id' => $row['id'], 'app_uniqueid' => $row['app_uniqueid'], 'mod_uniqueid' => $row['mod_uniqueid'], 'url' => 'run.php?mid=' . $row['id'], 'close' => 0, 'father_id' => 0, 'order_id' => $row['order_id'], 'include_apps' => $row['app_uniqueid'], '`index`' => 0); } } } $sql = 'TRUNCATE TABLE ' . DB_PREFIX . 'menu'; $this->db->query($sql); $file = 'conf/init.data'; if (is_file($file)) { $content = file_get_contents($file); if ($content) { $this->db = hg_checkDB(); preg_match_all('/INSERT\\s+INTO\\s+(.*?)\\(.*?\\)\\s*;;/is', $content, $match); $insertsql = $match[0]; if ($insertsql) { //$this->db->mErrorExit = false; foreach ($insertsql as $sql) { echo $sql = preg_replace('/INSERT\\s+INTO\\s+([`]{0,1})liv_/is', 'INSERT INTO \\1' . DB_PREFIX, $sql); $this->db->query($sql); } //$this->db->mErrorExit = true; } } } $menus = $menu; foreach ($menus as $menu) { if ($menu[-1]) { $mmenu = $menu[-1]; $sql = 'SELECT * FROM ' . DB_PREFIX . "menu WHERE app_uniqueid='{$mmenu['app_uniqueid']}' AND mod_uniqueid='{$mmenu['mod_uniqueid']}'"; $q = $this->db->query_first($sql); if ($q) { $sql = 'UPDATE ' . DB_PREFIX . "menu SET name='{$mmenu['name']}', father_id={$mmenu['father_id']},url='{$mmenu['url']}', module_id='{$mmenu['module_id']}' WHERE id={$q['id']} "; $this->db->query($sql); } else { $sql = 'INSERT INTO ' . DB_PREFIX . 'menu (' . implode(',', array_keys($mmenu)) . ') VALUES '; $sql .= "('" . implode("','", $mmenu) . "')"; $this->db->query($sql); $q['id'] = $this->db->insert_id(); $sql = 'UPDATE ' . DB_PREFIX . "menu set include_apps=concat(include_apps, '{$mmenu['app_uniqueid']}', ',') WHERE id=" . intval($mmenu['father_id']); $this->db->query($sql); } foreach ($menu as $k => $mmenu) { if ($k != -1) { $mmenu['father_id'] = $q['id']; $sql = 'SELECT * FROM ' . DB_PREFIX . "menu WHERE app_uniqueid='{$mmenu['app_uniqueid']}' AND mod_uniqueid='{$mmenu['mod_uniqueid']}'"; $exist = $this->db->query_first($sql); if ($exist) { $sql = 'UPDATE ' . DB_PREFIX . "menu SET name='{$mmenu['name']}', father_id={$mmenu['father_id']},url='{$mmenu['url']}', module_id='{$mmenu['module_id']}' WHERE id={$exist['id']} "; $this->db->query($sql); } else { $sql = 'INSERT INTO ' . DB_PREFIX . 'menu (' . implode(',', array_keys($mmenu)) . ') VALUES '; $sql .= "('" . implode("','", $mmenu) . "')"; $this->db->query($sql); } } } } } $this->cache->recache('applications'); $this->cache->recache('modules'); $this->cache->recache('menu'); }
function __construct() { parent::__construct(); $this->db = hg_checkDB(); }
protected function record_search() { $hash = $this->input['search_hash']; if ($this->input['hg_search']) { $this->db = hg_checkDB(); unset($this->input['search_hash']); $search = serialize($this->input); $hash = md5($search . SCRIPT_NAME); $data = array('hash' => $hash, 'search' => $search, 'update_time' => TIMENOW); $sql = 'SELECT * FROM ' . DB_PREFIX . 'search WHERE hash=\'' . $hash . "'"; $search = $this->db->query_first($sql); if ($search) { $searchs = unserialize($search['search']); $conditicon = "hash='{$hash}'"; } else { $searchs = $this->input; } hg_fetch_query_sql($data, 'search', $conditicon); $sql = 'DELETE FROM ' . DB_PREFIX . 'search WHERE update_time < ' . (TIMENOW - 3600); //1小时前的搜索清理 $this->db->query($sql); } if ($hash && !$searchs) { $this->db = hg_checkDB(); $sql = 'SELECT hash,search FROM ' . DB_PREFIX . 'search WHERE hash=\'' . $hash . "'"; $search = $this->db->query_first($sql); $searchs = unserialize($search['search']); } if ($searchs) { $this->input['search_hash'] = $hash; $this->input = $searchs + $this->input; } }