/** * 为指定的页面返回地址值 * @param int $pageno * @return string $url */ function _get_url($pageno = 1) { if (empty($this->page_tpl)) { return Tool::url_merge('page', $pageno, 'mvc,q'); } else { return str_replace('{page}', $pageno, $this->page_tpl); } }
/** * 为指定的页面返回地址值 * * @param int $pageno * @return string $url */ function _get_url($pageno = 1) { if (empty($this->page_tpl)) { return Tool::url_merge('page', $pageno, 'mvc,q'); } else { return sprintf($this->page_tpl, $pageno); } }
/** * 显示跟踪信息 * @return string */ public function showTrace() { $_trace = array(); $included_files = get_included_files(); // 系统默认显示信息 if (!empty($this->request->server['SCRIPT_NAME'])) { $_trace['请求脚本'] = $this->request->server['SCRIPT_NAME']; } $_trace['请求方法'] = $this->swoole->env['mvc']['controller'] . '/' . $this->swoole->env['mvc']['view']; $_trace['USER_AGENT'] = $this->request->server['HTTP_USER_AGENT']; $_trace['HTTP版本'] = $this->request->server['SERVER_PROTOCOL']; $_trace['请求时间'] = date('Y-m-d H:i:s', $this->request->server['REQUEST_TIME']); if (isset($_SESSION)) { $_trace['SESSION_ID'] = session_id(); } if ($this->swoole->db instanceof \Swoole\Database) { $_trace['读取数据库'] = $this->swoole->db->read_times . '次'; $_trace['写入数据库'] = $this->swoole->db->write_times . '次'; } $_trace['加载文件数目'] = count($included_files); $_trace['PHP执行占用'] = $this->showTime(); $_trace = array_merge($this->traceInfo, $_trace); // 调用Trace页面模板 $html = <<<HTMLS <style type="text/css"> #swoole_trace_content { font-family:\t\tConsolas, Courier New, Courier, monospace; font-size:\t\t\t14px; background-color:\t#fff; margin:\t\t\t\t40px; color:\t\t\t\t#000; border:\t\t\t\t#999 1px solid; padding:\t\t\t20px 20px 12px 20px; } </style> \t<div> \t\t<fieldset style="margin:5px;"> \t\t<div style="overflow:auto;text-align:left;"> HTMLS; $html .= "<a href='" . Tool::url_merge('_show_request', '1') . "'>显示请求参数</a> |\n <a href='" . Tool::url_merge('_show_session', '1') . "'>显示会话信息</a> |\n <a href='" . Tool::url_merge('_show_files', '1') . "'>显示加载的PHP文件</a>\n <hr/>"; foreach ($_trace as $key => $info) { $html .= $key . ' : ' . $info . BL; } if (!empty($this->request->get['_show_files'])) { //输出包含的文件 $html .= '加载的文件:' . BL . "<pre style='color: #666'>"; foreach ($included_files as $file) { $html .= $file . "\n"; } $html .= "</pre>"; } $html .= "</div></fieldset>"; $html .= "</div>"; if (!empty($this->request->get['_show_request'])) { $output = '<fieldset style="margin:5px;"><div style="overflow:auto;text-align:left;">'; $request = $this->swoole->request; $output .= "<h2>HEADER:</h2>" . Tool::dump($request->header); $output .= "<h2>SERVER:</h2>" . Tool::dump($request->server); if (!empty($request->files)) { $output .= "<h2>FILE:</h2>" . Tool::dump($request->files); } if (!empty($request->cookie)) { $output .= "<h2>COOKIES:</h2>" . Tool::dump($request->cookie); } if (!empty($request->get)) { $output .= "<h2>GET:</h2>" . Tool::dump($this->swoole->request->get); } if (!empty($request->post)) { $output .= "<h2>POST:</h2>" . Tool::dump($request->post); } $html .= $output . "</div></fieldset>"; } if (!empty($this->request->get['_show_session'])) { $output = '<fieldset style="margin:5px;"><div style="overflow:auto;text-align:left;">'; $this->session->start(); $output .= "<h2>SESSION:</h2>" . Tool::dump($request->session); $html .= $output . "</div></fieldset>"; } return $html; }