diff --git a/contrib/image_hash_ban/main.php b/contrib/image_hash_ban/main.php index 79150d98..f68c7205 100644 --- a/contrib/image_hash_ban/main.php +++ b/contrib/image_hash_ban/main.php @@ -47,7 +47,7 @@ class ImageBan extends Extension { global $database; $row = $database->get_row("SELECT * FROM image_bans WHERE hash = :hash", array("hash"=>$event->hash)); if($row) { - log_info("image_hash_ban", "Blocked image ({$event->hash})"); + log_info("image_hash_ban", "Attempted to upload a blocked image ({$event->hash} - {$row['reason']})"); throw new UploadException("Image ".html_escape($row["hash"])." has been banned, reason: ".format_text($row["reason"])); } } diff --git a/contrib/log_db/main.php b/contrib/log_db/main.php index 626b4360..8399720a 100644 --- a/contrib/log_db/main.php +++ b/contrib/log_db/main.php @@ -60,16 +60,20 @@ class LogDatabase extends Extension { if(!empty($_GET["user"])) { if($database->engine->name == "pgsql") { if(preg_match("#\d+\.\d+\.\d+\.\d+(/\d+)?#", $_GET["user"])) { - $wheres[] = "(username = :user OR address << :user)"; + $wheres[] = "(username = :user1 OR text(address) = :user2)"; + $args["user1"] = $_GET["user"]; + $args["user2"] = $_GET["user"] . "/32"; } else { $wheres[] = "lower(username) = lower(:user)"; + $args["user"] = $_GET["user"]; } } else { - $wheres[] = "(username = :user OR address = :user)"; + $wheres[] = "(username = :user1 OR address = :user2)"; + $args["user1"] = $_GET["user"]; + $args["user2"] = $_GET["user"]; } - $args["user"] = $_GET["user"]; } if(!empty($_GET["priority"])) { $wheres[] = "priority >= :priority"; diff --git a/contrib/log_net/main.php b/contrib/log_net/main.php index a35ea54a..5e952670 100644 --- a/contrib/log_net/main.php +++ b/contrib/log_net/main.php @@ -12,8 +12,9 @@ class LogNet extends Extension { global $user; if($event->priority > 10) { + // TODO: colour based on event->priority $username = ($user && $user->name) ? $user->name : "Anonymous"; - $str = sprintf("%2d %15s (%s): %s - %s", $event->priority, $_SERVER['REMOTE_ADDR'], $username, $event->section, $event->message); + $str = sprintf("%-15s %-10s: %s", $_SERVER['REMOTE_ADDR'], $username, $event->message); system("echo ".escapeshellarg($str)." | nc -q 0 localhost 5000"); } } diff --git a/contrib/pools/main.php b/contrib/pools/main.php index 8ca72765..585fd3ad 100644 --- a/contrib/pools/main.php +++ b/contrib/pools/main.php @@ -340,7 +340,7 @@ class Pools extends Extension { VALUES (:uid, :public, :title, :desc, now())", array("uid"=>$user->id, "public"=>$public, "title"=>$_POST["title"], "desc"=>$_POST["description"])); - $result['poolID'] = $database->get_last_insert_id(); + $result['poolID'] = $database->get_last_insert_id('pools_id_seq'); log_info("pools", "Pool {$result["poolID"]} created by {$user->name}"); diff --git a/core/database.class.php b/core/database.class.php index 7ff1617b..2f63ab1a 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -403,8 +403,13 @@ class Database { /** * get the ID of the last inserted row */ - public function get_last_insert_id() { - return $this->db->lastInsertId(); + public function get_last_insert_id($seq) { + if($this->engine->name == "pgsql") { + return $this->db->lastInsertId($seq); + } + else { + return $this->db->lastInsertId(); + } } diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index c9ad7633..5ec46ef4 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -419,7 +419,7 @@ class Image { $sln = $database->engine->scoreql_to_sql('SCORE_BOOL_'.$ln); $sln = str_replace("'", "", $sln); $sln = str_replace('"', "", $sln); - if($sln != $this->locked) { + if(undb_bool($sln) !== $this->locked) { $database->execute("UPDATE images SET locked=:yn WHERE id=:id", array("yn"=>$sln, "id"=>$this->id)); log_info("core-image", "Setting Image #{$this->id} lock to: $ln"); } diff --git a/ext/comment/main.php b/ext/comment/main.php index e7180efa..2b691c34 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -500,8 +500,11 @@ class CommentList extends Extension { "INSERT INTO comments(image_id, owner_id, owner_ip, posted, comment) ". "VALUES(:image_id, :user_id, :remote_addr, now(), :comment)", array("image_id"=>$image_id, "user_id"=>$user->id, "remote_addr"=>$_SERVER['REMOTE_ADDR'], "comment"=>$comment)); - $cid = $database->get_last_insert_id(); - log_info("comment", "Comment #$cid added to Image #$image_id"); + $cid = $database->get_last_insert_id('comments_id_seq'); + $snippet = substr($comment, 0, 100); + $snippet = str_replace("\n", " ", $snippet); + $snippet = str_replace("\r", " ", $snippet); + log_info("comment", "Comment #$cid added to Image #$image_id: $snippet"); } } // }}} diff --git a/ext/image/main.php b/ext/image/main.php index 4b306ab6..c999a5bc 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -328,13 +328,7 @@ class ImageIO extends Extension { "hash"=>$image->hash, "ext"=>$image->ext, "width"=>$image->width, "height"=>$image->height, "source"=>$image->source ) ); - //$database->Execute("UPDATE users SET image_count = image_count+1 WHERE id = :id ", array("id"=>$user->id)); - if($database->engine->name == "pgsql") { - $image->id = $database->get_one("SELECT id FROM images WHERE hash=:hash", array("hash"=>$image->hash)); - } - else { - $image->id = $database->get_last_insert_id(); - } + $image->id = $database->get_last_insert_id('images_id_seq'); log_info("image", "Uploaded Image #{$image->id} ({$image->hash})"); diff --git a/ext/upload/main.php b/ext/upload/main.php index fc0a2edd..9277826c 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -112,7 +112,6 @@ class Upload extends Extension { } } -// event handling {{{ public function onPageRequest($event) { global $config, $page, $user; @@ -187,16 +186,15 @@ class Upload extends Extension { else { /* Regular Upload Image */ if(count($_FILES) + count($_POST) > 0) { - $tags = Tag::explode($_POST['tags']); $source = isset($_POST['source']) ? $_POST['source'] : null; $ok = true; - foreach($_FILES as $file) { - reset($_FILES); // rewind to first element in array. + foreach($_FILES as $name => $file) { + $tags = $this->tags_for_upload_slot(int_escape(substr($name, 4))); $ok = $ok & $this->try_upload($file, $tags, $source); } foreach($_POST as $name => $value) { - reset($_POST); // rewind to first element in array. if(substr($name, 0, 3) == "url" && strlen($value) > 0) { + $tags = $this->tags_for_upload_slot(int_escape(substr($name, 3))); $ok = $ok & $this->try_transload($value, $tags, $source); } } @@ -223,7 +221,17 @@ class Upload extends Extension { } } } -// }}} + + private function tags_for_upload_slot($id) { + if(isset($_POST["tags$id"])) { + $tags = array_merge(Tag::explode($_POST['tags']), Tag::explode($_POST["tags$id"])); + } + else { + $tags = Tag::explode($_POST['tags']); + } + return $tags; + } + // do things {{{ /** diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 8745ee39..80494214 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -20,9 +20,9 @@ class UploadTheme extends Themelet { ".make_form(make_link("upload"), "POST", $multipart=True, 'file_upload')."
Tags | |||||
Source | |||||
Tags | |||||
Source | |||||