aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--inc/shaarli.css15
-rw-r--r--index.php19
-rw-r--r--tpl/404.html17
3 files changed, 45 insertions, 6 deletions
diff --git a/inc/shaarli.css b/inc/shaarli.css
index d6bbdbc1..96e2cae1 100644
--- a/inc/shaarli.css
+++ b/inc/shaarli.css
@@ -1101,4 +1101,17 @@ div.dailyNoEntry {
1101ul.errors { 1101ul.errors {
1102 color: red; 1102 color: red;
1103 float: left; 1103 float: left;
1104} \ No newline at end of file 1104}
1105
1106/* 404 page */
1107.error-container {
1108
1109 margin: 50px;
1110 margin-top: 20px;
1111}
1112
1113.error-container h1 {
1114 text-decoration: none;
1115 font-style: normal;
1116 color: #80AD48;
1117}
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 }
diff --git a/tpl/404.html b/tpl/404.html
new file mode 100644
index 00000000..a45be801
--- /dev/null
+++ b/tpl/404.html
@@ -0,0 +1,17 @@
1<!DOCTYPE html>
2<html>
3<head>
4 {include="includes"}
5</head>
6<body>
7<div id="pageheader">
8 {include="page.header"}
9</div>
10<div class="error-container">
11 <h1>404 Not found <small>Oh crap!</small></h1>
12 <p>{$error_message}</p>
13 <p>Would you mind <a href="?">clicking here</a> ?</p>
14</div>
15{include="page.footer"}
16</body>
17</html>