$v){ if ($v == PATH_ARCHIVES) { continue; } if ($v{0} == 'C') { /* category */ $serendipity['GET']['category'] = substr($v, 1); unset($_args[$k]); } elseif ($v{0} == 'W') { /* Week */ $week = substr($v, 1); unset($_args[$k]); } elseif ($v == 'summary') { /* Summary */ $serendipity['short_archives'] = true; unset($_args[$k]); } elseif ($v{0} == 'P') { /* Page */ $serendipity['GET']['page'] = substr($v, 1); unset($_args[$k]); unset($serendipity['uriArguments'][$k]); } } /* We must always *assume* that Year, Month and Day are the first 3 arguments */ list(,$year, $month, $day) = $_args; $serendipity['GET']['action'] = 'read'; $serendipity['GET']['hidefooter'] = true; if ( !isset($year) ) { $year = date('Y'); $month = date('m'); $day = date('j'); $serendipity['GET']['action'] = null; $serendipity['GET']['hidefooter'] = null; } if ($week) { $tm = strtotime('+ '. ($week-2) .' WEEKS monday', mktime(0, 0, 0, 1, 1, $year)); $ts = mktime(0, 0, 0, date('m', $tm), date('j', $tm), $year); $te = mktime(23, 59, 59, date('m', $tm), date('j', $tm)+7, $year); $date = serendipity_formatTime(WEEK .' '. $week .', %Y', $ts, false); } else { if ($day) { $ts = mktime(0, 0, 0, $month, $day, $year); $te = mktime(23, 59, 59, $month, $day, $year); $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false); } else { $ts = mktime(0, 0, 0, $month, 1, $year); $te = mktime(23, 59, 59, $month, date('t', $ts), $year); $date = serendipity_formatTime('%B %Y', $ts, $false); } } $serendipity['range'] = array($ts, $te); if ($serendipity['GET']['action'] == 'read') { $serendipity['head_subtitle'] = sprintf(ENTRIES_FOR, $date); } ob_start(); include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); $data = ob_get_contents(); ob_end_clean(); if (isset($serendipity['pregenerate']) && $serendipity['pregenerate']) { $fp = fopen('./'.PATH_ARCHIVES.'/' . $matches[1], 'w'); fwrite($fp, $data); fclose($fp); } echo $data; } else if (preg_match(PAT_COMMENTSUB, $uri, $matches)) { serendipity_rememberComment(); if (!empty($serendipity['POST']['submit'])) { $comment['url'] = $serendipity['POST']['url']; $comment['comment'] = trim($serendipity['POST']['comment']); $comment['name'] = $serendipity['POST']['name']; $comment['email'] = $serendipity['POST']['email']; $comment['subscribe'] = $serendipity['POST']['subscribe']; $comment['parent_id'] = $serendipity['POST']['replyTo']; if (!empty($comment['comment'])) { if (serendipity_saveComment($serendipity['POST']['entry_id'], $comment, 'NORMAL')) { $sc_url = $_SERVER['REQUEST_URI'] . (strstr($_SERVER['REQUEST_URI'], '?') ? '&' : '?') . 'serendipity[csuccess]=' . $serendipity['csuccess']; if (serendipity_isResponseClean($sc_url)) { header('Location: ' . $sc_url); } exit; } else { $serendipity['messagestack']['comments'][] = COMMENT_NOT_ADDED; } } else { $serendipity['messagestack']['comments'][] = sprintf(EMPTY_COMMENT, '', ''); } } $id = (int)$matches[1]; serendipity_track_referrer($id); $track_referer = false; $_GET['serendipity']['action'] = 'read'; $_GET['serendipity']['id'] = $id; $title = serendipity_db_query("SELECT title FROM {$serendipity['dbPrefix']}entries WHERE id=$id", true); $serendipity['head_title'] = $title[0]; $serendipity['head_subtitle'] = $serendipity['blogTitle']; ob_start(); include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); $data = ob_get_contents(); ob_end_clean(); if (isset($serendipity['pregenerate']) && $serendipity['pregenerate']) { $fp = fopen($serendipity['serendipityPath'] . PATH_ARCHIVES.'/' . $id, 'w'); fwrite($fp, $data); fclose($fp); } print $data; } elseif (preg_match(PAT_FEEDS, $uri)) { header('Content-Type: text/html; charset=utf-8'); if (preg_match('@/(index|atom|rss|comments|opml)\.(rss[0-9]?|rdf|rss|xml|atom)$@', $uri, $matches)) { list($_GET['version'], $_GET['type']) = serendipity_discover_rss($matches[1], $matches[2]); } if (preg_match(PAT_FEEDS_CATEGORIES, $uri, $matches)) { $_GET['category'] = $matches[1]; } ob_start(); include_once(S9Y_INCLUDE_PATH . 'rss.php'); $data = ob_get_contents(); ob_end_clean(); if ($serendipity['pregenerate']) { $fp = fopen($serendipity['serendipityPath'] . PATH_FEEDS.'/index.' . $matches[1], 'w'); fwrite($fp, $data); fclose($fp); } serendipity_gzCompression(); print $data; exit; } else if (preg_match(PAT_ADMIN, $uri)) { header("Location: {$serendipity['serendipityHTTPPath']}serendipity_admin.php"); exit; } else if (preg_match(PAT_ARCHIVE, $uri)) { $serendipity['GET']['action'] = 'archives'; include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); } else if (preg_match(PAT_PLUGIN, $uri, $matches)) { serendipity_plugin_api::hook_event('external_plugin', $matches[1]); exit; } else if (preg_match(PAT_CATEGORIES, $uri, $matches)) { $_args = $serendipity['uriArguments']; /* Attempt to locate hidden variables within the URI */ foreach ($_args as $k => $v){ if ($v == PATH_CATEGORIES) { continue; } if ($v{0} == 'P') { /* Page */ $serendipity['GET']['page'] = substr($v, 1); unset($_args[$k]); unset($serendipity['uriArguments'][$k]); } } $serendipity['GET']['category'] = $matches[1]; $serendipity['GET']['action'] = 'read'; $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']); $serendipity['head_title'] = $cInfo['category_name']; $serendipity['head_subtitle'] = $serendipity['blogTitle']; include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); } else if (preg_match(PAT_AUTHORS, $uri, $matches)) { $serendipity['GET']['viewAuthor'] = $matches[1]; $serendipity['GET']['action'] = 'read'; $uInfo = serendipity_fetchUsers($serendipity['GET']['viewAuthor']); $serendipity['head_title'] = sprintf(ENTRIES_BY, $uInfo[0]['username']); $serendipity['head_subtitle'] = $serendipity['blogTitle']; include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); } else if (preg_match(PAT_SEARCH, $uri, $matches)) { $_args = $serendipity['uriArguments']; /* Attempt to locate hidden variables within the URI */ $search = array(); foreach ($_args as $k => $v){ if ($v == PATH_SEARCH) { continue; } if ($v{0} == 'P') { /* Page */ $serendipity['GET']['page'] = substr($v, 1); unset($_args[$k]); unset($serendipity['uriArguments'][$k]); } else { $search[] = $v; } } $serendipity['GET']['action'] = 'search'; $serendipity['GET']['searchTerm'] = urldecode(htmlspecialchars(strip_tags(implode(' ', $search)))); include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); } elseif (preg_match(PAT_CSS, $uri, $matches)) { $css_mode = $matches[1]; include_once(S9Y_INCLUDE_PATH . 'serendipity.css.php'); exit; } else if (preg_match('@/(index(\.php|\.html)?)|'. preg_quote($serendipity['indexFile']) .'@', $uri) || preg_match('@^/' . preg_quote(trim($serendipity['serendipityHTTPPath'], '/')) . '/?(\?.*)?$@', $uri)) { if ($serendipity['GET']['action'] == 'search') { $serendipity['uriArguments'] = array(PATH_SEARCH, urlencode($serendipity['GET']['searchTerm'])); } else { $serendipity['uriArguments'][] = PATH_ARCHIVES; } include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); } else { header('HTTP/1.0 404 Not found'); include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); // printf('
' . DOCUMENT_NOT_FOUND . '
', $uri); } if ($track_referer) { serendipity_track_referrer(); } $raw_data = ob_get_contents(); ob_end_clean(); $serendipity['smarty']->assign('raw_data', $raw_data); if (empty($serendipity['smarty_file'])) { $serendipity['smarty_file'] = '404.tpl'; } serendipity_gzCompression(); $serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath')); if ($global_debug) { /* TODO: Remove (hide) this debug */ echo '
Page delivered in '. round(microtime_float()-$time_start,6) .' seconds, '. sizeof(get_included_files()) .' files included
'; echo ''; } /* vim: set sts=4 ts=4 expandtab : */ ?>