public static function run() { LJL_Registry::set('request', new LJL_Request()); $request = LJL_Registry::get('request'); LJL_Registry::set('response', new LJL_Response()); $response = LJL_Registry::get('response'); $controller = $request->getControllerName(); $action = $request->getActionName(); $controller = LJL_String::toValidVariableName($controller); $action = LJL_String::toValidVariableName($action); if (empty($controller)) { throw new LJL_Exception("The controller of '{$controller}' is empty in request!"); } if (empty($action)) { throw new LJL_Exception("The action of '{$action}' is empty in request!"); } $controller = APP_NAME . '_Page_' . ucfirst($controller); //var_dump($controller); $page = new $controller($request, $response); self::$_page = $page; self::$_url = empty($_SERVER['SCRIPT_URL']) ? '' : $_SERVER['SCRIPT_URL']; self::$_cacheKey = self::getCacheKey(); //var_dump($page); if ($page->isCache() && ($html = self::getCache())) { die($html); } if ($page->validate($request, $response)) { $actionMap = $page->getActionMapping(); if (empty($actionMap)) { $action = 'do' . ucfirst($action); if (method_exists($page, $action)) { $page->{$action}($request, $response); } else { throw new LJL_Exception("The function of '{$action}' does not exist in class '{$controller}'!"); } } else { foreach ($actionMap[$action] as $methodName) { $methodName = 'do' . ucfirst($methodName); if (method_exists($page, $methodName)) { $page->{$methodName}($request, $response); } else { throw new LJL_Exception(' the function dose not exist:' . $methodName); } } } } self::$_html = $response->display(); $page->isCache() && self::setCache(); }
public static function handler($exception) { if ($exception instanceof Exception) { $debugging = defined('IS_DEBUGGING') ? IS_DEBUGGING : false; $production = defined('IS_PRODUCTION') ? IS_PRODUCTION : false; if (true == $debugging) { if (true == $production) { LJL_Log::write(LJL_String::clean($exception), LJL_Log::TYPE_EXCEPTION); } else { echo LJL_Request::resolveType() == LJL_Request::CLI ? LJL_String::clean($exception) : $exception; } } else { header('location: ' . WWW_WEB); } } }
public static function handler($level, $errorMsg, $file, $line, $context = null) { if ('.tpl.php' == substr($file, -8)) { return; } $str = new LJL_Exception($errorMsg, $level, $file, $line); $debugging = IS_DEBUGGING; $production = IS_PRODUCTION; if ($debugging) { $content = "<br />\n<h2>Error Info:</h2>\n" . '<b>MESSAGE:</b> ' . $errorMsg . "<br />\n" . '<b>TYPE:</b> ' . (isset(self::$levels[$level]) ? self::$levels[$level] : $level) . "<br />\n" . '<b>FILE:</b> ' . $file . "<br />\n" . '<b>LINE:</b> ' . $line . "<br />\n" . $str; if ($production) { LJL_Log::write(LJL_String::clean($content), LJL_Log::TYPE_ERROR); } else { echo LJL_Request::resolveType() == LJL_Request::CLI ? LJL_String::clean($content) : $content; } } }
public function getByMethod($key = '', $method = 'get', $allowTags = false) { $ret = ''; if (empty($key)) { if (false === $allowTags) { $ret = LJL_String::clean($this->_a[$method]); } else { $ret = $this->_a[$method]; } } elseif (isset($this->_a[$method][$key])) { // don't operate on reference to avoid segfault :-( $ret = $this->_a[$method][$key]; // if html not allowed, run an enhanced strip_tags() if (false === $allowTags) { $ret = LJL_String::clean($ret); } } if (!empty($ret)) { if (self::AJAX == $this->getType() && strcasecmp(SYSTEM_CHARSET, 'utf-8')) { if (in_array(strtolower($method), array('get', 'post')) && !empty($ret)) { $ret = LJL_String::convertEncodingDeep($ret, SYSTEM_CHARSET, 'utf-8'); } } } return $ret; }