diff --git a/core/basethemelet.class.php b/core/basethemelet.class.php
index 1f63525c..19b17e6c 100644
--- a/core/basethemelet.class.php
+++ b/core/basethemelet.class.php
@@ -83,6 +83,7 @@ class BaseThemelet {
* @param string $query
* @param int $page_number
* @param int $total_pages
+ * @param bool $show_random
*/
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages, $show_random = FALSE) {
if($total_pages == 0) $total_pages = 1;
@@ -127,6 +128,7 @@ class BaseThemelet {
* @param int $total_pages
* @param string $base_url
* @param string $query
+ * @param bool $show_random
* @return string
*/
private function build_paginator($current_page, $total_pages, $base_url, $query, $show_random) {
diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php
index 3bee9ef3..9c4bf2ac 100644
--- a/core/imageboard.pack.php
+++ b/core/imageboard.pack.php
@@ -561,6 +561,7 @@ class Image {
* Set the tags for this image.
*
* @param string[] $tags
+ * @throws Exception
*/
public function set_tags($tags) {
assert('is_array($tags) && count($tags) > 0', var_export($tags, true));
@@ -918,6 +919,8 @@ class Image {
/**
* this function exists because mysql is a turd, see the docs for
* build_accurate_search_querylet() for a full explanation
+ *
+ * @param array $terms
*/
private static function build_ugly_search_querylet($terms) {
global $database;
diff --git a/core/sys_config.inc.php b/core/sys_config.inc.php
index dae1e161..46e43028 100644
--- a/core/sys_config.inc.php
+++ b/core/sys_config.inc.php
@@ -18,6 +18,8 @@
* define("SPEED_HAX", true);
*
*/
+
+/** @private */
function _d($name, $value) {if(!defined($name)) define($name, $value);}
_d("DATABASE_DSN", null); // string PDO database connection details
_d("DATABASE_KA", true); // string Keep database connection alive
diff --git a/core/user.class.php b/core/user.class.php
index fdaf03d0..53145633 100644
--- a/core/user.class.php
+++ b/core/user.class.php
@@ -204,6 +204,7 @@ class User {
/**
* @param string $name
+ * @throws Exception
*/
public function set_name(/*string*/ $name) {
global $database;
diff --git a/core/userclass.class.php b/core/userclass.class.php
index 7f02f570..5780b3fe 100644
--- a/core/userclass.class.php
+++ b/core/userclass.class.php
@@ -51,8 +51,6 @@ class UserClass {
* @throws SCoreException
*/
public function can(/*string*/ $ability) {
- global $config;
-
if(array_key_exists($ability, $this->abilities)) {
$val = $this->abilities[$ability];
return $val;
diff --git a/core/util.inc.php b/core/util.inc.php
index f30b6ff8..e1624c25 100644
--- a/core/util.inc.php
+++ b/core/util.inc.php
@@ -629,7 +629,6 @@ function is_https_enabled() {
* 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
@@ -1180,6 +1179,8 @@ function ip_in_range($IP, $CIDR) {
*
* from a patch by Christian Walde; only intended for use in the
* "extension manager" extension, but it seems to fit better here
+ *
+ * @param string $f
*/
function deltree($f) {
//Because Windows (I know, bad excuse)
@@ -1223,6 +1224,9 @@ function deltree($f) {
* Copy an entire file hierarchy
*
* from a comment on http://uk.php.net/copy
+ *
+ * @param string $source
+ * @param string $target
*/
function full_copy($source, $target) {
if(is_dir($source)) {
diff --git a/ext/admin/main.php b/ext/admin/main.php
index 9fe0efe8..446a984c 100644
--- a/ext/admin/main.php
+++ b/ext/admin/main.php
@@ -119,7 +119,7 @@ class AdminPage extends Extension {
}
private function delete_by_query() {
- global $page, $user;
+ global $page;
$query = $_POST['query'];
$reason = @$_POST['reason'];
assert(strlen($query) > 1);
diff --git a/ext/admin/theme.php b/ext/admin/theme.php
index 42ec6126..64ee1a92 100644
--- a/ext/admin/theme.php
+++ b/ext/admin/theme.php
@@ -20,7 +20,7 @@ class AdminPageTheme extends Themelet {
*/
protected function button(/*string*/ $name, /*string*/ $action, /*boolean*/ $protected=false) {
$c_protected = $protected ? " protected" : "";
- $html = make_form(make_link("admin/$action"), "POST", false, null, null, "admin$c_protected");
+ $html = make_form(make_link("admin/$action"), "POST", false, "admin$c_protected");
if($protected) {
$html .= "";
$html .= "";
diff --git a/ext/amazon_s3/main.php b/ext/amazon_s3/main.php
index 7b39e5a2..dc097465 100644
--- a/ext/amazon_s3/main.php
+++ b/ext/amazon_s3/main.php
@@ -67,8 +67,8 @@ class UploadS3 extends Extension {
if(!empty($bucket)) {
log_debug("amazon_s3", "Deleting Image #".$event->image->id." from S3");
$s3 = new S3($access, $secret);
- $s3->deleteObject($bucket, "images/"+$event->image->hash);
- $s3->deleteObject($bucket, "thumbs/"+$event->image->hash);
+ $s3->deleteObject($bucket, "images/" . $event->image->hash);
+ $s3->deleteObject($bucket, "thumbs/" . $event->image->hash);
}
}
}
diff --git a/ext/artists/main.php b/ext/artists/main.php
index 7bb6238b..c5e70b30 100644
--- a/ext/artists/main.php
+++ b/ext/artists/main.php
@@ -673,7 +673,7 @@ class Artists extends Extension {
$this->save_existing_member($membersIDsAsArray[$i], $membersAsArray[$i], $userID);
else
// if we already updated all, save new ones
- $this->save_new_member($artistID, $membersAsArray[$i], "", $userID);
+ $this->save_new_member($artistID, $membersAsArray[$i], $userID);
$i++;
}
@@ -839,7 +839,7 @@ class Artists extends Extension {
$membersArray = explode(" ", $members);
foreach ($membersArray as $member)
if (!$this->member_exists($artistID, $member))
- $this->save_new_member($artistID, $member, "", $userID);
+ $this->save_new_member($artistID, $member, $userID);
}
if (strlen($urls))
@@ -1132,7 +1132,6 @@ class Artists extends Extension {
return;
$aliasArray = explode(" ", $aliases);
- global $database;
foreach ($aliasArray as $alias)
if (!$this->alias_exists($artistID, $alias))
$this->save_new_alias($artistID, $alias, $userID);
diff --git a/ext/blocks/theme.php b/ext/blocks/theme.php
index 00cfd170..8a490977 100644
--- a/ext/blocks/theme.php
+++ b/ext/blocks/theme.php
@@ -1,7 +1,7 @@
";
foreach($blocks as $block) {
diff --git a/ext/blotter/main.php b/ext/blotter/main.php
index a0bd21b5..645154ec 100644
--- a/ext/blotter/main.php
+++ b/ext/blotter/main.php
@@ -44,7 +44,6 @@ class Blotter extends Extension {
}
public function onSetupBuilding(SetupBuildingEvent $event) {
- global $config;
$sb = new SetupBlock("Blotter");
$sb->add_int_option("blotter_recent", "
Number of recent entries to display: ");
$sb->add_text_option("blotter_color", "
Color of important updates: (ABCDEF format) ");
diff --git a/ext/bulk_add_csv/theme.php b/ext/bulk_add_csv/theme.php
index 01c2e21f..72b8d674 100644
--- a/ext/bulk_add_csv/theme.php
+++ b/ext/bulk_add_csv/theme.php
@@ -21,7 +21,7 @@ class BulkAddCSVTheme extends Themelet {
* csv file
*/
public function display_admin_block() {
- global $page, $user;
+ global $page;
$html = "
Add images from a csv. Images will be tagged and have their
source and rating set (if \"Image Ratings\" is enabled)
diff --git a/ext/comment/main.php b/ext/comment/main.php
index a8fd4f8d..9432468f 100644
--- a/ext/comment/main.php
+++ b/ext/comment/main.php
@@ -286,8 +286,6 @@ class CommentList extends Extension {
}
public function onSearchTermParse(SearchTermParseEvent $event) {
- global $database;
-
$matches = array();
if(preg_match("/^comments([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)$/i", $event->term, $matches)) {
@@ -447,7 +445,7 @@ class CommentList extends Extension {
// add / remove / edit comments {{{
private function is_comment_limit_hit() {
- global $user, $config, $database;
+ global $config, $database;
// sqlite fails at intervals
if($database->get_driver_name() === "sqlite") return false;
@@ -562,7 +560,7 @@ class CommentList extends Extension {
* @throws CommentPostingException
*/
private function add_comment_wrapper(/*int*/ $image_id, User $user, /*string*/ $comment) {
- global $database, $config, $page;
+ global $database, $page;
if(!$user->can("bypass_comment_checks")) {
// will raise an exception if anything is wrong
diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php
index a8517ce2..39069963 100644
--- a/ext/cron_uploader/main.php
+++ b/ext/cron_uploader/main.php
@@ -61,7 +61,7 @@ class CronUploader extends Extension {
}
private function display_documentation() {
- global $config, $page;
+ global $page;
$this->set_dir(); // Determines path to cron_uploader_dir
@@ -151,7 +151,6 @@ class CronUploader extends Extension {
}
public function onSetupBuilding(SetupBuildingEvent $event) {
- global $config;
$this->set_dir();
$cron_url = make_http(make_link("/cron_upload/" . $this->upload_key));
@@ -344,7 +343,7 @@ class CronUploader extends Extension {
foreach ( glob ( "$base/$subdir/*" ) as $fullpath ) {
$fullpath = str_replace ( "//", "/", $fullpath );
- $shortpath = str_replace ( $base, "", $fullpath );
+ //$shortpath = str_replace ( $base, "", $fullpath );
if (is_link ( $fullpath )) {
// ignore
diff --git a/ext/custom_html_headers/main.php b/ext/custom_html_headers/main.php
index f3ed3b6b..df04b436 100644
--- a/ext/custom_html_headers/main.php
+++ b/ext/custom_html_headers/main.php
@@ -15,10 +15,8 @@
* You can also add your website name as prefix or suffix to the title of each page on your website.
*/
class custom_html_headers extends Extension {
-# Adds setup block for custom
content
+ # Adds setup block for custom content
public function onSetupBuilding(SetupBuildingEvent $event) {
- global $config;
-
$sb = new SetupBlock("Custom HTML Headers");
// custom headers
diff --git a/ext/danbooru_api/main.php b/ext/danbooru_api/main.php
index 557dda2e..50f3799f 100644
--- a/ext/danbooru_api/main.php
+++ b/ext/danbooru_api/main.php
@@ -411,7 +411,6 @@ class DanbooruApi extends Extension {
private function authenticate_user()
{
global $config;
- global $database;
global $user;
if(isset($_REQUEST['login']) && isset($_REQUEST['password']))
diff --git a/ext/downtime/theme.php b/ext/downtime/theme.php
index aae0cca5..c61123b6 100644
--- a/ext/downtime/theme.php
+++ b/ext/downtime/theme.php
@@ -3,6 +3,8 @@
class DowntimeTheme extends Themelet {
/**
* Show the admin that downtime mode is enabled
+ *
+ * @param Page $page
*/
public function display_notification(Page $page) {
$page->add_block(new Block("Downtime",
@@ -11,6 +13,8 @@ class DowntimeTheme extends Themelet {
/**
* Display $message and exit
+ *
+ * @param string $message
*/
public function display_message(/*string*/ $message) {
global $config, $user;
diff --git a/ext/ext_manager/theme.php b/ext/ext_manager/theme.php
index fa340d41..b138ac49 100644
--- a/ext/ext_manager/theme.php
+++ b/ext/ext_manager/theme.php
@@ -2,7 +2,6 @@
class ExtManagerTheme extends Themelet {
public function display_table(Page $page, /*array*/ $extensions, /*bool*/ $editable) {
- global $user;
$h_en = $editable ? "Enabled | " : "";
$html = "
".make_form(make_link("ext_manager/set"))."
diff --git a/ext/favorites/main.php b/ext/favorites/main.php
index 80b722d9..0cfca51b 100644
--- a/ext/favorites/main.php
+++ b/ext/favorites/main.php
@@ -133,7 +133,6 @@ class Favorites extends Extension {
$event->add_querylet(new Querylet("images.id IN (SELECT id FROM images WHERE favorites $cmp $favorites)"));
}
else if(preg_match("/^favorited_by[=|:](.*)$/i", $event->term, $matches)) {
- global $database;
$user = User::by_name($matches[1]);
if(!is_null($user)) {
$user_id = $user->id;
diff --git a/ext/favorites/theme.php b/ext/favorites/theme.php
index d530e497..ae502ab2 100644
--- a/ext/favorites/theme.php
+++ b/ext/favorites/theme.php
@@ -2,8 +2,6 @@
class FavoritesTheme extends Themelet {
public function get_voter_html(Image $image, $is_favorited) {
- global $page, $user;
-
$i_image_id = int_escape($image->id);
$name = $is_favorited ? "unset" : "set";
$label = $is_favorited ? "Un-Favorite" : "Favorite";
diff --git a/ext/forum/main.php b/ext/forum/main.php
index 1fea2064..8a263364 100644
--- a/ext/forum/main.php
+++ b/ext/forum/main.php
@@ -71,7 +71,7 @@ class Forum extends Extension {
}
public function onUserPageBuilding(UserPageBuildingEvent $event) {
- global $page, $user, $database;
+ global $database;
$threads_count = $database->get_one("SELECT COUNT(*) FROM forum_threads WHERE user_id=?", array($event->display_user->id));
$posts_count = $database->get_one("SELECT COUNT(*) FROM forum_posts WHERE user_id=?", array($event->display_user->id));
@@ -250,7 +250,6 @@ class Forum extends Extension {
}
private function sanity_check_viewed_thread($threadID)
{
- global $database;
$errors = null;
if (!$this->threadExists($threadID))
{
@@ -298,7 +297,7 @@ class Forum extends Extension {
private function show_posts($event, $showAdminOptions = false)
{
- global $config, $database, $user;
+ global $config, $database;
$threadID = $event->get_arg(1);
$pageNumber = $event->get_arg(2);
$postsPerPage = $config->get_int('forumPostsPerPage', 15);
diff --git a/ext/handle_svg/main.php b/ext/handle_svg/main.php
index b6f562be..96640595 100644
--- a/ext/handle_svg/main.php
+++ b/ext/handle_svg/main.php
@@ -23,7 +23,6 @@ class SVGFileHandler extends Extension {
}
public function onThumbnailGeneration(ThumbnailGenerationEvent $event) {
- global $config;
if($this->supported_ext($event->type)) {
$hash = $event->hash;
@@ -39,7 +38,7 @@ class SVGFileHandler extends Extension {
}
public function onPageRequest(PageRequestEvent $event) {
- global $config, $database, $page;
+ global $page;
if($event->page_matches("get_svg")) {
$id = int_escape($event->get_arg(0));
$image = Image::by_id($id);
@@ -66,8 +65,6 @@ class SVGFileHandler extends Extension {
* @return Image
*/
private function create_image_from_data($filename, $metadata) {
- global $config;
-
$image = new Image();
$msp = new MiniSVGParser($filename);
diff --git a/ext/holiday/main.php b/ext/holiday/main.php
index be23350c..7912d8e1 100644
--- a/ext/holiday/main.php
+++ b/ext/holiday/main.php
@@ -13,7 +13,6 @@ class Holiday extends Extension {
}
public function onSetupBuilding(SetupBuildingEvent $event) {
- global $config;
$sb = new SetupBlock("Holiday Theme");
$sb->add_bool_option("holiday_aprilfools", "Enable April Fools");
$event->panel->add_block($sb);
diff --git a/ext/home/main.php b/ext/home/main.php
index d170b135..fb1269db 100644
--- a/ext/home/main.php
+++ b/ext/home/main.php
@@ -46,7 +46,6 @@ class Home extends Extension {
private function get_body() {
// returns just the contents of the body
- global $database;
global $config;
$base_href = get_base_href();
$sitename = $config->get_string('title');
diff --git a/ext/image/main.php b/ext/image/main.php
index bdd1978c..784ef564 100644
--- a/ext/image/main.php
+++ b/ext/image/main.php
@@ -217,7 +217,7 @@ class ImageIO extends Extension {
}
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) {
- global $user, $config;
+ global $user;
if($user->can("delete_image")) {
$event->add_part($this->theme->get_deleter_html($event->image->id));
@@ -310,7 +310,7 @@ class ImageIO extends Extension {
* @throws ImageAdditionException
*/
private function add_image(Image $image) {
- global $page, $user, $database, $config;
+ global $user, $database, $config;
/*
* Validate things
diff --git a/ext/image/theme.php b/ext/image/theme.php
index 072888bf..96f23501 100644
--- a/ext/image/theme.php
+++ b/ext/image/theme.php
@@ -8,8 +8,6 @@ class ImageIOTheme extends Themelet {
* @return string
*/
public function get_deleter_html(/*int*/ $image_id) {
- global $config;
-
$html = "
".make_form(make_link("image/delete"))."
diff --git a/ext/image_hash_ban/main.php b/ext/image_hash_ban/main.php
index 5037c844..742e8a85 100644
--- a/ext/image_hash_ban/main.php
+++ b/ext/image_hash_ban/main.php
@@ -53,7 +53,7 @@ class ImageBan extends Extension {
}
public function onPageRequest(PageRequestEvent $event) {
- global $config, $database, $page, $user;
+ global $database, $page, $user;
if($event->page_matches("image_hash_ban")) {
if($user->can("ban_image")) {
diff --git a/ext/index/main.php b/ext/index/main.php
index aba16e82..75a7fab0 100644
--- a/ext/index/main.php
+++ b/ext/index/main.php
@@ -235,7 +235,7 @@ class Index extends Extension {
}
public function onPageRequest(PageRequestEvent $event) {
- global $config, $database, $page, $user;
+ global $database, $page;
if($event->page_matches("post/list")) {
if(isset($_GET['search'])) {
$search = url_escape(Tag::implode(Tag::resolve_aliases(Tag::explode($_GET['search'], false))));
diff --git a/ext/index/script.js b/ext/index/script.js
index 7fd63d6a..e1499c74 100644
--- a/ext/index/script.js
+++ b/ext/index/script.js
@@ -3,7 +3,7 @@
$(function() {
var blocked_tags = ($.cookie("ui-blocked-tags") || "").split(" ");
var needs_refresh = false;
- for(i=0; ipage_matches("ip_ban")) {
- global $config, $database, $page, $user;
+ global $page, $user;
if($user->can("ban_ip")) {
if($event->get_arg(0) == "add" && $user->check_auth_token()) {
if(isset($_POST['ip']) && isset($_POST['reason']) && isset($_POST['end'])) {
diff --git a/ext/log_logstash/main.php b/ext/log_logstash/main.php
index fbbff556..43517add 100644
--- a/ext/log_logstash/main.php
+++ b/ext/log_logstash/main.php
@@ -53,4 +53,3 @@ class LogLogstash extends Extension {
}
}
}
-?>
diff --git a/ext/notes/main.php b/ext/notes/main.php
index f2ea535f..6a66996e 100644
--- a/ext/notes/main.php
+++ b/ext/notes/main.php
@@ -220,7 +220,6 @@ class Notes extends Extension {
$event->add_querylet(new Querylet("images.id IN (SELECT id FROM images WHERE notes $cmp $notes)"));
}
else if(preg_match("/^notes_by[=|:](.*)$/i", $event->term, $matches)) {
- global $database;
$user = User::by_name($matches[1]);
if(!is_null($user)) {
$user_id = $user->id;
@@ -323,7 +322,7 @@ class Notes extends Extension {
$noteY1 = int_escape($_POST["note_y1"]);
$noteHeight = int_escape($_POST["note_height"]);
$noteWidth = int_escape($_POST["note_width"]);
- $noteText = mysql_real_escape_string(html_escape($_POST["note_text"]));
+ $noteText = sql_escape(html_escape($_POST["note_text"]));
// validate parameters
if (is_null($imageID) || !is_numeric($imageID) ||
diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php
index c98fde08..5954afd5 100644
--- a/ext/numeric_score/main.php
+++ b/ext/numeric_score/main.php
@@ -29,14 +29,14 @@ class NumericScore extends Extension {
}
public function onDisplayingImage(DisplayingImageEvent $event) {
- global $user, $page;
+ global $user;
if(!$user->is_anonymous()) {
$this->theme->get_voter($event->image);
}
}
public function onUserPageBuilding(UserPageBuildingEvent $event) {
- global $page, $user;
+ global $user;
if($user->can("edit_other_vote")) {
$this->theme->get_nuller($event->display_user);
}
diff --git a/ext/oekaki/main.php b/ext/oekaki/main.php
index 0894dd2c..bf4c804d 100644
--- a/ext/oekaki/main.php
+++ b/ext/oekaki/main.php
@@ -54,7 +54,7 @@ class Oekaki extends Extension {
header('Content-type: text/plain');
$file = $_FILES['picture']['name'];
- $ext = (strpos($file, '.') === FALSE) ? '' : substr($file, strrpos($file, '.'));
+ //$ext = (strpos($file, '.') === FALSE) ? '' : substr($file, strrpos($file, '.'));
$uploadname = $_SERVER['REMOTE_ADDR'] . "." . time();
$uploadfile = data_path('oekaki_unclaimed/'.$uploadname);
diff --git a/ext/ouroboros_api/main.php b/ext/ouroboros_api/main.php
index 3ad5dbaa..674b3da8 100644
--- a/ext/ouroboros_api/main.php
+++ b/ext/ouroboros_api/main.php
@@ -399,7 +399,7 @@ class OuroborosAPI extends Extension
public function onPageRequest(PageRequestEvent $event)
{
- global $database, $page, $config, $user;
+ global $page, $user;
if (preg_match("%\.(xml|json)$%", implode('/', $event->args), $matches) === 1) {
$this->event = $event;
@@ -489,7 +489,7 @@ class OuroborosAPI extends Extension
*/
protected function postCreate(OuroborosPost $post, $md5 = '')
{
- global $page, $config, $user;
+ global $config;
$handler = $config->get_string("upload_collision_handler");
if (!empty($md5) && !($handler == 'merge')) {
$img = Image::by_hash($md5);
diff --git a/ext/pools/theme.php b/ext/pools/theme.php
index 2decb2df..b0e07866 100644
--- a/ext/pools/theme.php
+++ b/ext/pools/theme.php
@@ -61,7 +61,6 @@ class PoolsTheme extends Themelet {
* @param int $totalPages
*/
public function list_pools(Page $page, /*array*/ $pools, /*int*/ $pageNumber, /*int*/ $totalPages) {
- global $user;
$html = '
@@ -168,7 +167,7 @@ class PoolsTheme extends Themelet {
* @param int $totalPages
*/
public function view_pool(/*array*/ $pools, /*array*/ $images, /*int*/ $pageNumber, /*int*/ $totalPages) {
- global $user, $page;
+ global $page;
$this->display_top($pools, "Pool: ".html_escape($pools[0]['title']));
@@ -294,8 +293,6 @@ class PoolsTheme extends Themelet {
* @param array $images
*/
public function edit_order(Page $page, /*array*/ $pools, /*array*/ $images) {
- global $user;
-
$this->display_top($pools, "Sorting Pool");
$pool_images = "\n