[ Index ] |
|
Code source de Serendipity 1.2 |
1 <?php # $Id: index.php 1732 2007-06-18 11:57:15Z garvinhicking $ 2 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) 3 # All rights reserved. See LICENSE file for licensing details 4 5 $global_debug = false; 6 7 if ($global_debug) { 8 #apd_set_pprof_trace(); 9 10 function microtime_float() { 11 list($usec, $sec) = explode(" ", microtime()); 12 return ((float)$usec + (float)$sec); 13 } 14 15 $time_start = microtime_float(); 16 } 17 18 // We need to set this to return a 200 since we use .htaccess ErrorDocument 19 // rules to handle archives. 20 header('HTTP/1.0 200'); 21 22 // Session are needed to also remember an autologin user on the frontend 23 ob_start(); 24 include ('serendipity_config.inc.php'); 25 header('Content-Type: text/html; charset='. LANG_CHARSET); 26 27 if ($serendipity['expose_s9y']) { 28 header('X-Blog: Serendipity'); // Used for installer detection 29 } 30 31 if ($serendipity['CacheControl']) { 32 if (!empty($HTTP_SERVER_VARS['SERVER_SOFTWARE']) && strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Apache/2')) { 33 header('Cache-Control: no-cache, pre-check=0, post-check=0'); 34 } else { 35 header('Cache-Control: private, pre-check=0, post-check=0, max-age=0'); 36 } 37 header('Expires: 0'); 38 header('Pragma: no-cache'); 39 } 40 $track_referer = true; 41 $uri = $_SERVER['REQUEST_URI']; 42 43 $serendipity['uriArguments'] = serendipity_getUriArguments($uri); 44 45 if (isset($_SERVER['HTTP_REFERER']) && empty($_SESSION['HTTP_REFERER'])) { 46 $_SESSION['HTTP_REFERER'] = $_SERVER['HTTP_REFERER']; 47 } 48 49 if (preg_match(PAT_UNSUBSCRIBE, $uri, $res)) { 50 if (serendipity_cancelSubscription(urldecode($res[1]), $res[2])) { 51 define('DATA_UNSUBSCRIBED', sprintf(UNSUBSCRIBE_OK, urldecode($res[1]))); 52 } 53 54 $uri = '/' . PATH_UNSUBSCRIBE . '/' . $res[2] . '-untitled.html'; 55 } else { 56 define('DATA_UNSUBSCRIBED', false); 57 } 58 59 if (preg_match(PAT_DELETE, $uri, $res) && $serendipity['serendipityAuthedUser'] === true) { 60 if ($res[1] == 'comment' && serendipity_deleteComment($res[2], $res[3], 'comments')) { 61 define('DATA_COMMENT_DELETED', sprintf(COMMENT_DELETED, $res[2])); 62 } elseif ( $res[1] == 'trackback' && serendipity_deleteComment($res[2], $res[3], 'trackbacks') ) { 63 define('DATA_TRACKBACK_DELETED', sprintf(TRACKBACK_DELETED, $res[2])); 64 } 65 } else { 66 define('DATA_COMMENT_DELETED', false); 67 define('DATA_TRACKBACK_DELETED', false); 68 } 69 70 if (preg_match(PAT_APPROVE, $uri, $res) && $serendipity['serendipityAuthedUser'] === true) { 71 if ($res[1] == 'comment' && serendipity_approveComment($res[2], $res[3])) { 72 define('DATA_COMMENT_APPROVED', sprintf(COMMENT_APPROVED, $res[2])); 73 define('DATA_TRACKBACK_APPROVED', false); 74 } elseif ($res[1] == 'trackback' && serendipity_approveComment($res[2], $res[3])) { 75 define('DATA_COMMENT_APPROVED', false); 76 define('DATA_TRACKBACK_APPROVED', sprintf(TRACKBACK_APPROVED, $res[2])); 77 } 78 } else { 79 define('DATA_COMMENT_APPROVED', false); 80 define('DATA_TRACKBACK_APPROVED', false); 81 } 82 83 if (isset($serendipity['POST']['isMultiCat']) && is_array($serendipity['POST']['multiCat'])) { 84 $is_multicat = true; 85 } else { 86 $is_multicat = false; 87 } 88 89 if (isset($serendipity['POST']['isMultiAuth']) && is_array($serendipity['POST']['multiAuth'])) { 90 $is_multiauth = true; 91 } else { 92 $is_multiauth = false; 93 } 94 95 if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range']) && is_numeric($serendipity['GET']['range'])) { 96 $serendipity['view'] = 'archives'; 97 $_args = $serendipity['uriArguments']; 98 99 /* Attempt to locate hidden variables within the URI */ 100 foreach ($_args as $k => $v){ 101 if ($v == PATH_ARCHIVES) { 102 continue; 103 } 104 if ($v{0} == 'C') { /* category */ 105 $cat = substr($v, 1); 106 if (is_numeric($cat)) { 107 $serendipity['GET']['category'] = $cat; 108 unset($_args[$k]); 109 } 110 } elseif ($v{0} == 'A') { /* Author */ 111 $url_author = substr($v, 1); 112 if (is_numeric($url_author)) { 113 $serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'] = (int)$url_author; 114 unset($_args[$k]); 115 } 116 } elseif ($v{0} == 'W') { /* Week */ 117 $week = substr($v, 1); 118 if (is_numeric($week)) { 119 unset($_args[$k]); 120 } 121 } elseif ($v == 'summary') { /* Summary */ 122 $serendipity['short_archives'] = true; 123 unset($_args[$k]); 124 } elseif ($v{0} == 'P') { /* Page */ 125 $page = substr($v, 1); 126 if (is_numeric($page)) { 127 $serendipity['GET']['page'] = $page; 128 unset($_args[$k]); 129 unset($serendipity['uriArguments'][$k]); 130 } 131 } 132 } 133 134 /* We must always *assume* that Year, Month and Day are the first 3 arguments */ 135 list(,$year, $month, $day) = $_args; 136 137 $serendipity['GET']['action'] = 'read'; 138 $serendipity['GET']['hidefooter'] = true; 139 140 if (!isset($year)) { 141 $year = date('Y'); 142 $month = date('m'); 143 $day = date('j'); 144 $serendipity['GET']['action'] = null; 145 $serendipity['GET']['hidefooter'] = null; 146 } 147 148 if (isset($year) && !is_numeric($year)) { 149 $year = date('Y'); 150 } 151 152 if (isset($month) && !is_numeric($month)) { 153 $month = date('m'); 154 } 155 156 if (isset($day) && !is_numeric($day)) { 157 $day = date('d'); 158 } 159 160 switch($serendipity['calendar']) { 161 case 'gregorian': 162 default: 163 $gday = 1; 164 165 if ($week) { 166 $tm = strtotime('+ '. ($week-2) .' WEEKS monday', mktime(0, 0, 0, 1, 1, $year)); 167 $ts = mktime(0, 0, 0, date('m', $tm), date('j', $tm), $year); 168 $te = mktime(23, 59, 59, date('m', $tm), date('j', $tm)+7, $year); 169 $date = serendipity_formatTime(WEEK .' '. $week .', %Y', $ts, false); 170 } else { 171 if ($day) { 172 $ts = mktime(0, 0, 0, $month, $day, $year); 173 $te = mktime(23, 59, 59, $month, $day, $year); 174 $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false); 175 } else { 176 $ts = mktime(0, 0, 0, $month, $gday, $year); 177 if (!isset($gday2)) { 178 $gday2 = date('t', $ts); 179 } 180 $te = mktime(23, 59, 59, $month, $gday2, $year); 181 $date = serendipity_formatTime('%B %Y', $ts, false); 182 } 183 } 184 break; 185 186 case 'persian-utf8': 187 require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; 188 $gday = 1; 189 if ($week) { 190 --$week; 191 $week *= 7; 192 ++$week; 193 $day = $week; 194 195 // convert day number of year to day number of month AND month number of year 196 $j_days_in_month = array(0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29); 197 if(($g_y % 4) == 3) $j_days_in_month[12]++; 198 199 for($i=1; isset($j_days_in_month[$i]); ++$i){ 200 if(($day-$j_days_in_month[$i])>0){ 201 $day -= $j_days_in_month[$i]; 202 }else{ 203 break; 204 } 205 } 206 207 $tm = persian_mktime(0, 0, 0, $i, $day, $year); 208 $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $tm), persian_date_utf('j', $tm), $year); 209 $te = persian_mktime(23, 59, 59, persian_date_utf('m', $tm), persian_date_utf('j', $tm)+7, $year); 210 $date = serendipity_formatTime(WEEK .' '. $week .'، %Y', $ts, false); 211 } else { 212 if ($day) { 213 $ts = persian_mktime(0, 0, 0, $month, $day, $year); 214 $te = persian_mktime(23, 59, 59, $month, $day, $year); 215 $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false); 216 } else { 217 $ts = persian_mktime(0, 0, 0, $month, $gday, $year); 218 if (!isset($gday2)) { 219 $gday2 = persian_date_utf('t', $ts); 220 } 221 $te = persian_mktime(23, 59, 59, $month, $gday2, $year); 222 $date = serendipity_formatTime('%B %Y', $ts, false); 223 } 224 } 225 226 list($year, $month, $day) = p2g ($year, $month, $day); 227 break; 228 } 229 230 $serendipity['range'] = array($ts, $te); 231 232 if ($serendipity['GET']['action'] == 'read') { 233 if ($serendipity['GET']['category']) { 234 $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']); 235 $serendipity['head_title'] = $cInfo['category_name']; 236 } 237 $serendipity['head_subtitle'] .= sprintf(ENTRIES_FOR, $date); 238 } 239 240 ob_start(); 241 include (S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); 242 $data = ob_get_contents(); 243 ob_end_clean(); 244 245 if (isset($serendipity['pregenerate']) && $serendipity['pregenerate']) { 246 $fp = fopen('./'.PATH_ARCHIVES.'/' . $matches[1], 'w'); 247 fwrite($fp, $data); 248 fclose($fp); 249 } 250 251 echo $data; 252 } else if ( preg_match(PAT_COMMENTSUB, $uri, $matches) || 253 preg_match(PAT_PERMALINK, $uri, $matches) ) { 254 $serendipity['view'] = 'entry'; 255 256 $matches[1] = serendipity_searchPermalink($serendipity['permalinkStructure'], $uri, (!empty($matches[2]) ? $matches[2] : $matches[1]), 'entry'); 257 serendipity_rememberComment(); 258 259 if (!empty($serendipity['POST']['submit']) && !isset($_REQUEST['serendipity']['csuccess'])) { 260 $comment['url'] = $serendipity['POST']['url']; 261 $comment['comment'] = trim($serendipity['POST']['comment']); 262 $comment['name'] = $serendipity['POST']['name']; 263 $comment['email'] = $serendipity['POST']['email']; 264 $comment['subscribe'] = $serendipity['POST']['subscribe']; 265 $comment['parent_id'] = $serendipity['POST']['replyTo']; 266 if (!empty($comment['comment'])) { 267 if (serendipity_saveComment($serendipity['POST']['entry_id'], $comment, 'NORMAL')) { 268 $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'); 269 if (serendipity_isResponseClean($sc_url)) { 270 header('Location: ' . $sc_url); 271 } 272 exit; 273 } else { 274 $serendipity['messagestack']['comments'][] = COMMENT_NOT_ADDED; 275 } 276 } else { 277 $serendipity['messagestack']['comments'][] = sprintf(EMPTY_COMMENT, '', ''); 278 } 279 } 280 281 $id = (int)$matches[1]; 282 283 serendipity_track_referrer($id); 284 $track_referer = false; 285 286 $_GET['serendipity']['action'] = 'read'; 287 $_GET['serendipity']['id'] = $id; 288 289 $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); 290 if (is_array($title)) { 291 $serendipity['head_title'] = htmlspecialchars($title[0]); 292 $serendipity['head_subtitle'] = htmlspecialchars($serendipity['blogTitle']); 293 } else { 294 $serendipity['view'] = '404'; 295 header('HTTP/1.0 404 Not found'); 296 } 297 298 ob_start(); 299 include (S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); 300 $data = ob_get_contents(); 301 ob_end_clean(); 302 303 if (isset($serendipity['pregenerate']) && $serendipity['pregenerate']) { 304 $fp = fopen($serendipity['serendipityPath'] . PATH_ARCHIVES.'/' . $id, 'w'); 305 fwrite($fp, $data); 306 fclose($fp); 307 } 308 print $data; 309 } elseif (preg_match(PAT_PERMALINK_FEEDCATEGORIES, $uri, $matches) || preg_match(PAT_PERMALINK_FEEDAUTHORS, $uri, $matches) || preg_match(PAT_FEEDS, $uri)) { 310 $serendipity['view'] = 'feed'; 311 header('Content-Type: text/html; charset=utf-8'); 312 313 if (preg_match('@/(index|atom[0-9]*|rss|comments|trackbacks|comments_and_trackbacks|opml)\.(rss[0-9]?|rdf|rss|xml|atom)@', $uri, $vmatches)) { 314 list($_GET['version'], $_GET['type']) = serendipity_discover_rss($vmatches[1], $vmatches[2]); 315 } 316 317 if (is_array($matches)) { 318 if (preg_match('@(/?' . preg_quote(PATH_FEEDS, '@') . '/)(.+)\.rss@i', $uri, $uriparts)) { 319 if (strpos($uriparts[2], $serendipity['permalinkCategoriesPath']) === 0) { 320 $catid = serendipity_searchPermalink($serendipity['permalinkFeedCategoryStructure'], $uriparts[2], $matches[1], 'category'); 321 if (is_numeric($catid) && $catid > 0) { 322 $_GET['category'] = $catid; 323 } 324 } elseif (strpos($uriparts[2], $serendipity['permalinkAuthorsPath']) === 0) { 325 $authorid = serendipity_searchPermalink($serendipity['permalinkFeedAuthorStructure'], $uriparts[2], $matches[1], 'author'); 326 if (is_numeric($authorid) && $authorid > 0) { 327 $_GET['viewAuthor'] = $authorid; 328 } 329 } 330 } 331 } 332 333 ob_start(); 334 include (S9Y_INCLUDE_PATH . 'rss.php'); 335 $data = ob_get_contents(); 336 ob_end_clean(); 337 338 if ($serendipity['pregenerate']) { 339 $fp = fopen($serendipity['serendipityPath'] . PATH_FEEDS.'/index.' . $matches[1], 'w'); 340 fwrite($fp, $data); 341 fclose($fp); 342 } 343 344 serendipity_gzCompression(); 345 346 print $data; 347 exit; 348 } else if (preg_match(PAT_ADMIN, $uri)) { 349 $serendipity['view'] = 'admin'; 350 $base = $serendipity['baseURL']; 351 if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { 352 $base = str_replace('http://', 'https://', $base); 353 } 354 header("Location: {$base}serendipity_admin.php"); 355 exit; 356 } else if (preg_match(PAT_ARCHIVE, $uri)) { 357 $serendipity['view'] = 'archive'; 358 $serendipity['GET']['action'] = 'archives'; 359 $_args = $serendipity['uriArguments']; 360 /* Attempt to locate hidden variables within the URI */ 361 foreach ($_args as $k => $v){ 362 if ($v == PATH_ARCHIVE) { 363 continue; 364 } 365 366 if ($v{0} == 'C') { /* category */ 367 $cat = substr($v, 1); 368 if (is_numeric($cat)) { 369 $serendipity['GET']['category'] = $cat; 370 unset($_args[$k]); 371 } 372 } elseif ($v{0} == 'A') { /* Author */ 373 $url_author = substr($v, 1); 374 if (is_numeric($url_author)) { 375 $serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'] = (int)$url_author; 376 unset($_args[$k]); 377 } 378 } 379 } 380 381 include (S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); 382 } else if (preg_match(PAT_PLUGIN, $uri, $matches)) { 383 $serendipity['view'] = 'plugin'; 384 serendipity_plugin_api::hook_event('external_plugin', $matches[2]); 385 if (!defined('NO_EXIT')) { 386 exit; 387 } 388 } else if ($is_multicat || preg_match(PAT_PERMALINK_CATEGORIES, $uri, $matches)) { 389 $serendipity['view'] = 'categories'; 390 391 if ($is_multicat) { 392 $serendipity['GET']['category'] = implode(';', $serendipity['POST']['multiCat']); 393 $serendipity['uriArguments'][] = PATH_CATEGORIES; 394 $serendipity['uriArguments'][] = serendipity_db_escape_string($serendipity['GET']['category']) . '-multi'; 395 } elseif (preg_match('@/([0-9;]+)@', $uri, $multimatch)) { 396 $is_multicat = true; 397 $serendipity['GET']['category'] = $multimatch[1]; 398 } 399 400 $serendipity['GET']['action'] = 'read'; 401 402 $_args = $serendipity['uriArguments']; 403 404 /* Attempt to locate hidden variables within the URI */ 405 foreach ($_args as $k => $v) { 406 if ($v == PATH_CATEGORIES) { 407 continue; 408 } 409 if ($v{0} == 'P') { /* Page */ 410 $page = substr($v, 1); 411 if (is_numeric($page)) { 412 $serendipity['GET']['page'] = $page; 413 unset($_args[$k]); 414 unset($serendipity['uriArguments'][$k]); 415 } 416 } elseif ($v{0} == 'A') { /* Author */ 417 $url_author = substr($v, 1); 418 if (is_numeric($url_author)) { 419 $serendipity['GET']['viewAuthor'] = $_GET['viewAuthor'] = (int)$url_author; 420 unset($_args[$k]); 421 } 422 } 423 } 424 425 if (!$is_multicat) { 426 $matches[1] = serendipity_searchPermalink($serendipity['permalinkCategoryStructure'], implode('/', $_args), $matches[1], 'category'); 427 $serendipity['GET']['category'] = $matches[1]; 428 } 429 430 $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']); 431 432 if (!is_array($cInfo)) { 433 $serendipity['view'] = '404'; 434 header('HTTP/1.0 404 Not found'); 435 } else { 436 $serendipity['head_title'] = $cInfo['category_name']; 437 $serendipity['head_subtitle'] = $serendipity['blogTitle']; 438 } 439 440 include (S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); 441 } else if ($is_multiauth || preg_match(PAT_PERMALINK_AUTHORS, $uri, $matches)) { 442 $serendipity['view'] = 'authors'; 443 444 if ($is_multiauth) { 445 $serendipity['GET']['viewAuthor'] = implode(';', $serendipity['POST']['multiAuth']); 446 $serendipity['uriArguments'][] = PATH_AUTHORS; 447 $serendipity['uriArguments'][] = serendipity_db_escape_string($serendipity['GET']['viewAuthor']) . '-multi'; 448 } elseif (preg_match('@/([0-9;]+)@', $uri, $multimatch)) { 449 $is_multiauth = true; 450 $serendipity['GET']['viewAuthor'] = $multimatch[1]; 451 } 452 453 $serendipity['GET']['action'] = 'read'; 454 455 $_args = $serendipity['uriArguments']; 456 457 /* Attempt to locate hidden variables within the URI */ 458 foreach ($_args as $k => $v){ 459 if ($v{0} == 'P') { /* Page */ 460 $page = substr($v, 1); 461 if (is_numeric($page)) { 462 $serendipity['GET']['page'] = $page; 463 unset($_args[$k]); 464 unset($serendipity['uriArguments'][$k]); 465 } 466 } 467 } 468 469 if (!$is_multiauth) { 470 $matches[1] = serendipity_searchPermalink($serendipity['permalinkAuthorStructure'], implode('/', $serendipity['uriArguments']), $matches[1], 'author'); 471 $serendipity['GET']['viewAuthor'] = $matches[1]; 472 $serendipity['GET']['action'] = 'read'; 473 } 474 475 $uInfo = serendipity_fetchUsers($serendipity['GET']['viewAuthor']); 476 477 if (!is_array($uInfo)) { 478 $serendipity['view'] = '404'; 479 header('HTTP/1.0 404 Not found'); 480 } else { 481 $serendipity['head_title'] = sprintf(ENTRIES_BY, $uInfo[0]['realname']); 482 $serendipity['head_subtitle'] = $serendipity['blogTitle']; 483 } 484 485 include (S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); 486 } else if (preg_match(PAT_SEARCH, $uri, $matches)) { 487 $serendipity['view'] = 'search'; 488 $_args = $serendipity['uriArguments']; 489 490 /* Attempt to locate hidden variables within the URI */ 491 $search = array(); 492 foreach ($_args as $k => $v){ 493 if ($v == PATH_SEARCH) { 494 continue; 495 } 496 497 if ($v{0} == 'P') { /* Page */ 498 $page = substr($v, 1); 499 if (is_numeric($page)) { 500 $serendipity['GET']['page'] = $page; 501 unset($_args[$k]); 502 unset($serendipity['uriArguments'][$k]); 503 } else { 504 $search[] = $v; 505 } 506 } else { 507 $search[] = $v; 508 } 509 } 510 511 $serendipity['GET']['action'] = 'search'; 512 $serendipity['GET']['searchTerm'] = urldecode(htmlspecialchars(strip_tags(implode(' ', $search)))); 513 include (S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); 514 } elseif (preg_match(PAT_CSS, $uri, $matches)) { 515 $serendipity['view'] = 'css'; 516 $css_mode = $matches[1]; 517 include (S9Y_INCLUDE_PATH . 'serendipity.css.php'); 518 exit; 519 } else if (preg_match(PAT_COMMENTS, $uri, $matches)) { 520 $serendipity['view'] = 'comments'; 521 $_args = serendipity_getUriArguments($uri, true); // Need to also match "." character 522 $timedesc = array(); 523 524 /* Attempt to locate hidden variables within the URI */ 525 $search = array(); 526 foreach ($_args as $k => $v){ 527 if ($v == PATH_COMMENTS) { 528 continue; 529 } 530 531 if ($v{0} == 'P') { /* Page */ 532 $page = substr($v, 1); 533 if (is_numeric($page)) { 534 $serendipity['GET']['page'] = $page; 535 unset($_args[$k]); 536 unset($serendipity['uriArguments'][$k]); 537 } 538 } elseif (preg_match('@^(last|f|t|from|to)[\s_-]*([\d-/ ]+)$@', strtolower(urldecode($v)), $m)) { 539 if ($m[1] == 'last') { 540 $usetime = time() - ($m[2]*86400); 541 $serendipity['GET']['commentStartTime'] = $usetime; 542 $timedesc['start'] = serendipity_strftime(DATE_FORMAT_SHORT, $usetime); 543 continue; 544 } 545 546 $date = strtotime($m[2]); 547 if ($date < 1) { 548 continue; 549 } 550 551 if ($m[1] == 'f' || $m[1] == 'from') { 552 $serendipity['GET']['commentStartTime'] = $date; 553 $timedesc['start'] = serendipity_strftime(DATE_FORMAT_SHORT, $date); 554 } else { 555 $serendipity['GET']['commentEndTime'] = $date; 556 $timedesc['end'] = serendipity_strftime(DATE_FORMAT_SHORT, $date); 557 } 558 } elseif ($v == 'trackbacks' || $v == 'comments_and_trackbacks' || $v == 'comments') { 559 $serendipity['GET']['commentMode'] = $v; 560 } elseif (!empty($v)) { 561 $serendipity['GET']['viewCommentAuthor'] .= urldecode($v); 562 } 563 } 564 565 $serendipity['head_title'] = COMMENTS_FROM . ' ' . htmlspecialchars($serendipity['GET']['viewCommentAuthor']); 566 if (isset($timedesc['start']) && isset($timedesc['end'])) { 567 $serendipity['head_title'] .= ' (' . $timedesc['start'] . ' - ' . $timedesc['end'] . ')'; 568 } elseif (isset($timedesc['start'])) { 569 $serendipity['head_title'] .= ' (> ' . $timedesc['start'] . ')'; 570 } elseif (isset($timedesc['end'])) { 571 $serendipity['head_title'] .= ' (< ' . $timedesc['end'] . ')'; 572 } 573 $serendipity['head_subtitle'] = $serendipity['blogTitle']; 574 $serendipity['GET']['action'] = 'comments'; 575 include (S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); 576 } else if (preg_match('@/(index(\.php|\.html)?)|'. preg_quote($serendipity['indexFile']) .'@', $uri) || 577 preg_match('@^/' . preg_quote(trim($serendipity['serendipityHTTPPath'], '/')) . '/?(\?.*)?$@', $uri)) { 578 579 $serendipity['view'] = 'start'; 580 581 if ($serendipity['GET']['action'] == 'search') { 582 $serendipity['view'] = 'search'; 583 $serendipity['uriArguments'] = array(PATH_SEARCH, urlencode($serendipity['GET']['searchTerm'])); 584 } else { 585 $serendipity['uriArguments'][] = PATH_ARCHIVES; 586 } 587 588 include (S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); 589 } else { 590 $serendipity['view'] = '404'; 591 header('HTTP/1.0 404 Not found'); 592 include (S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); 593 // printf('<div class="serendipity_msg_important">' . DOCUMENT_NOT_FOUND . '</div>', $uri); 594 } 595 596 if ($track_referer) { 597 serendipity_track_referrer(); 598 } 599 600 if (!defined('NO_EXIT')) { 601 $raw_data = ob_get_contents(); 602 ob_end_clean(); 603 $serendipity['smarty']->assign_by_ref('raw_data', $raw_data); 604 if (empty($serendipity['smarty_file'])) { 605 $serendipity['smarty_file'] = '404.tpl'; 606 } 607 608 serendipity_gzCompression(); 609 610 $serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath')); 611 } 612 613 if ($global_debug) { 614 /* TODO: Remove (hide) this debug */ 615 echo '<div id="s9y_debug" style="text-align: center; color: red; font-size: 10pt; font-weight: bold; padding: 10px">Page delivered in '. round(microtime_float()-$time_start,6) .' seconds, '. sizeof(get_included_files()) .' files included</div>'; 616 echo '</div>'; 617 } 618 619 /* vim: set sts=4 ts=4 expandtab : */
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |