diff --git a/.gitignore b/.gitignore
index 33a39f7d..65079abb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,7 +55,6 @@ Icon
*.un~
Session.vim
.netrwhist
-*~
### PhpStorm ###
diff --git a/core/_install.php b/core/_install.php
index bf99bc21..a37553da 100644
--- a/core/_install.php
+++ b/core/_install.php
@@ -99,16 +99,6 @@ function check_im_version(): int
return (empty($convert_check) ? 0 : 1);
}
-
-function eok($name, $value)
-{
- echo "
$name ... ";
- if ($value) {
- echo "ok\n";
- } else {
- echo "failed\n";
- }
-}
// }}}
function do_install()
diff --git a/core/cacheengine.php b/core/cacheengine.php
index 7d78abff..f8ecbbcb 100644
--- a/core/cacheengine.php
+++ b/core/cacheengine.php
@@ -127,7 +127,7 @@ class RedisCache implements CacheEngine
public function delete(string $key)
{
- $this->redis->delete($key);
+ $this->redis->del($key);
}
}
diff --git a/core/imageboard/image.php b/core/imageboard/image.php
index 2c1a632e..1be0b839 100644
--- a/core/imageboard/image.php
+++ b/core/imageboard/image.php
@@ -13,7 +13,6 @@ class Image
public const IMAGE_DIR = "images";
public const THUMBNAIL_DIR = "thumbs";
- private static $tag_n = 0; // temp hack
public static $order_sql = null; // this feels ugly
/** @var null|int */
@@ -875,8 +874,6 @@ class Image
*/
private static function build_search_querylet(array $tag_conditions, array $img_conditions): Querylet
{
- global $database;
-
$positive_tag_count = 0;
$negative_tag_count = 0;
foreach ($tag_conditions as $tq) {
@@ -989,7 +986,6 @@ class Image
}
}
- $sql = "";
assert($positive_tag_id_array || $positive_wildcard_id_array || $negative_tag_id_array, @$_GET['q']);
if (!empty($positive_tag_id_array) || !empty($positive_wildcard_id_array)) {
$inner_joins = [];
diff --git a/core/polyfills.php b/core/polyfills.php
index 4f0b2c71..87e739e3 100644
--- a/core/polyfills.php
+++ b/core/polyfills.php
@@ -281,7 +281,6 @@ const MIME_TYPE_MAP = [
'mpg' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'mov' => 'video/quicktime',
- 'flv' => 'video/x-flv',
'php' => 'text/x-php',
'mp4' => 'video/mp4',
'ogv' => 'video/ogg',
diff --git a/ext/bulk_actions/main.php b/ext/bulk_actions/main.php
index dbae2b4c..d622f216 100644
--- a/ext/bulk_actions/main.php
+++ b/ext/bulk_actions/main.php
@@ -54,7 +54,7 @@ class BulkActions extends Extension
{
public function onPostListBuilding(PostListBuildingEvent $event)
{
- global $config, $page, $user;
+ global $page, $user;
if ($user->is_logged_in()) {
$babbe = new BulkActionBlockBuildingEvent();
diff --git a/ext/bulk_actions/theme.php b/ext/bulk_actions/theme.php
index ed3c8a1e..9d1b854e 100644
--- a/ext/bulk_actions/theme.php
+++ b/ext/bulk_actions/theme.php
@@ -4,8 +4,6 @@ class BulkActionsTheme extends Themelet
{
public function display_selector(Page $page, array $actions, string $query)
{
- global $user;
-
$body = "
diff --git a/ext/comment/main.php b/ext/comment/main.php
index b3bc2542..3791ea00 100644
--- a/ext/comment/main.php
+++ b/ext/comment/main.php
@@ -263,7 +263,7 @@ class CommentList extends Extension
public function onPostListBuilding(PostListBuildingEvent $event)
{
- global $cache, $config, $database;
+ global $cache, $config;
$cc = $config->get_int("comment_count");
if ($cc > 0) {
$recent = $cache->get("recent_comments");
diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php
index e2886f99..68a85635 100644
--- a/ext/cron_uploader/main.php
+++ b/ext/cron_uploader/main.php
@@ -323,8 +323,6 @@ class CronUploader extends Extension
private function move_uploaded($path, $filename, $output_subdir, $corrupt = false)
{
- global $config;
-
// Create
$newDir = $this->root_dir;
diff --git a/ext/danbooru_api/main.php b/ext/danbooru_api/main.php
index 304bd855..aa0ec9a7 100644
--- a/ext/danbooru_api/main.php
+++ b/ext/danbooru_api/main.php
@@ -242,7 +242,7 @@ class DanbooruApi extends Extension
*/
private function api_add_post()
{
- global $user, $config, $page;
+ global $user, $page;
$danboorup_kludge = 1; // danboorup for firefox makes broken links out of location: /path
// Check first if a login was supplied, if it wasn't check if the user is logged in via cookie
diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php
index 8a4add73..9e057b02 100644
--- a/ext/ext_manager/main.php
+++ b/ext/ext_manager/main.php
@@ -122,7 +122,6 @@ class ExtManager extends Extension
$extras = [];
foreach (ExtensionInfo::get_all_keys() as $key) {
- $matches = [];
if (!in_array($key, $core) && isset($settings["ext_$key"])) {
$extras[] = $key;
}
diff --git a/ext/featured/main.php b/ext/featured/main.php
index 63bc9cdb..1ea436f3 100644
--- a/ext/featured/main.php
+++ b/ext/featured/main.php
@@ -42,7 +42,7 @@ class Featured extends Extension
public function onPostListBuilding(PostListBuildingEvent $event)
{
- global $cache, $config, $database, $page, $user;
+ global $cache, $config, $page, $user;
$fid = $config->get_int("featured_id");
if ($fid > 0) {
$image = $cache->get("featured_image_object:$fid");
diff --git a/ext/forum/main.php b/ext/forum/main.php
index 064c09fe..e4c60df4 100644
--- a/ext/forum/main.php
+++ b/ext/forum/main.php
@@ -96,7 +96,7 @@ class Forum extends Extension
break;
case "view":
$threadID = int_escape($event->get_arg(1));
- $pageNumber = int_escape($event->get_arg(2));
+ // $pageNumber = int_escape($event->get_arg(2));
list($errors) = $this->sanity_check_viewed_thread($threadID);
if ($errors!=null) {
diff --git a/ext/handle_404/main.php b/ext/handle_404/main.php
index 69ca4123..4c6bd74d 100644
--- a/ext/handle_404/main.php
+++ b/ext/handle_404/main.php
@@ -5,7 +5,7 @@ class Handle404 extends Extension
{
public function onPageRequest(PageRequestEvent $event)
{
- global $config, $page;
+ global $page;
// hax.
if ($page->mode == PageMode::PAGE && (!isset($page->blocks) || $this->count_main($page->blocks) == 0)) {
$h_pagename = html_escape(implode('/', $event->args));
diff --git a/ext/handle_flash/main.php b/ext/handle_flash/main.php
index df93b408..9b738ee6 100644
--- a/ext/handle_flash/main.php
+++ b/ext/handle_flash/main.php
@@ -23,8 +23,6 @@ class FlashFileHandler extends DataHandlerExtension
protected function create_thumb(string $hash, string $type): bool
{
- global $config;
-
if (!Media::create_thumbnail_ffmpeg($hash)) {
copy("ext/handle_flash/thumb.jpg", warehouse_path(Image::THUMBNAIL_DIR, $hash));
}
diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php
index 855e4662..fbd98b65 100644
--- a/ext/handle_video/main.php
+++ b/ext/handle_video/main.php
@@ -115,8 +115,6 @@ class VideoFileHandler extends DataHandlerExtension
$image->ext = "ogv";
break;
case "video/flv":
- $image->ext = "flv";
- break;
case "video/x-flv":
$image->ext = "flv";
break;
diff --git a/ext/help_pages/main.php b/ext/help_pages/main.php
index 015ad40f..ac7f4cf1 100644
--- a/ext/help_pages/main.php
+++ b/ext/help_pages/main.php
@@ -35,7 +35,7 @@ class HelpPages extends Extension
public function onPageRequest(PageRequestEvent $event)
{
- global $page, $user;
+ global $page;
if ($event->page_matches("help")) {
$e = new HelpPageListBuildingEvent();
@@ -79,7 +79,6 @@ class HelpPages extends Extension
public function onUserBlockBuilding(UserBlockBuildingEvent $event)
{
- global $user;
$event->add_link("Help", make_link("help"));
}
diff --git a/ext/image/main.php b/ext/image/main.php
index 48a838ec..2dc8f72b 100644
--- a/ext/image/main.php
+++ b/ext/image/main.php
@@ -81,7 +81,7 @@ class ImageIO extends Extension
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
{
global $user;
-
+
if ($user->can(Permissions::DELETE_IMAGE)) {
$event->add_part($this->theme->get_deleter_html($event->image->id));
}
@@ -113,7 +113,7 @@ class ImageIO extends Extension
throw new UploadException($e->error);
}
}
-
+
public function onUserPageBuilding(UserPageBuildingEvent $event)
{
$u_id = url_escape($event->display_user->id);
@@ -126,8 +126,6 @@ class ImageIO extends Extension
public function onSetupBuilding(SetupBuildingEvent $event)
{
- global $config;
-
$sb = new SetupBlock("Image Options");
$sb->position = 30;
// advanced only
@@ -141,9 +139,6 @@ class ImageIO extends Extension
$event->panel->add_block($sb);
-
-
-
$sb = new SetupBlock("Thumbnailing");
$sb->add_choice_option(ImageConfig::THUMB_ENGINE, self::THUMBNAIL_ENGINES, "Engine: ");
$sb->add_label("
");
@@ -161,7 +156,6 @@ class ImageIO extends Extension
$sb->add_int_option(ImageConfig::THUMB_SCALING);
$sb->add_label("%");
-
$event->panel->add_block($sb);
}
@@ -286,7 +280,7 @@ class ImageIO extends Extension
}
$page->set_file($file);
-
+
if ($config->get_int(ImageConfig::EXPIRES)) {
$expires = date(DATE_RFC1123, time() + $config->get_int(ImageConfig::EXPIRES));
} else {
@@ -313,7 +307,7 @@ class ImageIO extends Extension
/* Check to make sure the image exists. */
$existing = Image::by_id($id);
-
+
if (is_null($existing)) {
throw new ImageReplaceException("Image to replace does not exist!");
}
diff --git a/ext/media/main.php b/ext/media/main.php
index 5c8c9957..24449e99 100644
--- a/ext/media/main.php
+++ b/ext/media/main.php
@@ -251,7 +251,7 @@ class Media extends Extension
public function onPageRequest(PageRequestEvent $event)
{
- global $database, $page, $user;
+ global $page, $user;
if ($event->page_matches("media_rescan/") && $user->can(Permissions::RESCAN_MEDIA) && isset($_POST['image_id'])) {
$image = Image::by_id(int_escape($_POST['image_id']));
diff --git a/ext/media/theme.php b/ext/media/theme.php
index 15c3e03e..64a12851 100644
--- a/ext/media/theme.php
+++ b/ext/media/theme.php
@@ -4,7 +4,7 @@ class MediaTheme extends Themelet
{
public function display_form(array $types)
{
- global $page, $database;
+ global $page;
$html = "Use this to force scanning for media properties.";
$html .= make_form(make_link("admin/media_rescan"));
diff --git a/ext/oekaki/main.php b/ext/oekaki/main.php
index ec2125d0..9ba7f128 100644
--- a/ext/oekaki/main.php
+++ b/ext/oekaki/main.php
@@ -49,7 +49,7 @@ class Oekaki extends Extension
if (isset($_FILES["picture"])) {
header('Content-type: text/plain');
- $file = $_FILES['picture']['name'];
+ //$file = $_FILES['picture']['name'];
//$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 7bf969ea..dfc4aa5c 100644
--- a/ext/ouroboros_api/main.php
+++ b/ext/ouroboros_api/main.php
@@ -589,17 +589,7 @@ class OuroborosAPI extends Extension
);
break;
case 'count':
- $tag_data = $database->get_all(
- "
- SELECT id, tag, count
- FROM tags
- WHERE count >= :tags_min
- ORDER BY count DESC, tag ASC LIMIT :start, :max_items
- ",
- ['tags_min' => $config->get_int(TagListConfig::TAGS_MIN), 'start' => $start, 'max_items' => $limit]
- );
- break;
- case 'date':
+ default:
$tag_data = $database->get_all(
"
SELECT id, tag, count
diff --git a/ext/pools/main.php b/ext/pools/main.php
index 6604e4f2..15e36c99 100644
--- a/ext/pools/main.php
+++ b/ext/pools/main.php
@@ -153,7 +153,7 @@ class Pools extends Extension
public function onPageRequest(PageRequestEvent $event)
{
- global $page, $user, $database;
+ global $page, $user;
if ($event->page_matches("pool")) {
$pool_id = 0;
@@ -428,7 +428,7 @@ class Pools extends Extension
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event)
{
- global $user, $database;
+ global $database;
$pools = $database->get_all("SELECT * FROM pools ORDER BY title ");
diff --git a/ext/post_titles/main.php b/ext/post_titles/main.php
index 6819d524..b9eb167f 100644
--- a/ext/post_titles/main.php
+++ b/ext/post_titles/main.php
@@ -12,7 +12,7 @@ class PostTitles extends Extension
public function onInitExt(InitExtEvent $event)
{
- global $config, $database;
+ global $config;
$config->set_default_bool(PostTitlesConfig::DEFAULT_TO_FILENAME, false);
$config->set_default_bool(PostTitlesConfig::SHOW_IN_WINDOW_TITLE, false);
diff --git a/ext/rating/main.php b/ext/rating/main.php
index dfc1071f..aa18cabd 100644
--- a/ext/rating/main.php
+++ b/ext/rating/main.php
@@ -128,7 +128,7 @@ class Ratings extends Extension
public function onInitExt(InitExtEvent $event)
{
- global $user, $config, $_shm_user_classes, $_shm_ratings;
+ global $config, $_shm_user_classes, $_shm_ratings;
if ($config->get_int(RatingsConfig::VERSION) < 4) {
$this->install();
@@ -149,7 +149,7 @@ class Ratings extends Extension
public function onUserOptionsBuilding(UserOptionsBuildingEvent $event)
{
- global $user, $user_config;
+ global $user;
$event->add__html(
$this->theme->get_user_options(
@@ -162,7 +162,7 @@ class Ratings extends Extension
public function onSetupBuilding(SetupBuildingEvent $event)
{
- global $config, $_shm_user_classes, $_shm_ratings;
+ global $_shm_user_classes;
$ratings = self::get_sorted_ratings();
@@ -238,8 +238,6 @@ class Ratings extends Extension
public function onHelpPageBuilding(HelpPageBuildingEvent $event)
{
- global $user;
-
if ($event->key===HelpPages::SEARCH) {
$block = new Block();
$block->header = "Ratings";
@@ -507,7 +505,7 @@ class Ratings extends Extension
*/
private function can_rate(): bool
{
- global $config, $user;
+ global $user;
if ($user->can("edit_image_rating")) {
return true;
}
diff --git a/ext/rating/theme.php b/ext/rating/theme.php
index 19ef6354..19908586 100644
--- a/ext/rating/theme.php
+++ b/ext/rating/theme.php
@@ -26,7 +26,7 @@ class RatingsTheme extends Themelet
public function display_form(array $current_ratings, array $available_ratings)
{
- global $page, $database;
+ global $page;
$html = make_form(make_link("admin/update_ratings"))."
";
return $output;
}
-
+
public function get_user_options(User $user, array $selected_ratings, array $available_ratings): string
{
$html = "
diff --git a/ext/regen_thumb/main.php b/ext/regen_thumb/main.php
index 31de0ed7..5be9b5f7 100644
--- a/ext/regen_thumb/main.php
+++ b/ext/regen_thumb/main.php
@@ -14,7 +14,7 @@ class RegenThumb extends Extension
public function onPageRequest(PageRequestEvent $event)
{
- global $database, $page, $user;
+ global $page, $user;
if ($event->page_matches("regen_thumb/one") && $user->can(Permissions::DELETE_IMAGE) && isset($_POST['image_id'])) {
$image = Image::by_id(int_escape($_POST['image_id']));
@@ -93,8 +93,6 @@ class RegenThumb extends Extension
public function onAdminAction(AdminActionEvent $event)
{
- global $database;
-
switch ($event->action) {
case "regen_thumbs":
$event->redirect = true;
diff --git a/ext/resize/main.php b/ext/resize/main.php
index ea133340..4ca8819e 100644
--- a/ext/resize/main.php
+++ b/ext/resize/main.php
@@ -171,7 +171,7 @@ class ResizeImage extends Extension
/* ----------------------------- */
private function resize_image(Image $image_obj, int $width, int $height)
{
- global $database, $config;
+ global $config;
if (($height <= 0) && ($width <= 0)) {
throw new ImageResizeException("Invalid options for height and width. ($width x $height)");
diff --git a/ext/rotate/main.php b/ext/rotate/main.php
index 1e0ece42..3b176a7c 100644
--- a/ext/rotate/main.php
+++ b/ext/rotate/main.php
@@ -99,8 +99,6 @@ class RotateImage extends Extension
/* ----------------------------- */
private function rotate_image(int $image_id, int $deg)
{
- global $database;
-
if (($deg <= -360) || ($deg >= 360)) {
throw new ImageRotateException("Invalid options for rotation angle. ($deg)");
}
@@ -177,7 +175,6 @@ class RotateImage extends Extension
}
/* Output to the same format as the original image */
- $result = false;
switch ($info[2]) {
case IMAGETYPE_GIF: $result = imagegif($image_rotated, $tmp_filename); break;
case IMAGETYPE_JPEG: $result = imagejpeg($image_rotated, $tmp_filename); break;
diff --git a/ext/rss_images/main.php b/ext/rss_images/main.php
index c12ad1db..8c164dfa 100644
--- a/ext/rss_images/main.php
+++ b/ext/rss_images/main.php
@@ -76,7 +76,7 @@ class RSSImages extends Extension
private function thumb(Image $image): string
{
- global $cache, $database;
+ global $cache;
$cached = $cache->get("rss-thumb:{$image->id}");
if ($cached) {
diff --git a/ext/setup/main.php b/ext/setup/main.php
index ae622c2a..676442fe 100644
--- a/ext/setup/main.php
+++ b/ext/setup/main.php
@@ -138,8 +138,6 @@ class SetupBlock extends Block
private function format_option(string $name, $html, ?string $label, bool $table_row)
{
- global $config;
-
if ($table_row) {
$this->start_table_row();
}
diff --git a/ext/system/main.php b/ext/system/main.php
index 5c9a21d1..7a78a113 100644
--- a/ext/system/main.php
+++ b/ext/system/main.php
@@ -4,7 +4,7 @@ class System extends Extension
{
public function onPageRequest(PageRequestEvent $event)
{
- global $page, $user;
+ global $page;
if ($event->page_matches("system")) {
$e = new PageSubNavBuildingEvent("system");
diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php
index a1ce5aab..24bdb92a 100644
--- a/ext/tag_list/main.php
+++ b/ext/tag_list/main.php
@@ -189,7 +189,6 @@ class TagList extends Extension
$results = $cache->get("tag_list_omitted_tags:".$tags_config);
if ($results==null) {
- $results = [];
$tags = explode(" ", $tags_config);
if (empty($tags)) {
@@ -572,7 +571,7 @@ class TagList extends Extension
*/
private function add_refine_block(Page $page, array $search)
{
- global $database, $config;
+ global $config;
if (count($search) > 5) {
return;
diff --git a/ext/transcode/main.php b/ext/transcode/main.php
index efc6d848..73623dab 100644
--- a/ext/transcode/main.php
+++ b/ext/transcode/main.php
@@ -100,7 +100,7 @@ class TranscodeImage extends Extension
public function onDataUpload(DataUploadEvent $event)
{
- global $config, $page;
+ global $config;
if ($config->get_bool(TranscodeConfig::UPLOAD) == true) {
$ext = strtolower($event->type);
@@ -196,7 +196,7 @@ class TranscodeImage extends Extension
$database->commit();
$total++;
} catch (Exception $e) {
- log_error("transcode", "Error while bulk transcode on item $id to $format: ".$e->getMessage());
+ log_error("transcode", "Error while bulk transcode on item {$image->id} to $format: ".$e->getMessage());
try {
$database->rollback();
} catch (Exception $e) {
@@ -291,6 +291,8 @@ class TranscodeImage extends Extension
return $this->transcode_image_gd($source_name, $source_format, $target_format);
case "convert":
return $this->transcode_image_convert($source_name, $source_format, $target_format);
+ default:
+ throw new ImageTranscodeException("No engine specified");
}
}
diff --git a/ext/transcode/theme.php b/ext/transcode/theme.php
index c52953b4..00ca6148 100644
--- a/ext/transcode/theme.php
+++ b/ext/transcode/theme.php
@@ -7,8 +7,6 @@ class TranscodeImageTheme extends Themelet
*/
public function get_transcode_html(Image $image, array $options)
{
- global $config;
-
$html = "
".make_form(
make_link("transcode/{$image->id}"),
@@ -23,10 +21,10 @@ class TranscodeImageTheme extends Themelet
";
-
+
return $html;
}
-
+
public function get_transcode_picker_html(array $options)
{
$html = "