diff options
author | Dimtion <zizou.xena@gmail.com> | 2016-01-20 10:57:07 +0100 |
---|---|---|
committer | Dimtion <zizou.xena@gmail.com> | 2016-01-20 22:52:28 +0100 |
commit | f4c84ad7fc981643d952a4fb4abfcdb85fccf621 (patch) | |
tree | 6f41c6cded0d22b6607e23f544662ff73b951e94 /index.php | |
parent | 25d88c90aa74ea05162dfc59f47843df639beb75 (diff) | |
download | Shaarli-f4c84ad7fc981643d952a4fb4abfcdb85fccf621.tar.gz Shaarli-f4c84ad7fc981643d952a4fb4abfcdb85fccf621.tar.zst Shaarli-f4c84ad7fc981643d952a4fb4abfcdb85fccf621.zip |
Create 404 template
Solve #430 for links
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 | } |