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')." $upload_list - - - + + +
Tags
Source
Tags
Source
(Max file size is $max_kb) @@ -48,6 +48,7 @@ class UploadTheme extends Themelet { Files URLs + Image-Specific Tags "; @@ -56,15 +57,24 @@ class UploadTheme extends Themelet { + "; } } else { + $upload_list .= " + + Files + Image-Specific Tags + + "; + for($i=0; $i<$upload_count; $i++) { $upload_list .= " + "; } diff --git a/ext/user/main.php b/ext/user/main.php index 0d5652f0..27e59e01 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -339,7 +339,7 @@ class UserPage extends Extension { $database->Execute( "INSERT INTO users (name, pass, joindate, email, class) VALUES (:username, :hash, now(), :email, :class)", array("username"=>$event->username, "hash"=>$hash, "email"=>$email, "class"=>$class)); - $uid = $database->get_last_insert_id(); + $uid = $database->get_last_insert_id('users_id_seq'); log_info("user", "Created User #$uid ({$event->username})"); } diff --git a/install.php b/install.php old mode 100755 new mode 100644 index 32fd376e..3ef97def --- a/install.php +++ b/install.php @@ -354,7 +354,7 @@ function insert_defaults() { // {{{ $db = new Database(); $db->execute("INSERT INTO users(name, pass, joindate, class) VALUES(:name, :pass, now(), :class)", Array("name" => 'Anonymous', "pass" => null, "class" => 'anonymous')); - $db->execute("INSERT INTO config(name, value) VALUES(:name, :value)", Array("name" => 'anon_id', "value" => $db->get_last_insert_id())); + $db->execute("INSERT INTO config(name, value) VALUES(:name, :value)", Array("name" => 'anon_id', "value" => $db->get_last_insert_id('users_id_seq'))); if(check_im_version() > 0) { $db->execute("INSERT INTO config(name, value) VALUES(:name, :value)", Array("name" => 'thumb_engine', "value" => 'convert')); diff --git a/lib/jquery.timeago-0.10.0.min.js b/lib/jquery.timeago-0.10.0.min.js index 4cfb3f4d..5c750501 100644 --- a/lib/jquery.timeago-0.10.0.min.js +++ b/lib/jquery.timeago-0.10.0.min.js @@ -1 +1 @@ -(function(d){d.timeago=function(g){if(g instanceof Date){return a(g)}else{if(typeof g==="string"){return a(d.timeago.parse(g))}else{return a(d.timeago.datetime(g))}}};var f=d.timeago;d.extend(d.timeago,{settings:{refreshMillis:60000,allowFuture:false,strings:{prefixAgo:null,prefixFromNow:null,suffixAgo:"ago",suffixFromNow:"from now",seconds:"less than a minute",minute:"about a minute",minutes:"%d minutes",hour:"about an hour",hours:"about %d hours",day:"a day",days:"%d days",month:"about a month",months:"%d months",year:"about a year",years:"%d years",numbers:[]}},inWords:function(l){var m=this.settings.strings;var i=m.prefixAgo;var q=m.suffixAgo;if(this.settings.allowFuture){if(l<0){i=m.prefixFromNow;q=m.suffixFromNow}}var o=Math.abs(l)/1000;var g=o/60;var n=g/60;var p=n/24;var j=p/365;function h(r,t){var s=d.isFunction(r)?r(t,l):r;var u=(m.numbers&&m.numbers[t])||t;return s.replace(/%d/i,u)}var k=o<45&&h(m.seconds,Math.round(o))||o<90&&h(m.minute,1)||g<45&&h(m.minutes,Math.round(g))||g<90&&h(m.hour,1)||n<24&&h(m.hours,Math.round(n))||n<48&&h(m.day,1)||p<30&&h(m.days,Math.floor(p))||p<60&&h(m.month,1)||p<365&&h(m.months,Math.floor(p/30))||j<2&&h(m.year,1)||h(m.years,Math.floor(j));return d.trim([i,k,q].join(" "))},parse:function(h){var g=d.trim(h);g=g.replace(/\.\d\d\d+/,"");g=g.replace(/-/,"/").replace(/-/,"/");g=g.replace(/T/," ").replace(/Z/," UTC");g=g.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2");return new Date(g)},datetime:function(h){var i=d(h).get(0).tagName.toLowerCase()==="time";var g=i?d(h).attr("datetime"):d(h).attr("title");return f.parse(g)}});d.fn.timeago=function(){var h=this;h.each(c);var g=f.settings;if(g.refreshMillis>0){setInterval(function(){h.each(c)},g.refreshMillis)}return h};function c(){var g=b(this);if(!isNaN(g.datetime)){d(this).text(a(g.datetime))}return this}function b(g){g=d(g);if(!g.data("timeago")){g.data("timeago",{datetime:f.datetime(g)});var h=d.trim(g.text());if(h.length>0){g.attr("title",h)}}return g.data("timeago")}function a(g){return f.inWords(e(g))}function e(g){return(new Date().getTime()-g.getTime())}document.createElement("abbr");document.createElement("time")}(jQuery)); \ No newline at end of file +(function(d){d.timeago=function(g){if(g instanceof Date){return a(g)}else{if(typeof g==="string"){return a(d.timeago.parse(g))}else{return a(d.timeago.datetime(g))}}};var f=d.timeago;d.extend(d.timeago,{settings:{refreshMillis:60000,allowFuture:false,strings:{prefixAgo:null,prefixFromNow:null,suffixAgo:"ago",suffixFromNow:"from now",seconds:"less than a minute",minute:"a minute",minutes:"%d minutes",hour:"an hour",hours:"%d hours",day:"a day",days:"%d days",month:"a month",months:"%d months",year:"a year",years:"%d years",numbers:[]}},inWords:function(l){var m=this.settings.strings;var i=m.prefixAgo;var q=m.suffixAgo;if(this.settings.allowFuture){if(l<0){i=m.prefixFromNow;q=m.suffixFromNow}}var o=Math.abs(l)/1000;var g=o/60;var n=g/60;var p=n/24;var j=p/365;function h(r,t){var s=d.isFunction(r)?r(t,l):r;var u=(m.numbers&&m.numbers[t])||t;return s.replace(/%d/i,u)}var k=o<45&&h(m.seconds,Math.round(o))||o<90&&h(m.minute,1)||g<45&&h(m.minutes,Math.round(g))||g<90&&h(m.hour,1)||n<24&&h(m.hours,Math.round(n))||n<48&&h(m.day,1)||p<30&&h(m.days,Math.floor(p))||p<60&&h(m.month,1)||p<365&&h(m.months,Math.floor(p/30))||j<2&&h(m.year,1)||h(m.years,Math.floor(j));return d.trim([i,k,q].join(" "))},parse:function(h){var g=d.trim(h);g=g.replace(/\.\d\d\d+/,"");g=g.replace(/-/,"/").replace(/-/,"/");g=g.replace(/T/," ").replace(/Z/," UTC");g=g.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2");return new Date(g)},datetime:function(h){var i=d(h).get(0).tagName.toLowerCase()==="time";var g=i?d(h).attr("datetime"):d(h).attr("title");return f.parse(g)}});d.fn.timeago=function(){var h=this;h.each(c);var g=f.settings;if(g.refreshMillis>0){setInterval(function(){h.each(c)},g.refreshMillis)}return h};function c(){var g=b(this);if(!isNaN(g.datetime)){d(this).text(a(g.datetime))}return this}function b(g){g=d(g);if(!g.data("timeago")){g.data("timeago",{datetime:f.datetime(g)});var h=d.trim(g.text());if(h.length>0){g.attr("title",h)}}return g.data("timeago")}function a(g){return f.inWords(e(g))}function e(g){return(new Date().getTime()-g.getTime())}document.createElement("abbr");document.createElement("time")}(jQuery)); diff --git a/themes/default/layout.class.php b/themes/default/layout.class.php index 9144be08..0673cdf5 100644 --- a/themes/default/layout.class.php +++ b/themes/default/layout.class.php @@ -91,8 +91,9 @@ EOD; $b = $block->body; $html = ""; $i = str_replace(' ', '_', $h) . $salt; + $h_toggler = $hidable ? " shm-toggler" : ""; if(!is_null($h)) $html .= " -

$h

+

$h

"; if(!is_null($b)) { if(strpos($b, "") === FALSE) {