$serendipity['GET']['action'] = 'read'; $_args = $serendipity['uriArguments']; /* Attempt to locate hidden variables within the URI */ foreach ($_args as $k => $v) { if ($v[0] == 'P') { /* Page */ $page = substr($v, 1); if (is_numeric($page)) { $serendipity['GET']['page'] = $page; unset($_args[$k]); unset($serendipity['uriArguments'][$k]); } } } if (!$is_multiauth) { $matches[1] = serendipity_searchPermalink($serendipity['permalinkAuthorStructure'], implode('/', $serendipity['uriArguments']), $matches[1], 'author'); $serendipity['GET']['viewAuthor'] = $matches[1]; $serendipity['GET']['action'] = 'read'; } $uInfo = serendipity_fetchUsers($serendipity['GET']['viewAuthor']); if (!is_array($uInfo)) { $serendipity['view'] = '404'; $serendipity['viewtype'] = '404_3'; header('HTTP/1.0 404 Not found'); header('Status: 404 Not found'); } else { $serendipity['head_title'] = sprintf(ENTRIES_BY, $uInfo[0]['realname']); $serendipity['head_subtitle'] = $serendipity['blogTitle']; } include S9Y_INCLUDE_PATH . 'include/genpage.inc.php'; } else {
function serveEntry($matches) { global $serendipity; $serendipity['view'] = 'entry'; $uri = $_SERVER['REQUEST_URI']; if (isset($serendipity['GET']['id'])) { $matches[1] = (int) $serendipity['GET']['id']; } elseif (isset($_GET['p'])) { $matches[1] = $_GET['p']; } else { $matches[1] = serendipity_searchPermalink($serendipity['permalinkStructure'], $uri, !empty($matches[2]) ? $matches[2] : $matches[1], 'entry'); } serendipity_rememberComment(); if (!empty($serendipity['POST']['submit']) && !isset($_REQUEST['serendipity']['csuccess'])) { $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['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . (strstr($_SERVER['REQUEST_URI'], '?') ? '&' : '?') . 'serendipity[csuccess]=' . (isset($serendipity['csuccess']) ? $serendipity['csuccess'] : 'true'); if (serendipity_isResponseClean($sc_url)) { header('Status: 302 Found'); header('Location: ' . $sc_url); } exit; } else { $serendipity['messagestack']['comments'][] = COMMENT_NOT_ADDED; } } else { $serendipity['messagestack']['comments'][] = sprintf(EMPTY_COMMENT, '', ''); } } $id = (int) $matches[1]; if ($id === 0) { $id = false; } $_GET['serendipity']['action'] = 'read'; $_GET['serendipity']['id'] = $id; $title = serendipity_db_query("SELECT title FROM {$serendipity['dbPrefix']}entries WHERE id={$id} AND isdraft = 'false' " . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . serendipity_db_time() : ''), true); if (is_array($title)) { $serendipity['head_title'] = serendipity_specialchars($title[0]); $serendipity['head_subtitle'] = serendipity_specialchars($serendipity['blogTitle']); } else { $serendipity['view'] = '404'; $serendipity['viewtype'] = '404_1'; header('HTTP/1.0 404 Not found'); header('Status: 404 Not found'); } include S9Y_INCLUDE_PATH . 'include/genpage.inc.php'; }
function linkmatch($link) { global $serendipity; static $my_base = null; $b = $serendipity['baseURL']; // We strip out the http:// part, to allow easier https/http matching if ($my_base === null) { $my_base = preg_replace('@(https?://|www.)@i', '', $b); } $my_link = preg_replace('@(https?://|www)@i', '', $link); // Check if our link is contained inside the foreign link if (stristr($my_link, $my_base)) { if ($this->debug) { $my_link . " is contained in " . $my_base . "\n"; } $check_link = str_replace($my_base, $serendipity['serendipityHTTPPath'], $my_link); if ($this->debug) { echo "Permalinkcheck for: {$check_link}\n"; } preg_match(PAT_PERMALINK, $check_link, $matches); $id = serendipity_searchPermalink($serendipity['permalinkStructure'], $check_link, !empty($matches[2]) ? $matches[2] : $matches[1], 'entry'); return $id; } if ($this->debug) { echo $my_link . " is NOT contained in " . $my_base . "\n"; } return false; }