diff --git a/contrib/image_hash_ban/main.php b/contrib/image_hash_ban/main.php index 4d0236bd..c58006a5 100644 --- a/contrib/image_hash_ban/main.php +++ b/contrib/image_hash_ban/main.php @@ -46,8 +46,9 @@ class Image_Hash_Ban extends Extension { if(is_a($event, 'DataUploadEvent')) { global $database; - if ($database->db->GetOne("SELECT COUNT(*) FROM image_bans WHERE hash = ?", $event->hash) == 1) { - $event->veto("This image has been banned!"); + $row = $database->db->GetRow("SELECT * FROM image_bans WHERE hash = ?", $event->hash); + if($row) { + $event->veto("Image ".html_escape($row["hash"])." has been banned, reason: ".format_text($row["reason"])); } } diff --git a/core/util.inc.php b/core/util.inc.php index e4ca8512..a62609f8 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -162,7 +162,12 @@ function _count_execs($db, $sql, $inputarray) { global $_execs; if(DEBUG) { $fp = fopen("sql.log", "a"); - fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)."\n"); + if(is_array($inputarray)) { + fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)." -- ".join(", ", $inputarray)."\n"); + } + else { + fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)."\n"); + } fclose($fp); } if (!is_array($inputarray)) $_execs++; @@ -262,6 +267,12 @@ function move_upload_to_archive($event) { return true; } +function format_text($string) { + $tfe = new TextFormattingEvent($string); + send_event($tfe); + return $tfe->formatted; +} + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Debugging functions * @@ -287,9 +298,13 @@ function get_debug_info() { } $i_files = count(get_included_files()); global $_execs; + global $database; + $hits = $database->cache_hits; + $miss = $database->cache_misses; $debug = "
Took $i_utime + $i_stime seconds and {$i_mem}MB of RAM"; $debug .= "; Used $i_files files and $_execs queries"; $debug .= "; Sent $_event_count events"; + $debug .= "; $hits cache hits and $miss misses"; return $debug; } diff --git a/ext/comment/main.php b/ext/comment/main.php index c143ebe2..50c76ce6 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -343,6 +343,12 @@ class CommentList extends Extension { else if($this->is_dupe($image_id, $comment)) { $event->veto("Someone already made that comment on that image -- try and be more original?"); } + else if(strlen($comment) > 9000) { + $event->veto("Comment too long~"); + } + else if(strlen($comment)/strlen(gzcompress($comment)) > 10) { + $event->veto("Comment too repetitive~"); + } else if($user->is_anonymous() && $this->is_spam($comment)) { $event->veto("Akismet thinks that your comment is spam. Try rewriting the comment, or logging in."); }