disinclined.org
/
git
/
dylansserver.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bc994b5
)
404s now raise notFound exceptions
author
Dylan Lloyd
<dylan@psu.edu>
Sun, 6 Mar 2011 09:22:39 +0000
(
04:22
-0500)
committer
Dylan Lloyd
<dylan@psu.edu>
Sun, 6 Mar 2011 09:22:39 +0000
(
04:22
-0500)
includes/cms.php
patch
|
blob
|
history
diff --git
a/includes/cms.php
b/includes/cms.php
index
9552941
..
0f23b80
100644
(file)
--- a/
includes/cms.php
+++ b/
includes/cms.php
@@
-31,13
+31,6
@@
abstract class cms {
}
}
}
}
- protected function not_found() {
- header("HTTP/1.0 404 Not Found");
- ob_end_clean();
- include("404.php");
- exit();
- }
-
public function query() {
$args = func_get_args();
$statement = $this->db->prepare($args[0]);
public function query() {
$args = func_get_args();
$statement = $this->db->prepare($args[0]);
@@
-199,7
+192,7
@@
class project extends index {
echo $text;
echo "</div>";
} else {
echo $text;
echo "</div>";
} else {
-
$this->not_f
ound();
+
throw new notF
ound();
}
}
}
}
}
}
@@
-223,13
+216,13
@@
class page extends cms {
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
$this->page = (int) $_GET['page'];
} else {
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
$this->page = (int) $_GET['page'];
} else {
-
$this->not_f
ound();
+
throw new notF
ound();
}
if ($this->page > $this->number_of_pages) {
}
if ($this->page > $this->number_of_pages) {
-
$this->not_f
ound();
+
throw new notF
ound();
}
if ($this->page < 1) {
}
if ($this->page < 1) {
-
$this->not_f
ound();
+
throw new notF
ound();
}
$this->offset = ($this->page - 1) * $this->notes_per_page;
}
}
$this->offset = ($this->page - 1) * $this->notes_per_page;
}
@@
-290,7
+283,7
@@
class note extends cms {
WHERE url = ?";
$results = $this->query($sql, "s", $_GET['note']);
if ($results[0]["COUNT(*)"] != 1) {
WHERE url = ?";
$results = $this->query($sql, "s", $_GET['note']);
if ($results[0]["COUNT(*)"] != 1) {
-
$this->not_f
ound();
+
throw new notF
ound();
}
}
}
}
@@
-324,6
+317,15
@@
class note extends cms {
}
}
}
}
+class notFound extends Exception {
+ public function __construct() {
+ header("HTTP/1.0 404 Not Found");
+ ob_end_clean();
+ include("404.php");
+ exit();
+ }
+}
+
## now actually do something:
switch (cms::determine_type()) {
case "index":
## now actually do something:
switch (cms::determine_type()) {
case "index":