/** * 将路由解析到的url参数信息保存早系统变量中 * * @return void */ protected function set_params() { if (isset($this->params['app'])) { $this->set_app(Base_Request::get_request('app', $this->_config['application'])); } $this->set_controller(Base_Request::get_request('controller', $this->_config['controller'])); $this->set_action(Base_Request::get_request('action', $this->_config['action'])); // 合并配置文件到变量 if (isset($this->_config['data']['POST']) && is_array($this->_config['data']['POST'])) { foreach ($this->_config['data']['POST'] as $_key => $_value) { if (!isset($_POST[$_key])) { $_POST[$_key] = $_value; } } } if (isset($this->_config['data']['GET']) && is_array($this->_config['data']['GET'])) { foreach ($this->_config['data']['GET'] as $_key => $_value) { if (!isset($_GET[$_key])) { $_GET[$_key] = $_value; } } } if (isset($_GET['page'])) { $_GET['page'] = max(intval($_GET['page']), 1); } return; }
/** * URL路径解析,pages 函数的辅助函数 * * @param string $par 传入需要解析的变量 默认为,page={$page} * @param string $url URL地址 * @return URL */ public static function url_par($par, $url = '') { if ($url == '') { $url = Base_Request::get_request_uri(); } $pos = strpos($url, '?'); if ($pos === false) { $url .= '?' . $par; } else { $querystring = substr(strstr($url, '?'), 1); parse_str($querystring, $pars); $query_array = array(); foreach ($pars as $k => $v) { if ($k == 'page') { continue; } $query_array[$k] = $v; } if ($query_array) { $querystring = http_build_query($query_array) . '&' . $par; } else { $querystring = $par; } $url = substr($url, 0, $pos) . '?' . $querystring; } return $url; }
/** * Agregamos una llamada al stack. * @param string $method Método llamado. * @param string $controller Controllador llamado. * @param string $action Acción llamada. * @param array $params Parametros de la llamada. * @param string $plugin Plugin si corresponde. */ public static function add_stack($method, $controller, $action, $params, $plugin) { if (!is_array(self::$request)) { self::$request = array(); } // Obtenemos metodo. $method = $method === NULL ? self::method() : $method; // Agregamos la petición al stack. self::$request[] = array('method' => $method, 'controller' => $controller, 'action' => $action, 'args' => $params, 'plugin' => $plugin); }
/** * url检查 * * 当$absolute === true且url不包含协议部分时,默认加上当前应用的协议部分. * * @param string $url 需要检查合法性的url * @param boolean $absolute 是否为绝对路径 * @return string */ public static function check_url($url, $absolute = true) { if ($absolute) { $_baseUrl = $absolute === true ? Base_Request::get_base_url(true) : $absolute; if (strpos($url, '://') === false) { $url = trim($_baseUrl, '/') . '/' . trim($url, '/'); } } return $url; }
/** * 判断用户是否已经登陆 */ public final function check_member() { $yuncms_auth = cookie('auth'); if (APP == 'member' && CONTROLLER == 'Passport') { return true; } else { // 判断是否存在auth cookie if (!empty($yuncms_auth)) { $yuncms_auth = String::authcode($yuncms_auth, 'DECODE', $this->auth_key); list($userid, $password) = explode("\t", $yuncms_auth); // 验证用户,获取用户信息 $this->memberinfo = $this->db->getby_userid($userid); // 获取用户模型信息 $this->db->set_model($this->memberinfo['modelid']); $_member_modelinfo = $this->db->getby_userid($userid); $_member_modelinfo = $_member_modelinfo ? $_member_modelinfo : array(); $this->db->set_model(); if (is_array($this->memberinfo)) { $this->memberinfo = array_merge($this->memberinfo, $_member_modelinfo); } if ($this->memberinfo && $this->memberinfo['password'] === $password) { if ($this->memberinfo['groupid'] == 2) { cookie('auth', ''); cookie('_userid', ''); cookie('_username', ''); cookie('_groupid', ''); showmessage(L('userid_banned_by_administrator', '', 'member'), U('member/passport/verify', array('t' => 1)), 301); } elseif ($this->memberinfo['groupid'] == 3) { cookie('auth', ''); cookie('_userid', ''); cookie('_groupid', ''); // 设置当前登录待验证账号COOKIE,为重发邮件所用 cookie('_regusername', $this->memberinfo['username']); cookie('_reguserid', $this->memberinfo['userid']); cookie('_reguseruid', $this->memberinfo['phpssouid']); cookie('email', $this->memberinfo['email']); showmessage(L('need_emial_authentication', '', 'member'), U('member/passport/register', array('t' => 2))); } $this->avatar = get_memberavatar($userid, false); } else { cookie('auth', ''); cookie('_userid', ''); cookie('_username', ''); cookie('_groupid', ''); } unset($userid, $password, $phpcms_auth, $auth_key); } else { $forward = isset($_GET['forward']) ? urlencode($_GET['forward']) : urlencode(Base_Request::get_url()); showmessage(L('please_login', '', 'member'), U('member/passport/login', array('forward' => $forward)), 301); } } }
public function _initialize() { if (C('router', SITE_HOST)) { // 加载基于域名的URL 路由配置 $this->_config = C('router', SITE_HOST); define('SUB_DOMAIN', strtolower(substr(SITE_HOST, 0, strpos(SITE_HOST, '.')))); // 二级域名定义 $this->params = array('action' => 2, 'controller' => 1); } else { // 使用默认路由配置 $this->_config = C('router', 'default'); } $full_url = Base_Request::get_host_info() . Base_Request::get_request_uri(); $this->_pathinfo = $_pathinfo = trim(str_replace(Base_Request::get_base_url(true), '', $full_url), '/'); }
?> ')" <?php if (isset($_GET['isurl']) && $_GET['isurl'] == 1) { echo 'checked'; } ?> > <?php echo L('yes'); ?> <input type="radio" name="info[isurl]" value="0" <?php if (!isset($_GET['isurl']) || isset($_GET['isurl']) && $_GET['isurl'] == 0) { echo 'checked'; } ?> onclick="redirect('<?php echo Base_Request::get_url() . '&isurl=0'; ?> ')"> <?php echo L('no'); ?> </td> </tr> <?php if (isset($_GET['isurl']) && $_GET['isurl'] == 1) { ?> <tr> <th><?php echo L('url'); ?> :</th> <td><input type="text" name="info[url]" class="input-text" size=80></td>
/** * 框架初始化 */ public static function init() { spl_autoload_register('Core::autoLoad'); if (!defined('CORE_FUNCTION') && !@(include FW_PATH . 'func.php')) { exit('func.php is missing'); } if (!defined('CUSTOM_FUNCTION') && !@(include FW_PATH . 'custom.php')) { exit('custom.php is missing'); } if (C('config', 'debug', false)) { define('IS_DEBUG', true); error_reporting(E_ALL); } else { define('IS_DEBUG', false); error_reporting(0); } set_error_handler('Core::_errorHandle', error_reporting()); set_exception_handler('Core::_exceptionHandle'); register_shutdown_function('Core::_shutdownHandle'); if (function_exists('date_default_timezone_set')) { @date_default_timezone_set(C('config', 'timezone', 'Etc/GMT-8')); } define('TIME', time()); define('IP', Base_Request::get_client_ip()); define('CHARSET', C('config', 'charset', 'UTF-8')); define('PHP_FILE', Base_Request::get_script_url()); define('SCRIPT_NAME', basename(PHP_FILE)); define('WEB_PATH', substr(PHP_FILE, 0, strrpos(PHP_FILE, '/')) . '/'); mb_internal_encoding(CHARSET); if (MAGIC_QUOTES_GPC) { $_POST = String::stripslashes($_POST); $_GET = String::stripslashes($_GET); $_COOKIE = String::stripslashes($_COOKIE); $_REQUEST = String::stripslashes($_REQUEST); } if (isset($_GET['page'])) { $_GET['page'] = max(intval($_GET['page']), 1); } if (!IS_CLI) { /* 协议 */ define('SITE_PROTOCOL', Base_Request::get_scheme() . '://'); /* 主机名 */ define('SITE_HOST', Base_Request::get_server_name()); /* 基础URL */ define('SITE_URL', htmlspecialchars(Base_Request::get_base_url(true)) . '/'); /* 设置来源 */ define('HTTP_REFERER', Base_Request::get_url_referer()); define('REQUEST_METHOD', Base_Request::get_request_method()); define('IS_GET', Base_Request::is_get()); define('IS_POST', Base_Request::is_post()); define('IS_PUT', Base_Request::is_put()); define('IS_DELETE', Base_Request::is_delete()); define('IS_AJAX', Base_Request::is_ajax()); @header('Content-Type: text/html; charset=' . CHARSET); @header('X-Powered-By: PHP/' . PHP_VERSION . ' Leaps/' . LEAPS_VERSION); // 页面压缩输出支持 if (C('config', 'gzip', true) && function_exists('ob_gzhandler')) { ob_start('ob_gzhandler'); } else { ob_start(); } } }
/** * (non-PHPdoc) * * @see Base_Router::_initialize() */ public function _initialize() { $this->_config = C('router', 'api'); $full_url = Base_Request::get_host_info() . Base_Request::get_request_uri(); $this->_pathinfo = $_pathinfo = trim(str_replace(Base_Request::get_base_url(true), '', $full_url), '/'); }
*/ @set_time_limit(1000); if (phpversion() < '5.2.0') { exit('您的php版本过低,不能安装本软件,请升级到5.2.0或更高版本再安装,谢谢!'); } defined('BASE_PATH') or define('BASE_PATH', dirname(dirname($_SERVER['SCRIPT_FILENAME'])) . DIRECTORY_SEPARATOR); require_once '../src/wekit.php'; define('INS_PATH', BASE_PATH . 'install' . DIRECTORY_SEPARATOR); if (file_exists(DATA_PATH . 'install.lock')) { exit('您已经安装过YUNCMS,如果需要重新安装,请删除 ' . DATA_PATH . 'install.lock 文件!'); } require_once INS_PATH . 'global.php'; $steps = (include INS_PATH . 'conf/step.php'); $step = isset($_REQUEST['step']) ? trim($_REQUEST['step']) : 1; $pos = strpos(Base_Request::get_url(), 'install/'); $siteurl = substr(Base_Request::get_url(), 0, $pos); if (strrpos(strtolower(PHP_OS), "win") === FALSE) { define('ISUNIX', TRUE); } else { define('ISUNIX', FALSE); } switch ($step) { case '1': // 安装许可协议 $license = file_get_contents(INS_PATH . "resource/license.txt"); include INS_PATH . "step/step_" . $step . ".tpl.php"; break; case '2': // 环境检测 (FTP帐号设置) $PHP_GD = ''; if (extension_loaded('gd')) {
public function init() { $a_k = trim($_GET['a_k']); if (!isset($a_k)) { showmessage(L('illegal_parameters')); } $a_k = String::authcode($a_k, 'DECODE', $this->auth_key); if (empty($a_k)) { showmessage(L('illegal_parameters')); } unset($i, $m, $f); parse_str($a_k); if (isset($i)) { $i = $id = intval($i); } if (!isset($m)) { showmessage(L('illegal_parameters')); } if (!isset($modelid) || !isset($catid)) { showmessage(L('illegal_parameters')); } if (empty($f)) { showmessage(L('url_invalid')); } $allow_visitor = 1; $MODEL = S('common/model'); $tablename = $this->db->table_name = $this->db->get_prefix() . $MODEL[$modelid]['tablename']; $this->db->table_name = $tablename . '_data'; $rs = $this->db->getby_id($id); $CATEGORYS = S('common/category_content'); $this->category = $CATEGORYS[$catid]; $this->category_setting = string2array($this->category['setting']); //检查文章会员组权限 $groupids_view = ''; if (isset($rs['groupids_view']) && !empty($rs['groupids_view'])) { $groupids_view = explode(',', $rs['groupids_view']); } if ($groupids_view && is_array($groupids_view)) { $_groupid = cookie('_groupid'); $_groupid = intval($_groupid); if (!$_groupid) { $forward = urlencode(Base_Request::get_url()); showmessage(L('login_website'), SITE_URL . 'index.php?app=member&controller=index&action=login&forward=' . $forward); } if (!in_array($_groupid, $groupids_view)) { showmessage(L('no_priv')); } } else { //根据栏目访问权限判断权限 $_priv_data = $this->_category_priv($catid); if ($_priv_data == '-1') { $forward = urlencode(Base_Request::get_url()); showmessage(L('login_website'), SITE_URL . 'index.php?app=member&controller=index&action=login&forward=' . $forward); } elseif ($_priv_data == '-2') { showmessage(L('no_priv')); } } //阅读收费 类型 $paytype = !empty($rs['paytype']) ? $rs['paytype'] : '0'; $readpoint = !empty($rs['readpoint']) ? $rs['readpoint'] : '0'; if ($readpoint || $this->category_setting['defaultchargepoint']) { if (!$readpoint) { $readpoint = $this->category_setting['defaultchargepoint']; $paytype = $this->category_setting['paytype']; } //检查是否支付过 $allow_visitor = self::_check_payment($catid . '_' . $id, $paytype, $catid); if (!$allow_visitor) { $http_referer = urlencode(Base_Request::get_url()); $allow_visitor = String::authcode($catid . '_' . $id . '|' . $readpoint . '|' . $paytype) . '&http_referer=' . $http_referer; } else { $allow_visitor = 1; } } if (preg_match('/(php|phtml|php3|php4|jsp|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\\.|$)/i', $f) || strpos($f, ":\\") !== FALSE || strpos($f, '..') !== FALSE) { showmessage(L('url_error')); } if (strpos($f, 'http://') !== FALSE || strpos($f, 'ftp://') !== FALSE || strpos($f, '://') === FALSE) { $yun_auth_key = md5($this->auth_key . $_SERVER['HTTP_USER_AGENT']); $a_k = urlencode(String::authcode("i={$i}&d={$d}&s={$s}&t=" . TIME . "&ip=" . IP . "&m=" . $m . "&f={$f}&modelid=" . $modelid, 'ENCODE', $yun_auth_key)); $downurl = '?app=content&controller=down&action=download&a_k=' . $a_k; } else { $downurl = $f; } header('HTTP/1.1 301 Moved Permanently'); //发出301头部 header('Location: ' . $downurl); //跳转到你希望的地址格式 }
?> "}).inputValidator({min:1, onerror:'<?php echo L('please_select_model'); ?> '});});</script></td> </tr> <?php if ($application) { ?> <tr> <th><?php echo L('selectingoperation'); ?> :</th> <td class="y-bg"><?php echo Form::radio($html['do'], $do, 'name="do" onclick="location.href=\'' . Base_Request::get_url() . '&do=\'+this.value"'); ?> </td> </tr> <?php } ?> <?php if (isset($html[$do]) && is_array($html[$do]) && $do) { foreach ($html[$do] as $k => $v) { ?> <tr> <th><?php echo $v['name']; ?> :</th>
/** * 生成内容页 */ public function show() { if (isset($_POST['dosubmit'])) { extract($_POST, EXTR_SKIP); $this->html = Loader::lib('content:html'); $modelid = intval($_POST['modelid']); if ($modelid) { // 设置模型数据表名 $this->db->set_model($modelid); $table_name = $this->db->table_name; if ($type == 'lastinput') { $offset = 0; } else { $page = max(intval($page), 1); $offset = $pagesize * ($page - 1); } $where = array('status' => 99); $order = 'ASC'; if (!isset($first) && is_array($catids) && $catids[0] > 0) { S('content/html_show_' . $_SESSION['userid'], $catids); $catids = implode(',', $catids); $where['catid'] = array('in', $catids); $first = 1; } elseif ($first) { $catids = S('content/html_show_' . $_SESSION['userid']); $catids = implode(',', $catids); $where['catid'] = array('in', $catids); } else { $first = 0; } if (count($catids) == 1 && $catids[0] == 0) { $message = L('create_update_success'); $forward = '?app=content&controller=create_html&action=show'; showmessage($message, $forward); } if ($type == 'lastinput' && $number) { $offset = 0; $pagesize = $number; $order = 'DESC'; } elseif ($type == 'date') { if ($fromdate) { $fromtime = strtotime($fromdate . ' 00:00:00'); $where['inputtime'] = array('egt', $fromtime); } if ($todate) { $totime = strtotime($todate . ' 23:59:59'); $where['inputtime'] = array('elt', $totime); } } elseif ($type == 'id') { $fromid = intval($fromid); $toid = intval($toid); if ($fromid) { $where['id'] = array('egt', $fromid); } if ($toid) { $where['id'] = array('elt', $toid); } } if (!isset($total) && $type != 'lastinput') { $total = $this->db->where($where)->count(); $pages = ceil($total / $pagesize); $start = 1; } $data = $this->db->where($where)->order(`id ` . $order)->limit($offset, $pagesize)->select(); $tablename = $this->db->table_name . '_data'; $this->url = Loader::lib('content:url'); foreach ($data as $r) { if ($r['islink']) { continue; } $this->db->table_name = $tablename; $r2 = $this->db->getby_id($r['id']); if ($r) { $r = array_merge($r, $r2); } if ($r['upgrade']) { $urls[1] = $r['url']; } else { $urls = $this->url->show($r['id'], '', $r['catid'], $r['inputtime']); } $this->html->show($urls[1], $r, 0, 'edit', $r['upgrade']); } if ($pages > $page) { $page++; $http_url = Base_Request::get_url(); $creatednum = $offset + count($data); $percent = round($creatednum / $total, 2) * 100; $message = L('need_update_items', array('total' => $total, 'creatednum' => $creatednum, 'percent' => $percent)); $forward = $start ? "?app=content&controller=create_html&action=show&type={$type}&dosubmit=1&first={$first}&fromid={$fromid}&toid={$toid}&fromdate={$fromdate}&todate={$todate}&pagesize={$pagesize}&page={$page}&pages={$pages}&total={$total}&modelid={$modelid}" : preg_replace("/&page=([0-9]+)&pages=([0-9]+)&total=([0-9]+)/", "&page={$page}&pages={$pages}&total={$total}", $http_url); } else { S('content/html_show_' . $_SESSION['userid'], ''); $message = L('create_update_success'); $forward = '?app=content&controller=create_html&action=show'; } showmessage($message, $forward, 200); } else { // 当没有选择模型时,需要按照栏目来更新 if (!isset($set_catid)) { if ($catids[0] != 0) { $update_url_catids = $catids; } else { foreach ($this->categorys as $catid => $cat) { if ($cat['child'] || $cat['type'] != 0) { continue; } $setting = string2array($cat['setting']); if (!$setting['content_ishtml']) { continue; } $update_url_catids[] = $catid; } } S('content/update_html_catid' . '-' . $_SESSION['userid'], $update_url_catids); $message = L('start_update'); $forward = "?app=content&controller=create_html&action=show&set_catid=1&pagesize={$pagesize}&dosubmit=1"; showmessage($message, $forward, 200); } if (count($catids) == 1 && $catids[0] == 0) { $message = L('create_update_success'); $forward = '?app=content&controller=create_html&action=show'; showmessage($message, $forward, 200); } $catid_arr = S('content/update_html_catid' . '-' . $_SESSION['userid']); $autoid = $autoid ? intval($autoid) : 0; if (!isset($catid_arr[$autoid])) { showmessage(L('create_update_success'), '?app=content&controller=create_html&action=show', 200); } $catid = $catid_arr[$autoid]; $modelid = $this->categorys[$catid]['modelid']; // 设置模型数据表名 $this->db->set_model($modelid); $table_name = $this->db->table_name; $page = max(intval($page), 1); $offset = $pagesize * ($page - 1); $where = array('status' => 99, 'catid' => $catid); $order = 'ASC'; if (!isset($total)) { $total = $this->db->where($where)->count(); $pages = ceil($total / $pagesize); $start = 1; } $data = $this->db->where($where)->order(`id ` . $order)->limit($offset, $pagesize)->select(); $tablename = $this->db->table_name . '_data'; $this->url = Loader::lib('content:url'); foreach ($data as $r) { if ($r['islink']) { continue; } // 写入文件 $this->db->table_name = $tablename; $r2 = $this->db->getby_id($r['id']); if ($r2) { $r = array_merge($r, $r2); } if ($r['upgrade']) { $urls[1] = $r['url']; } else { $urls = $this->url->show($r['id'], '', $r['catid'], $r['inputtime']); } $this->html->show($urls[1], $r, 0, 'edit', $r['upgrade']); } if ($pages > $page) { $page++; $http_url = Base_Request::get_url(); $creatednum = $offset + count($data); $percent = round($creatednum / $total, 2) * 100; $message = '【' . $this->categorys[$catid]['catname'] . '】 ' . L('have_update_items', array('total' => $total, 'creatednum' => $creatednum, 'percent' => $percent)); $forward = $start ? "?app=content&controller=create_html&action=show&type={$type}&dosubmit=1&first={$first}&fromid={$fromid}&toid={$toid}&fromdate={$fromdate}&todate={$todate}&pagesize={$pagesize}&page={$page}&pages={$pages}&total={$total}&autoid={$autoid}&set_catid=1" : preg_replace("/&page=([0-9]+)&pages=([0-9]+)&total=([0-9]+)/", "&page={$page}&pages={$pages}&total={$total}", $http_url); } else { $autoid++; $message = L('start_update') . $this->categorys[$catid]['catname'] . " ..."; $forward = "?app=content&controller=create_html&action=show&set_catid=1&pagesize={$pagesize}&dosubmit=1&autoid={$autoid}"; } showmessage($message, $forward, 200); } } else { $show_header = $show_dialog = ''; $admin_username = cookie('admin_username'); $modelid = isset($_GET['modelid']) ? intval($_GET['modelid']) : 0; $tree = Loader::lib('Tree'); $tree->icon = array(' │ ', ' ├─ ', ' └─ '); $tree->nbsp = ' '; $categorys = array(); if (!empty($this->categorys)) { foreach ($this->categorys as $catid => $r) { if ($r['type'] != 0 && $r['child'] == 0) { continue; } if ($modelid && $modelid != $r['modelid']) { continue; } if ($r['child'] == 0) { $setting = string2array($r['setting']); if (!$setting['content_ishtml']) { continue; } } $r['disabled'] = $r['child'] ? 'disabled' : ''; $categorys[$catid] = $r; } } $str = "<option value='\$catid' \$selected \$disabled>\$spacer \$catname</option>"; $tree->init($categorys); $string .= $tree->get_tree(0, $str); include $this->view('create_html_show'); } }
/** * (non-PHPdoc) * * @see Base_Router::_initialize() */ public function _initialize() { $this->_config = C('router', 'command'); $this->_pathinfo = trim(Base_Request::parse_cli_args(), '/'); }
/** * 返回包含由客户端提供的、跟在真实脚本名称之后并且在查询语句(query string)之前的路径信息 * * <pre>Example: * 请求: http://www.tintsoft.com/example/index.php?a=test * 返回: a=test * </pre> * * @throws Base_Exception */ private static function _init_path_info() { $request_uri = self::get_request_uri(); $script_url = self::get_script_url(); $base_url = self::get_base_url(); if (strpos($request_uri, $script_url) === 0) { $path_info = substr($request_uri, strlen($script_url)); } elseif ($base_url === '' || strpos($request_uri, $base_url) === 0) { $path_info = substr($request_uri, strlen($base_url)); } elseif (strpos($_SERVER['PHP_SELF'], $script_url) === 0) { $path_info = substr($_SERVER['PHP_SELF'], strlen($script_url)); } else { throw new Base_Exception('[Base.Base_Request._init_path_info] determine the entry path info failed!!'); } // if (($pos = strpos ( $path_info, '?' )) !== false) $path_info = // substr ( $path_info, $pos + 1 ); self::$_path_info = trim($path_info, '/'); }
/** * 栏目列表页 */ public function lists() { $catid = intval($_GET['catid']); $_priv_data = $this->_category_priv($catid); if ($_priv_data == '-1') { $forward = urlencode(Base_Request::get_url()); showmessage(L('login_website'), SITE_URL . 'index.php?app=member&controller=index&action=login&forward=' . $forward); } elseif ($_priv_data == '-2') { showmessage(L('no_priv')); } $_userid = $this->_userid; $_username = $this->_username; $_groupid = $this->_groupid; if (!$catid) { showmessage(L('category_not_exists'), 'blank'); } $CATEGORYS = S('common/category_content'); if (!isset($CATEGORYS[$catid])) { showmessage(L('category_not_exists'), 'blank'); } $CAT = $CATEGORYS[$catid]; extract($CAT); $setting = string2array($setting); // SEO if (!$setting['meta_title']) { $setting['meta_title'] = $catname; } $SEO = seo('', $setting['meta_title'], $setting['meta_description'], $setting['meta_keywords']); define('STYLE', $setting['template_list']); $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $template = isset($setting['category_template']) ? $setting['category_template'] : 'category'; $template_list = isset($setting['list_template']) ? $setting['list_template'] : 'list'; if ($type == 0) { $template = $child ? $template : $template_list; $arrparentid = explode(',', $arrparentid); $top_parentid = isset($arrparentid[1]) ? $arrparentid[1] : $catid; $array_child = array(); $self_array = explode(',', $arrchildid); // 获取一级栏目ids foreach ($self_array as $arr) { if ($arr != $catid && $CATEGORYS[$arr]['parentid'] == $catid) { $array_child[] = $arr; } } $arrchildid = implode(',', $array_child); // URL规则 $urlrules = S('common/urlrule'); $urlrules = str_replace('|', '~', $urlrules[$category_ruleid]); $tmp_urls = explode('~', $urlrules); $tmp_urls = isset($tmp_urls[1]) ? $tmp_urls[1] : $tmp_urls[0]; preg_match_all('/{\\$([a-z0-9_]+)}/i', $tmp_urls, $_urls); if (!empty($_urls[1])) { foreach ($_urls[1] as $_v) { $GLOBALS['URL_ARRAY'][$_v] = isset($_GET[$_v]) ? $_GET[$_v] : ''; } } define('URLRULE', $urlrules); $GLOBALS['URL_ARRAY']['categorydir'] = isset($categorydir) ? $categorydir : ''; $GLOBALS['URL_ARRAY']['catdir'] = isset($catdir) ? $catdir : ''; $GLOBALS['URL_ARRAY']['catid'] = isset($catid) ? $catid : ''; include template('content', $template); } else { // 单网页 $this->page_db = Loader::model('page_model'); $r = $this->page_db->getby_catid($catid); if ($r) { extract($r); } $template = isset($setting['page_template']) ? $setting['page_template'] : 'page'; $arrchild_arr = $CATEGORYS[$parentid]['arrchildid']; if ($arrchild_arr == '') { $arrchild_arr = $CATEGORYS[$catid]['arrchildid']; } $arrchild_arr = explode(',', $arrchild_arr); array_shift($arrchild_arr); $keywords = isset($keywords) ? $keywords : $setting['meta_keywords']; $SEO = seo(0, $title, $setting['meta_description'], $keywords); include template('content', $template); } }
function show_trace() { if (!Base_Request::is_ajax() && C('config', 'show_trace')) { $trace_page_tabs = array('BASE' => '基本', 'FILE' => '文件', 'INFO' => '流程', 'ERR|NOTIC' => '错误', 'SQL' => 'SQL', 'DEBUG' => '调试'); // 页面Trace可定制的选项卡 // 系统默认显示信息 $files = get_included_files(); $info = array(); foreach ($files as $key => $file) { $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )'; } $trace = array(); $base = array('请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['REQUEST_URI'], '运行时间' => show_time(), '内存开销' => MEMORY_LIMIT_ON ? number_format((memory_get_usage() - START_MEMORY) / 1024, 2) . ' kb' : '不支持', '查询信息' => N('db_query') . ' queries ' . N('db_write') . ' writes ', '文件加载' => count(get_included_files()), '缓存信息' => N('cache_read') . ' gets ' . N('cache_write') . ' writes ', '会话信息' => 'SESSION_ID=' . session_id()); $debug = trace(); foreach ($trace_page_tabs as $name => $title) { switch (strtoupper($name)) { case 'BASE': // 基本信息 $trace[$title] = $base; break; case 'FILE': // 文件信息 $trace[$title] = $info; break; default: // 调试信息 $name = strtoupper($name); if (strpos($name, '|')) { // 多组信息 $array = explode('|', $name); $result = array(); foreach ($array as $name) { $result += isset($debug[$name]) ? $debug[$name] : array(); } $trace[$title] = $result; } else { $trace[$title] = isset($debug[$name]) ? $debug[$name] : ''; } } } } include FW_PATH . 'errors' . DIRECTORY_SEPARATOR . 'trace.php'; }