From d98962a30ecde5bc830af7b8896daf722b032f32 Mon Sep 17 00:00:00 2001 From: Shish Date: Thu, 22 Jan 2009 05:42:44 -0800 Subject: [PATCH] a bunch of fixes --- contrib/event_log/main.php | 4 ++-- contrib/numeric_score/main.php | 9 --------- contrib/rating/main.php | 2 +- contrib/report_image/main.php | 6 ++---- contrib/report_image/theme.php | 2 +- contrib/tag_history/main.php | 4 ++-- contrib/text_score/main.php | 2 +- core/imageboard.pack.php | 4 ++-- ext/tag_list/main.php | 1 + ext/user/theme.php | 8 ++++---- ext/view/main.php | 9 +++++---- install.php | 17 +++++++---------- 12 files changed, 28 insertions(+), 40 deletions(-) diff --git a/contrib/event_log/main.php b/contrib/event_log/main.php index 053696d7..0f9e244d 100644 --- a/contrib/event_log/main.php +++ b/contrib/event_log/main.php @@ -82,11 +82,11 @@ class EventLog implements Extension { $this->add_to_log($user, 'Image Deletion', "Deleted image {$event->image->id} (tags: {$event->image->get_tag_list()})"); } if($event instanceof SourceSetEvent) { - $this->add_to_log($user, 'Source Set', "Source for image #{$event->image_id} set to '{$event->source}'"); + $this->add_to_log($user, 'Source Set', "Source for image #{$event->image->id} set to '{$event->source}'"); } if($event instanceof TagSetEvent) { $tags = implode($event->tags, ", "); - $this->add_to_log($user, 'Tags Set', "Tags for image #{$event->image_id} set to '$tags'"); + $this->add_to_log($user, 'Tags Set', "Tags for image #{$event->image->id} set to '$tags'"); } } diff --git a/contrib/numeric_score/main.php b/contrib/numeric_score/main.php index 393112c2..1182a14c 100644 --- a/contrib/numeric_score/main.php +++ b/contrib/numeric_score/main.php @@ -53,15 +53,6 @@ class NumericScore implements Extension { } } - if($event instanceof ImageInfoSetEvent) { - global $user; - $char = $_POST['numeric_score']; - $score = 0; - if($char == "u") $score = 1; - else if($char == "d") $score = -1; - if($score != 0) send_event(new NumericScoreSetEvent($event->image_id, $user, $score)); - } - if($event instanceof NumericScoreSetEvent) { $this->add_vote($event->image_id, $event->user->id, $event->score); } diff --git a/contrib/rating/main.php b/contrib/rating/main.php index 73194318..bab3576f 100644 --- a/contrib/rating/main.php +++ b/contrib/rating/main.php @@ -47,7 +47,7 @@ class Ratings implements Extension { if($event instanceof ImageInfoSetEvent) { global $user; if($user->is_admin()) { - send_event(new RatingSetEvent($event->image_id, $user, $_POST['rating'])); + send_event(new RatingSetEvent($event->image->id, $user, $_POST['rating'])); } } diff --git a/contrib/report_image/main.php b/contrib/report_image/main.php index 5025d621..ecb72083 100755 --- a/contrib/report_image/main.php +++ b/contrib/report_image/main.php @@ -85,10 +85,8 @@ class ReportImage implements Extension { } if($event instanceof DisplayingImageEvent) { - global $user; - global $config; - if($config->get_bool('report_image_anon') || !$user->is_anonymous()) { - $this->theme->display_image_banner($event->page, $event->image->id); + if($event->context->config->get_bool('report_image_anon') || !$event->context->user->is_anonymous()) { + $this->theme->display_image_banner($event->page, $event->image); } } diff --git a/contrib/report_image/theme.php b/contrib/report_image/theme.php index 528b6769..6cfc99f5 100755 --- a/contrib/report_image/theme.php +++ b/contrib/report_image/theme.php @@ -74,7 +74,7 @@ class ReportImageTheme extends Themelet { public function display_image_banner(Page $page, Image $image) { global $config; - $i_image = int_escape($image); + $i_image = int_escape($image->id); $html = "
diff --git a/contrib/tag_history/main.php b/contrib/tag_history/main.php index 1a7ab8d6..20d0ef70 100644 --- a/contrib/tag_history/main.php +++ b/contrib/tag_history/main.php @@ -57,7 +57,7 @@ class Tag_History implements Extension { $event->panel->add_block($sb); } if(($event instanceof TagSetEvent)) { - $this->add_tag_history($event->image_id, $event->tags); + $this->add_tag_history($event->image->id, $event->tags); } } @@ -76,7 +76,7 @@ class Tag_History implements Extension { date_set DATETIME NOT NULL, INDEX(image_id), FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - FOREIGN KEY (user_id) REFERENCES images(id) ON DELETE CASCADE + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE "); $config->set_int("ext_tag_history_version", 3); } diff --git a/contrib/text_score/main.php b/contrib/text_score/main.php index f28ee838..853d45db 100644 --- a/contrib/text_score/main.php +++ b/contrib/text_score/main.php @@ -48,7 +48,7 @@ class TextScore implements Extension { $i_score = int_escape($_POST['text_score__score']); if($i_score >= -2 || $i_score <= 2) { - send_event(new TextScoreSetEvent($event->image_id, $user, $i_score)); + send_event(new TextScoreSetEvent($event->image->id, $user, $i_score)); } } diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 9001e3bc..7864bec6 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -173,7 +173,7 @@ class Image { return $this->parse_link_template(make_link('_images/$hash/$id - $tags.$ext')); } else { - return $this->parse_link_template('image/$id.$ext'); + return $this->parse_link_template(make_link('image/$id.$ext')); } } @@ -190,7 +190,7 @@ class Image { return $this->parse_link_template(make_link('_thumbs/$hash/thumb.jpg')); } else { - return $this->parse_link_template('image/$id.jpg'); + return $this->parse_link_template(make_link('image/$id.jpg')); } } diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index 516261ee..ae36bd91 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -193,6 +193,7 @@ class TagList implements Extension { $h_tag = html_escape($row['tag']); $link = $this->tag_link($row['tag']); $image = Image::by_random($config, $database, array($row['tag'])); + if(is_null($image)) continue; // one of the popular tags has no images $thumb = $image->get_thumb_link(); $html .= "
$h_tag
\n"; if($n%3==2) $html .= ""; diff --git a/ext/user/theme.php b/ext/user/theme.php index ca1eb3e3..681e8c9f 100644 --- a/ext/user/theme.php +++ b/ext/user/theme.php @@ -33,7 +33,7 @@ class UserPageTheme extends Themelet { $html .= " - +
@@ -61,7 +61,7 @@ class UserPageTheme extends Themelet { global $config; $html = " -
Name
Password
Repeat Password
+
@@ -148,8 +148,8 @@ class UserPageTheme extends Themelet { -
Name
Password
- +
Change Password
+ diff --git a/ext/view/main.php b/ext/view/main.php index 527e7562..2e1a637f 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -9,11 +9,12 @@ * which only appears when an image actually exists. */ class DisplayingImageEvent extends Event { - var $image, $page; + var $image, $page, $context; - public function DisplayingImageEvent($image, $page) { + public function __construct(RequestContext $context, Image $image) { + parent::__construct($context); $this->image = $image; - $this->page = $page; + $this->page = $context->page; } public function get_image() { @@ -74,7 +75,7 @@ class ViewImage implements Extension { $image = Image::by_id($config, $database, $image_id); if(!is_null($image)) { - send_event(new DisplayingImageEvent($image, $event->page)); + send_event(new DisplayingImageEvent($event->context, $image)); $iabbe = new ImageAdminBlockBuildingEvent($image, $event->user); send_event($iabbe); ksort($iabbe->parts); diff --git a/install.php b/install.php index 8e0a3c48..46195d7b 100644 --- a/install.php +++ b/install.php @@ -154,7 +154,7 @@ function create_tables($dsn) { // {{{ $db->execute($engine->create_table_sql("aliases", " oldtag VARCHAR(128) NOT NULL PRIMARY KEY, newtag VARCHAR(128) NOT NULL, - UNIQUE(oldtag, newtag) + INDEX(newtag) ")); $db->execute($engine->create_table_sql("config", " name VARCHAR(128) NOT NULL PRIMARY KEY, @@ -162,12 +162,11 @@ function create_tables($dsn) { // {{{ ")); $db->execute($engine->create_table_sql("users", " id SCORE_AIPK, - name VARCHAR(32) NOT NULL, + name VARCHAR(32) UNIQUE NOT NULL, pass CHAR(32), joindate DATETIME NOT NULL DEFAULT SCORE_NOW, admin SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, - email VARCHAR(128), - INDEX(name) + email VARCHAR(128) ")); $db->execute($engine->create_table_sql("images", " id SCORE_AIPK, @@ -175,30 +174,28 @@ function create_tables($dsn) { // {{{ owner_ip SCORE_INET NOT NULL, filename VARCHAR(64) NOT NULL, filesize INTEGER NOT NULL, - hash CHAR(32) NOT NULL, + hash CHAR(32) UNIQUE NOT NULL, ext CHAR(4) NOT NULL, source VARCHAR(255), width INTEGER NOT NULL, height INTEGER NOT NULL, posted TIMESTAMP NOT NULL DEFAULT SCORE_NOW, INDEX(owner_id), - INDEX(hash), INDEX(width), INDEX(height), FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE ")); $db->execute($engine->create_table_sql("tags", " id SCORE_AIPK, - tag VARCHAR(64) NOT NULL, - count INTEGER NOT NULL DEFAULT 0, - UNIQUE(tag) + tag VARCHAR(64) UNIQUE NOT NULL, + count INTEGER NOT NULL DEFAULT 0 ")); $db->execute($engine->create_table_sql("image_tags", " image_id INTEGER NOT NULL, tag_id INTEGER NOT NULL, INDEX(image_id), INDEX(tag_id), - INDEX(image_id, tag_id), + UNIQUE(image_id, tag_id), FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE "));
Change Password
Password
Repeat Password