diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index f1eef1012..4ff513499 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -3,4 +3,4 @@ imports:
- php
filter:
- excluded_paths: [lib/*,ext/chatbox/js/jquery.js]
+ excluded_paths: [lib/*,ext/tagger/script.js]
diff --git a/core/basethemelet.class.php b/core/basethemelet.class.php
index 94cfc1595..3d62d3da0 100644
--- a/core/basethemelet.class.php
+++ b/core/basethemelet.class.php
@@ -1,10 +1,18 @@
add_block(new Block("Error", $message));
}
-
/**
* A specific, common error message
*/
@@ -36,6 +43,9 @@ public function display_permission_denied() {
/**
* Generic thumbnail code; returns HTML rather than adding
* a block since thumbs tend to go inside blocks...
+ *
+ * @param Image $image
+ * @return string
*/
public function build_thumb_html(Image $image) {
global $config;
@@ -56,18 +66,23 @@ public function build_thumb_html(Image $image) {
$custom_classes = "";
if(class_exists("Relationships")){
- if($image->parent_id !== NULL){ $custom_classes .= "shm-thumb-has_parent "; }
- if($image->has_children == TRUE){ $custom_classes .= "shm-thumb-has_child "; }
+ if(property_exists('Image', 'parent_id') && $image->parent_id !== NULL){ $custom_classes .= "shm-thumb-has_parent "; }
+ if(property_exists('Image', 'has_children') && $image->has_children == TRUE){ $custom_classes .= "shm-thumb-has_child "; }
}
return "".
- "".
- "\n";
+ "".
+ "\n";
}
-
/**
- * Add a generic paginator
+ * Add a generic paginator.
+ *
+ * @param Page $page
+ * @param string $base
+ * @param string $query
+ * @param int $page_number
+ * @param int $total_pages
*/
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages) {
if($total_pages == 0) $total_pages = 1;
@@ -75,11 +90,28 @@ public function display_paginator(Page $page, $base, $query, $page_number, $tota
$page->add_block(new Block(null, $body, "main", 90, "paginator"));
}
+ /**
+ * Generate a single HTML link.
+ *
+ * @param string $base_url
+ * @param string $query
+ * @param int|string $page
+ * @param string $name
+ * @return string
+ */
private function gen_page_link($base_url, $query, $page, $name) {
$link = make_link($base_url.'/'.$page, $query);
return ''.$name.'';
}
-
+
+ /**
+ * @param string $base_url
+ * @param string $query
+ * @param int|string $page
+ * @param int|string $current_page
+ * @param string $name
+ * @return string
+ */
private function gen_page_link_block($base_url, $query, $page, $current_page, $name) {
$paginator = "";
if($page == $current_page) $paginator .= "";
@@ -87,7 +119,16 @@ private function gen_page_link_block($base_url, $query, $page, $current_page, $n
if($page == $current_page) $paginator .= "";
return $paginator;
}
-
+
+ /**
+ * Build the paginator.
+ *
+ * @param int $current_page
+ * @param int $total_pages
+ * @param string $base_url
+ * @param string $query
+ * @return string
+ */
private function build_paginator($current_page, $total_pages, $base_url, $query) {
$next = $current_page + 1;
$prev = $current_page - 1;
@@ -115,4 +156,4 @@ private function build_paginator($current_page, $total_pages, $base_url, $query)
.'
<< '.$pages_html.' >>';
}
}
-?>
+
diff --git a/core/block.class.php b/core/block.class.php
index 149a0a132..bdbc215f4 100644
--- a/core/block.class.php
+++ b/core/block.class.php
@@ -6,39 +6,48 @@ class Block {
/**
* The block's title
*
- * @retval string
+ * @var string
*/
- var $header;
+ public $header;
/**
* The content
*
- * @retval string
+ * @var string
*/
- var $body;
+ public $body;
/**
* Where the block should be placed. The default theme supports
* "main" and "left", other themes can add their own areas
*
- * @retval string
+ * @var string
*/
- var $section;
+ public $section;
/**
* How far down the section the block should appear, higher
* numbers appear lower. The scale is 0-100 by convention,
* though any number or string will work.
*
- * @retval int
+ * @var int
*/
- var $position;
+ public $position;
/**
- *
+ * @var int
*/
- var $id;
+ public $id;
+ /**
+ * Construct a block.
+ *
+ * @param string $header
+ * @param string $body
+ * @param string $section
+ * @param int $position
+ * @param null|int $id
+ */
public function __construct($header, $body, /*string*/ $section="main", /*int*/ $position=50, $id=null) {
$this->header = $header;
$this->body = $body;
@@ -47,6 +56,12 @@ public function __construct($header, $body, /*string*/ $section="main", /*int*/
$this->id = str_replace(' ', '_', is_null($id) ? (is_null($header) ? md5($body) : $header) . $section : $id);
}
+ /**
+ * Get the HTML for this block.
+ *
+ * @param bool $hidable
+ * @return string
+ */
public function get_html($hidable=false) {
$h = $this->header;
$b = $this->body;
@@ -71,4 +86,4 @@ public function __construct() {
parent::__construct("Navigation", "Index", "left", 0);
}
}
-?>
+
diff --git a/core/config.class.php b/core/config.class.php
index 96e6e1560..7b0f6f1f0 100644
--- a/core/config.class.php
+++ b/core/config.class.php
@@ -224,4 +224,4 @@ public function __construct($config=array()) {
parent::__construct($config);
}
}
-?>
+
diff --git a/core/database.class.php b/core/database.class.php
index 5a889878d..1fbfb2f82 100644
--- a/core/database.class.php
+++ b/core/database.class.php
@@ -45,7 +45,7 @@ public function __construct($qlet, $positive) {
// }}}
// {{{ db engines
class DBEngine {
- var $name = null;
+ public $name = null;
public function init($db) {}
@@ -58,7 +58,7 @@ public function create_table_sql($name, $data) {
}
}
class MySQL extends DBEngine {
- var $name = "mysql";
+ public $name = "mysql";
public function init($db) {
$db->exec("SET NAMES utf8;");
@@ -84,7 +84,7 @@ public function create_table_sql($name, $data) {
}
}
class PostgreSQL extends DBEngine {
- var $name = "pgsql";
+ public $name = "pgsql";
public function init($db) {
$db->exec("SET application_name TO 'shimmie [{$_SERVER['REMOTE_ADDR']}]';");
@@ -123,7 +123,7 @@ function _concat($a, $b) { return $a . $b; }
function _lower($a) { return strtolower($a); }
class SQLite extends DBEngine {
- var $name = "sqlite";
+ public $name = "sqlite";
public function init($db) {
ini_set('sqlite.assoc_case', 0);
@@ -553,4 +553,4 @@ public function scoreql_to_sql($sql) {return $sql;}
public function create_table($name, $def) {}
public function connect_engine() {}
}
-?>
+
diff --git a/core/email.class.php b/core/email.class.php
index 63677b09d..8dd2db582 100644
--- a/core/email.class.php
+++ b/core/email.class.php
@@ -4,17 +4,17 @@ class Email {
/**
* A generic email.
*/
- var $to;
- var $subject;
- var $header;
- var $style;
- var $header_img;
- var $sitename;
- var $sitedomain;
- var $siteemail;
- var $date;
- var $body;
- var $footer;
+ public $to;
+ public $subject;
+ public $header;
+ public $style;
+ public $header_img;
+ public $sitename;
+ public $sitedomain;
+ public $siteemail;
+ public $date;
+ public $body;
+ public $footer;
public function __construct($to, $subject, $header, $body) {
global $config;
@@ -116,4 +116,4 @@ public function send() {
return $sent;
}
}
-?>
+
diff --git a/core/event.class.php b/core/event.class.php
index 7e069e2df..2b824e5bd 100644
--- a/core/event.class.php
+++ b/core/event.class.php
@@ -26,10 +26,13 @@ class InitExtEvent extends Event {}
* $event->get_arg(0) = "42"
*/
class PageRequestEvent extends Event {
- var $args;
- var $arg_count;
- var $part_count;
+ public $args;
+ public $arg_count;
+ public $part_count;
+ /**
+ * @param string $path
+ */
public function __construct($path) {
global $config;
@@ -63,7 +66,8 @@ public function __construct($path) {
*
* If it matches, store the remaining path elements in $args
*
- * @retval bool
+ * @param string $name
+ * @return bool
*/
public function page_matches(/*string*/ $name) {
$parts = explode("/", $name);
@@ -84,8 +88,9 @@ public function page_matches(/*string*/ $name) {
/**
* Get the n th argument of the page request (if it exists.)
- * @param $n integer
- * @retval The argmuent (string) or NULL
+ *
+ * @param int $n
+ * @return string|null The argmuent (string) or NULL
*/
public function get_arg(/*int*/ $n) {
$offset = $this->part_count + $n;
@@ -99,7 +104,7 @@ public function get_arg(/*int*/ $n) {
/**
* Returns the number of arguments the page request has.
- * @retval int
+ * @return int
*/
public function count_args() {
return (int)($this->arg_count - $this->part_count);
@@ -108,6 +113,10 @@ public function count_args() {
/*
* Many things use these functions
*/
+
+ /**
+ * @return array
+ */
public function get_search_terms() {
$search_terms = array();
if($this->count_args() === 2) {
@@ -115,6 +124,10 @@ public function get_search_terms() {
}
return $search_terms;
}
+
+ /**
+ * @return int
+ */
public function get_page_number() {
$page_number = 1;
if($this->count_args() === 1) {
@@ -126,6 +139,10 @@ public function get_page_number() {
if($page_number === 0) $page_number = 1; // invalid -> 0
return $page_number;
}
+
+ /**
+ * @return int
+ */
public function get_page_size() {
global $config;
return $config->get_int('index_images');
@@ -227,28 +244,28 @@ class LogEvent extends Event {
/**
* a category, normally the extension name
*
- * @retval string
+ * @return string
*/
var $section;
/**
* See python...
*
- * @retval int
+ * @return int
*/
var $priority = 0;
/**
* Free text to be logged
*
- * @retval text
+ * @return text
*/
var $message;
/**
* The time that the event was created
*
- * @retval int
+ * @return int
*/
var $time;
@@ -265,4 +282,4 @@ public function __construct($section, $priority, $message, $args) {
$this->time = time();
}
}
-?>
+
diff --git a/core/exceptions.class.php b/core/exceptions.class.php
index f9648bf86..d627dc3ce 100644
--- a/core/exceptions.class.php
+++ b/core/exceptions.class.php
@@ -8,4 +8,12 @@ class SCoreException extends Exception {}
* A fairly common, generic exception
*/
class PermissionDeniedException extends SCoreException {}
-?>
+
+/**
+ * Class ImageDoesNotExist
+ *
+ * This exception is used when an Image cannot be found by ID.
+ *
+ * Example: Image::by_id(-1) returns null
+ */
+class ImageDoesNotExist extends SCoreException {}
diff --git a/core/extension.class.php b/core/extension.class.php
index 9d881c800..1a0d50c5a 100644
--- a/core/extension.class.php
+++ b/core/extension.class.php
@@ -81,7 +81,7 @@
*/
abstract class Extension {
/** this theme's Themelet object */
- var $theme;
+ public $theme;
/** @private */
var $_child;
@@ -220,15 +220,18 @@ public function onDisplayingImage(DisplayingImageEvent $event) {
}
}
+ /*
public function onSetupBuilding(SetupBuildingEvent $event) {
$sb = $this->setup();
if($sb) $event->panel->add_block($sb);
}
protected function setup() {}
+ */
+
abstract protected function supported_ext($ext);
abstract protected function check_contents($tmpname);
abstract protected function create_image_from_data($filename, $metadata);
abstract protected function create_thumb($hash);
}
-?>
+
diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php
index 8e21de8bf..8c8e27b0a 100644
--- a/core/imageboard.pack.php
+++ b/core/imageboard.pack.php
@@ -36,14 +36,14 @@
* sound file, or any other supported upload type.
*/
class Image {
- var $id = null;
- var $height, $width;
- var $hash, $filesize;
- var $filename, $ext;
- var $owner_ip;
- var $posted;
- var $source;
- var $locked;
+ public $id = null;
+ public $height, $width;
+ public $hash, $filesize;
+ public $filename, $ext;
+ public $owner_id, $owner_ip;
+ public $posted, $posted_timestamp;
+ public $source;
+ public $locked;
/**
* One will very rarely construct an image directly, more common
@@ -54,7 +54,7 @@ public function __construct($row=null) {
foreach($row as $name => $value) {
// some databases use table.name rather than name
$name = str_replace("images.", "", $name);
- $this->$name = $value; // hax
+ $this->$name = $value; // hax, this is likely the cause of much scrutinizer-ci complaints.
}
$this->posted_timestamp = strtotime($this->posted); // pray
$this->locked = bool_escape($this->locked);
@@ -68,7 +68,8 @@ public function __construct($row=null) {
/**
* Find an image by ID
*
- * @retval Image
+ * @param int $id
+ * @return Image
*/
public static function by_id(/*int*/ $id) {
assert(is_numeric($id));
@@ -80,7 +81,8 @@ public static function by_id(/*int*/ $id) {
/**
* Find an image by hash
*
- * @retval Image
+ * @param string $hash
+ * @return Image
*/
public static function by_hash(/*string*/ $hash) {
assert(is_string($hash));
@@ -92,7 +94,8 @@ public static function by_hash(/*string*/ $hash) {
/**
* Pick a random image out of a set
*
- * @retval Image
+ * @param array $tags
+ * @return Image
*/
public static function by_random($tags=array()) {
assert(is_array($tags));
@@ -107,7 +110,11 @@ public static function by_random($tags=array()) {
/**
* Search for an array of images
*
- * @retval Array
+ * @param int $start
+ * @param int $limit
+ * @param array $tags
+ * @throws SCoreException
+ * @return Array
*/
public static function find_images(/*int*/ $start, /*int*/ $limit, $tags=array()) {
assert(is_numeric($start));
@@ -145,6 +152,9 @@ public static function find_images(/*int*/ $start, /*int*/ $limit, $tags=array()
/**
* Count the number of image results for a given search
+ *
+ * @param array $tags
+ * @return mixed
*/
public static function count_images($tags=array()) {
assert(is_array($tags));
@@ -174,6 +184,9 @@ public static function count_images($tags=array()) {
/**
* Count the number of pages for a given search
+ *
+ * @param array $tags
+ * @return float
*/
public static function count_pages($tags=array()) {
assert(is_array($tags));
@@ -192,7 +205,9 @@ public static function count_pages($tags=array()) {
* Rather than simply $this_id + 1, one must take into account
* deleted images and search queries
*
- * @retval Image
+ * @param array $tags
+ * @param bool $next
+ * @return Image
*/
public function get_next($tags=array(), $next=true) {
assert(is_array($tags));
@@ -224,7 +239,8 @@ public function get_next($tags=array(), $next=true) {
/**
* The reverse of get_next
*
- * @retval Image
+ * @param array $tags
+ * @return Image
*/
public function get_prev($tags=array()) {
return $this->get_next($tags, false);
@@ -233,14 +249,16 @@ public function get_prev($tags=array()) {
/**
* Find the User who owns this Image
*
- * @retval User
+ * @return User
*/
public function get_owner() {
return User::by_id($this->owner_id);
}
/**
- * Set the image's owner
+ * Set the image's owner.
+ *
+ * @param User $owner
*/
public function set_owner(User $owner) {
global $database;
@@ -262,7 +280,9 @@ public function get_tag_array() {
}
/**
- * Get this image's tags as a string
+ * Get this image's tags as a string.
+ *
+ * @return string
*/
public function get_tag_list() {
return Tag::implode($this->get_tag_array());
@@ -271,7 +291,7 @@ public function get_tag_list() {
/**
* Get the URL for the full size image
*
- * @retval string
+ * @return string
*/
public function get_image_link() {
global $config;
@@ -296,7 +316,7 @@ public function get_image_link() {
* Get a short link to the full size image
*
* @deprecated
- * @retval string
+ * @return string
*/
public function get_short_link() {
global $config;
@@ -306,7 +326,7 @@ public function get_short_link() {
/**
* Get the URL for the thumbnail
*
- * @retval string
+ * @return string
*/
public function get_thumb_link() {
global $config;
@@ -331,7 +351,7 @@ public function get_thumb_link() {
* Get the tooltip for this image, formatted according to the
* configured template
*
- * @retval string
+ * @return string
*/
public function get_tooltip() {
global $config;
@@ -360,7 +380,7 @@ public function get_tooltip() {
/**
* Figure out where the full size image is on disk
*
- * @retval string
+ * @return string
*/
public function get_image_filename() {
return warehouse_path("images", $this->hash);
@@ -369,7 +389,7 @@ public function get_image_filename() {
/**
* Figure out where the thumbnail is on disk
*
- * @retval string
+ * @return string
*/
public function get_thumb_filename() {
return warehouse_path("thumbs", $this->hash);
@@ -378,7 +398,7 @@ public function get_thumb_filename() {
/**
* Get the original filename
*
- * @retval string
+ * @return string
*/
public function get_filename() {
return $this->filename;
@@ -387,7 +407,7 @@ public function get_filename() {
/**
* Get the image's mime type
*
- * @retval string
+ * @return string
*/
public function get_mime_type() {
return getMimeType($this->get_image_filename(), $this->get_ext());
@@ -396,7 +416,7 @@ public function get_mime_type() {
/**
* Get the image's filename extension
*
- * @retval string
+ * @return string
*/
public function get_ext() {
return $this->ext;
@@ -405,7 +425,7 @@ public function get_ext() {
/**
* Get the image's source URL
*
- * @retval string
+ * @return string
*/
public function get_source() {
return $this->source;
@@ -413,6 +433,8 @@ public function get_source() {
/**
* Set the image's source URL
+ *
+ * @param string $new_source
*/
public function set_source(/*string*/ $new_source) {
global $database;
@@ -426,7 +448,7 @@ public function set_source(/*string*/ $new_source) {
/**
* Check if the image is locked.
- * @retval bool
+ * @return bool
*/
public function is_locked() {
return $this->locked;
@@ -542,7 +564,9 @@ public function remove_image_only() {
/**
* Someone please explain this
*
- * @retval string
+ * @param $tmpl
+ * @param string $_escape
+ * @return string
*/
public function parse_link_template($tmpl, $_escape="url_escape") {
global $config;
@@ -682,8 +706,8 @@ private static function build_accurate_search_querylet($terms) {
else {
$expansions = Tag::resolve_wildcard($term);
if($expansions && $positive) $positive_tag_count++;
- foreach($expansions as $term) {
- $tag_querylets[] = new TagQuerylet($term, $positive);
+ foreach($expansions as $expanded_term) {
+ $tag_querylets[] = new TagQuerylet($expanded_term, $positive);
}
}
}
@@ -966,6 +990,9 @@ private static function build_ugly_search_querylet($terms) {
class Tag {
/**
* Remove any excess fluff from a user-input tag
+ *
+ * @param string $tag
+ * @return mixed
*/
public static function sanitise($tag) {
assert(is_string($tag));
@@ -1005,6 +1032,10 @@ public static function explode($tags, $tagme=true) {
return $tag_array;
}
+ /**
+ * @param $tags
+ * @return string
+ */
public static function implode($tags) {
assert(is_string($tags) || is_array($tags));
@@ -1019,6 +1050,10 @@ public static function implode($tags) {
return $tags;
}
+ /**
+ * @param string $tag
+ * @return string
+ */
public static function resolve_alias($tag) {
assert(is_string($tag));
@@ -1067,8 +1102,8 @@ public static function resolve_wildcard($tag) {
/**
* This function takes a list (array) of tags and changes any tags that have aliases
*
- * @param $tags Array of tags
- * @return Array of tags
+ * @param array $tags Array of tags
+ * @return array of tags
*/
public static function resolve_aliases($tags) {
assert(is_array($tags));
@@ -1104,7 +1139,7 @@ public static function resolve_aliases($tags) {
/**
* Move a file from PHP's temporary area into shimmie's image storage
- * heirachy, or throw an exception trying
+ * hierarchy, or throw an exception trying
*/
function move_upload_to_archive(DataUploadEvent $event) {
$target = warehouse_path("images", $event->hash);
@@ -1116,8 +1151,12 @@ function move_upload_to_archive(DataUploadEvent $event) {
}
/**
- * Given a full size pair of dimentions, return a pair scaled down to fit
+ * Given a full size pair of dimensions, return a pair scaled down to fit
* into the configured thumbnail square, with ratio intact
+ *
+ * @param int $orig_width
+ * @param int $orig_height
+ * @return array
*/
function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) {
global $config;
@@ -1143,4 +1182,4 @@ function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) {
}
}
-?>
+
diff --git a/core/page.class.php b/core/page.class.php
index f56a4d466..db588e94b 100644
--- a/core/page.class.php
+++ b/core/page.class.php
@@ -251,11 +251,11 @@ protected function add_auto_html_headers() {
$data_href = get_base_href();
$theme_name = $config->get_string('theme', 'default');
- $this->add_html_header("");
+ $this->add_html_header("", 40);
# 404/static handler will map these to themes/foo/bar.ico or lib/static/bar.ico
- $this->add_html_header("");
- $this->add_html_header("");
+ $this->add_html_header("", 41);
+ $this->add_html_header("", 42);
$css_files = array();
$css_latest = 0;
@@ -275,7 +275,7 @@ protected function add_auto_html_headers() {
}
file_put_contents($css_cache_file, $css_data);
}
- $this->add_html_header("");
+ $this->add_html_header("", 43);
$js_files = array();
$js_latest = 0;
@@ -291,10 +291,10 @@ protected function add_auto_html_headers() {
}
file_put_contents($js_cache_file, $js_data);
}
- $this->add_html_header("");
+ $this->add_html_header("", 44);
}
}
class MockPage extends Page {
}
-?>
+
diff --git a/core/sys_config.inc.php b/core/sys_config.inc.php
index c70acb936..bd9f0616e 100644
--- a/core/sys_config.inc.php
+++ b/core/sys_config.inc.php
@@ -46,4 +46,5 @@ function _d($name, $value) {if(!defined($name)) define($name, $value);}
*/
_d("SCORE_VERSION", 's2hack/'.VERSION); // string SCore version
_d("ENABLED_EXTS", CORE_EXTS.",".EXTRA_EXTS);
-?>
+
+
diff --git a/core/user.class.php b/core/user.class.php
index 3adceadca..94e22c63c 100644
--- a/core/user.class.php
+++ b/core/user.class.php
@@ -8,16 +8,23 @@ function _new_user($row) {
/**
* An object representing a row in the "users" table.
*
- * The currently logged in user will always be accessable via the global variable $user
+ * The currently logged in user will always be accessible via the global variable $user
*/
class User {
- var $id;
- var $name;
- var $email;
- var $join_date;
- var $passhash;
+ /** @var int */
+ public $id;
- /* @var UserClass */
+ /** @var string */
+ public $name;
+
+ /** @var string */
+ public $email;
+
+ public $join_date;
+
+ public $passhash;
+
+ /** @var UserClass */
var $class;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -44,6 +51,13 @@ public function __construct($row) {
$this->class = $_user_classes[$row["class"]];
}
+ /**
+ * Construct a User by session.
+ *
+ * @param string $name
+ * @param string $session
+ * @return null|User
+ */
public static function by_session(/*string*/ $name, /*string*/ $session) {
global $config, $database;
$row = $database->cache->get("user-session-$name-$session");
@@ -60,6 +74,11 @@ public static function by_session(/*string*/ $name, /*string*/ $session) {
return is_null($row) ? null : new User($row);
}
+ /**
+ * Construct a User by session.
+ * @param int $id
+ * @return null|User
+ */
public static function by_id(/*int*/ $id) {
assert(is_numeric($id));
global $database;
@@ -72,6 +91,11 @@ public static function by_id(/*int*/ $id) {
return is_null($row) ? null : new User($row);
}
+ /**
+ * Construct a User by name.
+ * @param string $name
+ * @return null|User
+ */
public static function by_name(/*string*/ $name) {
assert(is_string($name));
global $database;
@@ -79,6 +103,12 @@ public static function by_name(/*string*/ $name) {
return is_null($row) ? null : new User($row);
}
+ /**
+ * Construct a User by name and hash.
+ * @param string $name
+ * @param string $hash
+ * @return null|User
+ */
public static function by_name_and_hash(/*string*/ $name, /*string*/ $hash) {
assert(is_string($name));
assert(is_string($hash));
@@ -88,6 +118,11 @@ public static function by_name_and_hash(/*string*/ $name, /*string*/ $hash) {
return is_null($row) ? null : new User($row);
}
+ /**
+ * @param int $offset
+ * @param int $limit
+ * @return array
+ */
public static function by_list(/*int*/ $offset, /*int*/ $limit=50) {
assert(is_numeric($offset));
assert(is_numeric($limit));
@@ -97,8 +132,12 @@ public static function by_list(/*int*/ $offset, /*int*/ $limit=50) {
}
- /*
- * useful user object functions start here
+ /* useful user object functions start here */
+
+
+ /**
+ * @param string $ability
+ * @return bool
*/
public function can($ability) {
return $this->class->can($ability);
@@ -108,7 +147,7 @@ public function can($ability) {
/**
* Test if this user is anonymous (not logged in)
*
- * @retval bool
+ * @return bool
*/
public function is_anonymous() {
global $config;
@@ -118,7 +157,7 @@ public function is_anonymous() {
/**
* Test if this user is logged in
*
- * @retval bool
+ * @return bool
*/
public function is_logged_in() {
global $config;
@@ -128,12 +167,15 @@ public function is_logged_in() {
/**
* Test if this user is an administrator
*
- * @retval bool
+ * @return bool
*/
public function is_admin() {
return ($this->class->name === "admin");
}
+ /**
+ * @param string $class
+ */
public function set_class(/*string*/ $class) {
assert(is_string($class));
global $database;
@@ -141,6 +183,9 @@ public function set_class(/*string*/ $class) {
log_info("core-user", 'Set class for '.$this->name.' to '.$class);
}
+ /**
+ * @param string $password
+ */
public function set_password(/*string*/ $password) {
global $database;
$hash = md5(strtolower($this->name) . $password);
@@ -157,7 +202,7 @@ public function set_email(/*string*/ $address) {
/**
* Get a snippet of HTML which will render the user's avatar, be that
* a local file, a remote file, a gravatar, a something else, etc
- * @retval String of HTML
+ * @return String of HTML
*/
public function get_avatar_html() {
// FIXME: configurable
@@ -186,7 +231,7 @@ public function get_avatar_html() {
* the form was generated within the session. Salted and re-hashed so that
* reading a web page from the user's cache doesn't give access to the session key
*
- * @retval String containing auth token (MD5sum)
+ * @return String containing auth token (MD5sum)
*/
public function get_auth_token() {
global $config;
@@ -218,4 +263,4 @@ public function __construct($name) {
parent::__construct($row);
}
}
-?>
+
diff --git a/core/userclass.class.php b/core/userclass.class.php
index a8bec4e54..ee6871eaa 100644
--- a/core/userclass.class.php
+++ b/core/userclass.class.php
@@ -2,9 +2,9 @@
$_user_classes = array();
class UserClass {
- var $name = null;
- var $parent = null;
- var $abilities = array();
+ public $name = null;
+ public $parent = null;
+ public $abilities = array();
public function __construct($name, $parent=null, $abilities=array()) {
global $_user_classes;
@@ -19,6 +19,13 @@ public function __construct($name, $parent=null, $abilities=array()) {
$_user_classes[$name] = $this;
}
+ /**
+ * Determine if this class of user can perform an action or has ability.
+ *
+ * @param string $ability
+ * @return bool
+ * @throws SCoreException
+ */
public function can(/*string*/ $ability) {
global $config;
@@ -164,4 +171,4 @@ public function can(/*string*/ $ability) {
));
@include_once "data/config/user-classes.conf.php";
-?>
+
diff --git a/core/util.inc.php b/core/util.inc.php
index b2dfa436b..60a95b6ff 100644
--- a/core/util.inc.php
+++ b/core/util.inc.php
@@ -10,6 +10,7 @@
/**
* Make some data safe for printing into HTML
*
+ * @param $input
* @return string
*/
function html_escape($input) {
@@ -19,6 +20,7 @@ function html_escape($input) {
/**
* Make sure some data is safe to be used in integer context
*
+ * @param $input
* @return int
*/
function int_escape($input) {
@@ -32,6 +34,7 @@ function int_escape($input) {
/**
* Make sure some data is safe to be used in URL context
*
+ * @param $input
* @return string
*/
function url_escape($input) {
@@ -66,6 +69,7 @@ function url_escape($input) {
/**
* Make sure some data is safe to be used in SQL context
*
+ * @param $input
* @return string
*/
function sql_escape($input) {
@@ -77,6 +81,7 @@ function sql_escape($input) {
/**
* Turn all manner of HTML / INI / JS / DB booleans into a PHP one
*
+ * @param $input
* @return boolean
*/
function bool_escape($input) {
@@ -112,6 +117,7 @@ function bool_escape($input) {
* Some functions require a callback function for escaping,
* but we might not want to alter the data
*
+ * @param $input
* @return string
*/
function no_escape($input) {
@@ -156,6 +162,7 @@ function truncate($string, $limit, $break=" ", $pad="...") {
/**
* Turn a human readable filesize into an integer, eg 1KB -> 1024
*
+ * @param $limit
* @return int
*/
function parse_shorthand_int($limit) {
@@ -167,8 +174,11 @@ function parse_shorthand_int($limit) {
$value = $m[1];
if (isset($m[2])) {
switch(strtolower($m[2])) {
+ /** @noinspection PhpMissingBreakStatementInspection */
case 'g': $value *= 1024; // fall through
+ /** @noinspection PhpMissingBreakStatementInspection */
case 'm': $value *= 1024; // fall through
+ /** @noinspection PhpMissingBreakStatementInspection */
case 'k': $value *= 1024; break;
default: $value = -1;
}
@@ -182,6 +192,7 @@ function parse_shorthand_int($limit) {
/**
* Turn an integer into a human readable filesize, eg 1024 -> 1KB
*
+ * @param $int
* @return string
*/
function to_shorthand_int($int) {
@@ -203,6 +214,8 @@ function to_shorthand_int($int) {
/**
* Turn a date into a time, a date, an "X minutes ago...", etc
*
+ * @param $date
+ * @param bool $html
* @return string
*/
function autodate($date, $html=true) {
@@ -214,6 +227,7 @@ function autodate($date, $html=true) {
/**
* Check if a given string is a valid date-time. ( Format: yyyy-mm-dd hh:mm:ss )
*
+ * @param $dateTime
* @return boolean
*/
function isValidDateTime($dateTime) {
@@ -229,6 +243,7 @@ function isValidDateTime($dateTime) {
/**
* Check if a given string is a valid date. ( Format: yyyy-mm-dd )
*
+ * @param $date
* @return boolean
*/
function isValidDate($date) {
@@ -248,6 +263,8 @@ function isValidDate($date) {
*
* FIXME: also check that IP ban ext is installed
*
+ * @param $ip
+ * @param $ban_reason
* @return string
*/
function show_ip($ip, $ban_reason) {
@@ -295,6 +312,8 @@ function endsWith(/*string*/ $haystack, /*string*/ $needle) {
*
* eg make_link("post/list") becomes "/v2/index.php?q=post/list"
*
+ * @param null|string $page
+ * @param null|string $query
* @return string
*/
function make_link($page=null, $query=null) {
@@ -329,8 +348,9 @@ function make_link($page=null, $query=null) {
/**
- * Take the current URL and modify some paramaters
+ * Take the current URL and modify some parameters
*
+ * @param $changes
* @return string
*/
function modify_current_url($changes) {
@@ -372,6 +392,7 @@ function modify_url($url, $changes) {
/**
* Turn a relative link into an absolute one, including hostname
*
+ * @param string $link
* @return string
*/
function make_http(/*string*/ $link) {
@@ -385,11 +406,11 @@ function make_http(/*string*/ $link) {
/**
* Make a form tag with relevant auth token and stuff
*
- * @param target string
- * @param method string
- * @param multipart boolean
- * @param form_id string
- * @param onsubmit string
+ * @param string $target
+ * @param string $method
+ * @param bool $multipart
+ * @param string $form_id
+ * @param string $onsubmit
*
* @return string
*/
@@ -412,6 +433,11 @@ function mtimefile($file) {
return "$data_href/$file?$mtime";
}
+/**
+ * Return the current theme as a string
+ *
+ * @return string
+ */
function get_theme() {
global $config;
$theme = $config->get_string("theme", "default");
@@ -505,16 +531,18 @@ function captcha_check() {
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
-* Get MIME type for file
-*
-* The contents of this function are taken from the __getMimeType() function
-* from the "Amazon S3 PHP class" which is Copyright (c) 2008, Donovan Schönknecht
-* and released under the 'Simplified BSD License'.
-*
-* @internal Used to get mime types
-* @param string &$file File path
-* @return string
-*/
+ * Get MIME type for file
+ *
+ * The contents of this function are taken from the __getMimeType() function
+ * from the "Amazon S3 PHP class" which is Copyright (c) 2008, Donovan Schönknecht
+ * and released under the 'Simplified BSD License'.
+ *
+ * @internal Used to get mime types
+ * @param string &$file File path
+ * @param string $ext
+ * @param bool $list
+ * @return string
+ */
function getMimeType($file, $ext="", $list=false) {
// Static extension lookup
@@ -639,6 +667,8 @@ function _count_execs($db, $sql, $inputarray) {
/**
* Compare two Block objects, used to sort them before being displayed
*
+ * @param Block $a
+ * @param Block $b
* @return int
*/
function blockcmp(Block $a, Block $b) {
@@ -702,6 +732,7 @@ function get_memory_limit() {
* Get the currently active IP, masked to make it not change when the last
* octet or two change, for use in session cookies and such
*
+ * @param Config $config
* @return string
*/
function get_session_ip(Config $config) {
@@ -788,6 +819,7 @@ function get_base_href() {
* A shorthand way to send a TextFormattingEvent and get the
* results
*
+ * @param $string
* @return string
*/
function format_text(/*string*/ $string) {
@@ -867,9 +899,11 @@ function transload($url, $mfile) {
fwrite($fp, $data);
fclose($fp);
- // Scrutinizer-ci complains that $http_response_header not defined.
- // However, it is auto defined by PHP.
- // See: http://us2.php.net/manual/en/reserved.variables.httpresponseheader.php
+ //
+ // Scrutinizer-ci complains that $http_response_header does not exist,
+ // however, $http_response_header is actually a super-global.
+ // I have filed a bug with PHP-Analyzer here: https://github.com/scrutinizer-ci/php-analyzer/issues/212
+ //
$headers = http_parse_headers(implode("\n", $http_response_header));
return $headers;
@@ -1004,6 +1038,8 @@ function get_request_id() {
/**
* Remove an item from an array
*
+ * @param $array
+ * @param $to_remove
* @return array
*/
function array_remove($array, $to_remove) {
@@ -1022,6 +1058,8 @@ function array_remove($array, $to_remove) {
*
* Also removes duplicate values from the array.
*
+ * @param $array
+ * @param $element
* @return array
*/
function array_add($array, $element) {
@@ -1035,6 +1073,7 @@ function array_add($array, $element) {
/**
* Return the unique elements of an array, case insensitively
*
+ * @param $array
* @return array
*/
function array_iunique($array) {
@@ -1058,6 +1097,8 @@ function array_iunique($array) {
*
* from http://uk.php.net/network
*
+ * @param $IP
+ * @param $CIDR
* @return bool
*/
function ip_in_range($IP, $CIDR) {
@@ -1118,7 +1159,7 @@ function deltree($f) {
}
/**
- * Copy an entire file heirachy
+ * Copy an entire file hierarchy
*
* from a comment on http://uk.php.net/copy
*/
@@ -1456,4 +1497,4 @@ function _end_coverage() {
file_put_contents("$absolute_path/$t.$n.log", gzdeflate(serialize(xdebug_get_code_coverage())));
}
}
-?>
+
diff --git a/ext/admin/main.php b/ext/admin/main.php
index 682731950..dc8be5f05 100644
--- a/ext/admin/main.php
+++ b/ext/admin/main.php
@@ -257,4 +257,4 @@ private function reset_image_ids() {
return true;
}
}
-?>
+
diff --git a/ext/admin/test.php b/ext/admin/test.php
index 73bc76294..3aad3d934 100644
--- a/ext/admin/test.php
+++ b/ext/admin/test.php
@@ -80,4 +80,4 @@ function testDBQ() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/admin/theme.php b/ext/admin/theme.php
index 3eefdb11c..d1f8c71b8 100644
--- a/ext/admin/theme.php
+++ b/ext/admin/theme.php
@@ -68,4 +68,4 @@ public function dbq_html($terms) {
return $html;
}
}
-?>
+
diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php
index 54015ab9f..883292d9a 100644
--- a/ext/alias_editor/main.php
+++ b/ext/alias_editor/main.php
@@ -153,4 +153,4 @@ private function add_alias_csv(Database $database, /*string*/ $csv) {
// missing out the images tagged with the oldtag
public function get_priority() {return 60;}
}
-?>
+
diff --git a/ext/alias_editor/test.php b/ext/alias_editor/test.php
index f1f9c6a12..2aa3ab781 100644
--- a/ext/alias_editor/test.php
+++ b/ext/alias_editor/test.php
@@ -97,4 +97,4 @@ function testAliasEditor() {
*/
}
}
-?>
+
diff --git a/ext/alias_editor/theme.php b/ext/alias_editor/theme.php
index 173f7bd2b..21a984b87 100644
--- a/ext/alias_editor/theme.php
+++ b/ext/alias_editor/theme.php
@@ -73,4 +73,4 @@ public function display_aliases($aliases, $pageNumber, $totalPages) {
$this->display_paginator($page, "alias/list", null, $pageNumber, $totalPages);
}
}
-?>
+
diff --git a/ext/amazon_s3/main.php b/ext/amazon_s3/main.php
index b4191a691..7b39e5a2c 100644
--- a/ext/amazon_s3/main.php
+++ b/ext/amazon_s3/main.php
@@ -72,4 +72,4 @@ public function onImageDeletion(ImageDeletionEvent $event) {
}
}
}
-?>
+
diff --git a/ext/arrowkey_navigation/main.php b/ext/arrowkey_navigation/main.php
index b1c1b9722..4d248f32e 100644
--- a/ext/arrowkey_navigation/main.php
+++ b/ext/arrowkey_navigation/main.php
@@ -79,4 +79,4 @@ private function get_list_pageinfo($event) {
return $pageinfo;
}
}
-?>
+
diff --git a/ext/artists/main.php b/ext/artists/main.php
index f74022d5c..43edec089 100644
--- a/ext/artists/main.php
+++ b/ext/artists/main.php
@@ -1221,4 +1221,4 @@ private function get_alias($artistID){
return $result;
}
}
-?>
+
diff --git a/ext/artists/test.php b/ext/artists/test.php
index 7f7943432..767d764b6 100644
--- a/ext/artists/test.php
+++ b/ext/artists/test.php
@@ -5,4 +5,4 @@ function testSearch() {
$this->get_page("post/list/author=bob/1");
}
}
-?>
+
diff --git a/ext/artists/theme.php b/ext/artists/theme.php
index c6d957a3f..3cecede4c 100644
--- a/ext/artists/theme.php
+++ b/ext/artists/theme.php
@@ -514,4 +514,4 @@ public function show_artist($artist, $aliases, $members, $urls, $images, $userIs
}
}
-?>
+
diff --git a/ext/ban_words/main.php b/ext/ban_words/main.php
index 88fe247a6..027f8d8fe 100644
--- a/ext/ban_words/main.php
+++ b/ext/ban_words/main.php
@@ -101,4 +101,4 @@ private function test_text($comment, $ex) {
public function get_priority() {return 30;}
}
-?>
+
diff --git a/ext/ban_words/test.php b/ext/ban_words/test.php
index e9f9cee82..37c0cfda1 100644
--- a/ext/ban_words/test.php
+++ b/ext/ban_words/test.php
@@ -42,4 +42,4 @@ function testWordBan() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/bbcode/main.php b/ext/bbcode/main.php
index 4b10a5c7e..9812d0ca1 100644
--- a/ext/bbcode/main.php
+++ b/ext/bbcode/main.php
@@ -156,4 +156,4 @@ private function insert_code(/*string*/ $text) {
return $text;
}
}
-?>
+
diff --git a/ext/bbcode/test.php b/ext/bbcode/test.php
index a24c548f6..14aac004c 100644
--- a/ext/bbcode/test.php
+++ b/ext/bbcode/test.php
@@ -81,4 +81,4 @@ private function strip($in) {
return $bb->strip($in);
}
}
-?>
+
diff --git a/ext/blocks/main.php b/ext/blocks/main.php
index c80ce1aff..9cd8f253f 100644
--- a/ext/blocks/main.php
+++ b/ext/blocks/main.php
@@ -85,4 +85,4 @@ public function onPageRequest(PageRequestEvent $event) {
}
}
}
-?>
+
diff --git a/ext/blocks/test.php b/ext/blocks/test.php
index a68442b3c..d6f91a385 100644
--- a/ext/blocks/test.php
+++ b/ext/blocks/test.php
@@ -8,4 +8,4 @@ function testBlocks() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/blocks/theme.php b/ext/blocks/theme.php
index 08f2eb1fd..00cfd170c 100644
--- a/ext/blocks/theme.php
+++ b/ext/blocks/theme.php
@@ -43,4 +43,4 @@ public function display_blocks($blocks) {
$page->add_block(new Block("Block Editor", $html));
}
}
-?>
+
diff --git a/ext/blotter/main.php b/ext/blotter/main.php
index f02e1461a..191d20ff0 100644
--- a/ext/blotter/main.php
+++ b/ext/blotter/main.php
@@ -131,4 +131,4 @@ private function display_blotter() {
$this->theme->display_blotter($entries);
}
}
-?>
+
diff --git a/ext/blotter/script.js b/ext/blotter/script.js
index e2f4f8927..25e3188c1 100644
--- a/ext/blotter/script.js
+++ b/ext/blotter/script.js
@@ -1,3 +1,5 @@
+/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
+
$(document).ready(function() {
$(".shm-blotter2-toggle").click(function() {
$(".shm-blotter2").slideToggle("slow", function() {
@@ -9,7 +11,7 @@ $(document).ready(function() {
}
});
});
- if($.cookie("ui-blotter2-hidden") == 'true') {
+ if($.cookie("ui-blotter2-hidden") === 'true') {
$(".shm-blotter2").hide();
}
});
diff --git a/ext/blotter/test.php b/ext/blotter/test.php
index 1e532906e..20c321b0e 100644
--- a/ext/blotter/test.php
+++ b/ext/blotter/test.php
@@ -34,4 +34,4 @@ function testAddViewRemove() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/blotter/theme.php b/ext/blotter/theme.php
index 23395bc57..279876877 100644
--- a/ext/blotter/theme.php
+++ b/ext/blotter/theme.php
@@ -176,4 +176,4 @@ private function get_html_for_blotter($entries) {
return $html;
}
}
-?>
+
diff --git a/ext/bookmarks/main.php b/ext/bookmarks/main.php
index 936610868..d864d92a8 100644
--- a/ext/bookmarks/main.php
+++ b/ext/bookmarks/main.php
@@ -32,8 +32,7 @@ public function onPageRequest(PageRequestEvent $event) {
}
protected function install() {
- global $database;
- global $config;
+ global $database, $config;
// shortcut to latest
if($config->get_int("ext_bookmarks_version") < 1) {
@@ -61,9 +60,9 @@ private function get_bookmarks() {
}
private function add_bookmark(/*string*/ $url, /*string*/ $title) {
- global $database;
+ global $database, $user;
$sql = "INSERT INTO bookmark(owner_id, url, title) VALUES (?, ?, ?)";
$database->Execute($sql, array($user->id, $url, $title));
}
}
-?>
+
diff --git a/ext/bookmarks/test.php b/ext/bookmarks/test.php
index 9bd0692a5..66d41a96e 100644
--- a/ext/bookmarks/test.php
+++ b/ext/bookmarks/test.php
@@ -1,4 +1,3 @@
-
get_page("bookmark/remove");
}
}
-?>
+
diff --git a/ext/bookmarks/theme.php b/ext/bookmarks/theme.php
index 83c43b420..a1cb7b423 100644
--- a/ext/bookmarks/theme.php
+++ b/ext/bookmarks/theme.php
@@ -2,4 +2,4 @@
class BookmarksTheme extends Themelet {
}
-?>
+
diff --git a/ext/browser_search/main.php b/ext/browser_search/main.php
index 266c7cd1d..719dddfc8 100644
--- a/ext/browser_search/main.php
+++ b/ext/browser_search/main.php
@@ -101,4 +101,4 @@ public function onSetupBuilding(SetupBuildingEvent $event) {
$event->panel->add_block($sb);
}
}
-?>
+
diff --git a/ext/browser_search/test.php b/ext/browser_search/test.php
index 0f7ce77fd..e0df2f926 100644
--- a/ext/browser_search/test.php
+++ b/ext/browser_search/test.php
@@ -5,4 +5,4 @@ function testBasic() {
$this->get_page("browser_search/test");
}
}
-?>
+
diff --git a/ext/bulk_add/main.php b/ext/bulk_add/main.php
index cf58e4a3e..ea590a3ff 100644
--- a/ext/bulk_add/main.php
+++ b/ext/bulk_add/main.php
@@ -111,4 +111,4 @@ private function add_dir(/*string*/ $base, $subdir="") {
}
}
}
-?>
+
diff --git a/ext/bulk_add/test.php b/ext/bulk_add/test.php
index 40b4d4e53..3f57fe99b 100644
--- a/ext/bulk_add/test.php
+++ b/ext/bulk_add/test.php
@@ -31,4 +31,4 @@ function testBulkAdd() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/bulk_add/theme.php b/ext/bulk_add/theme.php
index 3df8a40b7..787a45329 100644
--- a/ext/bulk_add/theme.php
+++ b/ext/bulk_add/theme.php
@@ -42,4 +42,4 @@ public function add_status($title, $body) {
$this->messages[] = new Block($title, $body);
}
}
-?>
+
diff --git a/ext/bulk_add_csv/main.php b/ext/bulk_add_csv/main.php
index 4ff15773e..7fd6d2a75 100644
--- a/ext/bulk_add_csv/main.php
+++ b/ext/bulk_add_csv/main.php
@@ -136,4 +136,4 @@ private function add_csv(/*string*/ $csvfile) {
fclose($csvhandle);
}
}
-?>
+
diff --git a/ext/bulk_add_csv/theme.php b/ext/bulk_add_csv/theme.php
index dfff459bf..01c2e21f4 100644
--- a/ext/bulk_add_csv/theme.php
+++ b/ext/bulk_add_csv/theme.php
@@ -41,4 +41,4 @@ public function add_status($title, $body) {
$this->messages[] = new Block($title, $body);
}
}
-?>
+
diff --git a/ext/bulk_remove/main.php b/ext/bulk_remove/main.php
index 2e6093868..592d85f6d 100644
--- a/ext/bulk_remove/main.php
+++ b/ext/bulk_remove/main.php
@@ -130,4 +130,4 @@ private function do_bulk_remove()
$image_arr = $_POST["bulk_remove_images"];
}
}
-?>
+
diff --git a/ext/chatbox/cp/js/admincp.js b/ext/chatbox/cp/js/admincp.js
index ba4ca788f..3fe93b27e 100644
--- a/ext/chatbox/cp/js/admincp.js
+++ b/ext/chatbox/cp/js/admincp.js
@@ -1,7 +1,11 @@
+/*jshint bitwise:true, curly:true, devel:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
+
Array.prototype.inArray = function (value) {
- for (var i = 0; i < this.length; i++)
- if (this[i] === value)
+ for (var i = 0; i < this.length; i++) {
+ if (this[i] === value) {
return true;
+ }
+ }
return false;
};
@@ -25,8 +29,9 @@ AdminCP.prototype = {
this.initializing = true;
this.loginForm();
this.initEvents();
- if (this.loaded()) this.afterLogin();
- else {
+ if (this.loaded()) {
+ this.afterLogin();
+ } else {
$('#login-password')[0].focus();
}
@@ -54,10 +59,11 @@ AdminCP.prototype = {
$('.logout').click(function() { self.logout(); return false; });
// Show the nav
- if (this.initializing)
+ if (this.initializing) {
$('#nav ul').css('display', 'block');
- else
+ } else {
$('#nav ul').slideDown();
+ }
// Some css for betterlookingness
$('#preferences-form fieldset:odd').addClass('odd');
@@ -75,10 +81,11 @@ AdminCP.prototype = {
// If they want to go directly to a section
var anchor = this.getAnchor();
- if (anchor.length > 0 && ['preferences', 'bans', 'about'].inArray(anchor))
+ if (anchor.length > 0 && ['preferences', 'bans', 'about'].inArray(anchor)) {
self.show(anchor);
- else
+ } else {
self.show('preferences');
+ }
},
initEventsAfter: function() {
@@ -101,15 +108,16 @@ AdminCP.prototype = {
// Preferences
$('#preferences-form input').keypress(function(e) {
var key = window.event ? e.keyCode : e.which;
- if (key == 13 || key == 3) {
+ if (key === 13 || key === 3) {
self.changePref.apply(self, [$(this).attr('rel'), this.value]);
return false;
}
}).focus(function() {
this.name = this.value;
}).blur(function() {
- if (this.name != this.value)
+ if (this.name !== this.value) {
self.changePref.apply(self, [$(this).attr('rel'), this.value]);
+ }
});
$('#preferences-form select').change(function() {
@@ -125,10 +133,11 @@ AdminCP.prototype = {
'value': value
};
this.ajax(function(json) {
- if (!json.error)
+ if (!json.error) {
this.done();
- else
+ } else {
alert(json.error);
+ }
}, pars);
},
@@ -137,20 +146,20 @@ AdminCP.prototype = {
var pars = {
mode: 'resetpreferences'
- }
+ };
this.ajax(function(json) {
this.done();
- if (json.prefs)
- for(pref in json.prefs) {
+ if (json.prefs) {
+ for (pref in json.prefs) {
var value = json.prefs[pref];
var el = $('#preferences-form input[@rel=' + pref + '], select[@rel=' + pref + ']')[0];
- if (el.type == 'text')
+ if (el.type === 'text') {
el.value = value;
- else {
- if (value == true) value = 'true';
- if (value == false) value = 'false';
+ } else {
+ if (value === true) { value = 'true'; }
+ if (value === false) { value = 'false'; }
$('#preferences-form select[@rel=' + pref + ']')
.find('option')
@@ -158,11 +167,10 @@ AdminCP.prototype = {
.end()
.find('option[@rel=' + value + ']')
.attr('selected', 'yeah');
-
}
}
- }, pars);
-
+ }
+ }, pars);
},
invalidPassword: function() {
@@ -230,49 +238,53 @@ AdminCP.prototype = {
// if (!sections.inArray(section)) section = 'preferences';
if ($.browser.msie) {
- if (section == 'preferences')
+ if (section === 'preferences') {
$('#preferences select').css('display', 'block');
- else
+ } else {
$('#preferences select').css('display', 'none');
+ }
}
- if (section == this.curSection) return;
+ if (section === this.curSection) { return; }
+
this.curSection = section;
$('#' + section)[0].style.zIndex = ++this.z;
- if (this.initializing)
+
+ if (this.initializing) {
$('#' + section).css('display', 'block');
- else
+ } else {
$('#' + section).fadeIn(this.animSpeed, callback);
+ }
},
showPrefPane: function(pane) {
var self = this;
- if (pane == this.curPrefPane) return;
+ if (pane === this.curPrefPane) { return; }
this.curPrefPane = pane;
$('#preferences .cp-pane').css('display', 'none');
$('#cp-pane-' + pane).css('display', 'block').fadeIn(this.animSpeed, function() {
- if (self.curPrefPane == pane)
+ if (self.curPrefPane === pane) {
$('#preferences .cp-pane').not('#cp-pane-' + pane).css('display', 'none');
- else
+ } else {
$('#cp-pane-' + pane).css('display', 'none');
-
+ }
});
},
showAboutPane: function(pane) {
var self = this;
- if (pane == this.curAboutPane) return;
+ if (pane === this.curAboutPane) { return; }
this.curAboutPane = pane;
$('#about .cp-pane').css('display', 'none');
$('#cp-pane-' + pane).css('display', 'block').fadeIn(this.animSpeed, function() {
- if (self.curAboutPane == pane)
+ if (self.curAboutPane === pane) {
$('#about .cp-pane').not('#cp-pane-' + pane).css('display', 'none');
- else
+ } else {
$('#cp-pane-' + pane).css('display', 'none');
-
+ }
});
},
@@ -281,13 +293,15 @@ AdminCP.prototype = {
$.post('ajax.php', pars, function(parse) {
// alert(parse);
- if (parse)
- if (html)
+ if (parse) {
+ if (html) {
callback.apply(self, [parse]);
- else
+ } else {
callback.apply(self, [self.json(parse)]);
- else
+ }
+ } else {
callback.apply(self);
+ }
});
},
@@ -297,7 +311,7 @@ AdminCP.prototype = {
},
loaded: function() {
- return ($('#cp-loaded').length == 1);
+ return ($('#cp-loaded').length === 1);
},
loading: function() {
@@ -325,10 +339,11 @@ AdminCP.prototype = {
},
getAnchor: function() {
- var href = window.location.href;
- if (href.indexOf('#') > -1 )
- return href.substr(href.indexOf('#') + 1).toLowerCase();
- return '';
+ var href = window.location.href;
+ if (href.indexOf('#') > -1 ) {
+ return href.substr(href.indexOf('#') + 1).toLowerCase();
+ }
+ return '';
},
unban: function(ip, el) {
@@ -357,7 +372,7 @@ AdminCP.prototype = {
var pars = {
mode: 'unbanall'
- }
+ };
this.ajax(function(json) {
this.done();
diff --git a/ext/chatbox/history/index.php b/ext/chatbox/history/index.php
index fd3d8e024..aadd28535 100644
--- a/ext/chatbox/history/index.php
+++ b/ext/chatbox/history/index.php
@@ -83,7 +83,6 @@
}
?>
-
@@ -109,13 +108,13 @@
YShout.History
- if($admin) : ?>
+
Clear this log, or
Clear all logs.
- endif; ?>
+
';
- if (this.prefs.inverse) $('#ys-posts').prepend(html);
- else $('#ys-posts').append(html);
+ if (this.prefs.inverse) { $('#ys-posts').prepend(html); }
+ else { $('#ys-posts').append(html); }
this.p.push(post);
$('#' + id)
.find('.ys-post-nickname').click(function() {
- if (post.adminInfo)
+ if (post.adminInfo) {
self.findBySame(post.adminInfo.ip);
+ }
}).end()
.find('.ys-info-link').toggle(
function() { self.showInfo.apply(self, [id, this]); return false; },
@@ -514,22 +522,24 @@ YShout.prototype = {
showInfo: function(id, el) {
var jEl = $('#' + id + ' .ys-post-info');
- if (this.prefs.info == 'overlay')
+ if (this.prefs.info === 'overlay') {
jEl.css('display', 'block').fadeIn(this.animSpeed);
- else
+ } else {
jEl.slideDown(this.animSpeed);
+ }
- el.innerHTML ='Close Info'
+ el.innerHTML = 'Close Info';
return false;
},
hideInfo: function(id, el) {
var jEl = $('#' + id + ' .ys-post-info');
- if (this.prefs.info == 'overlay')
+ if (this.prefs.info === 'overlay') {
jEl.fadeOut(this.animSpeed);
- else
+ } else {
jEl.slideUp(this.animSpeed);
-
+ }
+
el.innerHTML = 'Info';
return false;
},
@@ -557,26 +567,24 @@ YShout.prototype = {
return;
}
//alert('p: ' + this.p + ' / ' + this.p.length);
- if (json.bannedSelf)
+ if (json.bannedSelf) {
self.banned(); // ?
-
- else
+ } else {
$.each(self.p, function(i) {
- if (this.adminInfo && this.adminInfo.ip == post.adminInfo.ip)
+ if (this.adminInfo && this.adminInfo.ip === post.adminInfo.ip) {
$('#' + this.id)
.addClass('ys-banned-post')
.find('.ys-ban-link').html('Unban');
+ }
});
-
+ }
}, pars);
link.innerHTML = 'Banning...';
return false;
- break;
case 'Banning...':
return false;
- break;
case 'Unban':
var pars = {
@@ -590,26 +598,24 @@ YShout.prototype = {
case 'admin':
self.error('You\'re not an admin. Log in through the Admin CP to unban people.');
return;
- break;
}
}
$.each(self.p, function(i) {
- if (this.adminInfo && this.adminInfo.ip == post.adminInfo.ip)
+ if (this.adminInfo && this.adminInfo.ip === post.adminInfo.ip) {
$('#' + this.id)
.removeClass('ys-banned-post')
.find('.ys-ban-link').html('Ban');
+ }
});
}, pars);
link.innerHTML = 'Unbanning...';
return false;
- break;
case 'Unbanning...':
return false;
- break;
}
},
@@ -617,7 +623,7 @@ YShout.prototype = {
var self = this;
var link = $('#' + id).find('.ys-delete-link')[0];
- if (link.innerHTML == 'Deleting...') return;
+ if (link.innerHTML === 'Deleting...') { return; }
var pars = {
reqType: 'delete',
@@ -630,7 +636,6 @@ YShout.prototype = {
case 'admin':
self.error('You\'re not an admin. Log in through the Admin CP to ban people.');
return;
- break;
}
}
self.reload();
@@ -638,15 +643,15 @@ YShout.prototype = {
link.innerHTML = 'Deleting...';
return false;
-
},
banSelf: function(reason) {
var self = this;
this.ajax(function(json) {
- if (json.error == false)
+ if (json.error === false) {
self.banned();
+ }
}, {
reqType: 'banself',
nickname: $('#ys-input-nickname').val()
@@ -710,22 +715,24 @@ YShout.prototype = {
truncate: function(clearAll) {
var truncateTo = clearAll ? 0 : this.prefs.truncate;
var posts = $('#ys-posts .ys-post').length;
- if (posts <= truncateTo) return;
+ if (posts <= truncateTo) { return; }
//alert(this.initializing);
if (this.prefs.doTruncate || this.initializing) {
var diff = posts - truncateTo;
- for (var i = 0; i < diff; i++)
+ for (var i = 0; i < diff; i++) {
this.p.shift();
+ }
// $('#ys-posts .ys-post:gt(' + truncateTo + ')').remove();
- if (this.prefs.inverse)
+ if (this.prefs.inverse) {
$('#ys-posts .ys-post:gt(' + (truncateTo - 1) + ')').remove();
- else
+ } else {
$('#ys-posts .ys-post:lt(' + (posts - truncateTo) + ')').remove();
+ }
}
- this.markEnds();
+ this.markEnds();
},
markEnds: function() {
@@ -766,11 +773,11 @@ YShout.prototype = {
json: function(parse) {
this.d('In json: ' + parse);
var json = eval('(' + parse + ')');
- if (!this.checkError(json)) return json;
+ if (!this.checkError(json)) { return json; }
},
checkError: function(json) {
- if (!json.yError) return false;
+ if (!json.yError) { return false; }
this.d('Error: ' + json.yError);
return true;
@@ -789,10 +796,8 @@ YShout.prototype = {
dataType: html ? 'text' : 'json',
data: pars,
success: function(parse) {
-var arr = [parse];
-
+ var arr = [parse];
callback.apply(self, arr);
-
}
});
},
diff --git a/ext/chatbox/main.php b/ext/chatbox/main.php
index 8d52bd6a8..0f65d31be 100644
--- a/ext/chatbox/main.php
+++ b/ext/chatbox/main.php
@@ -33,4 +33,4 @@ public function onPageRequest(PageRequestEvent $event) {
$page->add_block($chatblock);
}
}
-?>
+
diff --git a/ext/chatbox/php/ajaxcall.class.php b/ext/chatbox/php/ajaxcall.class.php
index 7d175b25d..149a2ecc9 100644
--- a/ext/chatbox/php/ajaxcall.class.php
+++ b/ext/chatbox/php/ajaxcall.class.php
@@ -1,5 +1,9 @@
banned(ip())) { $this->sendBanned(); break; }
- if ($post = $ys->post($nickname, $message)) // To use $post somewheres later
- $this->sendUpdates();
+ if ($post = $ys->post($nickname, $message)) {
+ // To use $post somewheres later
+ $this->sendUpdates();
+ }
break;
case 'refresh':
@@ -138,7 +144,6 @@ function banSelf() {
$send['error'] = false;
echo jsonEncode($send);
-
}
function unbanSelf() {
@@ -235,7 +240,7 @@ function cleanPrefs($prefs) {
}
function clearLog() {
- $log = $_POST['log'];
+ //$log = $_POST['log'];
$send = array();
$ys = ys($_SESSION['yLog']);
@@ -254,10 +259,10 @@ function clearLog() {
function clearLogs() {
global $prefs;
- $log = $_POST['log'];
+ //$log = $_POST['log'];
$send = array();
- $ys = ys($_SESSION['yLog']);
+ //$ys = ys($_SESSION['yLog']);
switch(true) {
case !loggedIn():
@@ -272,8 +277,8 @@ function clearLogs() {
$send['error'] = false;
}
- echo jsonEncode($send);
+ echo jsonEncode($send);
}
}
-?>
\ No newline at end of file
+
diff --git a/ext/chatbox/php/filestorage.class.php b/ext/chatbox/php/filestorage.class.php
index 35b8ede1e..a7ab5ba4a 100644
--- a/ext/chatbox/php/filestorage.class.php
+++ b/ext/chatbox/php/filestorage.class.php
@@ -2,6 +2,8 @@
class FileStorage {
+ public $shoutLog, $path, $handle;
+
function FileStorage($path, $shoutLog = false) {
$this->shoutLog = $shoutLog;
$folder = 'logs';
@@ -56,7 +58,6 @@ function read() {
fseek($this->handle, 0);
//return stream_get_contents($this->handle);
return file_get_contents($this->path);
-
}
function write($contents) {
@@ -79,7 +80,5 @@ function resetArray() {
$this->save($default, false);
return $default;
}
-
}
-?>
\ No newline at end of file
diff --git a/ext/chatbox/php/functions.php b/ext/chatbox/php/functions.php
index 070785990..c61a65e33 100644
--- a/ext/chatbox/php/functions.php
+++ b/ext/chatbox/php/functions.php
@@ -16,8 +16,8 @@ function cookieClear($name) {
}
function getVar($name) {
- if (isset($_POST[$name])) return $_POST[$name];
- if (isset($_GET[$name])) return $_GET[$name];
+ if (isset($_POST[$name])) { return $_POST[$name]; }
+ if (isset($_GET[$name])) { return $_GET[$name]; }
return null;
}
@@ -28,7 +28,7 @@ function clean($s) {
}
function magic($s) {
- if (get_magic_quotes_gpc()) $s = stripslashes($s);
+ if (get_magic_quotes_gpc()) { $s = stripslashes($s); }
return $s;
}
@@ -147,6 +147,5 @@ function loggedIn() {
return $_SESSION['yLoginHash'] == md5($prefs['password']);
return false;
-
}
-?>
\ No newline at end of file
+
diff --git a/ext/chatbox/php/yshout.class.php b/ext/chatbox/php/yshout.class.php
index b5b83e0b9..e0074cba4 100644
--- a/ext/chatbox/php/yshout.class.php
+++ b/ext/chatbox/php/yshout.class.php
@@ -250,4 +250,3 @@ function postProcess(&$post) {
}
-?>
\ No newline at end of file
diff --git a/ext/chatbox/preferences.php b/ext/chatbox/preferences.php
index ef79bbf1d..cc72b33b9 100644
--- a/ext/chatbox/preferences.php
+++ b/ext/chatbox/preferences.php
@@ -71,4 +71,4 @@ function resetPrefs() {
resetPrefs();
//loadPrefs();
-?>
+
diff --git a/ext/comment/main.php b/ext/comment/main.php
index e61328070..f64247e2f 100644
--- a/ext/comment/main.php
+++ b/ext/comment/main.php
@@ -332,7 +332,7 @@ private function build_page(/*int*/ $current_page) {
$image = null; // this is "clever", I may live to regret it
}
}
- if(!is_null($image)) $images[] = array($image, $comments);
+ if(!is_null($image)) $images[] = array($image, $comments);
}
}
@@ -558,4 +558,4 @@ private function add_comment_wrapper(/*int*/ $image_id, User $user, /*string*/ $
}
// }}}
}
-?>
+
diff --git a/ext/comment/test.php b/ext/comment/test.php
index 600b2edc2..1cae2054e 100644
--- a/ext/comment/test.php
+++ b/ext/comment/test.php
@@ -101,4 +101,4 @@ function testSingleDel() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/comment/theme.php b/ext/comment/theme.php
index 7821b68cd..3a08c6950 100644
--- a/ext/comment/theme.php
+++ b/ext/comment/theme.php
@@ -296,4 +296,4 @@ protected function build_postbox(/*int*/ $image_id) {
';
}
}
-?>
+
diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php
index 24c62c554..97f4062c5 100644
--- a/ext/cron_uploader/main.php
+++ b/ext/cron_uploader/main.php
@@ -415,4 +415,4 @@ private function handle_log() {
file_put_contents ($log_path, $content);
}
}
-?>
+
diff --git a/ext/custom_html_headers/main.php b/ext/custom_html_headers/main.php
index 4bb00058b..d8dc8b57e 100644
--- a/ext/custom_html_headers/main.php
+++ b/ext/custom_html_headers/main.php
@@ -71,4 +71,4 @@ private function handle_modified_page_title() {
}
}
}
-?>
+
diff --git a/ext/danbooru_api/main.php b/ext/danbooru_api/main.php
index 2b475a9e1..af254ec7c 100644
--- a/ext/danbooru_api/main.php
+++ b/ext/danbooru_api/main.php
@@ -261,6 +261,8 @@ private function api_danbooru(PageRequestEvent $event)
if(($event->get_arg(1) == 'find_posts') || (($event->get_arg(1) == 'post') && ($event->get_arg(2) == 'index.xml')))
{
$this->authenticate_user();
+ $start = 0;
+
if(isset($_GET['md5']))
{
$md5list = explode(",",$_GET['md5']);
@@ -268,6 +270,7 @@ private function api_danbooru(PageRequestEvent $event)
{
$results[] = Image::by_hash($md5);
}
+ $count = count($results);
} elseif(isset($_GET['id']))
{
$idlist = explode(",",$_GET['id']);
@@ -275,6 +278,7 @@ private function api_danbooru(PageRequestEvent $event)
{
$results[] = Image::by_id($id);
}
+ $count = count($results);
} else
{
$limit = isset($_GET['limit']) ? int_escape($_GET['limit']) : 100;
@@ -294,7 +298,7 @@ private function api_danbooru(PageRequestEvent $event)
// Now we have the array $results filled with Image objects
// Let's display them
- $xml = "
\n";
+ $xml = "\n";
foreach($results as $img)
{
// Sanity check to see if $img is really an image object
@@ -435,4 +439,4 @@ private function xmlspecialchars($text)
}
}
-?>
+
diff --git a/ext/danbooru_api/test.php b/ext/danbooru_api/test.php
index a52186263..3717ed80b 100644
--- a/ext/danbooru_api/test.php
+++ b/ext/danbooru_api/test.php
@@ -23,4 +23,4 @@ function testSearch() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/downtime/main.php b/ext/downtime/main.php
index 63421db8a..2c857fba7 100644
--- a/ext/downtime/main.php
+++ b/ext/downtime/main.php
@@ -40,4 +40,4 @@ private function is_safe_page(PageRequestEvent $event) {
else return false;
}
}
-?>
+
diff --git a/ext/downtime/test.php b/ext/downtime/test.php
index 868eeef61..77657dffd 100644
--- a/ext/downtime/test.php
+++ b/ext/downtime/test.php
@@ -20,4 +20,4 @@ function testDowntime() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/downtime/theme.php b/ext/downtime/theme.php
index cec59c7bf..aae0cca51 100644
--- a/ext/downtime/theme.php
+++ b/ext/downtime/theme.php
@@ -59,4 +59,4 @@ public function display_message(/*string*/ $message) {
EOD;
}
}
-?>
+
diff --git a/ext/emoticons/main.php b/ext/emoticons/main.php
index ec7a071d0..a33b06c73 100644
--- a/ext/emoticons/main.php
+++ b/ext/emoticons/main.php
@@ -32,4 +32,4 @@ public function onPageRequest(PageRequestEvent $event) {
}
}
}
-?>
+
diff --git a/ext/emoticons/test.php b/ext/emoticons/test.php
index 3758ce3b7..7f9237c7d 100644
--- a/ext/emoticons/test.php
+++ b/ext/emoticons/test.php
@@ -19,4 +19,4 @@ function testEmoticons() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/emoticons/theme.php b/ext/emoticons/theme.php
index 22eaa3506..dff9f98ae 100644
--- a/ext/emoticons/theme.php
+++ b/ext/emoticons/theme.php
@@ -18,4 +18,4 @@ public function display_emotes(/*array*/ $list) {
$page->set_data($html);
}
}
-?>
+
diff --git a/ext/et/main.php b/ext/et/main.php
index 570eb3da5..d08fd552b 100644
--- a/ext/et/main.php
+++ b/ext/et/main.php
@@ -83,4 +83,4 @@ private function get_info() {
return $info;
}
}
-?>
+
diff --git a/ext/et/test.php b/ext/et/test.php
index 6d4fcae8b..d6df53b91 100644
--- a/ext/et/test.php
+++ b/ext/et/test.php
@@ -7,4 +7,4 @@ function testET() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/et/theme.php b/ext/et/theme.php
index 265b019a1..2239807b7 100644
--- a/ext/et/theme.php
+++ b/ext/et/theme.php
@@ -59,4 +59,4 @@ protected function build_data_form($info) {
return $html;
}
}
-?>
+
diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php
index fdd59c4e6..1dc416244 100644
--- a/ext/ext_manager/main.php
+++ b/ext/ext_manager/main.php
@@ -199,4 +199,4 @@ private function write_config($extras) {
}
}
}
-?>
+
diff --git a/ext/ext_manager/test.php b/ext/ext_manager/test.php
index 1ef29a377..4a4b06012 100644
--- a/ext/ext_manager/test.php
+++ b/ext/ext_manager/test.php
@@ -23,4 +23,4 @@ function testAuth() {
# FIXME: test that some extensions can be added and removed? :S
}
}
-?>
+
diff --git a/ext/ext_manager/theme.php b/ext/ext_manager/theme.php
index 0b9cb2704..fa340d419 100644
--- a/ext/ext_manager/theme.php
+++ b/ext/ext_manager/theme.php
@@ -136,4 +136,4 @@ public function display_doc(Page $page, ExtensionInfo $info) {
$page->add_block(new Block("Documentation", $html));
}
}
-?>
+
diff --git a/ext/favorites/main.php b/ext/favorites/main.php
index 10242e538..e90aa0099 100644
--- a/ext/favorites/main.php
+++ b/ext/favorites/main.php
@@ -196,4 +196,4 @@ private function list_persons_who_have_favorited(Image $image) {
array("image_id"=>$image->id));
}
}
-?>
+
diff --git a/ext/favorites/test.php b/ext/favorites/test.php
index 34dc91ebe..c3c4b8d1c 100644
--- a/ext/favorites/test.php
+++ b/ext/favorites/test.php
@@ -30,4 +30,4 @@ function testFavorites() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/favorites/theme.php b/ext/favorites/theme.php
index 14a4fd39a..d530e4977 100644
--- a/ext/favorites/theme.php
+++ b/ext/favorites/theme.php
@@ -35,4 +35,4 @@ public function display_people($username_array) {
}
}
-?>
+
diff --git a/ext/featured/main.php b/ext/featured/main.php
index 01bf64759..e0a236762 100644
--- a/ext/featured/main.php
+++ b/ext/featured/main.php
@@ -86,4 +86,4 @@ public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) {
}
}
}
-?>
+
diff --git a/ext/featured/test.php b/ext/featured/test.php
index 293efe69f..2308238e6 100644
--- a/ext/featured/test.php
+++ b/ext/featured/test.php
@@ -30,4 +30,4 @@ function testFeatured() {
$this->assert_no_text("Featured Image");
}
}
-?>
+
diff --git a/ext/featured/theme.php b/ext/featured/theme.php
index 77afe5ff2..35a64a36f 100644
--- a/ext/featured/theme.php
+++ b/ext/featured/theme.php
@@ -34,4 +34,4 @@ public function build_featured_html(Image $image, $query=null) {
";
}
}
-?>
+
diff --git a/ext/forum/main.php b/ext/forum/main.php
index 62951e4fe..1fea20641 100644
--- a/ext/forum/main.php
+++ b/ext/forum/main.php
@@ -412,4 +412,4 @@ private function threadExists($threadID){
}
}
}
-?>
+
diff --git a/ext/forum/theme.php b/ext/forum/theme.php
index 78c062612..74d7c5df4 100644
--- a/ext/forum/theme.php
+++ b/ext/forum/theme.php
@@ -229,4 +229,4 @@ private function make_thread_list($threads, $showAdminOptions)
return $html;
}
}
-?>
+
diff --git a/ext/google_analytics/main.php b/ext/google_analytics/main.php
index f1ef0b083..3f0f86082 100644
--- a/ext/google_analytics/main.php
+++ b/ext/google_analytics/main.php
@@ -35,4 +35,4 @@ public function onPageRequest(PageRequestEvent $event) {
}
}
}
-?>
+
diff --git a/ext/handle_404/main.php b/ext/handle_404/main.php
index cc41b03da..fd00790c6 100644
--- a/ext/handle_404/main.php
+++ b/ext/handle_404/main.php
@@ -50,4 +50,4 @@ private function count_main($blocks) {
public function get_priority() {return 99;}
}
-?>
+
diff --git a/ext/handle_404/test.php b/ext/handle_404/test.php
index 452af8dad..ad6d39430 100644
--- a/ext/handle_404/test.php
+++ b/ext/handle_404/test.php
@@ -10,4 +10,4 @@ function test404Handler() {
$this->assert_response(200);
}
}
-?>
+
diff --git a/ext/handle_archive/main.php b/ext/handle_archive/main.php
index f4dfe3dcf..3f61ad604 100644
--- a/ext/handle_archive/main.php
+++ b/ext/handle_archive/main.php
@@ -110,4 +110,4 @@ private function add_dir($base, $subdir="") {
// $this->theme->add_status("Adding $subdir", $list);
}
}
-?>
+
diff --git a/ext/handle_flash/main.php b/ext/handle_flash/main.php
index 88becce7b..f84153ade 100644
--- a/ext/handle_flash/main.php
+++ b/ext/handle_flash/main.php
@@ -46,4 +46,4 @@ protected function check_contents(/*string*/ $file) {
return true;
}
}
-?>
+
diff --git a/ext/handle_flash/theme.php b/ext/handle_flash/theme.php
index 6b956a753..e4557088b 100644
--- a/ext/handle_flash/theme.php
+++ b/ext/handle_flash/theme.php
@@ -23,4 +23,4 @@ public function display_image(Page $page, Image $image) {
$page->add_block(new Block("Flash Animation", $html, "main", 10));
}
}
-?>
+
diff --git a/ext/handle_ico/main.php b/ext/handle_ico/main.php
index 07fa97ec3..dae069c81 100644
--- a/ext/handle_ico/main.php
+++ b/ext/handle_ico/main.php
@@ -107,4 +107,4 @@ private function create_thumb($hash) {
return true;
}
}
-?>
+
diff --git a/ext/handle_ico/test.php b/ext/handle_ico/test.php
index dd3620553..9292a4a5d 100644
--- a/ext/handle_ico/test.php
+++ b/ext/handle_ico/test.php
@@ -17,4 +17,4 @@ function testPixelHander() {
# FIXME: test that it gets displayed properly
}
}
-?>
+
diff --git a/ext/handle_ico/theme.php b/ext/handle_ico/theme.php
index 27b1ae741..aa0927092 100644
--- a/ext/handle_ico/theme.php
+++ b/ext/handle_ico/theme.php
@@ -9,4 +9,4 @@ public function display_image(Page $page, Image $image) {
$page->add_block(new Block("Image", $html, "main", 10));
}
}
-?>
+
diff --git a/ext/handle_mp3/main.php b/ext/handle_mp3/main.php
index 2a81fcbbd..be807472e 100644
--- a/ext/handle_mp3/main.php
+++ b/ext/handle_mp3/main.php
@@ -59,4 +59,4 @@ protected function check_contents($file) {
return FALSE;
}
}
-?>
+
diff --git a/ext/handle_mp3/theme.php b/ext/handle_mp3/theme.php
index 59ecefac7..d6beb1265 100644
--- a/ext/handle_mp3/theme.php
+++ b/ext/handle_mp3/theme.php
@@ -20,4 +20,4 @@ public function display_image(Page $page, Image $image) {
$page->add_block(new Block("Music", $html, "main", 10));
}
}
-?>
+
diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php
index 0ee4ca69f..bf3453526 100644
--- a/ext/handle_pixel/main.php
+++ b/ext/handle_pixel/main.php
@@ -177,4 +177,4 @@ private function get_thumb(/*string*/ $tmpname) {
}
// }}}
}
-?>
+
diff --git a/ext/handle_pixel/test.php b/ext/handle_pixel/test.php
index ac8411c83..c80961143 100644
--- a/ext/handle_pixel/test.php
+++ b/ext/handle_pixel/test.php
@@ -14,4 +14,4 @@ function testPixelHander() {
# FIXME: test that it gets displayed properly
}
}
-?>
+
diff --git a/ext/handle_pixel/theme.php b/ext/handle_pixel/theme.php
index 74f9af4ca..de8c0c60e 100644
--- a/ext/handle_pixel/theme.php
+++ b/ext/handle_pixel/theme.php
@@ -31,4 +31,4 @@ public function display_image(Page $page, Image $image) {
$page->add_block(new Block("Image", $html, "main", 10));
}
}
-?>
+
diff --git a/ext/handle_svg/main.php b/ext/handle_svg/main.php
index 76b9a18df..d27bb6f09 100644
--- a/ext/handle_svg/main.php
+++ b/ext/handle_svg/main.php
@@ -103,4 +103,4 @@ function startElement($parser, $name, $attrs) {
function endElement($parser, $name) {
}
}
-?>
+
diff --git a/ext/handle_svg/test.php b/ext/handle_svg/test.php
index 934d6ef6a..f6420684b 100644
--- a/ext/handle_svg/test.php
+++ b/ext/handle_svg/test.php
@@ -34,4 +34,4 @@ function testSVGHander() {
# FIXME: test that it gets displayed properly
}
}
-?>
+
diff --git a/ext/handle_svg/theme.php b/ext/handle_svg/theme.php
index 304baf798..76d76aa38 100644
--- a/ext/handle_svg/theme.php
+++ b/ext/handle_svg/theme.php
@@ -12,4 +12,4 @@ public function display_image(Page $page, Image $image) {
$page->add_block(new Block("Image", $html, "main", 10));
}
}
-?>
+
diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php
index 9d34d4362..e08c005a6 100644
--- a/ext/handle_video/main.php
+++ b/ext/handle_video/main.php
@@ -79,4 +79,4 @@ protected function check_contents($file) {
return FALSE;
}
}
-?>
+
diff --git a/ext/handle_video/theme.php b/ext/handle_video/theme.php
index 3e584ce30..d6d7f723f 100644
--- a/ext/handle_video/theme.php
+++ b/ext/handle_video/theme.php
@@ -37,4 +37,4 @@ public function display_image(Page $page, Image $image) {
$page->add_block(new Block("Video", $html, "main", 10));
}
}
-?>
+
diff --git a/ext/hellban/main.php b/ext/hellban/main.php
index ae6e2be63..cac33ee9e 100644
--- a/ext/hellban/main.php
+++ b/ext/hellban/main.php
@@ -22,4 +22,4 @@ public function onPageRequest(PageRequestEvent $event) {
}
}
}
-?>
+
diff --git a/ext/holiday/main.php b/ext/holiday/main.php
index f435099a6..be23350ca 100644
--- a/ext/holiday/main.php
+++ b/ext/holiday/main.php
@@ -29,4 +29,4 @@ public function onPageRequest(PageRequestEvent $event) {
}
}
}
-?>
+
diff --git a/ext/holiday/theme.php b/ext/holiday/theme.php
index 2012f3eed..fa32d3501 100644
--- a/ext/holiday/theme.php
+++ b/ext/holiday/theme.php
@@ -17,4 +17,4 @@ public function display_holiday($date) {
}
}
}
-?>
+
diff --git a/ext/home/main.php b/ext/home/main.php
index 2c585a1a8..d170b135b 100644
--- a/ext/home/main.php
+++ b/ext/home/main.php
@@ -80,4 +80,4 @@ private function get_body() {
return $this->theme->build_body($sitename, $main_links, $main_text, $contact_link, $num_comma, $counter_text);
}
}
-?>
+
diff --git a/ext/home/test.php b/ext/home/test.php
index ada45afeb..3a142074c 100644
--- a/ext/home/test.php
+++ b/ext/home/test.php
@@ -8,4 +8,4 @@ function testHomePage() {
# FIXME: test search box
}
}
-?>
+
diff --git a/ext/home/theme.php b/ext/home/theme.php
index c93cdf13a..2d4fa889f 100644
--- a/ext/home/theme.php
+++ b/ext/home/theme.php
@@ -55,4 +55,4 @@ public function build_body(/*string*/ $sitename, /*string*/ $main_links, /*strin
";
}
}
-?>
+
diff --git a/ext/image/main.php b/ext/image/main.php
index 32d1bf972..d9a2edbb4 100644
--- a/ext/image/main.php
+++ b/ext/image/main.php
@@ -418,7 +418,7 @@ private function replace_image($id, $image) {
inspected later by an admin?
*/
log_debug("image", "Removing image with hash ".$existing->hash);
- $existing->remove_image_only(); // Actually delete the old image file from disk
+ $existing->remove_image_only(); // Actually delete the old image file from disk
// Update the data in the database.
$database->Execute(
@@ -441,4 +441,4 @@ private function replace_image($id, $image) {
} // end of class ImageIO
-?>
+
diff --git a/ext/image/test.php b/ext/image/test.php
index 0bb36eef3..3e5a94b30 100644
--- a/ext/image/test.php
+++ b/ext/image/test.php
@@ -23,4 +23,4 @@ public function testUserStats() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/image/theme.php b/ext/image/theme.php
index 9a07b7fe6..072888bfe 100644
--- a/ext/image/theme.php
+++ b/ext/image/theme.php
@@ -4,7 +4,8 @@ class ImageIOTheme extends Themelet {
* Display a link to delete an image
* (Added inline Javascript to confirm the deletion)
*
- * @param $image_id The image to delete
+ * @param $image_id integer The image to delete
+ * @return string
*/
public function get_deleter_html(/*int*/ $image_id) {
global $config;
@@ -18,11 +19,12 @@ public function get_deleter_html(/*int*/ $image_id) {
return $html;
}
-
+
/**
* Display link to replace the image
*
- * @param $image_id The image to replace
+ * @param $image_id integer The image to replace
+ * @return string
*/
public function get_replace_html(/*int*/ $image_id) {
$html = make_form(make_link("image/replace"))."
@@ -32,4 +34,4 @@ public function get_replace_html(/*int*/ $image_id) {
return $html;
}
}
-?>
+
diff --git a/ext/image_hash_ban/main.php b/ext/image_hash_ban/main.php
index 410f0b410..5037c8442 100644
--- a/ext/image_hash_ban/main.php
+++ b/ext/image_hash_ban/main.php
@@ -158,4 +158,4 @@ public function get_image_hash_bans($page, $size=100) {
// in before resolution limit plugin
public function get_priority() {return 30;}
}
-?>
+
diff --git a/ext/image_hash_ban/test.php b/ext/image_hash_ban/test.php
index 9af952e87..d84889fdb 100644
--- a/ext/image_hash_ban/test.php
+++ b/ext/image_hash_ban/test.php
@@ -34,4 +34,4 @@ function testBan() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/image_hash_ban/theme.php b/ext/image_hash_ban/theme.php
index 87c70cb10..0c759a4ab 100644
--- a/ext/image_hash_ban/theme.php
+++ b/ext/image_hash_ban/theme.php
@@ -92,4 +92,4 @@ public function get_buttons_html(Image $image) {
return $html;
}
}
-?>
+
diff --git a/ext/image_view_counter/main.php b/ext/image_view_counter/main.php
index a5da3593f..4d8fa1cfd 100644
--- a/ext/image_view_counter/main.php
+++ b/ext/image_view_counter/main.php
@@ -105,4 +105,4 @@ private function get_view_count($imgid = 0)
return $view_count;
}
}
-?>
+
diff --git a/ext/index/main.php b/ext/index/main.php
index e2664883d..1c00bdad2 100644
--- a/ext/index/main.php
+++ b/ext/index/main.php
@@ -381,4 +381,4 @@ public function onSearchTermParse(SearchTermParseEvent $event) {
$this->stpen++;
}
}
-?>
+
diff --git a/ext/index/script.js b/ext/index/script.js
index 6842ef34f..7fd63d6a7 100644
--- a/ext/index/script.js
+++ b/ext/index/script.js
@@ -1,3 +1,5 @@
+/*jshint bitwise:false, curly:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:false, strict:false, browser:true, jquery:true */
+
$(function() {
var blocked_tags = ($.cookie("ui-blocked-tags") || "").split(" ");
var needs_refresh = false;
diff --git a/ext/index/test.php b/ext/index/test.php
index 509ab7ffe..6496882ba 100644
--- a/ext/index/test.php
+++ b/ext/index/test.php
@@ -112,4 +112,4 @@ function testSearches() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/index/theme.php b/ext/index/theme.php
index 7c04910b0..81fb318f6 100644
--- a/ext/index/theme.php
+++ b/ext/index/theme.php
@@ -106,4 +106,4 @@ protected function build_table($images, $query) {
return $table;
}
}
-?>
+
diff --git a/ext/ipban/main.php b/ext/ipban/main.php
index c566f47aa..67e363fae 100644
--- a/ext/ipban/main.php
+++ b/ext/ipban/main.php
@@ -284,4 +284,4 @@ private function get_active_bans_sorted() {
}
// }}}
}
-?>
+
diff --git a/ext/ipban/test.php b/ext/ipban/test.php
index 9fd636d4b..4e4226b68 100644
--- a/ext/ipban/test.php
+++ b/ext/ipban/test.php
@@ -25,5 +25,5 @@ function testIPBan() {
# FIXME: test that the IP is actually banned
}
}
-?>
+
diff --git a/ext/ipban/theme.php b/ext/ipban/theme.php
index e9e927b60..9b9996e6f 100644
--- a/ext/ipban/theme.php
+++ b/ext/ipban/theme.php
@@ -57,4 +57,4 @@ public function display_bans(Page $page, $bans) {
$page->add_block(new Block("Edit IP Bans", $html));
}
}
-?>
+
diff --git a/ext/link_image/main.php b/ext/link_image/main.php
index 3183a41d8..75f972211 100644
--- a/ext/link_image/main.php
+++ b/ext/link_image/main.php
@@ -34,4 +34,4 @@ private function data(Image $image) {
'text_link' => $text_link);
}
}
-?>
+
diff --git a/ext/link_image/test.php b/ext/link_image/test.php
index 83f641f7f..1e70a4d28 100644
--- a/ext/link_image/test.php
+++ b/ext/link_image/test.php
@@ -22,4 +22,4 @@ function testLinkImage() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/link_image/theme.php b/ext/link_image/theme.php
index 24de94dcd..f92891c61 100644
--- a/ext/link_image/theme.php
+++ b/ext/link_image/theme.php
@@ -91,4 +91,4 @@ protected function link_code(/*string*/ $label, /*string*/ $content, $id=NULL) {
";
}
}
-?>
+
diff --git a/ext/log_db/main.php b/ext/log_db/main.php
index 126a6f663..c72c51cd2 100644
--- a/ext/log_db/main.php
+++ b/ext/log_db/main.php
@@ -135,4 +135,4 @@ public function onLog(LogEvent $event) {
}
}
}
-?>
+
diff --git a/ext/log_db/test.php b/ext/log_db/test.php
index f2e9b8dd8..2314d41fb 100644
--- a/ext/log_db/test.php
+++ b/ext/log_db/test.php
@@ -10,4 +10,4 @@ function testLog() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/log_db/theme.php b/ext/log_db/theme.php
index 777058265..1b0ba8b0d 100644
--- a/ext/log_db/theme.php
+++ b/ext/log_db/theme.php
@@ -103,4 +103,4 @@ protected function link_image($id) {
return "Image #$iid";
}
}
-?>
+
diff --git a/ext/log_net/main.php b/ext/log_net/main.php
index f82d01d3b..8a0fdd8a0 100644
--- a/ext/log_net/main.php
+++ b/ext/log_net/main.php
@@ -46,4 +46,4 @@ private function msg($data) {
}
}
}
-?>
+
diff --git a/ext/mail/main.php b/ext/mail/main.php
index 7d0ac4549..d4b8007fb 100644
--- a/ext/mail/main.php
+++ b/ext/mail/main.php
@@ -42,4 +42,4 @@ public function onPageRequest(PageRequestEvent $event) {
}
}
}
-?>
+
diff --git a/ext/mass_tagger/main.php b/ext/mass_tagger/main.php
index 2216699b4..aa9e650e3 100644
--- a/ext/mass_tagger/main.php
+++ b/ext/mass_tagger/main.php
@@ -57,4 +57,4 @@ private function _apply_mass_tags( $config, Page $page, $user, $event ) {
$page->set_redirect($_SERVER['HTTP_REFERER']);
}
}
-?>
+
diff --git a/ext/mass_tagger/script.js b/ext/mass_tagger/script.js
index 1cc4077c6..966e8ac2c 100644
--- a/ext/mass_tagger/script.js
+++ b/ext/mass_tagger/script.js
@@ -1,3 +1,5 @@
+/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
+
function activate_mass_tagger ( image_link ) {
$(".shm-thumb").each(
function ( index, block ) {
diff --git a/ext/mass_tagger/theme.php b/ext/mass_tagger/theme.php
index 5a844baca..56a2273ad 100644
--- a/ext/mass_tagger/theme.php
+++ b/ext/mass_tagger/theme.php
@@ -24,4 +24,4 @@ public function display_mass_tagger( Page $page, Event $event, $config ) {
$page->add_block( $block );
}
}
-?>
+
diff --git a/ext/not_a_tag/main.php b/ext/not_a_tag/main.php
index 5dcb41fc1..777d6dbe1 100644
--- a/ext/not_a_tag/main.php
+++ b/ext/not_a_tag/main.php
@@ -119,4 +119,4 @@ public function get_untags($page, $size=100) {
else {return array();}
}
}
-?>
+
diff --git a/ext/not_a_tag/theme.php b/ext/not_a_tag/theme.php
index 543af6f5f..d5b39cf03 100644
--- a/ext/not_a_tag/theme.php
+++ b/ext/not_a_tag/theme.php
@@ -55,4 +55,4 @@ public function display_untags(Page $page, $page_number, $page_count, $bans) {
$this->display_paginator($page, "untag/list", null, $page_number, $page_count);
}
}
-?>
+
diff --git a/ext/notes/main.php b/ext/notes/main.php
index cfbb62592..3a259c1cf 100644
--- a/ext/notes/main.php
+++ b/ext/notes/main.php
@@ -323,26 +323,16 @@ private function update_note()
$noteText = mysql_real_escape_string(html_escape($_POST["note_text"]));
// validate parameters
- if(is_null($imageID) || !is_numeric($imageID))
- return;
-
- if(is_null($noteID) || !is_numeric($noteID))
- return;
-
- if(is_null($noteX1) || !is_numeric($noteX1))
- return;
-
- if(is_null($noteY1) || !is_numeric($noteY1))
- return;
-
- if(is_null($noteHeight) || !is_numeric($noteHeight))
- return;
-
- if(is_null($noteWidth) || !is_numeric($noteWidth))
- return;
-
- if(is_null($noteText) || strlen($noteText) == 0)
+ if (is_null($imageID) || !is_numeric($imageID) ||
+ is_null($noteID) || !is_numeric($noteID) ||
+ is_null($noteX1) || !is_numeric($noteX1) ||
+ is_null($noteY1) || !is_numeric($noteY1) ||
+ is_null($noteHeight) || !is_numeric($noteHeight) ||
+ is_null($noteWidth) || !is_numeric($noteWidth) ||
+ is_null($noteText) || strlen($noteText) == 0)
+ {
return;
+ }
global $database;
$database->execute("UPDATE notes ".
@@ -369,11 +359,11 @@ private function delete_note()
$noteID = int_escape($_POST["note_id"]);
// validate parameters
- if(is_null($imageID) || !is_numeric($imageID))
- return;
-
- if(is_null($noteID) || !is_numeric($noteID))
+ if( is_null($imageID) || !is_numeric($imageID) ||
+ is_null($noteID) || !is_numeric($noteID))
+ {
return;
+ }
global $database;
@@ -609,4 +599,4 @@ private function revert_history($noteID, $reviewID){
}
}
-?>
+
diff --git a/ext/notes/script.js b/ext/notes/script.js
index c8bafab7e..43f492b25 100644
--- a/ext/notes/script.js
+++ b/ext/notes/script.js
@@ -1,3 +1,5 @@
+/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
+
$(function() {
if(window.notes) {
$('#main_image').imgNotes({notes: window.notes});
@@ -36,9 +38,9 @@ $(function() {
});
function showaddnote (img, area) {
- imgOffset = $(img).offset();
- form_left = parseInt(imgOffset.left) + parseInt(area.x1);
- form_top = parseInt(imgOffset.top) + parseInt(area.y1) + parseInt(area.height)+5;
+ var imgOffset = $(img).offset();
+ var form_left = parseInt(imgOffset.left) + parseInt(area.x1);
+ var form_top = parseInt(imgOffset.top) + parseInt(area.y1) + parseInt(area.height)+5;
$('#noteform').css({ left: form_left + 'px', top: form_top + 'px'});
$('#noteform').show();
@@ -50,9 +52,9 @@ function showaddnote (img, area) {
}
function showeditnote (img, area) {
- imgOffset = $(img).offset();
- form_left = parseInt(imgOffset.left) + area.x1;
- form_top = parseInt(imgOffset.top) + area.y2;
+ var imgOffset = $(img).offset();
+ var form_left = parseInt(imgOffset.left) + area.x1;
+ var form_top = parseInt(imgOffset.top) + area.y2;
$('#noteEditForm').css({ left: form_left + 'px', top: form_top + 'px'});
$('#noteEditForm').show();
diff --git a/ext/notes/theme.php b/ext/notes/theme.php
index 99359b925..38e7a9684 100644
--- a/ext/notes/theme.php
+++ b/ext/notes/theme.php
@@ -235,5 +235,5 @@ public function display_history($histories, $pageNumber, $totalPages) {
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
}
-}
-?>
+}
+
diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php
index e9a471f53..e2754f5af 100644
--- a/ext/numeric_score/main.php
+++ b/ext/numeric_score/main.php
@@ -137,6 +137,10 @@ public function onPageRequest(PageRequestEvent $event) {
else if($event->page_matches("popular_by_year")){
$dte = array($totaldate, $year, "\\y\\e\\a\\r\=Y", "year");
}
+ else {
+ // this should never happen due to the fact that the page event is already matched against earlier.
+ throw new UnexpectedValueException("Error: Invalid page event.");
+ }
$sql .= " AND NOT numeric_score=0 ORDER BY numeric_score DESC LIMIT :limit OFFSET 0";
//filter images by score != 0 + date > limit to max images on one page > order from highest to lowest score
@@ -300,4 +304,4 @@ private function add_vote(/*int*/ $image_id, /*int*/ $user_id, /*int*/ $score) {
array("imageid" => $image_id, "id" => $image_id));
}
}
-?>
+
diff --git a/ext/numeric_score/test.php b/ext/numeric_score/test.php
index 69f1d64f5..ed2302726 100644
--- a/ext/numeric_score/test.php
+++ b/ext/numeric_score/test.php
@@ -54,4 +54,4 @@ function testNumericScore() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/numeric_score/theme.php b/ext/numeric_score/theme.php
index e805c929b..e089bc74b 100644
--- a/ext/numeric_score/theme.php
+++ b/ext/numeric_score/theme.php
@@ -89,4 +89,4 @@ public function view_popular($images, $dte) {
}
}
-?>
+
diff --git a/ext/oekaki/main.php b/ext/oekaki/main.php
index 6c114537f..b9081fe10 100644
--- a/ext/oekaki/main.php
+++ b/ext/oekaki/main.php
@@ -87,4 +87,4 @@ function onPostListBuilding(PostListBuildingEvent $event) {
}
}
}
-?>
+
diff --git a/ext/oekaki/test.php b/ext/oekaki/test.php
index f42575907..07ca4ec3d 100644
--- a/ext/oekaki/test.php
+++ b/ext/oekaki/test.php
@@ -6,4 +6,4 @@ function testLog() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/oekaki/theme.php b/ext/oekaki/theme.php
index 468c0bdbe..8a0ee9b99 100644
--- a/ext/oekaki/theme.php
+++ b/ext/oekaki/theme.php
@@ -61,4 +61,4 @@ public function display_block() {
, "left", 21)); // upload is 20
}
}
-?>
+
diff --git a/ext/ouroboros_api/main.php b/ext/ouroboros_api/main.php
index fa9ef5da6..c223690cc 100644
--- a/ext/ouroboros_api/main.php
+++ b/ext/ouroboros_api/main.php
@@ -573,12 +573,17 @@ protected function postCreate(OuroborosPost $post, $md5 = '')
protected function postShow($id = null)
{
if (!is_null($id)) {
- $post = new _SafeOuroborosImage(Image::by_id($id));
- $this->sendData('post', $post);
- } else {
- $this->sendResponse(424, 'ID is mandatory');
- }
- }
+ $image = Image::by_id($id);
+ if ( ! $image instanceof Image) {
+ $this->sendResponse(404, 'ID not found');
+ } else {
+ $post = new _SafeOuroborosImage($image);
+ $this->sendData('post', $post);
+ }
+ } else {
+ $this->sendResponse(424, 'ID is mandatory');
+ }
+ }
/**
* Wrapper for getting a list of posts
diff --git a/ext/pm/main.php b/ext/pm/main.php
index 9cd781e7a..2deaf4e40 100644
--- a/ext/pm/main.php
+++ b/ext/pm/main.php
@@ -210,4 +210,4 @@ private function count_pms(User $user) {
return $count;
}
}
-?>
+
diff --git a/ext/pm/test.php b/ext/pm/test.php
index 0717433af..f08a0274f 100644
--- a/ext/pm/test.php
+++ b/ext/pm/test.php
@@ -50,4 +50,4 @@ function testAdminAccess() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/pm/theme.php b/ext/pm/theme.php
index 7b0f5be1f..790016174 100644
--- a/ext/pm/theme.php
+++ b/ext/pm/theme.php
@@ -70,4 +70,4 @@ public function display_message(Page $page, User $from, User $to, PM $pm) {
$page->add_block(new Block("Message from {$from->name}", format_text($pm->message), "main", 10));
}
}
-?>
+
diff --git a/ext/pm_triggers/main.php b/ext/pm_triggers/main.php
index a09454a15..7cb80013b 100644
--- a/ext/pm_triggers/main.php
+++ b/ext/pm_triggers/main.php
@@ -26,4 +26,4 @@ private function send($to_id, $subject, $body) {
)));
}
}
-?>
+
diff --git a/ext/pools/main.php b/ext/pools/main.php
index 965fb98e9..40270a0bd 100644
--- a/ext/pools/main.php
+++ b/ext/pools/main.php
@@ -881,4 +881,4 @@ private function delete_post(/*int*/ $poolID, /*int*/ $imageID, $history=false)
}
}
-?>
+
diff --git a/ext/pools/script.js b/ext/pools/script.js
index 505718a95..c5e91d4ef 100644
--- a/ext/pools/script.js
+++ b/ext/pools/script.js
@@ -1,3 +1,5 @@
+/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
+
$(function() {
var order_pool = $.cookie("shm_ui-order-pool") || "created";
$("#order_pool option[value="+order_pool+"]").attr("selected", true);
diff --git a/ext/pools/test.php b/ext/pools/test.php
index ea8015c38..8a59dce98 100644
--- a/ext/pools/test.php
+++ b/ext/pools/test.php
@@ -38,4 +38,4 @@ function testPools() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/pools/theme.php b/ext/pools/theme.php
index fd25d431c..c8cc4e02a 100644
--- a/ext/pools/theme.php
+++ b/ext/pools/theme.php
@@ -423,4 +423,4 @@ public function show_history($histories, /*int*/ $pageNumber, /*int*/ $totalPage
$this->display_paginator($page, "pool/updated", null, $pageNumber, $totalPages);
}
}
-?>
+
diff --git a/ext/qr_code/main.php b/ext/qr_code/main.php
index ed671fd33..4fe864d8c 100644
--- a/ext/qr_code/main.php
+++ b/ext/qr_code/main.php
@@ -12,4 +12,4 @@ public function onDisplayingImage(DisplayingImageEvent $event) {
$this->theme->links_block(make_http(make_link('image/'.$event->image->id.'.jpg')));
}
}
-?>
+
diff --git a/ext/qr_code/theme.php b/ext/qr_code/theme.php
index 8f6103de2..3e82351dc 100644
--- a/ext/qr_code/theme.php
+++ b/ext/qr_code/theme.php
@@ -6,4 +6,4 @@ public function links_block($link) {
"QR Code","","left",50));
}
}
-?>
+
diff --git a/ext/random_image/main.php b/ext/random_image/main.php
index 0d799855a..1d2d194a9 100644
--- a/ext/random_image/main.php
+++ b/ext/random_image/main.php
@@ -76,4 +76,4 @@ public function onPostListBuilding(PostListBuildingEvent $event) {
}
}
}
-?>
+
diff --git a/ext/random_image/test.php b/ext/random_image/test.php
index 4d30c0e1f..f11c83ef2 100644
--- a/ext/random_image/test.php
+++ b/ext/random_image/test.php
@@ -55,4 +55,4 @@ function testPostListBlock() {
$this->assert_no_text("Random Image");
}
}
-?>
+
diff --git a/ext/random_image/theme.php b/ext/random_image/theme.php
index 87806bec4..1210959e8 100644
--- a/ext/random_image/theme.php
+++ b/ext/random_image/theme.php
@@ -24,4 +24,4 @@ public function build_random_html(Image $image, $query=null) {
";
}
}
-?>
+
diff --git a/ext/random_list/main.php b/ext/random_list/main.php
index c96713095..609766fb5 100644
--- a/ext/random_list/main.php
+++ b/ext/random_list/main.php
@@ -51,4 +51,4 @@ public function onSetupBuilding(SetupBuildingEvent $event) {
$event->panel->add_block($sb);
}
}
-?>
+
diff --git a/ext/rating/main.php b/ext/rating/main.php
index eda011454..c9f3c8aaa 100644
--- a/ext/rating/main.php
+++ b/ext/rating/main.php
@@ -235,4 +235,4 @@ private function set_rating(/*int*/ $image_id, /*string*/ $rating, /*string*/ $o
}
}
}
-?>
+
diff --git a/ext/rating/test.php b/ext/rating/test.php
index ac092c2f4..81d02dfc0 100644
--- a/ext/rating/test.php
+++ b/ext/rating/test.php
@@ -52,4 +52,4 @@ function testRating() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/rating/theme.php b/ext/rating/theme.php
index 3e9437a64..4fde82741 100644
--- a/ext/rating/theme.php
+++ b/ext/rating/theme.php
@@ -45,4 +45,4 @@ public function rating_to_name(/*string*/ $rating) {
}
}
-?>
+
diff --git a/ext/regen_thumb/main.php b/ext/regen_thumb/main.php
index b417e539a..4c12f0c44 100644
--- a/ext/regen_thumb/main.php
+++ b/ext/regen_thumb/main.php
@@ -31,4 +31,4 @@ public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) {
}
}
}
-?>
+
diff --git a/ext/regen_thumb/test.php b/ext/regen_thumb/test.php
index cb2139f6d..e2b5dc631 100644
--- a/ext/regen_thumb/test.php
+++ b/ext/regen_thumb/test.php
@@ -12,4 +12,4 @@ function testRegenThumb() {
# FIXME: test that the thumb's modified time has been updated
}
}
-?>
+
diff --git a/ext/regen_thumb/theme.php b/ext/regen_thumb/theme.php
index 6f5720a74..68d7904cf 100644
--- a/ext/regen_thumb/theme.php
+++ b/ext/regen_thumb/theme.php
@@ -24,4 +24,4 @@ public function display_results(Page $page, Image $image) {
$page->add_block(new Block("Thumbnail", $this->build_thumb_html($image)));
}
}
-?>
+
diff --git a/ext/relatationships/main.php b/ext/relatationships/main.php
index b1be3c363..846687a1e 100644
--- a/ext/relatationships/main.php
+++ b/ext/relatationships/main.php
@@ -120,4 +120,4 @@ private function remove_parent(/*int*/ $imageID){
}
}
}
-?>
+
diff --git a/ext/relatationships/theme.php b/ext/relatationships/theme.php
index b40c62898..a73e22935 100644
--- a/ext/relatationships/theme.php
+++ b/ext/relatationships/theme.php
@@ -42,4 +42,4 @@ public function get_parent_editor_html(Image $image) {
return $html;
}
}
-?>
+
diff --git a/ext/report_image/main.php b/ext/report_image/main.php
index a21a05814..b99f7030e 100644
--- a/ext/report_image/main.php
+++ b/ext/report_image/main.php
@@ -181,4 +181,4 @@ public function count_reported_images() {
// * Version 0.2b - 10/27/07 - Now supports Shimmie2 RC2!
// * Version 0.2a - 10/24/07 - Fixed some SQL issues. I will make sure to test before commiting :)
// * Version 0.2 - 10/24/07 - First public release.
-?>
+
diff --git a/ext/report_image/test.php b/ext/report_image/test.php
index cb1339db1..65b89aef4 100644
--- a/ext/report_image/test.php
+++ b/ext/report_image/test.php
@@ -37,4 +37,4 @@ function testReportImage() {
# FIXME: test that >>123 works
}
}
-?>
+
diff --git a/ext/report_image/theme.php b/ext/report_image/theme.php
index b62fd02ab..35aca30fb 100644
--- a/ext/report_image/theme.php
+++ b/ext/report_image/theme.php
@@ -78,4 +78,4 @@ public function display_image_banner(Image $image, /*array*/ $reporters) {
$page->add_block(new Block("Report Image", $html, "left"));
}
}
-?>
+
diff --git a/ext/res_limit/main.php b/ext/res_limit/main.php
index c17ad203c..34b0f90d8 100644
--- a/ext/res_limit/main.php
+++ b/ext/res_limit/main.php
@@ -70,4 +70,4 @@ public function onSetupBuilding(SetupBuildingEvent $event) {
$event->panel->add_block($sb);
}
}
-?>
+
diff --git a/ext/res_limit/test.php b/ext/res_limit/test.php
index 2707923a1..9d66d3cef 100644
--- a/ext/res_limit/test.php
+++ b/ext/res_limit/test.php
@@ -110,4 +110,4 @@ public function tearDown() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/resize/main.php b/ext/resize/main.php
index 705980ebb..72b292315 100644
--- a/ext/resize/main.php
+++ b/ext/resize/main.php
@@ -59,7 +59,8 @@ public function onSetupBuilding(SetupBuildingEvent $event) {
}
public function onDataUpload(DataUploadEvent $event) {
- global $config;
+ global $config, $page;
+
$image_obj = Image::by_id($event->image_id);
if($config->get_bool("resize_upload") == true && ($image_obj->ext == "jpg" || $image_obj->ext == "png" || $image_obj->ext == "gif")){
@@ -312,4 +313,4 @@ private function resize_image(Image $image_obj, /*int*/ $width, /*int*/ $height)
log_info("resize", "Resized Image #{$image_obj->id} - New hash: {$new_hash}");
}
}
-?>
+
diff --git a/ext/resize/theme.php b/ext/resize/theme.php
index e19a8e326..3d09e1f02 100644
--- a/ext/resize/theme.php
+++ b/ext/resize/theme.php
@@ -35,4 +35,4 @@ public function display_resize_error(Page $page, /*string*/ $title, /*string*/ $
$page->add_block(new Block($title, $message));
}
}
-?>
+
diff --git a/ext/rotate/main.php b/ext/rotate/main.php
index cde59505c..5e1c8af82 100644
--- a/ext/rotate/main.php
+++ b/ext/rotate/main.php
@@ -231,4 +231,4 @@ private function rotate_image(/*int*/ $image_id, /*int*/ $deg) {
log_info("rotate", "Rotated Image #{$image_id} - New hash: {$new_hash}");
}
}
-?>
+
diff --git a/ext/rotate/theme.php b/ext/rotate/theme.php
index ddef58c71..c6481469f 100644
--- a/ext/rotate/theme.php
+++ b/ext/rotate/theme.php
@@ -25,4 +25,4 @@ public function display_rotate_error(Page $page, /*string*/ $title, /*string*/ $
$page->add_block(new Block($title, $message));
}
}
-?>
+
diff --git a/ext/rss_comments/main.php b/ext/rss_comments/main.php
index a141cc390..7ae90be55 100644
--- a/ext/rss_comments/main.php
+++ b/ext/rss_comments/main.php
@@ -75,4 +75,4 @@ public function onPageRequest(PageRequestEvent $event) {
}
}
}
-?>
+
diff --git a/ext/rss_comments/test.php b/ext/rss_comments/test.php
index e6062c298..1036c1774 100644
--- a/ext/rss_comments/test.php
+++ b/ext/rss_comments/test.php
@@ -19,4 +19,4 @@ function testImageFeed() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/rss_images/main.php b/ext/rss_images/main.php
index f9d4b3304..cef020759 100644
--- a/ext/rss_images/main.php
+++ b/ext/rss_images/main.php
@@ -112,4 +112,4 @@ private function thumb(Image $image) {
return $data;
}
}
-?>
+
diff --git a/ext/rss_images/test.php b/ext/rss_images/test.php
index 9447ecc6f..4322b3082 100644
--- a/ext/rss_images/test.php
+++ b/ext/rss_images/test.php
@@ -33,4 +33,4 @@ function testImageFeed() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/rss_images/theme.php b/ext/rss_images/theme.php
index d1f2734f0..ef4ac101a 100644
--- a/ext/rss_images/theme.php
+++ b/ext/rss_images/theme.php
@@ -1,4 +1,4 @@
+
diff --git a/ext/setup/main.php b/ext/setup/main.php
index d6c0cd452..f34e0d4d9 100644
--- a/ext/setup/main.php
+++ b/ext/setup/main.php
@@ -306,4 +306,4 @@ public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
}
}
}
-?>
+
diff --git a/ext/setup/test.php b/ext/setup/test.php
index c990f2ee5..6114b030c 100644
--- a/ext/setup/test.php
+++ b/ext/setup/test.php
@@ -28,4 +28,4 @@ function testAuth() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/setup/theme.php b/ext/setup/theme.php
index 3bad70073..99fa314ae 100644
--- a/ext/setup/theme.php
+++ b/ext/setup/theme.php
@@ -96,4 +96,4 @@ protected function sb_to_html(SetupBlock $block) {
return $html;
}
}
-?>
+
diff --git a/ext/shimmie_api/main.php b/ext/shimmie_api/main.php
index da65a2d6d..0ea29ead8 100644
--- a/ext/shimmie_api/main.php
+++ b/ext/shimmie_api/main.php
@@ -21,6 +21,17 @@
class _SafeImage {
#{"id":"2","height":"768","width":"1024","hash":"71cdfaabbcdad3f777e0b60418532e94","filesize":"439561","filename":"HeilAmu.png","ext":"png","owner_ip":"0.0.0.0","posted":"0000-00-00 00:00:00","source":null,"locked":"N","owner_id":"0","rating":"u","numeric_score":"0","text_score":"0","notes":"0","favorites":"0","posted_timestamp":-62169955200,"tag_array":["cat","kunimitsu"]}
+ public $id;
+ public $height;
+ public $width;
+ public $hash;
+ public $filesize;
+ public $ext;
+ public $posted;
+ public $source;
+ public $owner_id;
+ public $tags;
+
function __construct(Image $img) {
$this->id = $img->id;
$this->height = $img->height;
@@ -146,4 +157,4 @@ public function onPageRequest(PageRequestEvent $event) {
}
}
}
-?>
+
diff --git a/ext/shimmie_api/test.php b/ext/shimmie_api/test.php
index 961afa0ab..c8dfa91c4 100644
--- a/ext/shimmie_api/test.php
+++ b/ext/shimmie_api/test.php
@@ -26,4 +26,4 @@ function testAPI() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/simpletest/main.php b/ext/simpletest/main.php
index 523204cb5..2ff0abf00 100644
--- a/ext/simpletest/main.php
+++ b/ext/simpletest/main.php
@@ -91,6 +91,7 @@
* A set of common SCore activities to test
*/
class SCoreWebTestCase extends WebTestCase {
+
/**
* Click on a link or a button
*/
@@ -257,4 +258,4 @@ public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
}
}
}
-?>
+
diff --git a/ext/simpletest/theme.php b/ext/simpletest/theme.php
index 4ed982d91..44d22a8ca 100644
--- a/ext/simpletest/theme.php
+++ b/ext/simpletest/theme.php
@@ -84,4 +84,4 @@ function paintException($message) {
/** @private */
class SCoreCLIReporter extends TextReporter {
}
-?>
+
diff --git a/ext/site_description/main.php b/ext/site_description/main.php
index 9adaa5d3e..80563617a 100644
--- a/ext/site_description/main.php
+++ b/ext/site_description/main.php
@@ -30,4 +30,4 @@ public function onSetupBuilding(SetupBuildingEvent $event) {
$event->panel->add_block($sb);
}
}
-?>
+
diff --git a/ext/site_description/test.php b/ext/site_description/test.php
index ee27e2fc4..293c6a1a7 100644
--- a/ext/site_description/test.php
+++ b/ext/site_description/test.php
@@ -15,4 +15,4 @@ function testSiteDescription() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/sitemap/main.php b/ext/sitemap/main.php
index 056d07fe0..7172dc214 100644
--- a/ext/sitemap/main.php
+++ b/ext/sitemap/main.php
@@ -164,4 +164,4 @@ private function display_existing_sitemap()
$page->set_data($xml);
}
}
-?>
+
diff --git a/ext/sitemap/test.php b/ext/sitemap/test.php
index 0d4208885..fa459d9b8 100644
--- a/ext/sitemap/test.php
+++ b/ext/sitemap/test.php
@@ -6,4 +6,4 @@ function testBasic() {
$this->get_page('sitemap.xml');
}
}
-?>
+
diff --git a/ext/source_history/main.php b/ext/source_history/main.php
index 366ea7cf6..a9eab563e 100644
--- a/ext/source_history/main.php
+++ b/ext/source_history/main.php
@@ -140,13 +140,20 @@ private function process_revert_request($revert_id) {
}
// lets get the values out of the result
- $stored_result_id = $result['id'];
+ //$stored_result_id = $result['id'];
$stored_image_id = $result['image_id'];
$stored_source = $result['source'];
log_debug("source_history", 'Reverting source of Image #'.$stored_image_id.' to ['.$stored_source.']');
+
+ $image = Image::by_id($stored_image_id);
+
+ if (is_null($image)) {
+ die('Error: No image with the id ('.$stored_image_id.') was found. Perhaps the image was deleted while processing this request.');
+ }
+
// all should be ok so we can revert by firing the SetUserSources event.
- send_event(new SourceSetEvent(Image::by_id($stored_image_id), $stored_source));
+ send_event(new SourceSetEvent($image, $stored_source));
// all should be done now so redirect the user back to the image
$page->set_mode("redirect");
@@ -309,8 +316,15 @@ public function process_revert_all_changes($name, $ip, $date) {
$stored_source = $result['source'];
log_debug("source_history", 'Reverting source of Image #'.$stored_image_id.' to ['.$stored_source.']');
+
+ $image = Image::by_id($stored_image_id);
+
+ if (is_null($image)) {
+ die('Error: No image with the id ('.$stored_image_id.') was found. Perhaps the image was deleted while processing this request.');
+ }
+
// all should be ok so we can revert by firing the SetSources event.
- send_event(new SourceSetEvent(Image::by_id($stored_image_id), $stored_source));
+ send_event(new SourceSetEvent($image, $stored_source));
$this->theme->add_status('Reverted Change','Reverted Image #'.$image_id.' to Source History #'.$stored_result_id.' ('.$row['source'].')');
}
}
@@ -373,4 +387,4 @@ private function add_source_history($image, $source) {
}
}
}
-?>
+
diff --git a/ext/source_history/theme.php b/ext/source_history/theme.php
index 29bcc019d..4399c3008 100644
--- a/ext/source_history/theme.php
+++ b/ext/source_history/theme.php
@@ -134,4 +134,4 @@ public function add_status(/*string*/ $title, /*string*/ $body) {
$this->messages[] = ''. $title .'
'. $body .'
';
}
}
-?>
+
diff --git a/ext/tag_categories/main.php b/ext/tag_categories/main.php
index 80f62e88a..4e0fbdda4 100644
--- a/ext/tag_categories/main.php
+++ b/ext/tag_categories/main.php
@@ -146,4 +146,4 @@ public function show_tag_categories($page) {
}
}
-?>
+
diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php
index eb58efe35..8161af831 100644
--- a/ext/tag_edit/main.php
+++ b/ext/tag_edit/main.php
@@ -320,4 +320,4 @@ private function mass_source_edit($tags, $source) {
}
}
}
-?>
+
diff --git a/ext/tag_edit/test.php b/ext/tag_edit/test.php
index a88bfc37a..89541830e 100644
--- a/ext/tag_edit/test.php
+++ b/ext/tag_edit/test.php
@@ -68,4 +68,4 @@ function testMassEdit() {
}
*/
}
-?>
+
diff --git a/ext/tag_edit/theme.php b/ext/tag_edit/theme.php
index 4cd67bae8..4e1650cc0 100644
--- a/ext/tag_edit/theme.php
+++ b/ext/tag_edit/theme.php
@@ -134,4 +134,4 @@ public function get_lock_editor_html(Image $image) {
";
}
}
-?>
+
diff --git a/ext/tag_editcloud/main.php b/ext/tag_editcloud/main.php
index d74e061e0..d1cd2bd29 100644
--- a/ext/tag_editcloud/main.php
+++ b/ext/tag_editcloud/main.php
@@ -156,4 +156,4 @@ private function can_tag($image) {
return ($user->can("edit_image_tag") && (!$image->is_locked() || $user->can("edit_image_lock")));
}
}
-?>
+
diff --git a/ext/tag_editcloud/script.js b/ext/tag_editcloud/script.js
index b71818c49..71a9c2870 100644
--- a/ext/tag_editcloud/script.js
+++ b/ext/tag_editcloud/script.js
@@ -1,3 +1,5 @@
+/*jshint bitwise:true, curly:true, eqeqeq: false, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
+
Array.prototype.editcloud_contains = function (ele) {
for (var i = 0; i < this.length; i++) {
if (this[i] == ele) {
@@ -7,7 +9,7 @@ Array.prototype.editcloud_contains = function (ele) {
return false;
};
Array.prototype.editcloud_remove = function (ele) {
- var arr = new Array();
+ var arr = [];
var count = 0;
for (var i = 0; i < this.length; i++) {
if (this[i] != ele) {
@@ -25,8 +27,8 @@ function tageditcloud_toggle_extra(hide) {
}
var el = document.getElementById('tagcloud_extra');
- el.style.display = (el.style.display != 'none' ? 'none' : '' );
- hide.innerHTML = (el.style.display != 'none' ? 'show fewer tags' : hide_text );
+ el.style.display = (el.style.display !== 'none' ? 'none' : '' );
+ hide.innerHTML = (el.style.display !== 'none' ? 'show fewer tags' : hide_text );
}
function tageditcloud_toggle_tag(ele,fullTag) {
@@ -42,5 +44,5 @@ function tageditcloud_toggle_tag(ele,fullTag) {
}
taglist.value = tags.join(' ');
- document.getElementById('tags').focus();
+ document.getElementById('tag_editor').focus();
}
diff --git a/ext/tag_history/main.php b/ext/tag_history/main.php
index b6e6605cc..e3c601317 100644
--- a/ext/tag_history/main.php
+++ b/ext/tag_history/main.php
@@ -143,10 +143,15 @@ private function process_revert_request($revert_id) {
$stored_result_id = $result['id'];
$stored_image_id = int_escape($result['image_id']);
$stored_tags = $result['tags'];
-
+
+ $image = Image::by_id($stored_image_id);
+ if ( ! $image instanceof Image) {
+ throw new ImageDoesNotExist("Error: cannot find any image with the ID = ". $stored_image_id);
+ }
+
log_debug("tag_history", 'Reverting tags of Image #'.$stored_image_id.' to ['.$stored_tags.']');
// all should be ok so we can revert by firing the SetUserTags event.
- send_event(new TagSetEvent(Image::by_id($stored_image_id), $stored_tags));
+ send_event(new TagSetEvent($image, $stored_tags));
// all should be done now so redirect the user back to the image
$page->set_mode("redirect");
@@ -307,10 +312,15 @@ public function process_revert_all_changes($name, $ip, $date) {
$stored_result_id = int_escape($result['id']);
$stored_image_id = int_escape($result['image_id']);
$stored_tags = $result['tags'];
-
+
+ $image = Image::by_id($stored_image_id);
+ if ( ! $image instanceof Image) {
+ throw new ImageDoesNotExist("Error: cannot find any image with the ID = ". $stored_image_id);
+ }
+
log_debug("tag_history", 'Reverting tags of Image #'.$stored_image_id.' to ['.$stored_tags.']');
// all should be ok so we can revert by firing the SetTags event.
- send_event(new TagSetEvent(Image::by_id($stored_image_id), $stored_tags));
+ send_event(new TagSetEvent($image, $stored_tags));
$this->theme->add_status('Reverted Change','Reverted Image #'.$image_id.' to Tag History #'.$stored_result_id.' ('.$row['tags'].')');
}
}
@@ -373,4 +383,4 @@ private function add_tag_history($image, $tags) {
}
}
}
-?>
+
diff --git a/ext/tag_history/test.php b/ext/tag_history/test.php
index 5ca06e444..ae8f2bdf0 100644
--- a/ext/tag_history/test.php
+++ b/ext/tag_history/test.php
@@ -20,4 +20,4 @@ function testTagHistory() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/tag_history/theme.php b/ext/tag_history/theme.php
index 62efac5a9..1f516d64d 100644
--- a/ext/tag_history/theme.php
+++ b/ext/tag_history/theme.php
@@ -146,4 +146,4 @@ public function add_status(/*string*/ $title, /*string*/ $body) {
$this->messages[] = ''. $title .'
'. $body .'
';
}
}
-?>
+
diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php
index 3677c98a9..53f748ea1 100644
--- a/ext/tag_list/main.php
+++ b/ext/tag_list/main.php
@@ -492,4 +492,4 @@ private function add_refine_block(Page $page, /*array(string)*/ $search) {
}
// }}}
}
-?>
+
diff --git a/ext/tag_list/test.php b/ext/tag_list/test.php
index fc574eabc..6b50fc874 100644
--- a/ext/tag_list/test.php
+++ b/ext/tag_list/test.php
@@ -34,4 +34,4 @@ function testMinCount() {
}
}
}
-?>
+
diff --git a/ext/tag_list/theme.php b/ext/tag_list/theme.php
index 878664768..525330e20 100644
--- a/ext/tag_list/theme.php
+++ b/ext/tag_list/theme.php
@@ -272,4 +272,4 @@ protected function tag_link($tag) {
return make_link("post/list/$u_tag/1");
}
}
-?>
+
diff --git a/ext/tagger/main.php b/ext/tagger/main.php
index 4df81ee8a..553a8fc64 100644
--- a/ext/tagger/main.php
+++ b/ext/tagger/main.php
@@ -139,4 +139,4 @@ private function count($query,$values) {
"SELECT COUNT(*) FROM `tags` $query",$values)->fields['COUNT(*)'];
}
}
-?>
+
diff --git a/ext/tagger/script.js b/ext/tagger/script.js
index e01c81686..511a2684a 100644
--- a/ext/tagger/script.js
+++ b/ext/tagger/script.js
@@ -1,9 +1,11 @@
+/*jshint forin:false, nonew:true, undef:true, strict:false, browser:true, jquery:true */
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* Tagger - Advanced Tagging v2 *
* Author: Artanis (Erik Youngren ) *
* Do not remove this notice. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
+
var Tagger = {
initialize : function (image_id) {
// object navigation
@@ -25,7 +27,7 @@ var Tagger = {
this.tag.suggest = null;
this.tag.image_tags();
- // reveal
+ // reveal
this.editor.container.style.display = "";
// dragging
@@ -39,10 +41,10 @@ var Tagger = {
},
alert : function (type,text,timeout) {
- var id = "tagger_alert-"+type
+ var id = "tagger_alert-"+type;
var t_alert = byId(id);
if (t_alert) {
- if(text == false) {
+ if(text === false) {
// remove
t_alert.parentNode.removeChild(t_alert);
} else {
@@ -150,10 +152,10 @@ var Tagger = {
},
ajax : function (url, callback) {
- var http = (new XMLHttpRequest || new ActiveXObject("Microsoft.XMLHTTP"));
+ var http = (new XMLHttpRequest() || new ActiveXObject("Microsoft.XMLHTTP"));
http.open("GET",url,true);
http.onreadystatechange = function () {
- if(http.readyState == 4) callback(http);
+ if(http.readyState == 4) { callback(http); }
};
http.send(null);
}
@@ -162,22 +164,19 @@ var Tagger = {
position : {
set : function (x,y) {
if (!x || !y) {
- with(this.parent.editor.container.style) {
- top = "25px";
- left = "";
- right = "25px";
- bottom = "";
- }
+ this.parent.editor.container.style.top = "25px";
+ this.parent.editor.container.style.left = "";
+ this.parent.editor.container.style.right = "25px";
+ this.parent.editor.container.style.bottom = "";
+
var xy = this.get();
x = xy[0];
y = xy[1];
}
- with(this.parent.editor.container.style) {
- top = y+"px";
- left = x+"px";
- right = "";
- bottom = "";
- }
+ this.parent.editor.container.style.top = y+"px";
+ this.parent.editor.container.style.left = x+"px";
+ this.parent.editor.container.style.right = "";
+ this.parent.editor.container.style.bottom = "";
},
get : function () {
diff --git a/ext/tagger/theme.php b/ext/tagger/theme.php
index 733db116f..27ac184a0 100644
--- a/ext/tagger/theme.php
+++ b/ext/tagger/theme.php
@@ -11,10 +11,14 @@ public function build_tagger (Page $page, $event) {
// Initialization code
$base_href = get_base_href();
// TODO: AJAX test and fallback.
+
$page->add_html_header("");
$page->add_block(new Block(null,
- "","main",1000));
+ "","main",1000));
// Tagger block
$page->add_block( new Block(
@@ -62,4 +66,4 @@ private function html(Image $image) {
return $html;
}
}
-?>
+
diff --git a/ext/tagger/webtoolkit.drag.js b/ext/tagger/webtoolkit.drag.js
index 3ba875074..68d48f4a0 100644
--- a/ext/tagger/webtoolkit.drag.js
+++ b/ext/tagger/webtoolkit.drag.js
@@ -1,3 +1,5 @@
+/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
+
/**
*
* Crossbrowser Drag Handler
@@ -18,9 +20,9 @@ var DragHandler = {
oElem.onmousedown = DragHandler._dragBegin;
// callbacks
- oElem.dragBegin = new Function();
- oElem.drag = new Function();
- oElem.dragEnd = new Function();
+ oElem.dragBegin = function () {};
+ oElem.drag = function () {};
+ oElem.dragEnd = function () {};
return oElem;
},
@@ -82,4 +84,4 @@ var DragHandler = {
DragHandler._oElem = null;
}
-}
+};
diff --git a/ext/tips/main.php b/ext/tips/main.php
index d1c08929f..94f8bf2fb 100644
--- a/ext/tips/main.php
+++ b/ext/tips/main.php
@@ -137,9 +137,9 @@ private function setStatus($tipID) {
$tip = $database->get_row("SELECT * FROM tips WHERE id = ? ", array($tipID));
- if($tip['enable'] == "Y") {
+ if (bool_escape($tip['enable'])) {
$enable = "N";
- } elseif($tip['enable'] == "N") {
+ } else {
$enable = "Y";
}
@@ -151,4 +151,4 @@ private function deleteTip($tipID) {
$database->execute("DELETE FROM tips WHERE id = ?", array($tipID));
}
}
-?>
+
diff --git a/ext/tips/test.php b/ext/tips/test.php
index 7e3998a6a..6b5e6c1ab 100644
--- a/ext/tips/test.php
+++ b/ext/tips/test.php
@@ -68,4 +68,4 @@ function testDisabled() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/tips/theme.php b/ext/tips/theme.php
index 2f4b84bac..2aa3ef516 100644
--- a/ext/tips/theme.php
+++ b/ext/tips/theme.php
@@ -92,4 +92,4 @@ public function showAll($url, $tips){
$page->add_block(new Block("All Tips", $html, "main", 20));
}
}
-?>
+
diff --git a/ext/twitter_soc/main.php b/ext/twitter_soc/main.php
index c81a2d6af..0242c7d42 100644
--- a/ext/twitter_soc/main.php
+++ b/ext/twitter_soc/main.php
@@ -21,4 +21,4 @@ public function onSetupBuilding(SetupBuildingEvent $event) {
$event->panel->add_block($sb);
}
}
-?>
+
diff --git a/ext/twitter_soc/script.js b/ext/twitter_soc/script.js
index 06457f3a3..62e316d08 100644
--- a/ext/twitter_soc/script.js
+++ b/ext/twitter_soc/script.js
@@ -1,3 +1,5 @@
+/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
+
// jquery.tweet.js - See http://tweet.seaofclouds.com/ or https://github.com/seaofclouds/tweet for more info
// Copyright (c) 2008-2011 Todd Matthews & Steve Purcell
(function($) {
@@ -27,7 +29,7 @@
twitter_search_url: "search.twitter.com", // [string] custom twitter search url, if any (apigee, etc.)
template: "{avatar}{time}{join}{text}", // [string or function] template used to construct each tweet - see code for available vars
comparator: function(tweet1, tweet2) { // [function] comparator used to sort tweets (see Array.sort)
- return tweet2["tweet_time"] - tweet1["tweet_time"];
+ return tweet2.tweet_time - tweet1.tweet_time;
},
filter: function(tweet) { // [function] whether or not to include a particular tweet (be sure to also set 'fetch')
return true;
@@ -46,7 +48,7 @@
result = result.replace(new RegExp('{'+key+'}','g'), val === null ? '' : val);
}
return result;
- } else return template(info);
+ } else { return template(info); }
}
// Export the t function for use when passing a function as the 'template' option
$.extend({tweet: {t: t}});
@@ -69,7 +71,7 @@
linkUser: replacer(/(^|[\W])@(\w+)/gi, "$1@$2"),
// Support various latin1 (\u00**) and arabic (\u06**) alphanumeric chars
linkHash: replacer(/(?:^| )[\#]+([\w\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0600-\u06ff]+)/gi,
- ' #$1'),
+ ' #$1'),
capAwesome: replacer(/\b(awesome)\b/gi, '$1'),
capEpic: replacer(/\b(epic)\b/gi, '$1'),
makeHeart: replacer(/(<)+[3]/gi, "♥")
@@ -81,7 +83,7 @@
var text = match;
for(var i = 0; i < entities.length; ++i) {
var entity = entities[i];
- if (entity.url == url && entity.expanded_url) {
+ if (entity.url === url && entity.expanded_url) {
url = entity.expanded_url;
text = entity.display_url;
break;
@@ -137,14 +139,14 @@
}
function build_api_url() {
- var proto = ('https:' == document.location.protocol ? 'https:' : 'http:');
+ var proto = ('https:' === document.location.protocol ? 'https:' : 'http:');
var count = (s.fetch === null) ? s.count : s.fetch;
var common_params = '&include_entities=1&callback=?';
if (s.list) {
return proto+"//"+s.twitter_api_url+"/1/"+s.username[0]+"/lists/"+s.list+"/statuses.json?page="+s.page+"&per_page="+count+common_params;
} else if (s.favorites) {
return proto+"//"+s.twitter_api_url+"/favorites/"+s.username[0]+".json?page="+s.page+"&count="+count+common_params;
- } else if (s.query === null && s.username.length == 1) {
+ } else if (s.query === null && s.username.length === 1) {
return proto+'//'+s.twitter_api_url+'/1/statuses/user_timeline.json?screen_name='+s.username[0]+'&count='+count+(s.retweets ? '&include_rts=1' : '')+'&page='+s.page+common_params;
} else {
var query = (s.query || 'from:'+s.username.join(' OR from:'));
@@ -172,9 +174,9 @@
o.screen_name = item.from_user || item.user.screen_name;
o.avatar_size = s.avatar_size;
o.avatar_url = extract_avatar_url(item, (document.location.protocol === 'https:'));
- o.retweet = typeof(item.retweeted_status) != 'undefined';
+ o.retweet = typeof(item.retweeted_status) !== 'undefined';
o.tweet_time = parse_date(item.created_at);
- o.join_text = s.join_text == "auto" ? build_auto_join_text(item.text) : s.join_text;
+ o.join_text = s.join_text === "auto" ? build_auto_join_text(item.text) : s.join_text;
o.tweet_id = item.id_str;
o.twitter_base = "http://"+s.twitter_url+"/";
o.user_url = o.twitter_base+o.screen_name;
@@ -213,10 +215,10 @@
}
$(widget).bind("tweet:load", function(){
- if (s.loading_text) $(widget).empty().append(loading);
+ if (s.loading_text) { $(widget).empty().append(loading); }
$.getJSON(build_api_url(), function(data){
$(widget).empty().append(list);
- if (s.intro_text) list.before(intro);
+ if (s.intro_text) { list.before(intro); }
list.empty();
var tweets = $.map(data.results || data, extract_template_data);
@@ -226,7 +228,7 @@
children('li:odd').addClass('tweet_even').end().
children('li:even').addClass('tweet_odd');
- if (s.outro_text) list.after(outro);
+ if (s.outro_text) { list.after(outro); }
$(widget).trigger("loaded").trigger((tweets.length === 0 ? "empty" : "full"));
if (s.refresh_interval) {
window.setTimeout(function() { $(widget).trigger("tweet:load"); }, 1000 * s.refresh_interval);
diff --git a/ext/twitter_soc/test.php b/ext/twitter_soc/test.php
index 438e530b3..cbc700deb 100644
--- a/ext/twitter_soc/test.php
+++ b/ext/twitter_soc/test.php
@@ -26,4 +26,4 @@ function testFeed() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/twitter_soc/theme.php b/ext/twitter_soc/theme.php
index efbf79599..c8685f4bf 100644
--- a/ext/twitter_soc/theme.php
+++ b/ext/twitter_soc/theme.php
@@ -22,4 +22,4 @@ public function display_feed(Page $page, /*string*/ $username) {
', "left", 25));
}
}
-?>
+
diff --git a/ext/update/main.php b/ext/update/main.php
index 6cd29b263..8804e787c 100644
--- a/ext/update/main.php
+++ b/ext/update/main.php
@@ -109,4 +109,4 @@ private function update_shimmie() {
}
}
-?>
+
diff --git a/ext/update/script.js b/ext/update/script.js
index dea04c24c..c2719786d 100644
--- a/ext/update/script.js
+++ b/ext/update/script.js
@@ -1,3 +1,5 @@
+/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
+
$(function() {
if($('#updatecheck').length !== 0){
$.getJSON('https://api.github.com/repos/shish/shimmie2/commits', function(data){
diff --git a/ext/update/theme.php b/ext/update/theme.php
index 4823e0c6d..e3dffb6a3 100644
--- a/ext/update/theme.php
+++ b/ext/update/theme.php
@@ -11,4 +11,4 @@ public function display_admin_block(){
$page->add_block(new Block("Software Update", $html, "main", 75));
}
}
-?>
+
diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php
index d79677540..477452cba 100644
--- a/ext/upgrade/main.php
+++ b/ext/upgrade/main.php
@@ -95,4 +95,4 @@ public function onInitExt(InitExtEvent $event) {
public function get_priority() {return 5;}
}
-?>
+
diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js
index 0c4dda317..26b4766c8 100644
--- a/ext/upload/bookmarklet.js
+++ b/ext/upload/bookmarklet.js
@@ -1,3 +1,5 @@
+/*jshint bitwise:true, curly:true, devel:true, forin:false, noarg:true, undef:true, strict:false, browser:true, jquery:true */
+
/* Imageboard to Shimmie */
// This should work with "most" sites running Danbooru/Gelbooru/Shimmie
// maxsize, supext, CA are set inside the bookmarklet (see theme.php)
@@ -7,10 +9,7 @@ var toobig = "The file you are trying to upload is too big to upload!";
var notsup = "The file you are trying to upload is not supported!";
if(CA === 0 || CA > 2) { // Default
- if(confirm("Keep existing tags?\n(Cancel will prompt for new tags)")) {
- // Do nothing
- }
- else {
+ if (confirm("Keep existing tags?\n(Cancel will prompt for new tags)") === false) {
var tag = prompt("Enter Tags", "");
var chk = 1; // This makes sure it doesn't use current tags.
}
@@ -39,14 +38,14 @@ if(document.getElementById("post_tag_string") !== null) {
var source = "http://" + document.location.hostname + document.location.href.match("\/posts\/[0-9]+");
var rlist = $('[name="post[rating]"]');
- for(x=0;x<3;x++){
- var rating = (rlist[x].checked == true ? rlist[x].value : rating);
+ for( var x=0; x < 3; x++){
+ var rating = (rlist[x].checked === true ? rlist[x].value : rating);
}
var fileinfo = $('#sidebar > section:eq(3) > ul > :contains("Size") > a');
var furl = "http://" + document.location.hostname + fileinfo.attr('href');
var fs = fileinfo.text().split(" ");
- var filesize = (fs[1] == "MB" ? fs[0] * 1024 : fs[0]);
+ var filesize = (fs[1] === "MB" ? fs[0] * 1024 : fs[0]);
if(supext.search(furl.match("[a-zA-Z0-9]+$")[0]) !== -1){
if(filesize <= maxsize){
@@ -84,12 +83,12 @@ else if(document.getElementById('tag-sidebar') !== null) {
}else if(source.search("gelbooru\\.com") >= 0){
var fileinfo = document.getElementById('pfd').parentNode.parentNode.getElementsByTagName('a')[0];
//gelbooru has no easy way to select the original image link, so we need to double check it is the correct link.
- fileinfo = (fileinfo.getAttribute('href') == "#" ? document.getElementById('pfd').parentNode.parentNode.getElementsByTagName('a')[1] : fileinfo);
+ fileinfo = (fileinfo.getAttribute('href') === "#" ? document.getElementById('pfd').parentNode.parentNode.getElementsByTagName('a')[1] : fileinfo);
}
fileinfo = fileinfo || document.getElementsByTagName('embed')[0]; //If fileinfo is null then image is most likely flash.
var furl = fileinfo.href || fileinfo.src;
var fs = (fileinfo.innerText.match(/[0-9]+ (KB|MB)/) || ["0 KB"])[0].split(" ");
- var filesize = (fs[1] == "MB" ? fs[0] * 1024 : fs[0]);
+ var filesize = (fs[1] === "MB" ? fs[0] * 1024 : fs[0]);
if(supext.search(furl.match("[a-zA-Z0-9]+$")[0]) !== -1){
if(filesize <= maxsize){
@@ -116,8 +115,8 @@ else if(document.getElementById('tag-sidebar') !== null) {
* This crazy way of checking "should" work with older releases though
* (Seems to work with 2009~ ver)
*/
-else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.-]+\: ") == 0) {
- if(typeof tag !=="ftp://ftp." && chk !==1) {
+else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.-]+\: ") === 0) {
+ if(typeof tag !== "ftp://ftp." && chk !==1) {
var tag = document.getElementsByTagName("title")[0].innerHTML.match("Image [0-9.-]+\: (.*)")[1];
}
@@ -126,7 +125,7 @@ else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.-
// TODO: Make file size show on all themes
// (Only seems to show in lite/Danbooru themes.)
- if(tag.search(/\bflash\b/) == -1) {
+ if(tag.search(/\bflash\b/) === -1) {
var img = document.getElementById("main_image").src;
if(supext.search(img.match(".*\\.([a-z0-9]+)")[1]) !== -1) {
location.href = ste+img+"&tags="+tag+"&source="+source;
diff --git a/ext/upload/main.php b/ext/upload/main.php
index e0a2c9b81..028c28575 100644
--- a/ext/upload/main.php
+++ b/ext/upload/main.php
@@ -15,9 +15,9 @@ class DataUploadEvent extends Event {
/**
* Some data is being uploaded.
* This should be caught by a file handler.
- * @param $user The user uploading the data.
- * @param $tmpname The temporary file used for upload.
- * @param $metadata Info about the file, should contain at least "filename", "extension", "tags" and "source".
+ * -- Removed: param $user The user uploading the data.
+ * @param $tmpname string The temporary file used for upload.
+ * @param $metadata array Info about the file, should contain at least "filename", "extension", "tags" and "source".
*/
public function __construct(/*string*/ $tmpname, /*array*/ $metadata) {
assert(file_exists($tmpname));
@@ -42,6 +42,9 @@ class UploadException extends SCoreException {}
* This also includes transloaded files as well.
*/
class Upload extends Extension {
+
+ public $is_full;
+
// early, so it can stop the DataUploadEvent before any data handlers see it
public function get_priority() {return 40;}
@@ -59,7 +62,6 @@ public function onInitExt(InitExtEvent $event) {
else {
$this->is_full = $free_num < MIN_FREE_SPACE;
}
-
}
public function onPostListBuilding(PostListBuildingEvent $event) {
@@ -235,8 +237,8 @@ private function tags_for_upload_slot($id) {
*
* TODO: Make these messages user/admin editable
*
- * @param $error_code PHP error code (int)
- * @retval String
+ * @param $error_code integer PHP error code
+ * @return String
*/
private function upload_error_message($error_code) {
switch ($error_code) {
@@ -258,10 +260,14 @@ private function upload_error_message($error_code) {
return 'Unknown upload error';
}
}
-
+
/**
* Handle an upload.
- * @retval bool TRUE on upload successful.
+ * @param $file
+ * @param $tags
+ * @param $source
+ * @param string $replace
+ * @return bool TRUE on upload successful.
*/
private function try_upload($file, $tags, $source, $replace='') {
global $page, $config, $user;
@@ -310,7 +316,11 @@ private function try_upload($file, $tags, $source, $replace='') {
/**
* Handle an transload.
- * @retval bool TRUE on transload successful.
+ * @param $url
+ * @param $tags
+ * @param $source
+ * @param string $replace
+ * @return bool TRUE on transload successful.
*/
private function try_transload($url, $tags, $source, $replace='') {
global $page, $config, $user;
@@ -388,4 +398,4 @@ private function try_transload($url, $tags, $source, $replace='') {
}
// }}}
}
-?>
+
diff --git a/ext/upload/test.php b/ext/upload/test.php
index 7a9c12818..7eb0b08dc 100644
--- a/ext/upload/test.php
+++ b/ext/upload/test.php
@@ -39,4 +39,4 @@ function testUpload() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/upload/theme.php b/ext/upload/theme.php
index 464d8ee97..e1c9692de 100644
--- a/ext/upload/theme.php
+++ b/ext/upload/theme.php
@@ -319,4 +319,4 @@ protected function build_upload_block() {
";
}
}
-?>
+
diff --git a/ext/user/main.php b/ext/user/main.php
index 677550047..130930dd8 100644
--- a/ext/user/main.php
+++ b/ext/user/main.php
@@ -50,6 +50,8 @@ public function __construct($id) {
class UserCreationException extends SCoreException {}
+class NullUserException extends SCoreException {}
+
class UserPage extends Extension {
public function onInitExt(InitExtEvent $event) {
global $config;
@@ -147,11 +149,13 @@ public function onPageRequest(PageRequestEvent $event) {
// Try forwarding to same page on logout unless user comes from registration page
if ($config->get_int("user_loginshowprofile",0) == 0 &&
- isset($_SERVER['HTTP_REFERER']) &&
- strstr($_SERVER['HTTP_REFERER'], "post/"))
- $page->set_redirect ($_SERVER['HTTP_REFERER']);
- else
- $page->set_redirect(make_link());
+ isset($_SERVER['HTTP_REFERER']) &&
+ strstr($_SERVER['HTTP_REFERER'], "post/"))
+ {
+ $page->set_redirect ($_SERVER['HTTP_REFERER']);
+ } else {
+ $page->set_redirect(make_link());
+ }
}
if(!$user->check_auth_token()) {
@@ -161,6 +165,9 @@ public function onPageRequest(PageRequestEvent $event) {
else if($event->get_arg(0) == "change_pass") {
if(isset($_POST['id']) && isset($_POST['pass1']) && isset($_POST['pass2'])) {
$duser = User::by_id($_POST['id']);
+ if ( ! $duser instanceof User) {
+ throw new NullUserException("Error: the user id does not exist!");
+ }
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
$this->change_password_wrapper($duser, $pass1, $pass2);
@@ -169,6 +176,9 @@ public function onPageRequest(PageRequestEvent $event) {
else if($event->get_arg(0) == "change_email") {
if(isset($_POST['id']) && isset($_POST['address'])) {
$duser = User::by_id($_POST['id']);
+ if ( ! $duser instanceof User) {
+ throw new NullUserException("Error: the user id does not exist!");
+ }
$address = $_POST['address'];
$this->change_email_wrapper($duser, $address);
}
@@ -177,6 +187,9 @@ public function onPageRequest(PageRequestEvent $event) {
global $_user_classes;
if(isset($_POST['id']) && isset($_POST['class'])) {
$duser = User::by_id($_POST['id']);
+ if ( ! $duser instanceof User) {
+ throw new NullUserException("Error: the user id does not exist!");
+ }
$class = $_POST['class'];
if(!array_key_exists($class, $_user_classes)) {
throw Exception("Invalid user class: ".html_escape($class));
@@ -349,13 +362,16 @@ private function login(Page $page) {
$this->set_login_cookie($duser->name, $pass);
log_info("user", "{$user->class->name} logged in");
$page->set_mode("redirect");
-
- // Try returning to previous page
- if ($config->get_int("user_loginshowprofile",0) == 0 &&
- isset($_SERVER['HTTP_REFERER']) &&
- strstr($_SERVER['HTTP_REFERER'], "post/"))
- $page->set_redirect($_SERVER['HTTP_REFERER']);
- else $page->set_redirect(make_link("user"));
+
+ // Try returning to previous page
+ if ($config->get_int("user_loginshowprofile",0) == 0 &&
+ isset($_SERVER['HTTP_REFERER']) &&
+ strstr($_SERVER['HTTP_REFERER'], "post/"))
+ {
+ $page->set_redirect($_SERVER['HTTP_REFERER']);
+ } else {
+ $page->set_redirect(make_link("user"));
+ }
}
else {
log_warning("user", "Failed to log in as ".html_escape($name)." [$hash]");
@@ -490,6 +506,9 @@ private function change_class_wrapper(User $duser, /*string(class)*/ $class) {
if($user->class->name == "admin") {
$duser = User::by_id($_POST['id']);
+ if ( ! $duser instanceof User) {
+ throw new NullUserException("Error: the user id does not exist!");
+ }
$duser->set_class($class);
flash_message("Class changed");
@@ -585,4 +604,4 @@ private function delete_user(Page $page, /*boolean*/ $with_images=false, /*boole
}
// }}}
}
-?>
+
diff --git a/ext/user/test.php b/ext/user/test.php
index 8655cd5e6..cd55086b5 100644
--- a/ext/user/test.php
+++ b/ext/user/test.php
@@ -37,4 +37,4 @@ function testUserPage() {
$this->assert_text("demo");
}
}
-?>
+
diff --git a/ext/user/theme.php b/ext/user/theme.php
index 2f0c0363d..7d749de81 100644
--- a/ext/user/theme.php
+++ b/ext/user/theme.php
@@ -235,4 +235,4 @@ protected function build_options(User $duser) {
}
// }}}
}
-?>
+
diff --git a/ext/view/main.php b/ext/view/main.php
index c97e05922..35bb80817 100644
--- a/ext/view/main.php
+++ b/ext/view/main.php
@@ -139,4 +139,4 @@ public function onDisplayingImage(DisplayingImageEvent $event) {
$this->theme->display_page($event->get_image(), $iibbe->parts);
}
}
-?>
+
diff --git a/ext/view/test.php b/ext/view/test.php
index 9338f841e..2398e356d 100644
--- a/ext/view/test.php
+++ b/ext/view/test.php
@@ -42,4 +42,4 @@ function testViewPage() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/view/theme.php b/ext/view/theme.php
index c043ff838..a2775c8bf 100644
--- a/ext/view/theme.php
+++ b/ext/view/theme.php
@@ -90,4 +90,4 @@ protected function build_info(Image $image, $editor_parts) {
return $html;
}
}
-?>
+
diff --git a/ext/wiki/main.php b/ext/wiki/main.php
index 94f9fb0fa..d14575844 100644
--- a/ext/wiki/main.php
+++ b/ext/wiki/main.php
@@ -483,4 +483,4 @@ private function formatline( $nr1, $nr2, $stat, &$value ) { #change to $value if
}
// }}}
}
-?>
+
diff --git a/ext/wiki/test.php b/ext/wiki/test.php
index 7694a496c..3cbbd44c1 100644
--- a/ext/wiki/test.php
+++ b/ext/wiki/test.php
@@ -111,4 +111,4 @@ function testRevisions() {
$this->log_out();
}
}
-?>
+
diff --git a/ext/wiki/theme.php b/ext/wiki/theme.php
index 54e7338dc..99b94a413 100644
--- a/ext/wiki/theme.php
+++ b/ext/wiki/theme.php
@@ -106,4 +106,4 @@ protected function create_display_html(WikiPage $page) {
";
}
}
-?>
+
diff --git a/ext/word_filter/main.php b/ext/word_filter/main.php
index f85cc3de1..0ce8d5ea1 100644
--- a/ext/word_filter/main.php
+++ b/ext/word_filter/main.php
@@ -48,4 +48,4 @@ private function get_map() {
return $map;
}
}
-?>
+
diff --git a/ext/word_filter/test.php b/ext/word_filter/test.php
index 5fbe0f191..6b3df0b27 100644
--- a/ext/word_filter/test.php
+++ b/ext/word_filter/test.php
@@ -53,4 +53,4 @@ function testWordFilter() {
$this->log_out();
}
}
-?>
+
diff --git a/index.php b/index.php
index 28d6811a4..1599e2c49 100644
--- a/index.php
+++ b/index.php
@@ -100,4 +100,4 @@
_fatal_error($e);
ctx_log_ender();
}
-?>
+
diff --git a/lib/shimmie.js b/lib/shimmie.js
index 2a1f09eda..794192372 100644
--- a/lib/shimmie.js
+++ b/lib/shimmie.js
@@ -1,3 +1,4 @@
+/*jshint bitwise:false, curly:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:false, strict:false, browser:true */
// Adding jQuery ui stuff
$(document).ready(function() {
@@ -49,7 +50,7 @@ $(document).ready(function() {
if(sidebar_hidden.hasOwnProperty(i) && sidebar_hidden[i].length > 0) {
$(sidebar_hidden[i]+" .blockbody").hide();
}
- };
+ }
}
catch(err) {
var sidebar_hidden = [];
@@ -59,7 +60,7 @@ $(document).ready(function() {
var tob = $(tid+" .blockbody");
$(elm).click(function(e) {
tob.slideToggle("slow");
- if(sidebar_hidden.indexOf(tid) == -1) {
+ if(sidebar_hidden.indexOf(tid) === -1) {
sidebar_hidden.push(tid);
}
else {
@@ -70,7 +71,7 @@ $(document).ready(function() {
}
}
$.cookie("ui-sidebar-hidden", sidebar_hidden.join("|"), {path: '/', expires: 365});
- })
+ });
});
$(".shm-unlocker").each(function(idx, elm) {
@@ -140,12 +141,12 @@ function getHTTPObject() {
function getCookie( name ) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
- if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
+ if ( ( !start ) && ( name !== document.cookie.substring( 0, name.length ) ) ) {
return null;
}
- if ( start == -1 ) return null;
+ if ( start === -1 ) { return null; }
var end = document.cookie.indexOf( ";", len );
- if ( end == -1 ) end = document.cookie.length;
+ if ( end === -1 ) { end = document.cookie.length; }
return unescape( document.cookie.substring( len, end ) );
}
@@ -164,10 +165,11 @@ function setCookie( name, value, expires, path, domain, secure ) {
}
function deleteCookie( name, path, domain ) {
- if ( getCookie( name ) ) document.cookie = name + "=" +
+ if ( getCookie( name ) ) { document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
+ }
}
function replyTo(imageId, commentId, userId) {
diff --git a/tests/test_install.php b/tests/test_install.php
index 80a4d20dc..2c2cbacea 100644
--- a/tests/test_install.php
+++ b/tests/test_install.php
@@ -21,7 +21,7 @@
$host = rtrim(trim(trim($options["h"], '"')), "/");
// Check if they are empty.
-if (empty($db)){ die("Error: need to specifiy a database for the test environment."); }
+if (empty($db)){ die("Error: need to specify a database for the test environment."); }
if (empty($host)){ $host = "http://127.0.0.1"; }
define("_TRAVIS_DATABASE", $db);
diff --git a/themes/danbooru/comment.theme.php b/themes/danbooru/comment.theme.php
index f9fcdfca4..826c87d48 100644
--- a/themes/danbooru/comment.theme.php
+++ b/themes/danbooru/comment.theme.php
@@ -49,7 +49,7 @@ public function display_comment_list($images, $page_number, $total_pages, $can_p
$comment_count = count($comments);
if($comment_limit > 0 && $comment_count > $comment_limit) {
- $hidden = $comment_count - $comment_limit;
+ //$hidden = $comment_count - $comment_limit;
$comment_html .= "showing $comment_limit of $comment_count comments
";
$comments = array_slice($comments, -$comment_limit);
}
@@ -93,9 +93,9 @@ protected function comment_to_html($comment, $trim=false) {
$tfe = new TextFormattingEvent($comment->comment);
send_event($tfe);
- $i_uid = int_escape($comment->owner_id);
+ //$i_uid = int_escape($comment->owner_id);
$h_name = html_escape($comment->owner_name);
- $h_poster_ip = html_escape($comment->poster_ip);
+ //$h_poster_ip = html_escape($comment->poster_ip);
$h_comment = ($trim ? substr($tfe->stripped, 0, 50)."..." : $tfe->formatted);
$i_comment_id = int_escape($comment->comment_id);
$i_image_id = int_escape($comment->image_id);
@@ -107,7 +107,7 @@ protected function comment_to_html($comment, $trim=false) {
$h_del = $user->can("delete_comment") ?
' - Del' : '';
- $h_imagelink = $trim ? ">>>\n" : "";
+ //$h_imagelink = $trim ? ">>>\n" : "";
if($trim) {
return "";
}
@@ -121,4 +121,4 @@ protected function comment_to_html($comment, $trim=false) {
}
}
}
-?>
+
diff --git a/themes/danbooru/custompage.class.php b/themes/danbooru/custompage.class.php
index 1e71720b0..16d676cff 100644
--- a/themes/danbooru/custompage.class.php
+++ b/themes/danbooru/custompage.class.php
@@ -6,4 +6,4 @@ public function disable_left() {
$this->left_enabled = false;
}
}
-?>
+
diff --git a/themes/danbooru/index.theme.php b/themes/danbooru/index.theme.php
index b27aa0282..47bd2d9a2 100644
--- a/themes/danbooru/index.theme.php
+++ b/themes/danbooru/index.theme.php
@@ -58,4 +58,4 @@ protected function build_table($images, $query) {
return $table;
}
}
-?>
+
diff --git a/themes/danbooru/layout.class.php b/themes/danbooru/layout.class.php
index 27af88106..ca0f3fe05 100644
--- a/themes/danbooru/layout.class.php
+++ b/themes/danbooru/layout.class.php
@@ -265,4 +265,4 @@ private function navlinks($link, $desc, $pages_matched) {
return $html;
}
}
-?>
+
diff --git a/themes/danbooru/tag_list.theme.php b/themes/danbooru/tag_list.theme.php
index 3c1683802..6628ca298 100644
--- a/themes/danbooru/tag_list.theme.php
+++ b/themes/danbooru/tag_list.theme.php
@@ -6,4 +6,4 @@ public function display_page(Page $page) {
parent::display_page($page);
}
}
-?>
+
diff --git a/themes/danbooru/themelet.class.php b/themes/danbooru/themelet.class.php
index b69c52882..9eb986c76 100644
--- a/themes/danbooru/themelet.class.php
+++ b/themes/danbooru/themelet.class.php
@@ -48,4 +48,4 @@ private function build_paginator($current_page, $total_pages, $base_url, $query)
return "$prev_html $first_html $pdots $pages_html $ndots $last_html $next_html
";
}
}
-?>
+
diff --git a/themes/danbooru/upload.theme.php b/themes/danbooru/upload.theme.php
index 7e5f75bf4..a7047cf3b 100644
--- a/themes/danbooru/upload.theme.php
+++ b/themes/danbooru/upload.theme.php
@@ -11,4 +11,4 @@ public function display_page(Page $page) {
parent::display_page($page);
}
}
-?>
+
diff --git a/themes/danbooru/user.theme.php b/themes/danbooru/user.theme.php
index fba58e8d0..9990879e7 100644
--- a/themes/danbooru/user.theme.php
+++ b/themes/danbooru/user.theme.php
@@ -98,4 +98,4 @@ public function display_user_page(User $duser, $stats) {
parent::display_user_page($duser, $stats);
}
}
-?>
+
diff --git a/themes/danbooru/view.theme.php b/themes/danbooru/view.theme.php
index 19aa4fcf2..427d4f487 100644
--- a/themes/danbooru/view.theme.php
+++ b/themes/danbooru/view.theme.php
@@ -51,4 +51,4 @@ private function build_stats(Image $image) {
return $html;
}
}
-?>
+
diff --git a/themes/danbooru2/admin.theme.php b/themes/danbooru2/admin.theme.php
index b08d12c3a..2007705d3 100644
--- a/themes/danbooru2/admin.theme.php
+++ b/themes/danbooru2/admin.theme.php
@@ -8,4 +8,4 @@ public function display_page() {
}
}
-?>
+
diff --git a/themes/danbooru2/comment.theme.php b/themes/danbooru2/comment.theme.php
index f9fcdfca4..826c87d48 100644
--- a/themes/danbooru2/comment.theme.php
+++ b/themes/danbooru2/comment.theme.php
@@ -49,7 +49,7 @@ public function display_comment_list($images, $page_number, $total_pages, $can_p
$comment_count = count($comments);
if($comment_limit > 0 && $comment_count > $comment_limit) {
- $hidden = $comment_count - $comment_limit;
+ //$hidden = $comment_count - $comment_limit;
$comment_html .= "showing $comment_limit of $comment_count comments
";
$comments = array_slice($comments, -$comment_limit);
}
@@ -93,9 +93,9 @@ protected function comment_to_html($comment, $trim=false) {
$tfe = new TextFormattingEvent($comment->comment);
send_event($tfe);
- $i_uid = int_escape($comment->owner_id);
+ //$i_uid = int_escape($comment->owner_id);
$h_name = html_escape($comment->owner_name);
- $h_poster_ip = html_escape($comment->poster_ip);
+ //$h_poster_ip = html_escape($comment->poster_ip);
$h_comment = ($trim ? substr($tfe->stripped, 0, 50)."..." : $tfe->formatted);
$i_comment_id = int_escape($comment->comment_id);
$i_image_id = int_escape($comment->image_id);
@@ -107,7 +107,7 @@ protected function comment_to_html($comment, $trim=false) {
$h_del = $user->can("delete_comment") ?
' - Del' : '';
- $h_imagelink = $trim ? ">>>\n" : "";
+ //$h_imagelink = $trim ? ">>>\n" : "";
if($trim) {
return "";
}
@@ -121,4 +121,4 @@ protected function comment_to_html($comment, $trim=false) {
}
}
}
-?>
+
diff --git a/themes/danbooru2/custompage.class.php b/themes/danbooru2/custompage.class.php
index 1e71720b0..16d676cff 100644
--- a/themes/danbooru2/custompage.class.php
+++ b/themes/danbooru2/custompage.class.php
@@ -6,4 +6,4 @@ public function disable_left() {
$this->left_enabled = false;
}
}
-?>
+
diff --git a/themes/danbooru2/ext_manager.theme.php b/themes/danbooru2/ext_manager.theme.php
index 67449dcf4..1c42e2e85 100644
--- a/themes/danbooru2/ext_manager.theme.php
+++ b/themes/danbooru2/ext_manager.theme.php
@@ -11,4 +11,4 @@ public function display_doc(Page $page, ExtensionInfo $info) {
}
}
-?>
+
diff --git a/themes/danbooru2/index.theme.php b/themes/danbooru2/index.theme.php
index 4d0ca68f4..090cd2483 100644
--- a/themes/danbooru2/index.theme.php
+++ b/themes/danbooru2/index.theme.php
@@ -58,4 +58,4 @@ protected function build_table($images, $query) {
return $table;
}
}
-?>
+
diff --git a/themes/danbooru2/layout.class.php b/themes/danbooru2/layout.class.php
index d7e108b20..e937ed8b9 100644
--- a/themes/danbooru2/layout.class.php
+++ b/themes/danbooru2/layout.class.php
@@ -291,4 +291,4 @@ private function navlinks($link, $desc, $pages_matched) {
return $html;
}
}
-?>
+
diff --git a/themes/danbooru2/tag_list.theme.php b/themes/danbooru2/tag_list.theme.php
index 3c1683802..6628ca298 100644
--- a/themes/danbooru2/tag_list.theme.php
+++ b/themes/danbooru2/tag_list.theme.php
@@ -6,4 +6,4 @@ public function display_page(Page $page) {
parent::display_page($page);
}
}
-?>
+
diff --git a/themes/danbooru2/themelet.class.php b/themes/danbooru2/themelet.class.php
index b69c52882..9eb986c76 100644
--- a/themes/danbooru2/themelet.class.php
+++ b/themes/danbooru2/themelet.class.php
@@ -48,4 +48,4 @@ private function build_paginator($current_page, $total_pages, $base_url, $query)
return "$prev_html $first_html $pdots $pages_html $ndots $last_html $next_html
";
}
}
-?>
+
diff --git a/themes/danbooru2/upload.theme.php b/themes/danbooru2/upload.theme.php
index 7e5f75bf4..a7047cf3b 100644
--- a/themes/danbooru2/upload.theme.php
+++ b/themes/danbooru2/upload.theme.php
@@ -11,4 +11,4 @@ public function display_page(Page $page) {
parent::display_page($page);
}
}
-?>
+
diff --git a/themes/danbooru2/user.theme.php b/themes/danbooru2/user.theme.php
index fba58e8d0..9990879e7 100644
--- a/themes/danbooru2/user.theme.php
+++ b/themes/danbooru2/user.theme.php
@@ -98,4 +98,4 @@ public function display_user_page(User $duser, $stats) {
parent::display_user_page($duser, $stats);
}
}
-?>
+
diff --git a/themes/danbooru2/view.theme.php b/themes/danbooru2/view.theme.php
index 11956fc98..bd6e5f454 100644
--- a/themes/danbooru2/view.theme.php
+++ b/themes/danbooru2/view.theme.php
@@ -64,4 +64,4 @@ protected function build_navigation(Image $image) {
return "$h_search";
}
}
-?>
+
diff --git a/themes/default/layout.class.php b/themes/default/layout.class.php
index 078e143ff..87b86d31e 100644
--- a/themes/default/layout.class.php
+++ b/themes/default/layout.class.php
@@ -94,4 +94,4 @@ public function display_page(Page $page) {
EOD;
}
}
-?>
+
diff --git a/themes/default/themelet.class.php b/themes/default/themelet.class.php
index d13596ce7..77c927c32 100644
--- a/themes/default/themelet.class.php
+++ b/themes/default/themelet.class.php
@@ -1,3 +1,3 @@
+
diff --git a/themes/futaba/comment.theme.php b/themes/futaba/comment.theme.php
index f65b0b146..2b4c35181 100644
--- a/themes/futaba/comment.theme.php
+++ b/themes/futaba/comment.theme.php
@@ -1,13 +1,13 @@
get_string('title');
$page->set_title($page_title);
@@ -51,7 +51,7 @@ public function display_recent_comments($comments) {
// sidebar fails in this theme
}
- private function build_upload_box() {
+ public function build_upload_box() {
return "[[ insert upload-and-comment extension here ]]";
}
@@ -63,9 +63,9 @@ protected function comment_to_html($comment, $trim=false) {
$tfe = new TextFormattingEvent($comment->comment);
send_event($tfe);
- $i_uid = int_escape($comment->owner_id);
+ //$i_uid = int_escape($comment->owner_id);
$h_name = html_escape($comment->owner_name);
- $h_poster_ip = html_escape($comment->poster_ip);
+ //$h_poster_ip = html_escape($comment->poster_ip);
$h_comment = ($trim ? substr($tfe->stripped, 0, 50)."..." : $tfe->formatted);
$i_comment_id = int_escape($comment->comment_id);
$i_image_id = int_escape($comment->image_id);
@@ -89,4 +89,4 @@ protected function comment_to_html($comment, $trim=false) {
}
}
}
-?>
+
diff --git a/themes/futaba/custompage.class.php b/themes/futaba/custompage.class.php
index 1e71720b0..16d676cff 100644
--- a/themes/futaba/custompage.class.php
+++ b/themes/futaba/custompage.class.php
@@ -6,4 +6,4 @@ public function disable_left() {
$this->left_enabled = false;
}
}
-?>
+
diff --git a/themes/futaba/layout.class.php b/themes/futaba/layout.class.php
index b42c9ad24..a2f1c370d 100644
--- a/themes/futaba/layout.class.php
+++ b/themes/futaba/layout.class.php
@@ -102,4 +102,4 @@ function display_page(Page $page) {
EOD;
}
}
-?>
+
diff --git a/themes/futaba/themelet.class.php b/themes/futaba/themelet.class.php
index 5770b05b1..3f38fdfc8 100644
--- a/themes/futaba/themelet.class.php
+++ b/themes/futaba/themelet.class.php
@@ -1,53 +1,87 @@
build_paginator($page_number, $total_pages, $base, $query);
+ $body = $this->futaba_build_paginator($page_number, $total_pages, $base, $query);
$page->add_block(new Block(null, $body, "main", $position));
}
- private function gen_page_link($base_url, $query, $page, $name) {
+ /**
+ * Generate a single HTML link.
+ *
+ * @param string $base_url
+ * @param string $query
+ * @param int|string $page
+ * @param string $name
+ * @return string
+ */
+ public function futaba_gen_page_link($base_url, $query, $page, $name) {
$link = make_link("$base_url/$page", $query);
- return "[$name]";
+ return "[{$name}]";
}
-
- private function gen_page_link_block($base_url, $query, $page, $current_page, $name) {
+
+ /**
+ * @param string $base_url
+ * @param string $query
+ * @param int|string $page
+ * @param int|string $current_page
+ * @param string $name
+ * @return string
+ */
+ public function futaba_gen_page_link_block($base_url, $query, $page, $current_page, $name) {
$paginator = "";
if($page == $current_page) $paginator .= "";
- $paginator .= $this->gen_page_link($base_url, $query, $page, $name);
+ $paginator .= $this->futaba_gen_page_link($base_url, $query, $page, $name);
if($page == $current_page) $paginator .= "";
return $paginator;
}
-
- private function build_paginator($current_page, $total_pages, $base_url, $query) {
+
+ /**
+ * Build the paginator.
+ *
+ * @param int $current_page
+ * @param int $total_pages
+ * @param string $base_url
+ * @param string $query
+ * @return string
+ */
+ public function futaba_build_paginator($current_page, $total_pages, $base_url, $query) {
$next = $current_page + 1;
$prev = $current_page - 1;
- $rand = mt_rand(1, $total_pages);
+ //$rand = mt_rand(1, $total_pages);
$at_start = ($current_page <= 1 || $total_pages <= 1);
$at_end = ($current_page >= $total_pages);
- $first_html = $at_start ? "First" : $this->gen_page_link($base_url, $query, 1, "First");
- $prev_html = $at_start ? "Prev" : $this->gen_page_link($base_url, $query, $prev, "Prev");
- $random_html = $this->gen_page_link($base_url, $query, $rand, "Random");
- $next_html = $at_end ? "Next" : $this->gen_page_link($base_url, $query, $next, "Next");
- $last_html = $at_end ? "Last" : $this->gen_page_link($base_url, $query, $total_pages, "Last");
+ //$first_html = $at_start ? "First" : $this->futaba_gen_page_link($base_url, $query, 1, "First");
+ $prev_html = $at_start ? "Prev" : $this->futaba_gen_page_link($base_url, $query, $prev, "Prev");
+ //$random_html = $this->futaba_gen_page_link($base_url, $query, $rand, "Random");
+ $next_html = $at_end ? "Next" : $this->futaba_gen_page_link($base_url, $query, $next, "Next");
+ //$last_html = $at_end ? "Last" : $this->futaba_gen_page_link($base_url, $query, $total_pages, "Last");
$start = $current_page-5 > 1 ? $current_page-5 : 1;
$end = $start+10 < $total_pages ? $start+10 : $total_pages;
$pages = array();
foreach(range($start, $end) as $i) {
- $pages[] = $this->gen_page_link_block($base_url, $query, $i, $current_page, $i);
+ $pages[] = $this->futaba_gen_page_link_block($base_url, $query, $i, $current_page, $i);
}
$pages_html = implode(" ", $pages);
//return "$first_html | $prev_html | $random_html | $next_html | $last_html".
// "
<< $pages_html >>
";
- return "$prev_html $pages_html $next_html
";
+ return "{$prev_html} {$pages_html} {$next_html}
";
}
}
-?>
+
diff --git a/themes/futaba/view.theme.php b/themes/futaba/view.theme.php
index c8c3519b6..54b66e88a 100644
--- a/themes/futaba/view.theme.php
+++ b/themes/futaba/view.theme.php
@@ -8,4 +8,4 @@ public function display_page(Image $image, $editor_parts) {
$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 10));
}
}
-?>
+
diff --git a/themes/lite/comment.theme.php b/themes/lite/comment.theme.php
index 97676e24e..9c4638ea3 100644
--- a/themes/lite/comment.theme.php
+++ b/themes/lite/comment.theme.php
@@ -9,4 +9,3 @@ protected function build_postbox($image_id) {
return $this->rr(parent::build_postbox($image_id));
}
}
-?>
diff --git a/themes/lite/custompage.class.php b/themes/lite/custompage.class.php
index 1e71720b0..16d676cff 100644
--- a/themes/lite/custompage.class.php
+++ b/themes/lite/custompage.class.php
@@ -6,4 +6,4 @@ public function disable_left() {
$this->left_enabled = false;
}
}
-?>
+
diff --git a/themes/lite/layout.class.php b/themes/lite/layout.class.php
index 3cf8e9d94..29c0bb3d5 100644
--- a/themes/lite/layout.class.php
+++ b/themes/lite/layout.class.php
@@ -8,6 +8,7 @@
* some other sites, packaged in a light blue color.
*/
class Layout {
+
/**
* turns the Page into HTML
*/
@@ -20,13 +21,14 @@ public function display_page(Page $page) {
$contact_link = $config->get_string('contact_link');
$header_html = "";
+ ksort($page->html_headers);
foreach($page->html_headers as $line) {
- $header_html .= "\t\t$line\n";
+ $header_html .= "\t\t{$line}\n";
}
$menu = "";
+ $menu .= "{$custom_links}";
$left_block_html = "";
$main_block_html = "";
@@ -76,11 +78,11 @@ public function display_page(Page $page) {
$custom_sublinks = "";
// hack
- global $user;
$username = url_escape($user->name);
// hack
$qp = explode("/", ltrim(@$_GET["q"], "/"));
- $hw = class_exists("Wiki");
+ $cs = "";
+
// php sucks
switch($qp[0]) {
default:
@@ -93,12 +95,14 @@ public function display_page(Page $page) {
# the subnav links aren't shown, but it would
# be nice to be correct
case "post":
- if(class_exists("NumericScore")){ $cs .= "
Popular by Day/Month/Year ";}
+ if(class_exists("NumericScore")){
+ $cs .= "
Popular by Day/Month/Year ";
+ }
$cs .= "
All";
- if(class_exists("Favorites")){ $cs .= "
My Favorites";}
+ if(class_exists("Favorites")){ $cs .= "
My Favorites";}
if(class_exists("RSS_Images")){ $cs .= "
Feed";}
if(class_exists("Random_Image")){ $cs .= "
Random Image";}
- if($hw){ $cs .= "
Help";
+ if(class_exists("Wiki")){ $cs .= "
Help";
}else{ $cs .= "
Help";}
break;
case "comment":
@@ -127,7 +131,7 @@ public function display_page(Page $page) {
$cs .= "
Help";
break;
case "upload":
- if($hw) $cs .= "
Guidelines";
+ if(class_exists("Wiki")) { $cs .= "
Guidelines"; }
break;
case "random":
$cs .= "
Shuffle";
@@ -137,25 +141,28 @@ public function display_page(Page $page) {
$cs .= "
Download";
break;
}
- if($cs == "") {$custom_sublinks = "";} else {
- $custom_sublinks .= "$cs
";}
+ if($cs == "") {
+ $custom_sublinks = "";
+ } else {
+ $custom_sublinks .= "$cs";
+ }
$debug = get_debug_info();
- $contact = empty($contact_link) ? "" : "
Contact";
- $subheading = empty($page->subheading) ? "" : "{$page->subheading}
";
+ $contact = empty($contact_link) ? "" : "
Contact";
+ //$subheading = empty($page->subheading) ? "" : "{$page->subheading}
";
- $wrapper = "";
+ /*$wrapper = "";
if(strlen($page->heading) > 100) {
$wrapper = ' style="height: 3em; overflow: auto;"';
- }
- if($page->left_enabled==false) {
+ }*/
+ if($page->left_enabled == false) {
$left_block_html = "";
- $main_block_html = "$main_block_html";
+ $main_block_html = "{$main_block_html}";
} else {
- $left_block_html = "";
- $main_block_html = "$main_block_html";
+ $left_block_html = "";
+ $main_block_html = "{$main_block_html}";
}
$flash = get_prefixed_cookie("flash_message");
@@ -199,62 +206,63 @@ public function display_page(Page $page) {