setMarkupEscaped(false); $parser->setSafeMode(false); try { SiteMeta::load(); // 格式化所给链接,并将链接转化为路径字符串数组 $tmp = $_GET['p']; if (strlen($tmp) > 0 && $tmp[strlen($tmp) - 1] === '/') $tmp = substr($tmp, 0, -1); $uri = explode("/", $tmp, 2); if (sizeof($uri) > 0 && $uri[0] != null) { // 非主页面,判定当前定义的 book $tmp = SiteMeta::getBookshelf()->getBook($uri[0]); if ($tmp == null) throw new Exception("Book required \"$uri[0]\" not found!"); PageMeta::$book = $tmp->getContentedNode(); // 判定当前页面 if (sizeof($uri) > 1 && $uri[1] != null) { $tmp = PageMeta::$book->getPage($uri[1]); if ($tmp == null) throw new Exception("Page required \"$uri[1]\" not found on book \"$uri[0]\"!"); PageMeta::$page = $tmp; } else { PageMeta::$page = PageMeta::$book->getChilds()->getChilds()[0]; } } else { // 主页面 PageMeta::$book = SiteMeta::getBookshelf()->getRootBook(); PageMeta::$page = PageMeta::$book->getChilds()->getChilds()[0]; PageMeta::$isMainPage = true; } require "./template/header.php"; ?>
" . $e->getMessage() . "
"; }