public function sendResponse($status, $param = array()) { $response = \Ouno\Ouno::getCoreClass('HttpResponse'); $this->response = new $response(); $this->response->setContentType($format); if ($status != 200) { $message = $this->response->getErrorMessage($status); $param = array_merge($message, $param); } $this->response->setStatus($status); $this->sendHeader(); echo $this->response->setBody($param); exit; }
<?php error_reporting(-1); define('APP_PATH', __DIR__ . '/app'); require "./Ouno/Ouno.php"; \Ouno\Ouno::getInstance()->run(APP_PATH, 'default');
/** * 路由分发,获取Uri数据参数 * 1. 对Service变量中的uri进行过滤 * 2. 配合全局站点url处理request * @return string */ public function parsePathRequest() { $filter_param = array('<', '>', '"', "'", '%3C', '%3E', '%22', '%27', '%3c', '%3e'); $request = array(); if (isset($_SERVER['PATH_INFO'])) { $path = str_replace($filter_param, '', $_SERVER['PATH_INFO']); $request = explode('/', trim($path, '/')); } $i = -1; if (\Ouno\Ouno::config('MODULE')) { $_GET['m'] = !empty($request[++$i]) ? $request[$i] : 'index'; unset($request[$i]); } $_GET['c'] = !empty($request[++$i]) ? $request[$i] : 'index'; unset($request[$i]); $_GET['a'] = !empty($request[++$i]) ? $request[$i] : 'index'; unset($request[$i]); if (count($request) >= 2) { foreach ($request as $k => $val) { if ($k % 2 == 0) { $key[] = $val; } else { $value[] = $val; } } if (count($key) !== count($value)) { $value[] = ''; } if (count($key) === count($value)) { $get = array_combine($value, $key); if (!empty($get)) { foreach ($get as $key => $value) { $_GET[$key] = $value; } } } $this->param['get'] = $_GET; } }