diff --git a/contrib/mass_tagger/main.php b/contrib/mass_tagger/main.php
index 751cfcdf..f91c05a5 100644
--- a/contrib/mass_tagger/main.php
+++ b/contrib/mass_tagger/main.php
@@ -31,7 +31,7 @@ class MassTagger extends Extension {
if($event->get_arg(0) == "tag") $this->_apply_mass_tags( $config, $page, $user, $event );
}
- private function _apply_mass_tags( $config, $page, $user, $event ) {
+ private function _apply_mass_tags( $config, Page $page, $user, $event ) {
if( !isset($_POST['ids']) or !isset($_POST['tag']) ) return;
$tag = $_POST['tag'];
diff --git a/contrib/rating/main.php b/contrib/rating/main.php
index ac9ba0fb..072f11e2 100644
--- a/contrib/rating/main.php
+++ b/contrib/rating/main.php
@@ -167,7 +167,7 @@ class Ratings extends Extension {
return $sqes;
}
- public static function privs_to_sql($sqes) {
+ public static function privs_to_sql(/*string*/ $sqes) {
$arr = array();
$length = strlen($sqes);
for($i=0; $i<$length; $i++) {
@@ -177,7 +177,7 @@ class Ratings extends Extension {
return $set;
}
- public static function rating_to_human($rating) {
+ public static function rating_to_human(/*string*/ $rating) {
switch($rating) {
case "s": return "Safe";
case "q": return "Questionable";
@@ -225,7 +225,7 @@ class Ratings extends Extension {
}
}
- private function set_rating($image_id, $rating, $old_rating) {
+ private function set_rating(/*int*/ $image_id, /*string*/ $rating, /*string*/ $old_rating) {
global $database;
if($old_rating != $rating){
$database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $image_id));
diff --git a/contrib/rating/theme.php b/contrib/rating/theme.php
index 87efa7ef..11667a96 100644
--- a/contrib/rating/theme.php
+++ b/contrib/rating/theme.php
@@ -1,7 +1,7 @@
add_block(new Block("Bulk Rating", $html));
}
- public function rating_to_name($rating) {
+ public function rating_to_name(/*string*/ $rating) {
switch($rating) {
case 's': return "Safe";
case 'q': return "Questionable";
diff --git a/contrib/res_limit/main.php b/contrib/res_limit/main.php
index b9657a17..c17ad203 100644
--- a/contrib/res_limit/main.php
+++ b/contrib/res_limit/main.php
@@ -2,6 +2,7 @@
/*
* Name: Resolution Limiter
* Author: Shish
+ * Link: http://code.shishnet.org/shimmie2/
* License: GPLv2
* Description: Allows the admin to set min / max image dimentions
*/
diff --git a/contrib/resize/main.php b/contrib/resize/main.php
index 38075290..51b1bf24 100644
--- a/contrib/resize/main.php
+++ b/contrib/resize/main.php
@@ -143,16 +143,14 @@ class ResizeImage extends Extension {
// Private functions
+ /* ----------------------------- */
/*
This function could be made much smaller by using the ImageReplaceEvent
ie: Pretend that we are replacing the image with a resized copy.
*/
- private function resize_image($image_id, $width, $height) {
- global $config;
- global $user;
- global $page;
- global $database;
+ private function resize_image(/*int*/ $image_id, /*int*/ $width, /*int*/ $height) {
+ global $config, $user, $page, $database;
if ( ($height <= 0) && ($width <= 0) ) {
throw new ImageResizeException("Invalid options for height and width. ($width x $height)");
diff --git a/contrib/resize/theme.php b/contrib/resize/theme.php
index ee920b81..c331dbbb 100644
--- a/contrib/resize/theme.php
+++ b/contrib/resize/theme.php
@@ -4,9 +4,8 @@ class ResizeImageTheme extends Themelet {
/*
* Display a link to resize an image
*/
- public function get_resize_html($image_id) {
- global $user;
- global $config;
+ public function get_resize_html(/*int*/ $image_id) {
+ global $user, $config;
$i_image_id = int_escape($image_id);
@@ -20,14 +19,14 @@ class ResizeImageTheme extends Themelet {
return $html;
}
- public function display_resize_error(Page $page, $title, $message) {
+ public function display_resize_error(Page $page, /*string*/ $title, /*string*/ $message) {
$page->set_title("Resize Image");
$page->set_heading("Resize Image");
$page->add_block(new NavBlock());
$page->add_block(new Block($title, $message));
}
- public function display_resize_page(Page $page, $image_id) {
+ public function display_resize_page(Page $page, /*int*/ $image_id) {
global $config;
$default_width = $config->get_int('resize_default_width');
diff --git a/contrib/rss_comments/main.php b/contrib/rss_comments/main.php
index d7c02b87..a141cc39 100644
--- a/contrib/rss_comments/main.php
+++ b/contrib/rss_comments/main.php
@@ -2,6 +2,7 @@
/*
* Name: RSS for Comments
* Author: Shish
+ * Link: http://code.shishnet.org/shimmie2/
* License: GPLv2
* Description: Self explanatory
*/
diff --git a/contrib/rss_images/main.php b/contrib/rss_images/main.php
index 26924d62..55bad355 100644
--- a/contrib/rss_images/main.php
+++ b/contrib/rss_images/main.php
@@ -2,6 +2,7 @@
/*
* Name: RSS for Images
* Author: Shish
+ * Link: http://code.shishnet.org/shimmie2/
* License: GPLv2
* Description: Self explanatory
*/
@@ -33,7 +34,7 @@ class RSS_Images extends Extension {
}
- private function do_rss($images, $search_terms, $page_number) {
+ private function do_rss($images, $search_terms, /*int*/ $page_number) {
global $page;
global $config;
$page->set_mode("data");
diff --git a/contrib/simpletest/main.php b/contrib/simpletest/main.php
index 38666898..f0b91ffb 100644
--- a/contrib/simpletest/main.php
+++ b/contrib/simpletest/main.php
@@ -2,6 +2,7 @@
/*
* Name: SimpleTest integration
* Author: Shish
+ * Link: http://code.shishnet.org/shimmie2/
* License: GPLv2
* Description: adds unit testing to SCore
*/
diff --git a/contrib/tag_history/main.php b/contrib/tag_history/main.php
index 8525c9ea..02f42948 100644
--- a/contrib/tag_history/main.php
+++ b/contrib/tag_history/main.php
@@ -9,7 +9,7 @@ class Tag_History extends Extension {
// in before tags are actually set, so that "get current tags" works
public function get_priority() {return 40;}
- public function onInitExtEvent(InitExtEvent $event) {
+ public function onInitExt(InitExtEvent $event) {
global $config;
$config->set_default_int("history_limit", -1);
@@ -19,7 +19,7 @@ class Tag_History extends Extension {
}
}
- public function onAdminBuildingEvent(AdminBuildingEvent $event) {
+ public function onAdminBuilding(AdminBuildingEvent $event) {
global $user;
if(isset($_POST['revert_ip']) && $user->is_admin() && $user->check_auth_token()) {
@@ -110,8 +110,7 @@ class Tag_History extends Extension {
}
protected function install() {
- global $database;
- global $config;
+ global $database, $config;
if($config->get_int("ext_tag_history_version") < 1) {
$database->create_table("tag_histories", "
@@ -188,7 +187,7 @@ class Tag_History extends Extension {
* This function is used by process_revert_all_changes_by_ip()
* to just revert an image's tag history.
*/
- private function process_revert_request_only($revert_id)
+ private function process_revert_request_only(/*int*/ $revert_id)
{
if(empty($revert_id)) {
return;
@@ -214,7 +213,7 @@ class Tag_History extends Extension {
send_event(new TagSetEvent(Image::by_id($stored_image_id), $stored_tags));
}
- public function get_tag_history_from_revert($revert_id)
+ public function get_tag_history_from_revert(/*int*/ $revert_id)
{
global $database;
$row = $database->get_row("
@@ -225,7 +224,7 @@ class Tag_History extends Extension {
return ($row ? $row : null);
}
- public function get_tag_history_from_id($image_id)
+ public function get_tag_history_from_id(/*int*/ $image_id)
{
global $database;
$row = $database->get_all("
@@ -315,7 +314,7 @@ class Tag_History extends Extension {
/*
* this function is called when an image has been deleted
*/
- private function delete_all_tag_history($image_id)
+ private function delete_all_tag_history(/*int*/ $image_id)
{
global $database;
$database->execute("DELETE FROM tag_histories WHERE image_id = ?", array($image_id));
@@ -326,25 +325,32 @@ class Tag_History extends Extension {
*/
private function add_tag_history($image, $tags)
{
- global $database;
- global $config;
- global $user;
+ global $database, $config, $user;
$new_tags = Tag::implode($tags);
$old_tags = Tag::implode($image->get_tag_array());
- log_debug("tag_history", "adding tag history: [$old_tags] -> [$new_tags]");
+
if($new_tags == $old_tags) return;
+
+ if (empty($old_tags)) {
+ /* no old tags, so we are probably adding the image for the first time */
+ log_debug("tag_history", "adding new tag history: [$new_tags]");
+ } else {
+ log_debug("tag_history", "adding tag history: [$old_tags] -> [$new_tags]");
+ }
+
$allowed = $config->get_int("history_limit");
if($allowed == 0) return;
// if the image has no history, make one with the old tags
$entries = $database->get_one("SELECT COUNT(*) FROM tag_histories WHERE image_id = ?", array($image->id));
if($entries == 0){
+ /* We have no tag history for this image, so we will use the new_tags as the starting tags for this image. */
/* these two queries could probably be combined */
$database->execute("
INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set)
VALUES (?, ?, ?, ?, now())",
- array($image->id, $old_tags, 1, '127.0.0.1')); // TODO: Pick appropriate user id
+ array($image->id, $new_tags, 1, '127.0.0.1')); // TODO: Pick appropriate user id
$entries++;
}
@@ -360,6 +366,13 @@ class Tag_History extends Extension {
if($entries > $allowed)
{
// TODO: Make these queries better
+ /*
+ MySQL does NOT allow you to modify the same table which you use in the SELECT part.
+ Which means that these will probably have to stay as TWO separate queries...
+
+ http://dev.mysql.com/doc/refman/5.1/en/subquery-restrictions.html
+ http://stackoverflow.com/questions/45494/mysql-error-1093-cant-specify-target-table-for-update-in-from-clause
+ */
$min_id = $database->get_one("SELECT MIN(id) FROM tag_histories WHERE image_id = ?", array($image->id));
$database->execute("DELETE FROM tag_histories WHERE id = ?", array($min_id));
}
diff --git a/contrib/tag_history/theme.php b/contrib/tag_history/theme.php
index 842ed8bd..77ee1ad8 100644
--- a/contrib/tag_history/theme.php
+++ b/contrib/tag_history/theme.php
@@ -7,7 +7,7 @@
class Tag_HistoryTheme extends Themelet {
var $messages = array();
- public function display_history_page(Page $page, $image_id, $history) {
+ public function display_history_page(Page $page, /*int*/ $image_id, /*array*/ $history) {
global $user;
$start_string = "
@@ -50,7 +50,7 @@ class Tag_HistoryTheme extends Themelet {
$page->add_block(new Block("Tag History", $history_html, "main", 10));
}
- public function display_global_page(Page $page, $history) {
+ public function display_global_page(Page $page, /*array*/ $history) {
$start_string = "
".make_form(make_link("tag_history/revert"))."
@@ -91,7 +91,7 @@ class Tag_HistoryTheme extends Themelet {
$page->add_block(new Block("Tag History", $history_html, "main", 10));
}
- public function display_history_link(Page $page, $image_id) {
+ public function display_history_link(Page $page, /*int*/ $image_id) {
$link = 'Tag History';
$page->add_block(new Block(null, $link, "main", 5));
}
@@ -99,7 +99,7 @@ class Tag_HistoryTheme extends Themelet {
/*
* Add a section to the admin page.
*/
- public function display_admin_block($validation_msg='') {
+ public function display_admin_block(/*string*/ $validation_msg='') {
global $page;
if (!empty($validation_msg)) {
@@ -130,7 +130,7 @@ class Tag_HistoryTheme extends Themelet {
$page->add_block(new Block("Revert by IP", $html));
}
- public function add_status($title, $body) {
+ public function add_status(/*string*/ $title, /*string*/ $body) {
$this->messages[] = '
'. $title .' '. $body .'
';
}
}
diff --git a/contrib/twitter_soc/main.php b/contrib/twitter_soc/main.php
index 90f60658..c81a2d6a 100644
--- a/contrib/twitter_soc/main.php
+++ b/contrib/twitter_soc/main.php
@@ -2,6 +2,7 @@
/*
* Name: Tweet!
* Author: Shish
+ * Link: http://code.shishnet.org/shimmie2/
* License: GPLv2
* Description: Show a twitter feed with the Sea of Clouds script
*/
diff --git a/contrib/twitter_soc/theme.php b/contrib/twitter_soc/theme.php
index be5c68fe..efbf7959 100644
--- a/contrib/twitter_soc/theme.php
+++ b/contrib/twitter_soc/theme.php
@@ -4,7 +4,7 @@ class TwitterSocTheme extends Themelet {
/*
* Show $text on the $page
*/
- public function display_feed(Page $page, $username) {
+ public function display_feed(Page $page, /*string*/ $username) {
$page->add_block(new Block("Tweets", '
Follow us on Twitter
diff --git a/contrib/word_filter/main.php b/contrib/word_filter/main.php
index df13e73f..f85cc3de 100644
--- a/contrib/word_filter/main.php
+++ b/contrib/word_filter/main.php
@@ -2,6 +2,7 @@
/*
* Name: Word Filter
* Author: Shish
+ * Link: http://code.shishnet.org/shimmie2/
* License: GPLv2
* Description: Simple search and replace
*/
@@ -22,7 +23,7 @@ class WordFilter extends Extension {
$event->panel->add_block($sb);
}
- private function filter($text) {
+ private function filter(/*string*/ $text) {
$map = $this->get_map();
foreach($map as $search => $replace) {
$search = trim($search);
diff --git a/core/util.inc.php b/core/util.inc.php
index 69822c94..4fa1eb88 100644
--- a/core/util.inc.php
+++ b/core/util.inc.php
@@ -671,16 +671,16 @@ define("SCORE_LOG_NOTSET", 0);
/**
* A shorthand way to send a LogEvent
*/
-function log_msg($section, $priority, $message) {
+function log_msg(/*string*/ $section, /*int*/ $priority, /*string*/ $message) {
send_event(new LogEvent($section, $priority, $message));
}
// More shorthand ways of logging
-function log_debug($section, $message) {log_msg($section, SCORE_LOG_DEBUG, $message);}
-function log_info($section, $message) {log_msg($section, SCORE_LOG_INFO, $message);}
-function log_warning($section, $message) {log_msg($section, SCORE_LOG_WARNING, $message);}
-function log_error($section, $message) {log_msg($section, SCORE_LOG_ERROR, $message);}
-function log_critical($section, $message) {log_msg($section, SCORE_LOG_CRITICAL, $message);}
+function log_debug(/*string*/ $section, /*string*/ $message) {log_msg($section, SCORE_LOG_DEBUG, $message);}
+function log_info(/*string*/ $section, /*string*/ $message) {log_msg($section, SCORE_LOG_INFO, $message);}
+function log_warning(/*string*/ $section, /*string*/ $message) {log_msg($section, SCORE_LOG_WARNING, $message);}
+function log_error(/*string*/ $section, /*string*/ $message) {log_msg($section, SCORE_LOG_ERROR, $message);}
+function log_critical(/*string*/ $section, /*string*/ $message) {log_msg($section, SCORE_LOG_CRITICAL, $message);}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
diff --git a/ext/comment/theme.php b/ext/comment/theme.php
index e4b63f04..acdabed2 100644
--- a/ext/comment/theme.php
+++ b/ext/comment/theme.php
@@ -171,14 +171,14 @@ class CommentListTheme extends Themelet {
$anoncode2 = "";
if($this->show_anon_id) {
$anoncode = ''.$this->anon_id.'';
- }
- if($user->can("view_ip")) {
- #$style = " style='color: ".$this->get_anon_colour($comment->poster_ip).";'";
- if(!array_key_exists($comment->poster_ip, $this->anon_map)) {
- $this->anon_map[$comment->poster_ip] = $this->anon_id;
- }
- if($this->anon_map[$comment->poster_ip] != $this->anon_id) {
- $anoncode2 = '('.$this->anon_map[$comment->poster_ip].')';
+ if($user->can("view_ip")) {
+ #$style = " style='color: ".$this->get_anon_colour($comment->poster_ip).";'";
+ if(!array_key_exists($comment->poster_ip, $this->anon_map)) {
+ $this->anon_map[$comment->poster_ip] = $this->anon_id;
+ }
+ if($this->anon_map[$comment->poster_ip] != $this->anon_id) {
+ $anoncode2 = '('.$this->anon_map[$comment->poster_ip].')';
+ }
}
}
$h_userlink = "" . $h_name . $anoncode . $anoncode2 . "";
diff --git a/ext/ext_manager/theme.php b/ext/ext_manager/theme.php
index 25f4aac7..7dd74d5c 100644
--- a/ext/ext_manager/theme.php
+++ b/ext/ext_manager/theme.php
@@ -1,7 +1,7 @@
Enabled" : "";
$html = "
diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php
index 2904ed0f..b5bb9601 100644
--- a/ext/handle_pixel/main.php
+++ b/ext/handle_pixel/main.php
@@ -2,6 +2,7 @@
/**
* Name: Handle Pixel
* Author: Shish
+ * Link: http://code.shishnet.org/shimmie2/
* Description: Handle JPEG, PNG, GIF, etc files
*/
@@ -17,7 +18,7 @@ class PixelFileHandler extends DataHandlerExtension {
return in_array(strtolower($ext), $exts);
}
- protected function create_image_from_data($filename, $metadata) {
+ protected function create_image_from_data(/*string*/ $filename, /*array*/ $metadata) {
global $config;
$image = new Image();
@@ -38,7 +39,7 @@ class PixelFileHandler extends DataHandlerExtension {
return $image;
}
- protected function check_contents($file) {
+ protected function check_contents(/*string*/ $file) {
$valid = Array(IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG);
if(!file_exists($file)) return false;
$info = getimagesize($file);
@@ -47,7 +48,7 @@ class PixelFileHandler extends DataHandlerExtension {
return false;
}
- protected function create_thumb($hash) {
+ protected function create_thumb(/*string*/ $hash) {
$outname = warehouse_path("thumbs", $hash);
if(file_exists($outname)) {
return true;
@@ -55,7 +56,7 @@ class PixelFileHandler extends DataHandlerExtension {
return $this->create_thumb_force($hash);
}
- protected function create_thumb_force($hash) {
+ protected function create_thumb_force(/*string*/ $hash) {
$inname = warehouse_path("images", $hash);
$outname = warehouse_path("thumbs", $hash);
global $config;
@@ -76,7 +77,7 @@ class PixelFileHandler extends DataHandlerExtension {
}
// IM thumber {{{
- private function make_thumb_convert($inname, $outname) {
+ private function make_thumb_convert(/*string*/ $inname, /*string*/ $outname) {
global $config;
$w = $config->get_int("thumb_width");
@@ -113,7 +114,7 @@ class PixelFileHandler extends DataHandlerExtension {
}
// }}}
// epeg thumber {{{
- private function make_thumb_epeg($inname, $outname) {
+ private function make_thumb_epeg(/*string*/ $inname, /*string*/ $outname) {
global $config;
$w = $config->get_int("thumb_width");
exec("epeg $inname -c 'Created by EPEG' --max $w $outname");
@@ -121,7 +122,7 @@ class PixelFileHandler extends DataHandlerExtension {
}
// }}}
// GD thumber {{{
- private function make_thumb_gd($inname, $outname) {
+ private function make_thumb_gd(/*string*/ $inname, /*string*/ $outname) {
global $config;
$thumb = $this->get_thumb($inname);
$ok = imagejpeg($thumb, $outname, $config->get_int('thumb_quality'));
@@ -129,7 +130,7 @@ class PixelFileHandler extends DataHandlerExtension {
return $ok;
}
- private function get_thumb($tmpname) {
+ private function get_thumb(/*string*/ $tmpname) {
global $config;
$info = getimagesize($tmpname);
@@ -165,7 +166,7 @@ class PixelFileHandler extends DataHandlerExtension {
}
}
- private function read_file($fname) {
+ private function read_file(/*string*/ $fname) {
$fp = fopen($fname, "r");
if(!$fp) return false;
diff --git a/ext/image/main.php b/ext/image/main.php
index b6d842b0..9446a3e3 100644
--- a/ext/image/main.php
+++ b/ext/image/main.php
@@ -3,6 +3,7 @@
* Name: Image Manager
* Author: Shish
* Modified by: jgen
+ * Link: http://code.shishnet.org/shimmie2/
* Description: Handle the image database
* Visibility: admin
*/
@@ -280,10 +281,7 @@ class ImageIO extends Extension {
// add image {{{
private function add_image($image) {
- global $page;
- global $user;
- global $database;
- global $config;
+ global $page, $user, $database, $config;
/*
* Validate things
diff --git a/ext/upload/main.php b/ext/upload/main.php
index d438febb..6966d198 100644
--- a/ext/upload/main.php
+++ b/ext/upload/main.php
@@ -1,7 +1,8 @@
+ * Link: http://code.shishnet.org/shimmie2/
* Description: Allows people to upload files to the website
*/
@@ -18,7 +19,7 @@ class DataUploadEvent extends Event {
* @param $tmpname The temporary file used for upload.
* @param $metadata Info about the file, should contain at least "filename", "extension", "tags" and "source".
*/
- public function DataUploadEvent(User $user, $tmpname, $metadata) {
+ public function DataUploadEvent(User $user, /*string*/ $tmpname, /*array*/ $metadata) {
assert(file_exists($tmpname));
$this->user = $user;
@@ -272,9 +273,7 @@ class Upload extends Extension {
* @retval bool TRUE on upload successful.
*/
private function try_upload($file, $tags, $source, $replace='') {
- global $page;
- global $config;
- global $user;
+ global $page, $config, $user;
if(empty($source)) $source = null;
@@ -322,9 +321,7 @@ class Upload extends Extension {
* @retval bool TRUE on transload successful.
*/
private function try_transload($url, $tags, $source, $replace='') {
- global $page;
- global $config;
- global $user;
+ global $page, $config, $user;
$ok = true;
diff --git a/ext/upload/theme.php b/ext/upload/theme.php
index 2a493007..986dd8ad 100644
--- a/ext/upload/theme.php
+++ b/ext/upload/theme.php
@@ -155,7 +155,7 @@ class UploadTheme extends Themelet {
}
/* only allows 1 file to be uploaded - for replacing another image file */
- public function display_replace_page(Page $page, $image_id) {
+ public function display_replace_page(Page $page, /*int*/ $image_id) {
global $config, $page;
$page->add_html_header("");
$tl_enabled = ($config->get_string("transload_engine", "none") != "none");
@@ -211,7 +211,7 @@ class UploadTheme extends Themelet {
$page->add_block(new Block("Upload Replacement Image", $html, "main", 20));
}
- public function display_upload_status(Page $page, $ok) {
+ public function display_upload_status(Page $page, /*bool*/ $ok) {
if($ok) {
$page->set_mode("redirect");
$page->set_redirect(make_link());
@@ -223,7 +223,7 @@ class UploadTheme extends Themelet {
}
}
- public function display_upload_error(Page $page, $title, $message) {
+ public function display_upload_error(Page $page, /*string*/ $title, /*string*/ $message) {
$page->add_block(new Block($title, $message));
}