diff options
author | Arthur <arthur@hoa.ro> | 2016-01-21 19:27:00 +0100 |
---|---|---|
committer | Arthur <arthur@hoa.ro> | 2016-01-21 19:27:00 +0100 |
commit | db36b8812d30d2a1dcb1a5a0544893ee863f45dd (patch) | |
tree | ead3362c2f8cb2c41a40330219c18cc0152e5df7 /index.php | |
parent | 55d0a5c445cbbd4fc322051b7753d0b2106cfe68 (diff) | |
parent | f4c84ad7fc981643d952a4fb4abfcdb85fccf621 (diff) | |
download | Shaarli-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.php | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -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 | } |