aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthur <arthur@hoa.ro>2016-01-21 19:27:00 +0100
committerArthur <arthur@hoa.ro>2016-01-21 19:27:00 +0100
commitdb36b8812d30d2a1dcb1a5a0544893ee863f45dd (patch)
treeead3362c2f8cb2c41a40330219c18cc0152e5df7 /index.php
parent55d0a5c445cbbd4fc322051b7753d0b2106cfe68 (diff)
parentf4c84ad7fc981643d952a4fb4abfcdb85fccf621 (diff)
downloadShaarli-db36b8812d30d2a1dcb1a5a0544893ee863f45dd.tar.gz
Shaarli-db36b8812d30d2a1dcb1a5a0544893ee863f45dd.tar.zst
Shaarli-db36b8812d30d2a1dcb1a5a0544893ee863f45dd.zip
Merge pull request #444 from dimtion/404_template
Create 404 template
Diffstat (limited to 'index.php')
-rw-r--r--index.php19
1 files changed, 14 insertions, 5 deletions
diff --git a/index.php b/index.php
index 553f65e4..beba9c32 100644
--- a/index.php
+++ b/index.php
@@ -472,7 +472,7 @@ if (isset($_POST['login']))
472 session_set_cookie_params(0,$cookiedir,$_SERVER['SERVER_NAME']); // 0 means "When browser closes" 472 session_set_cookie_params(0,$cookiedir,$_SERVER['SERVER_NAME']); // 0 means "When browser closes"
473 session_regenerate_id(true); 473 session_regenerate_id(true);
474 } 474 }
475 475
476 // Optional redirect after login: 476 // Optional redirect after login:
477 if (isset($_GET['post'])) { 477 if (isset($_GET['post'])) {
478 $uri = '?post='. urlencode($_GET['post']); 478 $uri = '?post='. urlencode($_GET['post']);
@@ -681,6 +681,18 @@ class pageBuilder
681 if ($this->tpl===false) $this->initialize(); // Lazy initialization 681 if ($this->tpl===false) $this->initialize(); // Lazy initialization
682 $this->tpl->draw($page); 682 $this->tpl->draw($page);
683 } 683 }
684
685 /**
686 * Render a 404 page (uses the template : tpl/404.tpl)
687 *
688 * usage : $PAGE->render404('The link was deleted')
689 * @param string $message A messate to display what is not found
690 */
691 public function render404($message='The page you are trying to reach does not exist or has been deleted.') {
692 header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
693 $this->tpl->assign('error_message', $message);
694 $this->renderPage('404');
695 }
684} 696}
685 697
686// ------------------------------------------------------------------------------------------ 698// ------------------------------------------------------------------------------------------
@@ -1883,10 +1895,7 @@ function buildLinkList($PAGE,$LINKSDB)
1883 $linksToDisplay = $LINKSDB->filter($search_type, $search_crits); 1895 $linksToDisplay = $LINKSDB->filter($search_type, $search_crits);
1884 1896
1885 if (count($linksToDisplay) == 0) { 1897 if (count($linksToDisplay) == 0) {
1886 header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); 1898 $PAGE->render404('The link you are trying to reach does not exist or has been deleted.');
1887 echo '<h1>404 Not found.</h1>Oh crap.
1888 The link you are trying to reach does not exist or has been deleted.';
1889 echo '<br>Would you mind <a href="?">clicking here</a>?';
1890 exit; 1899 exit;
1891 } 1900 }
1892 } 1901 }