summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@n0v4.com>2010-11-02 22:54:08 +1100
committerSavetheinternet <savetheinternet@n0v4.com>2010-11-02 22:54:08 +1100
commit494387589c7c12819006bf354a4211ad4e15f8c0 (patch)
tree95cba7a71b56ccc08d7954f0088d4cc5a8241f36
parentc645e6ae6f033b5588bd4139bc1c1b1d50db000c (diff)
Error handling
-rw-r--r--inc/functions.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/inc/functions.php b/inc/functions.php
index 22a576ee..aafb0d93 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -76,12 +76,12 @@
$page = 1;
while($page <= MAX_PAGES && $content = index($page)) {
$filename = $page==1 ? FILE_INDEX : sprintf(FILE_PAGE, $page);
- $md5 = md5_file($filename);
+ if(file_exists($filename)) $md5 = md5_file($filename);
$content['pages'] = $pages;
- file_put_contents($filename, Element('index.html', $content));
+ file_put_contents($filename, Element('index.html', $content)) or error("Couldn't write to file.");
- if($md5 == md5_file($filename)) {
+ if(isset($md5) && $md5 == md5_file($filename)) {
break;
}
$page++;
@@ -89,7 +89,7 @@
if($page < MAX_PAGES) {
for(;$page<=MAX_PAGES;$page++) {
$filename = $page==1 ? FILE_INDEX : sprintf(FILE_PAGE, $page);
- unlink($filename);
+ @unlink($filename);
}
}
}
@@ -189,7 +189,7 @@
} else {
$thread->add(new Post($post['id'], $thread->id, $post['subject'], $post['email'], $post['name'], $post['trip'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename']));
}
- file_put_contents(DIR_RES . $id . '.html', Element('thread.html', Array('button'=>BUTTON_REPLY, 'board'=>$board, 'body'=>$thread->build(), 'post_url' => POST_URL, 'index' => ROOT, 'id' => $id)));
+ file_put_contents(DIR_RES . $id . '.html', Element('thread.html', Array('button'=>BUTTON_REPLY, 'board'=>$board, 'body'=>$thread->build(), 'post_url' => POST_URL, 'index' => ROOT, 'id' => $id))) or error("Couldn't write to file.");
}
mysql_free_result($query);
}