public function _initialize() { if (isset($_GET['code']) && hy_check($_GET['code'], 'un') == '#@_error') { hy_404(); } $this->registerPlugin("function", "func", array('appController', 'tpl_model')); }
/** * 加载类 * @access private * @return void */ private static function run() { $target = ROOT_PATH . GROUP_NAME . '/Controller/' . MODULE_NAME . "Controller.php"; if (file_exists($target)) { include_once $target; $class = MODULE_NAME . "Controller"; if (class_exists($class)) { $controller = new $class(); } else { hy_404(); //die('class does not exist!'); } if (ACTION_NAME) { if (!method_exists($controller, ACTION_NAME)) { hy_404(); //die('The method does not exist'); } else { $action = ACTION_NAME; $controller->{$action}(); } } } else { hy_404(); //die('page does not exist!'); } }
/** * 是否已登录 * @access public * @return void */ public function check_admin() { if (!Model('app')->check_admin() && ACTION_NAME != 'login' && ACTION_NAME != 'act_login' && ACTION_NAME != 'captcha') { header("Location:/qq_admin.php"); } elseif (ACTION_NAME == 'login' || ACTION_NAME == 'act_login') { if (!is_array($_COOKIE['QIAQIA']) || empty($_COOKIE['QIAQIA']['admin_access'])) { hy_404(); } } }
public function _initialize() { if (isset($_GET['code']) && hy_check($_GET['code'], 'un') == '#@_error') { hy_404(); } /*开启手机功能*/ //$cfg=Model('app')->get_cfg(); $is_wap = C('wap_support'); //需要在controller取消注释Model()->getCfg() if ($is_wap == 1) { $ua = strtolower($_SERVER['HTTP_USER_AGENT']); $uachar = "/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i"; if (($ua == '' || preg_match($uachar, $ua)) && !strpos(strtolower($_SERVER['REQUEST_URI']), 'wap')) { $Loaction = '?g=mobile&a=index&m=index'; if (!empty($Loaction)) { header("Location: {$Loaction}\n"); } } } $this->registerPlugin("function", "func", array('appController', 'tpl_model')); }
public function page() { $cache_id = $_GET['code'] . '-' . DEFAULT_LANG . '-' . session('user_id'); $cache_id = sprintf('%X', crc32($cache_id)); if (!$this->is_cached('page.html', $cache_id)) { $app = Model('app'); if (!($id = $app->code_to_id($_GET['code']))) { hy_404(); } $photo_id = $app->code_to_id($_GET['code']); $cat_list = $app->getCurClass($photo_id); $this->assign('cat', $cat_list); $config[c] = array('site_name' => $cat_list['name'] . '-' . $app->get_cfg('site_name')); $this->assign_global($config); $page = Model('article')->get_single_page($id); if ($page['form_id']) { Model('forms')->get_form($page['form_id']); } $this->assign('art', $page); } $this->display('page.html', $cache_id); }
public function index() { if (in_array($_GET['code'], array('wardrobe'))) { //$this->check_member(); } $page = $_GET['page'] > 0 ? intval($_REQUEST['page']) : 1; $cache_id = $_GET['code'] . '-' . DEFAULT_LANG . '-' . session('user_id'); $cache_id = sprintf('%X', crc32($cache_id)); if (!$this->is_cached($_GET['code'] . '.html', $cache_id)) { $app = Model('app'); if (!($id = $app->code_to_id($_GET['code']))) { hy_404(); } if ($_GET['code'] == 'storeimage') { $subclass = $app->getSubClass($id); $this->assign('sub', $subclass); } $pcat = $app->getPClass($id); $cat = $app->getCurClass($id); $config[c] = array('site_name' => $cat['name'] . '-' . $app->get_cfg('site_name')); $this->assign('cat', $cat); $this->assign_global($config); if ($_GET['code'] == 'birthdaty' || $_GET['code'] == 'integral') { $page_size = 8; } else { $page_size = 30; } $art_list = Model('photo')->get_photo_list($page, $id, $page_size); $this->assign('photo_list', $art_list['data']); $this->assign('show_page', $art_list['pagelink']); } if ($pcat['code'] == storeimage) { $tpl = 'store_view.html'; } else { $tpl = $_GET['code'] . '.html'; } $this->display($tpl, $cache_id); }
function define_request() { $request = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; $group = ''; $action = ''; $module = ''; $parsed = explode('&', $request); if (!empty($request)) { foreach ($parsed as $argument) { list($variable, $value) = explode('=', $argument); $getVars[$variable] = $value; } } if (!isset($getVars['g']) && !isset($getVars['m']) && !isset($getVars['a'])) { $getVars['g'] = 'home'; $getVars['m'] = 'index'; $getVars['a'] = 'index'; } if ($getVars['g']) { $group = '/' . ucfirst($getVars['g']); } else { $group = '/Home'; } if ($getVars['m']) { $module = "/Controller/" . $getVars['m'] . "Controller.php"; } else { hy_404(); } if ($getVars['a']) { $action = $getVars['a']; } define('GROUP_NAME', ucfirst($getVars['g'])); define('MODULE_NAME', $getVars['m']); define('ACTION_NAME', $getVars['a']); }