From c8aa3327a1a23d7317b32dd58d852ca37c2963d5 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 30 Mar 2014 13:26:48 +0100 Subject: [PATCH] A bunch of small changes from scrutinizer-ci; some tidying, some actual bug fixes --- core/database.class.php | 2 + core/extension.class.php | 6 +- core/imageboard.pack.php | 6 +- core/user.class.php | 3 + core/util.inc.php | 11 ++- ext/admin/theme.php | 4 +- ext/artists/main.php | 2 +- ext/artists/theme.php | 37 ++++++---- ext/bulk_add/main.php | 3 +- ext/bulk_add_csv/main.php | 3 +- ext/bulk_remove/main.php | 9 ++- ext/chatbox/main.php | 2 +- ext/cron_uploader/main.php | 42 +++-------- ext/ext_manager/main.php | 2 + ext/favorites/main.php | 4 +- ext/handle_archive/main.php | 4 +- ext/handle_flash/main.php | 74 +++---------------- ext/handle_ico/main.php | 4 +- ext/handle_ico/test.php | 4 +- ext/handle_pixel/main.php | 17 +---- ext/handle_pixel/script.js | 14 ++-- ext/handle_video/theme.php | 3 + ext/image/main.php | 19 ++--- ext/index/theme.php | 2 + ext/link_image/theme.php | 2 +- ext/livefeed/main.php | 1 + ext/log_net/main.php | 1 + ext/not_a_tag/main.php | 6 +- ext/notes/main.php | 6 +- ext/notes/theme.php | 142 +++++++++++++++--------------------- ext/oekaki/main.php | 1 + 31 files changed, 170 insertions(+), 266 deletions(-) diff --git a/core/database.class.php b/core/database.class.php index 2ee4db23..14bac1af 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -271,11 +271,13 @@ class Database { /** * Meta info about the database engine + * @var DBEngine */ private $engine = null; /** * The currently active cache engine + * @var CacheEngine */ public $cache = null; diff --git a/core/extension.class.php b/core/extension.class.php index b288e91f..bce72590 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -140,9 +140,9 @@ abstract class FormatterExtension extends Extension { */ abstract class DataHandlerExtension extends Extension { public function onDataUpload(DataUploadEvent $event) { - global $user; - - if(($supported_ext = $this->supported_ext($event->type)) && ($check_contents = $this->check_contents($event->tmpname))) { + $supported_ext = $this->supported_ext($event->type); + $check_contents = $this->check_contents($event->tmpname); + if($supported_ext && $check_contents) { if(!move_upload_to_archive($event)) return; send_event(new ThumbnailGenerationEvent($event->hash, $event->type)); diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index f6a4500a..8e21de8b 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -122,7 +122,7 @@ class Image { if(SPEED_HAX) { if(!$user->can("big_search") and count($tags) > 3) { - die("Anonymous users may only search for up to 3 tags at a time"); // FIXME: throw an exception? + throw new SCoreException("Anonymous users may only search for up to 3 tags at a time"); } } @@ -644,7 +644,7 @@ class Image { * images table. Yes, MySQL does suck this much. */ private static function build_accurate_search_querylet($terms) { - global $config, $database; + global $database; $tag_querylets = array(); $img_querylets = array(); @@ -804,7 +804,7 @@ class Image { * build_accurate_search_querylet() for a full explanation */ private static function build_ugly_search_querylet($terms) { - global $config, $database; + global $database; $tag_querylets = array(); $img_querylets = array(); diff --git a/core/user.class.php b/core/user.class.php index 50034926..110774c5 100644 --- a/core/user.class.php +++ b/core/user.class.php @@ -15,6 +15,9 @@ class User { var $name; var $email; var $join_date; + var $passhash; + + /* @var UserClass */ var $class; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * diff --git a/core/util.inc.php b/core/util.inc.php index 6de64efb..6bda7f04 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -385,7 +385,13 @@ function make_http(/*string*/ $link) { /** * Make a form tag with relevant auth token and stuff * - * @retval string + * @param target string + * @param method string + * @param multipart boolean + * @param form_id string + * @param onsubmit string + * + * @return string */ function make_form($target, $method="POST", $multipart=False, $form_id="", $onsubmit="") { global $user; @@ -1276,6 +1282,7 @@ function _sanitise_environment() { } function _get_themelet_files($_theme) { + $base_themelets = array(); if(file_exists('themes/'.$_theme.'/custompage.class.php')) $base_themelets[] = 'themes/'.$_theme.'/custompage.class.php'; $base_themelets[] = 'themes/'.$_theme.'/layout.class.php'; $base_themelets[] = 'themes/'.$_theme.'/themelet.class.php'; @@ -1406,7 +1413,7 @@ function _decaret($str) { } function _get_user() { - global $config, $database; + global $config; $user = null; if(get_prefixed_cookie("user") && get_prefixed_cookie("session")) { $tmp_user = User::by_session(get_prefixed_cookie("user"), get_prefixed_cookie("session")); diff --git a/ext/admin/theme.php b/ext/admin/theme.php index 64c18d2f..3eefdb11 100644 --- a/ext/admin/theme.php +++ b/ext/admin/theme.php @@ -14,9 +14,9 @@ class AdminPageTheme extends Themelet { protected function button(/*string*/ $name, /*string*/ $action, /*boolean*/ $protected=false) { $c_protected = $protected ? " protected" : ""; - $html = make_form(make_link("admin/$action"), "POST", false, false, false, "admin$c_protected"); + $html = make_form(make_link("admin/$action"), "POST", false, null, null, "admin$c_protected"); if($protected) { - $html .= ""; + $html .= ""; $html .= ""; } else { diff --git a/ext/artists/main.php b/ext/artists/main.php index 38c614f9..7aea77ad 100644 --- a/ext/artists/main.php +++ b/ext/artists/main.php @@ -143,7 +143,7 @@ class Artists extends Extension { } public function handle_commands($event) { - global $config, $page, $user; + global $page, $user; if($event->page_matches("artist")) { diff --git a/ext/artists/theme.php b/ext/artists/theme.php index acfe05e7..3fddc369 100644 --- a/ext/artists/theme.php +++ b/ext/artists/theme.php @@ -14,19 +14,11 @@ class ArtistsTheme extends Themelet { "; } - public function display_artists(){ - global $page; - - $page->set_title("Artists"); - $page->set_heading("Artists"); - $page->add_block(new Block("Artists", $html, "main", 10)); - - //$this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages); - } - public function sidebar_options(/*string*/ $mode, $artistID=NULL, $is_admin=FALSE){ - global $page; - + global $page, $user; + + $html = ""; + if($mode == "neutral"){ $html = "
".$user->get_auth_html()." @@ -72,11 +64,14 @@ class ArtistsTheme extends Themelet {
"; } - $page->add_block(new Block("Manage Artists", $html, "left", 10)); + + if($html) $page->add_block(new Block("Manage Artists", $html, "left", 10)); } public function show_artist_editor($artist, $aliases, $members, $urls) { + global $user; + $artistName = $artist['name']; $artistNotes = $artist['notes']; $artistID = $artist['id']; @@ -140,7 +135,7 @@ class ArtistsTheme extends Themelet { public function new_artist_composer() { - global $page; + global $page, $user; $html = "
".$user->get_auth_html()." @@ -234,6 +229,8 @@ class ArtistsTheme extends Themelet { public function show_new_alias_composer($artistID) { + global $user; + $html = ' '.$user->get_auth_html().' @@ -250,6 +247,8 @@ class ArtistsTheme extends Themelet { } public function show_new_member_composer($artistID) { + global $user; + $html = ' '.$user->get_auth_html().' @@ -267,6 +266,8 @@ class ArtistsTheme extends Themelet { public function show_new_url_composer($artistID) { + global $user; + $html = ' '.$user->get_auth_html().' @@ -284,6 +285,8 @@ class ArtistsTheme extends Themelet { public function show_alias_editor($alias) { + global $user; + $html = ' @@ -301,6 +304,8 @@ class ArtistsTheme extends Themelet { public function show_url_editor($url) { + global $user; + $html = ' @@ -318,6 +323,8 @@ class ArtistsTheme extends Themelet { public function show_member_editor($member) { + global $user; + $html = ' @@ -335,7 +342,7 @@ class ArtistsTheme extends Themelet { public function show_artist($artist, $aliases, $members, $urls, $images, $userIsLogged, $userIsAdmin) { - global $user, $event, $page; + global $page; $artist_link = "".str_replace("_", " ", $artist['name']).""; diff --git a/ext/bulk_add/main.php b/ext/bulk_add/main.php index 2cab0f46..408db0fc 100644 --- a/ext/bulk_add/main.php +++ b/ext/bulk_add/main.php @@ -53,6 +53,7 @@ class BulkAdd extends Extension { if(!array_key_exists('extension', $pathinfo)) { throw new UploadException("File has no extension"); } + $metadata = array(); $metadata['filename'] = $pathinfo['basename']; $metadata['extension'] = $pathinfo['extension']; $metadata['tags'] = $tags; @@ -65,8 +66,6 @@ class BulkAdd extends Extension { } private function add_dir(/*string*/ $base, $subdir="") { - global $page; - if(!is_dir($base)) { $this->theme->add_status("Error", "$base is not a directory"); return; diff --git a/ext/bulk_add_csv/main.php b/ext/bulk_add_csv/main.php index fd177846..cd9ead8b 100644 --- a/ext/bulk_add_csv/main.php +++ b/ext/bulk_add_csv/main.php @@ -62,6 +62,7 @@ class BulkAddCSV extends Extension { if(!array_key_exists('extension', $pathinfo)) { throw new UploadException("File has no extension"); } + $metadata = array(); $metadata['filename'] = $pathinfo['basename']; $metadata['extension'] = $pathinfo['extension']; $metadata['tags'] = $tags; @@ -82,8 +83,6 @@ class BulkAddCSV extends Extension { } private function add_csv(/*string*/ $csvfile) { - global $page; - if(!file_exists($csvfile)) { $this->theme->add_status("Error", "$csvfile not found"); return; diff --git a/ext/bulk_remove/main.php b/ext/bulk_remove/main.php index 73bcbb8e..2e609386 100644 --- a/ext/bulk_remove/main.php +++ b/ext/bulk_remove/main.php @@ -12,7 +12,7 @@ class BulkRemove extends Extension { public function onPageRequest(PageRequestEvent $event) { - global $page, $user; + global $user; if($event->page_matches("bulk_remove") && $user->is_admin() && $user->check_auth_token()) { if ($event->get_arg(0) == "confirm") $this->do_bulk_remove(); else $this->show_confirm(); @@ -20,7 +20,7 @@ class BulkRemove extends Extension { } public function onAdminBuilding(AdminBuildingEvent $event) { - global $page, $user; + global $page; $html = "Be extremely careful when using this!
Once an image is removed there is no way to recover it so it is recommended that you first take when removing a large amount of images.
@@ -83,10 +83,10 @@ class BulkRemove extends Extension { // if no images were found with the given info - if (count($images_for_removal) == 0 && $html == "") + if (count($images_for_removal) == 0) $error = "No images selected for removal"; - var_dump($tags_arr); + //var_dump($tags_arr); return array( "error" => $error, "images_for_removal" => $images_for_removal); @@ -119,6 +119,7 @@ class BulkRemove extends Extension { private function do_bulk_remove() { + global $page; // display error if user didn't go through admin board if (!isset($_POST["bulk_remove_images"])) { $page->add_block(new Block("Bulk Remove Error", diff --git a/ext/chatbox/main.php b/ext/chatbox/main.php index 9c48ce40..fc48cac1 100644 --- a/ext/chatbox/main.php +++ b/ext/chatbox/main.php @@ -13,7 +13,7 @@ class Chatbox extends Extension { global $page, $user; // Adds header to enable chatbox - $root = make_http(); + $root = get_base_href(); $yPath = "$root/ext/chatbox/"; $page->add_html_header(" diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index 49180ca8..56d23f40 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -206,7 +206,7 @@ class CronUploader extends Extension { /** * Returns amount of files & total size of dir. - * @param unknown $path + * @param $path string * @return multitype:number */ function scan_dir($path){ @@ -227,7 +227,7 @@ class CronUploader extends Extension { /** * Uploads the image & handles everything - * @param number $upload_count to upload a non-config amount of imgs + * @param $upload_count int to upload a non-config amount of imgs * @return boolean returns true if the upload was successful */ public function process_upload($upload_count = 0) { @@ -254,11 +254,11 @@ class CronUploader extends Extension { try { $this->add_image($img[0], $img[1], $img[2]); - $newPath = $this->move_uploaded($img[0], $img[1], false); + $this->move_uploaded($img[0], $img[1], false); } catch (Exception $e) { - $newPath = $this->move_uploaded($img[0], $img[1], true); + $this->move_uploaded($img[0], $img[1], true); } // Remove img from queue array @@ -295,37 +295,17 @@ class CronUploader extends Extension { $this->add_upload_info($info . "Image \"$filename\" moved from queue to \"$newPath\"."); } - /** - * moves a directory up or gets the directory of a file - * - * @param string $path Path to modify - * @param int $depth Amount of directories to go up - * @return unknown Path to correct Directory - */ - private function move_directory_up($path, $depth=1) - { - $path = str_replace("//", "/", $path); - $array = explode("/", $path); - - for ($i = 0; $i < $depth; $i++) { - $to_remove = count($array) -1; // Gets number of element to remove - unset($array[$to_remove]); - } - - return implode("/", $array); - } - /** * Generate the necessary DataUploadEvent for a given image and tags. */ private function add_image($tmpname, $filename, $tags) { - global $user, $image; assert ( file_exists ( $tmpname ) ); $pathinfo = pathinfo ( $filename ); if (! array_key_exists ( 'extension', $pathinfo )) { throw new UploadException ( "File has no extension" ); } + $metadata = array(); $metadata ['filename'] = $pathinfo ['basename']; $metadata ['extension'] = $pathinfo ['extension']; $metadata ['tags'] = ""; // = $tags; doesn't work when not logged in here @@ -343,12 +323,9 @@ class CronUploader extends Extension { // Set tags $img = Image::by_id($event->image_id); $img->set_tags($tags); - } private function generate_image_queue($base = "", $subdir = "") { - global $config; - if ($base == "") $base = $this->root_dir . "/queue"; @@ -391,8 +368,9 @@ class CronUploader extends Extension { /** * Adds a message to the info being published at the end - * @param string $text - * @param int $addon Enter a value to modify an existing value (enter value number) + * @param $text string + * @param $addon int Enter a value to modify an existing value (enter value number) + * @return int */ private function add_upload_info($text, $addon = 0) { $info = $this->upload_info; @@ -409,7 +387,7 @@ class CronUploader extends Extension { // else if addon function is used, select the line & modify it $lines = substr($info, "\n"); // Seperate the string to array in lines - $lines[$addon] = "$line[$addon] $text"; // Add the content to the line + $lines[$addon] = "$lines[$addon] $text"; // Add the content to the line $this->upload_info = implode("\n", $lines); // Put string back together & update return $addon; // Return line number @@ -419,7 +397,7 @@ class CronUploader extends Extension { * This is run at the end to display & save the log. */ private function handle_log() { - global $page, $config; + global $page; // Display message $page->set_mode("data"); diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index d79cfbed..3d92a092 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -21,6 +21,7 @@ function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b) { class ExtensionInfo { var $ext_name, $name, $link, $author, $email; var $description, $documentation, $version, $visibility; + var $enabled; function __construct($main) { $matches = array(); @@ -167,6 +168,7 @@ class ExtManager extends Extension { private function set_things($settings) { $core = explode(",", CORE_EXTS); + $extras = array(); foreach(glob("ext/*/main.php") as $main) { $matches = array(); diff --git a/ext/favorites/main.php b/ext/favorites/main.php index 3c3494f2..10242e53 100644 --- a/ext/favorites/main.php +++ b/ext/favorites/main.php @@ -35,7 +35,7 @@ class Favorites extends Extension { } public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { - global $database, $page, $user; + global $database, $user; if(!$user->is_anonymous()) { $user_id = $user->id; $image_id = $event->image->id; @@ -88,7 +88,7 @@ class Favorites extends Extension { in_array('favorite_action', $_POST) && (($_POST['favorite_action'] == "set") || ($_POST['favorite_action'] == "unset")) ) { - send_event(new FavoriteSetEvent($event->image_id, $user, ($_POST['favorite_action'] == "set"))); + send_event(new FavoriteSetEvent($event->image->id, $user, ($_POST['favorite_action'] == "set"))); } } diff --git a/ext/handle_archive/main.php b/ext/handle_archive/main.php index a01589f8..a6787ac6 100644 --- a/ext/handle_archive/main.php +++ b/ext/handle_archive/main.php @@ -50,11 +50,11 @@ class ArchiveFileHandler extends Extension { assert(file_exists($tmpname)); try { - global $user; $pathinfo = pathinfo($filename); if(!array_key_exists('extension', $pathinfo)) { throw new UploadException("File has no extension"); } + $metadata = array(); $metadata['filename'] = $pathinfo['basename']; $metadata['extension'] = $pathinfo['extension']; $metadata['tags'] = $tags; @@ -69,8 +69,6 @@ class ArchiveFileHandler extends Extension { // copied from bulk add extension private function add_dir($base, $subdir="") { - global $page; - $list = ""; $dir = opendir("$base/$subdir"); diff --git a/ext/handle_flash/main.php b/ext/handle_flash/main.php index e59b8892..d7e42f9b 100644 --- a/ext/handle_flash/main.php +++ b/ext/handle_flash/main.php @@ -17,8 +17,6 @@ class FlashFileHandler extends DataHandlerExtension { } protected function create_image_from_data(/*string*/ $filename, /*array*/ $metadata) { - global $config; - $image = new Image(); $image->filesize = $metadata['size']; @@ -28,15 +26,8 @@ class FlashFileHandler extends DataHandlerExtension { $image->tag_array = Tag::explode($metadata['tags']); $image->source = $metadata['source']; - // redundant, since getimagesize() works on SWF o_O -// $rect = $this->swf_get_bounds($filename); -// if(is_null($rect)) { -// return $null; -// } -// $image->width = $rect[1]; -// $image->height = $rect[3]; - - if(!($info = getimagesize($filename))) return null; + $info = getimagesize($filename); + if(!$info) return null; $image->width = $info[0]; $image->height = $info[1]; @@ -45,61 +36,14 @@ class FlashFileHandler extends DataHandlerExtension { } protected function check_contents(/*string*/ $file) { - if(!file_exists($file)) return false; + if (!file_exists($file)) return false; - $fp = fopen($file, "r"); - $head = fread($fp, 3); - fclose($fp); - if(!in_array($head, array("CWS", "FWS"))) return false; + $fp = fopen($file, "r"); + $head = fread($fp, 3); + fclose($fp); + if (!in_array($head, array("CWS", "FWS"))) return false; - return true; - } - - private function str_to_binarray(/*string*/ $string) { - $binary = array(); - $length = strlen($string); - for($j=0; $j<$length; $j++) { - $c = ord($string[$j]); - for($i=7; $i>=0; $i--) { - $binary[] = ($c >> $i) & 0x01; - } - } - return $binary; - } - - private function binarray_to_int($binarray, $start=0, $length=32) { - $int = 0; - for($i=$start; $i<$start + $length; $i++) { - $int = $int << 1; - $int = $int + ($binarray[$i] == "1" ? 1 : 0); - } - return $int; - } - - private function swf_get_bounds(/*string*/ $filename) { - $fp = fopen($filename, "r"); - $head = fread($fp, 3); - $version = fread($fp, 1); - $length = fread($fp, 4); - - if($head == "FWS") { - $data = fread($fp, 16); - } - else if($head == "CWS") { - $data = fread($fp, 128*1024); - $data = gzuncompress($data); - $data = substr($data, 0, 16); - } - - $bounds = array(); - $rect_bin = $this->str_to_binarray($data); - $nbits = $this->binarray_to_int($rect_bin, 0, 5); - $bounds[] = $this->binarray_to_int($rect_bin, 5 + 0 * $nbits, $nbits) / 20; - $bounds[] = $this->binarray_to_int($rect_bin, 5 + 1 * $nbits, $nbits) / 20; - $bounds[] = $this->binarray_to_int($rect_bin, 5 + 2 * $nbits, $nbits) / 20; - $bounds[] = $this->binarray_to_int($rect_bin, 5 + 3 * $nbits, $nbits) / 20; - - return $bounds; - } + return true; + } } ?> diff --git a/ext/handle_ico/main.php b/ext/handle_ico/main.php index 269cbbb0..07fa97ec 100644 --- a/ext/handle_ico/main.php +++ b/ext/handle_ico/main.php @@ -36,7 +36,7 @@ class IcoFileHandler extends Extension { } public function onPageRequest(PageRequestEvent $event) { - global $config, $database, $page; + global $page; if($event->page_matches("get_ico")) { $id = int_escape($event->get_arg(0)); $image = Image::by_id($id); @@ -56,8 +56,6 @@ class IcoFileHandler extends Extension { } private function create_image_from_data($filename, $metadata) { - global $config; - $image = new Image(); $fp = fopen($filename, "r"); diff --git a/ext/handle_ico/test.php b/ext/handle_ico/test.php index 956ad322..dd362055 100644 --- a/ext/handle_ico/test.php +++ b/ext/handle_ico/test.php @@ -6,8 +6,8 @@ class IcoHandlerTest extends ShimmieWebTestCase { $this->assert_response(302); $this->log_out(); - $raw = $this->get_page("post/view/$image_id"); // test for no crash - $raw = $this->get_page("get_ico/$image_id"); // test for no crash + $this->get_page("post/view/$image_id"); // test for no crash + $this->get_page("get_ico/$image_id"); // test for no crash $this->log_in_as_admin(); $this->delete_image($image_id); diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index 0e7d54a4..da8e5e31 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -14,8 +14,6 @@ class PixelFileHandler extends DataHandlerExtension { } protected function create_image_from_data(/*string*/ $filename, /*array*/ $metadata) { - global $config; - $image = new Image(); $info = getimagesize($filename); @@ -52,9 +50,10 @@ class PixelFileHandler extends DataHandlerExtension { } protected function create_thumb_force(/*string*/ $hash) { + global $config; + $inname = warehouse_path("images", $hash); $outname = warehouse_path("thumbs", $hash); - global $config; $ok = false; @@ -165,7 +164,7 @@ class PixelFileHandler extends DataHandlerExtension { if($width > $height*5) $width = $height*5; if($height > $width*5) $height = $width*5; - $image = imagecreatefromstring($this->read_file($tmpname)); + $image = imagecreatefromstring(file_get_contents($tmpname)); $tsize = get_thumbnail_size($width, $height); $thumb = imagecreatetruecolor($tsize[0], $tsize[1]); @@ -176,16 +175,6 @@ class PixelFileHandler extends DataHandlerExtension { return $thumb; } } - - private function read_file(/*string*/ $fname) { - $fp = fopen($fname, "r"); - if(!$fp) return false; - - $data = fread($fp, filesize($fname)); - fclose($fp); - - return $data; - } // }}} } ?> diff --git a/ext/handle_pixel/script.js b/ext/handle_pixel/script.js index aa83fa16..8c3a50dd 100644 --- a/ext/handle_pixel/script.js +++ b/ext/handle_pixel/script.js @@ -15,26 +15,26 @@ $(function() { } }); -function zoom(zoom) { +function zoom(zoom_type) { var img = $('.shm-main-image'); - if(zoom == "full") { + if(zoom_type == "full") { img.css('max-width', img.data('width') + 'px'); img.css('max-height', img.data('height') + 'px'); } - if(zoom == "width") { + if(zoom_type == "width") { img.css('max-width', '95%'); img.css('max-height', img.data('height') + 'px'); } - if(zoom == "height") { + if(zoom_type == "height") { img.css('max-width', img.data('width') + 'px'); img.css('max-height', (window.innerHeight * 0.95) + 'px'); } - if(zoom == "both") { + if(zoom_type == "both") { img.css('max-width', '95%'); img.css('max-height', (window.innerHeight * 0.95) + 'px'); } - $(".shm-zoomer").val(zoom); + $(".shm-zoomer").val(zoom_type); - $.cookie("ui-image-zoom", zoom, {path: '/', expires: 365}); + $.cookie("ui-image-zoom", zoom_type, {path: '/', expires: 365}); } diff --git a/ext/handle_video/theme.php b/ext/handle_video/theme.php index c58dd6e5..b4e87dde 100644 --- a/ext/handle_video/theme.php +++ b/ext/handle_video/theme.php @@ -31,6 +31,9 @@ else { "; } + else { + $html = "Video type '$ext' not recognised"; + } $page->add_block(new Block("Video", $html, "main", 10)); } } diff --git a/ext/image/main.php b/ext/image/main.php index 59369dd9..51de36b0 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -20,7 +20,7 @@ class ImageAdditionEvent extends Event { * this new image. * * @sa TagSetEvent - * @param $image The new image to add. + * @param $image Image The new image to add. */ public function __construct(Image $image) { $this->image = $image; @@ -46,7 +46,7 @@ class ImageDeletionEvent extends Event { * Used by things like tags and comments handlers to * clean out related rows in their tables. * - * @param $image The image being deleted + * @param $image Image The image being deleted */ public function __construct(Image $image) { $this->image = $image; @@ -93,8 +93,9 @@ class ThumbnailGenerationEvent extends Event { /** * Request a thumbnail be made for an image object * - * @param $hash The unique hash of the image - * @param $type The type of the image + * @param $hash string The unique hash of the image + * @param $type string The type of the image + * @param $force boolean Regenerate the thumbnail even if one already exists */ public function __construct($hash, $type, $force=false) { $this->hash = $hash; @@ -223,9 +224,6 @@ class ImageIO extends Extension { } public function onUserPageBuilding(UserPageBuildingEvent $event) { - global $user; - global $config; - $u_id = url_escape($event->display_user->id); $i_image_count = Image::count_images(array("user_id={$event->display_user->id}")); $i_days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1; @@ -279,7 +277,7 @@ class ImageIO extends Extension { // add image {{{ - private function add_image($image) { + private function add_image(Image $image) { global $page, $user, $database, $config; /* @@ -401,11 +399,8 @@ class ImageIO extends Extension { // replace image {{{ private function replace_image($id, $image) { - global $page; - global $user; global $database; - global $config; - + /* Check to make sure the image exists. */ $existing = Image::by_id($id); diff --git a/ext/index/theme.php b/ext/index/theme.php index 0b7f5ee5..99a0e839 100644 --- a/ext/index/theme.php +++ b/ext/index/theme.php @@ -1,6 +1,8 @@ page_number = $page_number; $this->total_pages = $total_pages; diff --git a/ext/link_image/theme.php b/ext/link_image/theme.php index 1e5d2196..24de94dc 100644 --- a/ext/link_image/theme.php +++ b/ext/link_image/theme.php @@ -62,7 +62,7 @@ class LinkImageTheme extends Themelet { $text = "[url=".$url."]".$content."[/url]"; break; default: - $text = $link." - ".$content; + $text = $url." - ".$content; } return $text; } diff --git a/ext/livefeed/main.php b/ext/livefeed/main.php index 3ce78f83..804b57e6 100644 --- a/ext/livefeed/main.php +++ b/ext/livefeed/main.php @@ -63,6 +63,7 @@ class LiveFeed extends Extension { fwrite($fp, "$data\n"); fclose($fp); } catch (Exception $e) { + /* logging errors shouldn't break everything */ } } } diff --git a/ext/log_net/main.php b/ext/log_net/main.php index 56ee4c9e..918a1b8e 100644 --- a/ext/log_net/main.php +++ b/ext/log_net/main.php @@ -42,6 +42,7 @@ class LogNet extends Extension { fwrite($fp, "$data\n"); fclose($fp); } catch (Exception $e) { + /* logging errors shouldn't break everything */ } } } diff --git a/ext/not_a_tag/main.php b/ext/not_a_tag/main.php index 0aa72f19..5dcb41fc 100644 --- a/ext/not_a_tag/main.php +++ b/ext/not_a_tag/main.php @@ -29,7 +29,7 @@ class NotATag extends Extension { } private function scan(/*array*/ $tags_mixed) { - global $config, $database; + global $database; $tags = array(); foreach($tags_mixed as $tag) $tags[] = strtolower($tag); @@ -53,12 +53,12 @@ class NotATag extends Extension { } public function onPageRequest(PageRequestEvent $event) { - global $config, $database, $page, $user; + global $database, $page, $user; if($event->page_matches("untag")) { if($user->can("ban_image")) { if($event->get_arg(0) == "add") { - $tag = isset($_POST["tag"]) ? $_POST["tag"] : $image->tag; + $tag = $_POST["tag"]; $redirect = isset($_POST['redirect']) ? $_POST['redirect'] : "DNP"; $database->Execute( diff --git a/ext/notes/main.php b/ext/notes/main.php index 5aa2e72b..cfbb6259 100644 --- a/ext/notes/main.php +++ b/ext/notes/main.php @@ -363,6 +363,8 @@ class Notes extends Extension { */ private function delete_note() { + global $user; + $imageID = int_escape($_POST["image_id"]); $noteID = int_escape($_POST["note_id"]); @@ -388,7 +390,7 @@ class Notes extends Extension { * HERE WE DELETE ALL NOTES FROM IMAGE */ private function nuke_notes() { - global $database; + global $database, $user; $image_id = int_escape($_POST["image_id"]); $database->execute("DELETE FROM notes WHERE image_id = ?", array($image_id)); log_info("notes", "Notes deleted from {$image_id} by {$user->name}"); @@ -400,7 +402,7 @@ class Notes extends Extension { * HERE WE DELETE ALL REQUESTS FOR IMAGE */ private function nuke_requests() { - global $database; + global $database, $user; $image_id = int_escape($_POST["image_id"]); $database->execute("DELETE FROM note_request WHERE image_id = ?", array($image_id)); diff --git a/ext/notes/theme.php b/ext/notes/theme.php index 90ed4948..38bfcbb3 100644 --- a/ext/notes/theme.php +++ b/ext/notes/theme.php @@ -42,7 +42,7 @@ class NotesTheme extends Themelet { $page->add_block(new Block("Search Note", $html, "main", 10)); } - // check action POST on form + // check action POST on form public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions) { $to_json = array(); @@ -169,94 +169,66 @@ class NotesTheme extends Themelet { $page->set_heading("Note Requests"); $page->add_block(new Block("Note Requests", $pool_images, "main", 20)); } - + + private function get_history($histories) { + global $user; + + $html = "". + "". + "". + "". + "". + "". + ""; + + if(!$user->is_anonymous()){ + $html .= ""; + } + + $html .= "". + ""; + + foreach($histories as $history) { + $image_link = "".$history['image_id'].""; + $history_link = "".$history['note_id'].".".$history['review_id'].""; + $user_link = "".$history['user_name'].""; + $revert_link = "Revert"; + + $html .= "". + "". + "". + "". + "". + ""; + + if(!$user->is_anonymous()){ + $html .= ""; + } + + } + + $html .= "
ImageNoteBodyUpdaterDateAction
".$image_link."".$history_link."".$history['note']."".$user_link."".autodate($history['date'])."".$revert_link."
"; + + return $html; + } + public function display_histories($histories, $pageNumber, $totalPages) { - global $user, $page; - - $html = "". - "". - "". - "". - "". - "". - ""; - - - if(!$user->is_anonymous()){ - $html .= ""; - } - - $html .= "". - ""; - - foreach($histories as $history) { - $image_link = "".$history['image_id'].""; - $history_link = "".$history['note_id'].".".$history['review_id'].""; - $user_link = "".$history['user_name'].""; - $revert_link = "Revert"; - - $html .= "". - "". - "". - "". - "". - ""; - - if(!$user->is_anonymous()){ - $html .= ""; - } - - } - - $html .= "
ImageNoteBodyUpdaterDateAction
".$image_link."".$history_link."".$history['note']."".$user_link."".autodate($history['date'])."".$revert_link."
"; - - $page->set_title("Note Updates"); - $page->set_heading("Note Updates"); - $page->add_block(new Block("Note Updates", $html, "main", 10)); - - $this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages); + global $page; + + $html = $this->get_history($histories); + + $page->set_title("Note Updates"); + $page->set_heading("Note Updates"); + $page->add_block(new Block("Note Updates", $html, "main", 10)); + + $this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages); } public function display_history($histories, $pageNumber, $totalPages) { - global $user, $page; - - $html = "". - "". - "". - "". - "". - "". - ""; - - - if(!$user->is_anonymous()){ - $html .= ""; - } - - $html .= "". - ""; - - foreach($histories as $history) { - $image_link = "".$history['image_id'].""; - $history_link = "".$history['note_id'].".".$history['review_id'].""; - $user_link = "".$history['user_name'].""; - $revert_link = "Revert"; - - $html .= "". - "". - "". - "". - "". - ""; - - if(!$user->is_anonymous()){ - $html .= ""; - } - - } - - $html .= "
ImageNoteBodyUpdaterDateAction
".$image_link."".$history_link."".$history['note']."".$user_link."".autodate($history['date'])."".$revert_link."
"; - + global $page; + + $html = $this->get_history($histories); + $page->set_title("Note History"); $page->set_heading("Note History"); $page->add_block(new Block("Note History", $html, "main", 10)); diff --git a/ext/oekaki/main.php b/ext/oekaki/main.php index 42d06e10..942e5f30 100644 --- a/ext/oekaki/main.php +++ b/ext/oekaki/main.php @@ -28,6 +28,7 @@ class Oekaki extends Extension { throw new UploadException("File has no extension"); } log_info("oekaki", "Processing file [{$pathinfo['filename']}]"); + $metadata = array(); $metadata['filename'] = 'oekaki.png'; $metadata['extension'] = $pathinfo['extension']; $metadata['tags'] = 'oekaki tagme';