diff options
| author | Savetheinternet <savetheinternet@n0v4.com> | 2011-02-11 23:02:30 +1100 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@n0v4.com> | 2011-02-11 23:02:30 +1100 |
| commit | c34ea2e3af01d9a688fb14b3da550aa96615f312 (patch) | |
| tree | 8560552c1f92ce13452cca79172799491ff9b69a /inc | |
| parent | 0346862645aa0b9a8ba0f0d929b336b08ff8fcf4 (diff) | |
a Fixed delete by IP, plus a bunch of small stuff
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/functions.php | 12 | ||||
| -rw-r--r-- | inc/mod.php | 12 |
2 files changed, 19 insertions, 5 deletions
diff --git a/inc/functions.php b/inc/functions.php index c9b85ad4..6901de62 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -299,7 +299,7 @@ } // Delete a post (reply or thread) - function deletePost($id) { + function deletePost($id, $error_if_doesnt_exist=true) { global $board; // Select post and replies (if thread) in one query @@ -308,7 +308,9 @@ $query->execute() or error(db_error($query)); if($query->rowCount() < 1) { - error(ERROR_INVALIDPOST); + if($error_if_doesnt_exist) + error(ERROR_INVALIDPOST); + else return false; } // Delete posts and maybe replies @@ -337,6 +339,8 @@ if(isset($rebuild)) { buildThread($rebuild); } + + return true; } function clean() { @@ -370,7 +374,7 @@ while($th = $query->fetch()) { $thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename'], $th['ip'], $th['sticky'], $th['locked'], $mod ? '?/' : ROOT, $mod); - $posts = prepare(sprintf("SELECT `id`, `subject`, `email`, `name`, `trip`, `body`, `time`, `thumb`, `thumbwidth`, `thumbheight`, `file`, `filewidth`, `fileheight`, `filesize`, `filename`,`ip` FROM `posts_%s` WHERE `thread` = ? ORDER BY `time` DESC LIMIT ?", $board['uri'])); + $posts = prepare(sprintf("SELECT `id`, `subject`, `email`, `name`, `trip`, `body`, `time`, `thumb`, `thumbwidth`, `thumbheight`, `file`, `filewidth`, `fileheight`, `filesize`, `filename`,`ip` FROM `posts_%s` WHERE `thread` = ? ORDER BY `id` DESC LIMIT ?", $board['uri'])); $posts->bindValue(1, $th['id']); $posts->bindValue(2, THREADS_PREVIEW, PDO::PARAM_INT); $posts->execute() or error(db_error($posts)); @@ -859,7 +863,7 @@ switch($type) { case 'jpg': case 'jpeg': - if(!$image = imagecreatefromjpeg($source_pic)) { + if(!$image = @imagecreatefromjpeg($source_pic)) { unlink($source_pic); error(ERR_INVALIDIMG); } diff --git a/inc/mod.php b/inc/mod.php index 5a3e6157..115c595a 100644 --- a/inc/mod.php +++ b/inc/mod.php @@ -20,7 +20,7 @@ $query = prepare("SELECT `id`,`type` FROM `mods` WHERE `username` = :username AND `password` = :password LIMIT 1"); $query->bindValue(':username', $username); $query->bindValue(':password', $password); - $query->execute(); + $query->execute() or error(db_error($query)); if($user = $query->fetch()) { return $mod = Array( @@ -56,6 +56,16 @@ unset($_SESSION['mod']); } + function modLog($action) { + global $mod; + $query = prepare("INSERT INTO `modlogs` VALUES (:id, :ip, :time, :text)"); + $query->bindValue(':id', $mod['id'], PDO::PARAM_INT); + $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); + $query->bindValue(':time', time(), PDO::PARAM_INT); + $query->bindValue(':text', $action); + $query->execute() or error(db_error($query)); + } + if(isset($_COOKIE['mod']) && isset($_SESSION['mod']) && is_array($_SESSION['mod'])) { // Should be username:session hash $cookie = explode(':', $_COOKIE['mod']); |
