remove a bunch of dead variables and things

This commit is contained in:
Shish 2019-10-02 11:23:57 +01:00
parent e08cdb1638
commit 30698fefdc
45 changed files with 51 additions and 111 deletions

1
.gitignore vendored
View File

@ -55,7 +55,6 @@ Icon
*.un~
Session.vim
.netrwhist
*~
### PhpStorm ###

View File

@ -99,16 +99,6 @@ function check_im_version(): int
return (empty($convert_check) ? 0 : 1);
}
function eok($name, $value)
{
echo "<br>$name ... ";
if ($value) {
echo "<span style='color: green'>ok</span>\n";
} else {
echo "<span style='color: green'>failed</span>\n";
}
}
// }}}
function do_install()

View File

@ -127,7 +127,7 @@ class RedisCache implements CacheEngine
public function delete(string $key)
{
$this->redis->delete($key);
$this->redis->del($key);
}
}

View File

@ -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 = [];

View File

@ -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',

View File

@ -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();

View File

@ -4,8 +4,6 @@ class BulkActionsTheme extends Themelet
{
public function display_selector(Page $page, array $actions, string $query)
{
global $user;
$body = "<input type='hidden' name='bulk_selected_ids' id='bulk_selected_ids' />
<input id='bulk_selector_activate' type='button' onclick='activate_bulk_selector();' value='Activate (M)anual Select' accesskey='m'/>
<div id='bulk_selector_controls' style='display: none;'>

View File

@ -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");

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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");

View File

@ -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) {

View File

@ -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));

View File

@ -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));
}

View File

@ -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;

View File

@ -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"));
}

View File

@ -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("<br>");
@ -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!");
}

View File

@ -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']));

View File

@ -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"));

View File

@ -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);

View File

@ -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

View File

@ -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 ");

View File

@ -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);

View File

@ -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;
}

View File

@ -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"))."<table class='form'><tr>
<th>Change</th><td><select name='rating_old' required='required'><option></option>";
@ -66,8 +66,6 @@ class RatingsTheme extends Themelet
public function get_selection_rater_html(array $selected_options, bool $multiple = false, array $available_options = null)
{
global $_shm_ratings;
$output = "<select name='rating".($multiple ? "[]' multiple='multiple'" : "' ")." >";
$options = Ratings::get_sorted_ratings();
@ -111,7 +109,7 @@ class RatingsTheme extends Themelet
$output .= "</table>";
return $output;
}
public function get_user_options(User $user, array $selected_ratings, array $available_ratings): string
{
$html = "

View File

@ -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;

View File

@ -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)");

View File

@ -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;

View File

@ -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) {

View File

@ -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();
}

View File

@ -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");

View File

@ -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;

View File

@ -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");
}
}

View File

@ -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
<br><input id='transcodebutton' type='submit' value='Transcode'>
</form>
";
return $html;
}
public function get_transcode_picker_html(array $options)
{
$html = "<select id='transcode_format' name='transcode_format' required='required' >";

View File

@ -115,7 +115,7 @@ class Trash extends Extension
}
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
{
global $config, $database, $user;
global $user;
if ($event->image->trash===true && $user->can(Permissions::VIEW_TRASH)) {
$event->add_part($this->theme->get_image_admin_html($event->image->id));
}

View File

@ -343,8 +343,7 @@ class UserPage extends Extension
// Things done *with* the user {{{
private function page_login($name, $pass)
{
global $config, $user, $page;
global $config, $page;
if (empty($name) || empty($pass)) {
$this->theme->display_error(400, "Error", "Username or password left blank");

View File

@ -234,7 +234,7 @@ class UserPageTheme extends Themelet
public function display_user_page(User $duser, $stats)
{
global $page, $user;
global $page;
assert(is_array($stats));
$stats[] = 'User ID: '.$duser->id;
@ -249,7 +249,7 @@ class UserPageTheme extends Themelet
global $config, $user;
$html = "";
if ($duser->id != $config->get_int('anon_id')) { //justa fool-admin protection so they dont mess around with anon users.
if ($user->can(Permissions::EDIT_USER_NAME)) {
$html .= "
<p>".make_form(make_link("user_admin/change_name"))."

View File

@ -46,7 +46,7 @@ class Layout
{
public function display_page(Page $page, array $nav_links, array $sub_links)
{
global $config, $user;
global $config;
$theme_name = $config->get_string(SetupConfig::THEME);
//$base_href = $config->get_string('base_href');
@ -174,7 +174,7 @@ $header_html
</html>
EOD;
}
/**
* #param string[] $pages_matched
*/

View File

@ -8,7 +8,7 @@ class CustomExtManagerTheme extends ExtManagerTheme
parent::display_table($page, $extensions, $editable);
}
public function display_doc(Page $page, ExtensionManagerInfo $info)
public function display_doc(Page $page, ExtensionInfo $info)
{
$page->disable_left();
parent::display_doc($page, $info);

View File

@ -46,7 +46,7 @@ class Layout
{
public function display_page($page, array $nav_links, array $sub_links)
{
global $config, $user;
global $config;
//$theme_name = $config->get_string(SetupConfig::THEME);
//$base_href = $config->get_string('base_href');

View File

@ -9,8 +9,7 @@ class Layout
*/
public function display_page(Page $page, array $nav_links)
{
global $config;
//global $config;
//$theme_name = $config->get_string(SetupConfig::THEME, 'default');
//$data_href = get_base_href();
$contact_link = contact_link();

View File

@ -11,7 +11,7 @@ class Layout
{
public function display_page(Page $page, array $nav_links, array $sub_links)
{
global $config, $user;
global $config;
$theme_name = $config->get_string(SetupConfig::THEME, 'lite');
$site_name = $config->get_string(SetupConfig::TITLE);
@ -30,7 +30,7 @@ class Layout
$custom_links .= $this->navlinks($nav_link->link, $nav_link->description, $nav_link->active);
}
$menu .= "{$custom_links}</div>";
$left_block_html = "";
$main_block_html = "";
$sub_block_html = "";

View File

@ -14,7 +14,7 @@ class Layout
$theme_name = $config->get_string(SetupConfig::THEME, 'material');
$site_name = $config->get_string(SetupConfig::TITLE);
$data_href = get_base_href();
$main_page = $config->get_string(SetupConfig::MAIN_PAGE);
// $main_page = $config->get_string(SetupConfig::MAIN_PAGE);
$contact_link = contact_link();
$site_link = make_link();
$header_html = $page->get_all_html_headers();
@ -26,7 +26,7 @@ class Layout
$drawer_block_html = ""; //use exampled in user.theme.php & view.theme.php
$toolbar_block_html = ""; // not used at this point
$subtoolbar_block_html = ""; // use exampled in user.theme.php
$navigation = "";
// $navigation = "";
$h_search = "
<div class='mdl-textfield mdl-js-textfield mdl-textfield--expandable
@ -201,13 +201,13 @@ EOD;
public function rework_navigation(Block $block)
{
$h = $block->header;
// $h = $block->header;
$b = $block->body;
$i = $block->id;
$dom = new DomDocument();
$dom->loadHTML($b);
$output = [];
// $output = [];
$html = "<section id='$i'>\n<nav class='mdl-navigation'>\n";
foreach ($dom->getElementsByTagName('a') as $item) {
$item->setAttribute('class', 'mdl-navigation__link');

View File

@ -22,13 +22,9 @@ class CustomViewImageTheme extends ViewImageTheme
protected function build_pin(Image $image)
{
global $database;
if (isset($_GET['search'])) {
$search_terms = explode(' ', $_GET['search']);
$query = "search=".url_escape($_GET['search']);
} else {
$search_terms = [];
$query = null;
}