formatting

This commit is contained in:
Shish 2019-09-29 14:30:55 +01:00
parent 56e247faf5
commit a6bb15d859
108 changed files with 424 additions and 429 deletions

View file

@ -313,9 +313,12 @@ class DatabaseConfig extends BaseConfig
private $sub_column; private $sub_column;
private $sub_value; private $sub_value;
public function __construct(Database $database, string $table_name = "config", public function __construct(
string $sub_column = null, string $sub_value = null) Database $database,
{ string $table_name = "config",
string $sub_column = null,
string $sub_value = null
) {
$this->database = $database; $this->database = $database;
$this->table_name = $table_name; $this->table_name = $table_name;
$this->sub_value = $sub_value; $this->sub_value = $sub_value;
@ -371,7 +374,8 @@ class DatabaseConfig extends BaseConfig
$args["value"] =$this->values[$name]; $args["value"] =$this->values[$name];
$this->database->Execute( $this->database->Execute(
"INSERT INTO {$this->table_name} (".join(",", $cols).") VALUES (".join(",", $params).")", "INSERT INTO {$this->table_name} (".join(",", $cols).") VALUES (".join(",", $params).")",
$args); $args
);
} }
// rather than deleting and having some other request(s) do a thundering // rather than deleting and having some other request(s) do a thundering
// herd of race-conditioned updates, just save the updated version once here // herd of race-conditioned updates, just save the updated version once here

View file

@ -1,5 +1,6 @@
<?php <?php
abstract class SCORE { abstract class SCORE
{
const AIPK = "SCORE_AIPK"; const AIPK = "SCORE_AIPK";
const INET = "SCORE_INET"; const INET = "SCORE_INET";
const BOOL_Y = "SCORE_BOOL_Y"; const BOOL_Y = "SCORE_BOOL_Y";

View file

@ -132,8 +132,10 @@ abstract class Extension
public static function determine_enabled_extensions() public static function determine_enabled_extensions()
{ {
self::$enabled_extensions = []; self::$enabled_extensions = [];
foreach(array_merge(ExtensionInfo::get_core_extensions(), foreach (array_merge(
explode(",", EXTRA_EXTS)) as $key) { ExtensionInfo::get_core_extensions(),
explode(",", EXTRA_EXTS)
) as $key) {
$ext = ExtensionInfo::get_by_key($key); $ext = ExtensionInfo::get_by_key($key);
if ($ext===null) { if ($ext===null) {
continue; continue;
@ -296,7 +298,6 @@ abstract class ExtensionInfo
public static function load_all_extension_info() public static function load_all_extension_info()
{ {
foreach (get_declared_classes() as $class) { foreach (get_declared_classes() as $class) {
$rclass = new ReflectionClass($class); $rclass = new ReflectionClass($class);
if ($rclass->isAbstract()) { if ($rclass->isAbstract()) {

View file

@ -835,8 +835,7 @@ class Image
if (isset($flexihashes[$opts])) { if (isset($flexihashes[$opts])) {
$flexihash = $flexihashes[$opts]; $flexihash = $flexihashes[$opts];
} } else {
else {
$flexihash = new Flexihash\Flexihash(); $flexihash = new Flexihash\Flexihash();
foreach (explode(",", $opts) as $opt) { foreach (explode(",", $opts) as $opt) {
$parts = explode("=", $opt); $parts = explode("=", $opt);

View file

@ -138,7 +138,6 @@ function get_thumbnail_size(int $orig_width, int $orig_height, bool $use_dpi_sca
} else { } else {
return $output; return $output;
} }
} }
function get_scaled_by_aspect_ratio(int $original_width, int $original_height, int $max_width, int $max_height) : array function get_scaled_by_aspect_ratio(int $original_width, int $original_height, int $max_width, int $max_height) : array
@ -167,7 +166,8 @@ function get_thumbnail_max_size_scaled(): array
} }
function create_image_thumb(string $hash, string $type, string $engine = null) { function create_image_thumb(string $hash, string $type, string $engine = null)
{
global $config; global $config;
$inname = warehouse_path(Image::IMAGE_DIR, $hash); $inname = warehouse_path(Image::IMAGE_DIR, $hash);
@ -206,7 +206,7 @@ function format_milliseconds(int $input): string
$remainder = floor($input / 1000); $remainder = floor($input / 1000);
foreach (TIME_UNITS AS $unit=>$conversion) { foreach (TIME_UNITS as $unit=>$conversion) {
$count = $remainder % $conversion; $count = $remainder % $conversion;
$remainder = floor($remainder / $conversion); $remainder = floor($remainder / $conversion);
if ($count==0&&$remainder<1) { if ($count==0&&$remainder<1) {

View file

@ -372,7 +372,6 @@ class Page
header('Accept-Ranges: bytes'); header('Accept-Ranges: bytes');
if (isset($_SERVER['HTTP_RANGE'])) { if (isset($_SERVER['HTTP_RANGE'])) {
$c_start = $start; $c_start = $start;
$c_end = $end; $c_end = $end;
list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
@ -418,9 +417,10 @@ class Page
// After flush, we can tell if the client browser has disconnected. // After flush, we can tell if the client browser has disconnected.
// This means we can start sending a large file, and if we detect they disappeared // This means we can start sending a large file, and if we detect they disappeared
// then we can just stop and not waste any more resources or bandwidth. // then we can just stop and not waste any more resources or bandwidth.
if (connection_status() != 0) if (connection_status() != 0) {
break; break;
} }
}
} finally { } finally {
fclose($fp); fclose($fp);
} }
@ -580,7 +580,6 @@ class NavLink
} else { } else {
$this->active = $active; $this->active = $active;
} }
} }
public static function is_active(array $pages_matched, string $url = null): bool public static function is_active(array $pages_matched, string $url = null): bool

View file

@ -66,5 +66,4 @@ abstract class Permissions
public const VIEW_TRASH = "view_trash"; public const VIEW_TRASH = "view_trash";
public const PERFORM_BULK_ACTIONS = "perform_bulk_actions"; public const PERFORM_BULK_ACTIONS = "perform_bulk_actions";
} }

View file

@ -810,12 +810,16 @@ function get_class_from_file(string $file): string
$class = $buffer = ''; $class = $buffer = '';
$i = 0; $i = 0;
while (!$class) { while (!$class) {
if (feof($fp)) break; if (feof($fp)) {
break;
}
$buffer .= fread($fp, 512); $buffer .= fread($fp, 512);
$tokens = token_get_all($buffer); $tokens = token_get_all($buffer);
if (strpos($buffer, '{') === false) continue; if (strpos($buffer, '{') === false) {
continue;
}
for (;$i<count($tokens);$i++) { for (;$i<count($tokens);$i++) {
if ($tokens[$i][0] === T_CLASS) { if ($tokens[$i][0] === T_CLASS) {

View file

@ -108,21 +108,29 @@ function send_event(Event $event): void
// send_event() is performance sensitive, and with the number // send_event() is performance sensitive, and with the number
// of times tracer gets called the time starts to add up // of times tracer gets called the time starts to add up
if ($tracer_enabled) $_tracer->begin(get_class($event)); if ($tracer_enabled) {
$_tracer->begin(get_class($event));
}
// SHIT: http://bugs.php.net/bug.php?id=35106 // SHIT: http://bugs.php.net/bug.php?id=35106
$my_event_listeners = $_shm_event_listeners[get_class($event)]; $my_event_listeners = $_shm_event_listeners[get_class($event)];
ksort($my_event_listeners); ksort($my_event_listeners);
foreach ($my_event_listeners as $listener) { foreach ($my_event_listeners as $listener) {
if ($tracer_enabled) $_tracer->begin(get_class($listener)); if ($tracer_enabled) {
$_tracer->begin(get_class($listener));
}
if (method_exists($listener, $method_name)) { if (method_exists($listener, $method_name)) {
$listener->$method_name($event); $listener->$method_name($event);
} }
if ($tracer_enabled) $_tracer->end(); if ($tracer_enabled) {
$_tracer->end();
}
if ($event->stop_processing===true) { if ($event->stop_processing===true) {
break; break;
} }
} }
$_shm_event_count++; $_shm_event_count++;
if ($tracer_enabled) $_tracer->end(); if ($tracer_enabled) {
$_tracer->end();
}
} }

View file

@ -48,7 +48,6 @@ class PolyfillsTest extends \PHPUnit\Framework\TestCase
public function test_sanitize_path() public function test_sanitize_path()
{ {
$this->assertEquals( $this->assertEquals(
"one", "one",
sanitize_path("one") sanitize_path("one")
@ -88,7 +87,6 @@ class PolyfillsTest extends \PHPUnit\Framework\TestCase
DIRECTORY_SEPARATOR."one".DIRECTORY_SEPARATOR."two".DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR."one".DIRECTORY_SEPARATOR."two".DIRECTORY_SEPARATOR,
sanitize_path("\\/one/\\/\\/two\\/") sanitize_path("\\/one/\\/\\/two\\/")
); );
} }
public function test_join_path() public function test_join_path()

View file

@ -3,7 +3,6 @@ require_once "core/util.php";
class UtilTest extends \PHPUnit\Framework\TestCase class UtilTest extends \PHPUnit\Framework\TestCase
{ {
public function test_warehouse_path() public function test_warehouse_path()
{ {
$hash = "7ac19c10d6859415"; $hash = "7ac19c10d6859415";
@ -62,6 +61,5 @@ class UtilTest extends \PHPUnit\Framework\TestCase
join_path(DATA_DIR, "base", "7a", "c1", "9c", "10", "d6", "85", "94", "15", $hash), join_path(DATA_DIR, "base", "7a", "c1", "9c", "10", "d6", "85", "94", "15", $hash),
warehouse_path("base", $hash, false, 10) warehouse_path("base", $hash, false, 10)
); );
} }
} }

View file

@ -55,7 +55,6 @@ class AdminPageTheme extends Themelet
$html .= "<input type='submit' value='Set Tag Case'>"; $html .= "<input type='submit' value='Set Tag Case'>";
$html .= "</form>\n"; $html .= "</form>\n";
$page->add_block(new Block("Set Tag Case", $html)); $page->add_block(new Block("Set Tag Case", $html));
} }
public function dbq_html($terms) public function dbq_html($terms)
@ -75,6 +74,4 @@ class AdminPageTheme extends Themelet
"; ";
return $html; return $html;
} }
} }

View file

@ -81,14 +81,14 @@ class BulkActions extends Extension
} }
if ($user->can(Permissions::BULK_EDIT_IMAGE_TAG)) { if ($user->can(Permissions::BULK_EDIT_IMAGE_TAG)) {
$event->add_action( $event->add_action(
"bulk_tag", "bulk_tag",
"Tag", "Tag",
"t", "t",
"", "",
$this->theme->render_tag_input(), $this->theme->render_tag_input(),
10); 10
);
} }
if ($user->can(Permissions::BULK_EDIT_IMAGE_SOURCE)) { if ($user->can(Permissions::BULK_EDIT_IMAGE_SOURCE)) {

View file

@ -312,6 +312,5 @@ class CommentListTheme extends Themelet
<p>Returns images that have been commented on by user 123. </p> <p>Returns images that have been commented on by user 123. </p>
</div> </div>
'; ';
} }
} }

View file

@ -28,4 +28,3 @@ becomes a link to smile.gif
<p>Images are stored in /ext/emoticons/default/, and you can <p>Images are stored in /ext/emoticons/default/, and you can
add more emoticons by uploading images into that folder."; add more emoticons by uploading images into that folder.";
} }

View file

@ -18,4 +18,3 @@ class Emoticons extends FormatterExtension
return $text; return $text;
} }
} }

View file

@ -3,10 +3,12 @@
function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b): int function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b): int
{ {
if($a->beta===true&&$b->beta===false) if ($a->beta===true&&$b->beta===false) {
return 1; return 1;
if($a->beta===false&&$b->beta===true) }
if ($a->beta===false&&$b->beta===true) {
return -1; return -1;
}
return strcmp($a->name, $b->name); return strcmp($a->name, $b->name);
} }

View file

@ -56,6 +56,5 @@ class FavoritesTheme extends Themelet
<p>Returns images that have been favorited by user 123. </p> <p>Returns images that have been favorited by user 123. </p>
</div> </div>
'; ';
} }
} }

View file

@ -2,7 +2,6 @@
class FlashFileHandler extends DataHandlerExtension class FlashFileHandler extends DataHandlerExtension
{ {
public function onMediaCheckProperties(MediaCheckPropertiesEvent $event) public function onMediaCheckProperties(MediaCheckPropertiesEvent $event)
{ {
switch ($event->ext) { switch ($event->ext) {

View file

@ -12,7 +12,6 @@ class MP3FileHandler extends DataHandlerExtension
break; break;
} }
// TODO: Buff out audio format support, length scanning // TODO: Buff out audio format support, length scanning
} }
protected function create_thumb(string $hash, string $type): bool protected function create_thumb(string $hash, string $type): bool

View file

@ -111,5 +111,4 @@ class PixelFileHandler extends DataHandlerExtension
</form> </form>
", 20); ", 20);
} }
} }

View file

@ -4,7 +4,6 @@ use enshrined\svgSanitize\Sanitizer;
class SVGFileHandler extends DataHandlerExtension class SVGFileHandler extends DataHandlerExtension
{ {
public function onMediaCheckProperties(MediaCheckPropertiesEvent $event) public function onMediaCheckProperties(MediaCheckPropertiesEvent $event)
{ {
switch ($event->ext) { switch ($event->ext) {

View file

@ -68,7 +68,6 @@ class VideoFileHandler extends DataHandlerExtension
&& is_numeric($stream["height"]) && intval($stream["height"]) > ($event->height) ?? 0) { && is_numeric($stream["height"]) && intval($stream["height"]) > ($event->height) ?? 0) {
$event->height = intval($stream["height"]); $event->height = intval($stream["height"]);
} }
} }
} }
$event->video = $video; $event->video = $video;
@ -83,7 +82,6 @@ class VideoFileHandler extends DataHandlerExtension
} }
} }
} catch (MediaException $e) { } catch (MediaException $e) {
} }
} }
} }

View file

@ -8,7 +8,6 @@ class HelpPageListBuildingEvent extends Event
{ {
$this->pages[$key] = $name; $this->pages[$key] = $name;
} }
} }
class HelpPageBuildingEvent extends Event class HelpPageBuildingEvent extends Event
@ -21,10 +20,9 @@ class HelpPageBuildingEvent extends Event
$this->key = $key; $this->key = $key;
} }
function add_block(Block $block, int $position = 50) public function add_block(Block $block, int $position = 50)
{
if(!array_key_exists("$position",$this->blocks))
{ {
if (!array_key_exists("$position", $this->blocks)) {
$this->blocks["$position"] = []; $this->blocks["$position"] = [];
} }
$this->blocks["$position"][] = $block; $this->blocks["$position"][] = $block;
@ -85,8 +83,8 @@ class HelpPages extends Extension
$event->add_link("Help", make_link("help")); $event->add_link("Help", make_link("help"));
} }
public function onHelpPageBuilding(HelpPageBuildingEvent $event) { public function onHelpPageBuilding(HelpPageBuildingEvent $event)
{
if ($event->key=="licenses") { if ($event->key=="licenses") {
$block = new Block("Software Licenses"); $block = new Block("Software Licenses");
$block->body = "The code in Shimmie is contributed by numerous authors under multiple licenses. For reference, these licenses are listed below. The base software is in general licensed under the GPLv2 license."; $block->body = "The code in Shimmie is contributed by numerous authors under multiple licenses. For reference, these licenses are listed below. The base software is in general licensed under the GPLv2 license.";
@ -472,8 +470,6 @@ SOFTWARE.</pre>";
</pre>"; </pre>";
$event->add_block($block); $event->add_block($block);
} }
} }
} }

View file

@ -2,7 +2,6 @@
class HelpPagesTheme extends Themelet class HelpPagesTheme extends Themelet
{ {
public function display_list_page(array $pages) public function display_list_page(array $pages)
{ {
global $page; global $page;
@ -27,5 +26,4 @@ class HelpPagesTheme extends Themelet
$page->set_title("Help - $title"); $page->set_title("Help - $title");
$page->set_heading("Help - $title"); $page->set_heading("Help - $title");
} }
} }

View file

@ -1,6 +1,7 @@
<?php <?php
abstract class ImageConfig { abstract class ImageConfig
{
const THUMB_ENGINE = 'thumb_engine'; const THUMB_ENGINE = 'thumb_engine';
const THUMB_WIDTH = 'thumb_width'; const THUMB_WIDTH = 'thumb_width';
const THUMB_HEIGHT = 'thumb_height'; const THUMB_HEIGHT = 'thumb_height';
@ -17,5 +18,4 @@ abstract class ImageConfig {
const COLLISION_MERGE = 'merge'; const COLLISION_MERGE = 'merge';
const COLLISION_ERROR = 'error'; const COLLISION_ERROR = 'error';
} }

View file

@ -7,7 +7,6 @@ require_once "config.php";
*/ */
class ImageIO extends Extension class ImageIO extends Extension
{ {
const COLLISION_OPTIONS = ['Error'=>ImageConfig::COLLISION_ERROR, 'Merge'=>ImageConfig::COLLISION_MERGE]; const COLLISION_OPTIONS = ['Error'=>ImageConfig::COLLISION_ERROR, 'Merge'=>ImageConfig::COLLISION_MERGE];
const EXIF_READ_FUNCTION = "exif_read_data"; const EXIF_READ_FUNCTION = "exif_read_data";
@ -243,7 +242,6 @@ class ImageIO extends Extension
} catch (MediaException $e) { } catch (MediaException $e) {
log_warning("add_image", "Error while running update_image_media_properties: ".$e->getMessage()); log_warning("add_image", "Error while running update_image_media_properties: ".$e->getMessage());
} }
} }
// }}} end add // }}} end add

View file

@ -108,10 +108,13 @@ class Index extends Extension
if (SPEED_HAX) { if (SPEED_HAX) {
if (!$user->can("big_search")) { if (!$user->can("big_search")) {
$fast_page_limit = 500; $fast_page_limit = 500;
if ($total_pages > $fast_page_limit) $total_pages = $fast_page_limit; if ($total_pages > $fast_page_limit) {
$total_pages = $fast_page_limit;
}
if ($page_number > $fast_page_limit) { if ($page_number > $fast_page_limit) {
$this->theme->display_error( $this->theme->display_error(
404, "Search limit hit", 404,
"Search limit hit",
"Only $fast_page_limit pages of results are searchable - " . "Only $fast_page_limit pages of results are searchable - " .
"if you want to find older results, use more specific search terms" "if you want to find older results, use more specific search terms"
); );

View file

@ -339,6 +339,5 @@ and of course start organising your images :-)
</ul> </ul>
</p> </p>
'; ';
} }
} }

View file

@ -11,7 +11,6 @@ abstract class MediaConfig
const CONVERT_PATH = "media_convert_path"; const CONVERT_PATH = "media_convert_path";
const VERSION = "ext_media_version"; const VERSION = "ext_media_version";
const MEM_LIMIT = 'media_mem_limit'; const MEM_LIMIT = 'media_mem_limit';
} }
abstract class MediaEngine abstract class MediaEngine
@ -98,14 +97,19 @@ class MediaResizeEvent extends Event
public $ignore_aspect_ratio; public $ignore_aspect_ratio;
public $allow_upscale; public $allow_upscale;
public function __construct(String $engine, string $input_path, string $input_type, string $output_path, public function __construct(
int $target_width, int $target_height, String $engine,
string $input_path,
string $input_type,
string $output_path,
int $target_width,
int $target_height,
bool $ignore_aspect_ratio = false, bool $ignore_aspect_ratio = false,
string $target_format = null, string $target_format = null,
int $target_quality = 80, int $target_quality = 80,
bool $minimize = false, bool $minimize = false,
bool $allow_upscale = true) bool $allow_upscale = true
{ ) {
assert(in_array($engine, MediaEngine::ALL)); assert(in_array($engine, MediaEngine::ALL));
$this->engine = $engine; $this->engine = $engine;
$this->input_path = $input_path; $this->input_path = $input_path;
@ -137,7 +141,6 @@ class MediaCheckPropertiesEvent extends Event
$this->file_name = $file_name; $this->file_name = $file_name;
$this->ext = $ext; $this->ext = $ext;
} }
} }
@ -186,7 +189,7 @@ class Media extends Extension
[0x52, 0x49, 0x46, 0x46, null, null, null, null, 0x57, 0x45, 0x42, 0x50, 0x56, 0x50, 0x38, 0x4C]; [0x52, 0x49, 0x46, 0x46, null, null, null, null, 0x57, 0x45, 0x42, 0x50, 0x56, 0x50, 0x38, 0x4C];
static function imagick_available(): bool public static function imagick_available(): bool
{ {
return extension_loaded("imagick"); return extension_loaded("imagick");
} }
@ -286,7 +289,6 @@ class Media extends Extension
$sb->end_table(); $sb->end_table();
$event->panel->add_block($sb); $event->panel->add_block($sb);
} }
public function onAdminBuilding(AdminBuildingEvent $event) public function onAdminBuilding(AdminBuildingEvent $event)
@ -368,7 +370,8 @@ class Media extends Extension
$event->target_format, $event->target_format,
$event->ignore_aspect_ratio, $event->ignore_aspect_ratio,
$event->target_quality, $event->target_quality,
$event->allow_upscale); $event->allow_upscale
);
break; break;
case MediaEngine::IMAGICK: case MediaEngine::IMAGICK:
@ -384,7 +387,8 @@ class Media extends Extension
$event->ignore_aspect_ratio, $event->ignore_aspect_ratio,
$event->target_quality, $event->target_quality,
$event->minimize, $event->minimize,
$event->allow_upscale); $event->allow_upscale
);
//} //}
break; break;
default: default:
@ -473,7 +477,8 @@ class Media extends Extension
"video" => $database->scoresql_value_prepare($mcpe->video), "video" => $database->scoresql_value_prepare($mcpe->video),
"audio" => $database->scoresql_value_prepare($mcpe->audio), "audio" => $database->scoresql_value_prepare($mcpe->audio),
"length" => $mcpe->length "length" => $mcpe->length
]); ]
);
} }
public function get_images(String $ext = null) public function get_images(String $ext = null)
@ -729,7 +734,8 @@ class Media extends Extension
// } // }
// } // }
public static function is_lossless(string $filename, string $format) { public static function is_lossless(string $filename, string $format)
{
if (in_array($format, self::LOSSLESS_FORMATS)) { if (in_array($format, self::LOSSLESS_FORMATS)) {
return true; return true;
} }
@ -752,8 +758,7 @@ class Media extends Extension
int $output_quality = 80, int $output_quality = 80,
bool $minimize = false, bool $minimize = false,
bool $allow_upscale = true bool $allow_upscale = true
): void ): void {
{
global $config; global $config;
$convert = $config->get_string(MediaConfig::CONVERT_PATH); $convert = $config->get_string(MediaConfig::CONVERT_PATH);
@ -840,8 +845,7 @@ class Media extends Extension
bool $ignore_aspect_ratio = false, bool $ignore_aspect_ratio = false,
int $output_quality = 80, int $output_quality = 80,
bool $allow_upscale = true bool $allow_upscale = true
) ) {
{
$width = $info[0]; $width = $info[0];
$height = $info[1]; $height = $info[1];
@ -1040,7 +1044,6 @@ class Media extends Extension
} else { } else {
throw new MediaException("Unable to open file for byte check: $file_name"); throw new MediaException("Unable to open file for byte check: $file_name");
} }
} }
public static function is_animated_webp(String $image_filename): bool public static function is_animated_webp(String $image_filename): bool
@ -1084,7 +1087,7 @@ class Media extends Extension
* @param $format * @param $format
* @return string|null The format name that the media extension will recognize. * @return string|null The format name that the media extension will recognize.
*/ */
static public function normalize_format(string $format, ?bool $lossless = null): ?string public static function normalize_format(string $format, ?bool $lossless = null): ?string
{ {
if ($format == "webp") { if ($format == "webp") {
if ($lossless === true) { if ($lossless === true) {
@ -1107,7 +1110,7 @@ class Media extends Extension
* @param string $filename * @param string $filename
* @return array [width, height] * @return array [width, height]
*/ */
static public function video_size(string $filename): array public static function video_size(string $filename): array
{ {
global $config; global $config;
$ffmpeg = $config->get_string(MediaConfig::FFMPEG_PATH); $ffmpeg = $config->get_string(MediaConfig::FFMPEG_PATH);
@ -1132,5 +1135,4 @@ class Media extends Extension
log_debug('Media', "Getting video size with `$cmd`, returns $output -- $size[0], $size[1]"); log_debug('Media', "Getting video size with `$cmd`, returns $output -- $size[0], $size[1]");
return $size; return $size;
} }
} }

View file

@ -42,6 +42,5 @@ class MediaTheme extends Themelet
</div> </div>
<p>These search terms depend on the items being scanned for media content. Automatic scanning was implemented in mid-2019, so items uploaded before, or items uploaded on a system without ffmpeg, will require additional scanning before this will work.</p> <p>These search terms depend on the items being scanned for media content. Automatic scanning was implemented in mid-2019, so items uploaded before, or items uploaded on a system without ffmpeg, will require additional scanning before this will work.</p>
'; ';
} }
} }

View file

@ -269,7 +269,5 @@ class NotesTheme extends Themelet
<p>Returns images with note(s) by user 123.</p> <p>Returns images with note(s) by user 123.</p>
</div> </div>
'; ';
} }
} }

View file

@ -300,7 +300,6 @@ class NumericScore extends Extension
$event->add_nav_link("numeric_score_day", new Link('popular_by_day'), "Popular by Day"); $event->add_nav_link("numeric_score_day", new Link('popular_by_day'), "Popular by Day");
$event->add_nav_link("numeric_score_month", new Link('popular_by_month'), "Popular by Month"); $event->add_nav_link("numeric_score_month", new Link('popular_by_month'), "Popular by Month");
$event->add_nav_link("numeric_score_year", new Link('popular_by_year'), "Popular by Year"); $event->add_nav_link("numeric_score_year", new Link('popular_by_year'), "Popular by Year");
} }
} }

View file

@ -132,6 +132,5 @@ class NumericScoreTheme extends Themelet
<p>Sorts the search results by score, ascending.</p> <p>Sorts the search results by score, ascending.</p>
</div> </div>
'; ';
} }
} }

View file

@ -37,7 +37,6 @@ class PoolAddPostsEvent extends Event
$this->pool_id = $pool_id; $this->pool_id = $pool_id;
$this->posts = $posts; $this->posts = $posts;
} }
} }
class PoolCreationEvent extends Event class PoolCreationEvent extends Event
@ -58,7 +57,6 @@ class PoolCreationEvent extends Event
$this->public = $public; $this->public = $public;
$this->description = $description; $this->description = $description;
} }
} }
class Pools extends Extension class Pools extends Extension
@ -189,7 +187,8 @@ class Pools extends Extension
$title, $title,
$user, $user,
$_POST["public"] === "Y", $_POST["public"] === "Y",
$_POST["description"]); $_POST["description"]
);
send_event($event); send_event($event);
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
@ -452,7 +451,8 @@ class Pools extends Extension
if ($this->have_permission($user, $pool)) { if ($this->have_permission($user, $pool)) {
send_event( send_event(
new PoolAddPostsEvent($pool_id,iterator_map_to_array("image_to_id", $event->items))); new PoolAddPostsEvent($pool_id, iterator_map_to_array("image_to_id", $event->items))
);
} }
break; break;
case "bulk_pool_add_new": case "bulk_pool_add_new":

View file

@ -429,6 +429,5 @@ class PoolsTheme extends Themelet
<p>Returns images in the "swimming pool" pool. Note that the underscore becomes a space</p> <p>Returns images in the "swimming pool" pool. Note that the underscore becomes a space</p>
</div> </div>
'; ';
} }
} }

View file

@ -3,8 +3,6 @@ class PostTitlesTheme extends Themelet
{ {
public function get_title_set_html(string $title, bool $can_set): string public function get_title_set_html(string $title, bool $can_set): string
{ {
$html = " $html = "
<tr> <tr>
<th>Title</th> <th>Title</th>

View file

@ -134,7 +134,6 @@ class Relationships extends Extension
if ($old_parent!=$event->parent_id) { if ($old_parent!=$event->parent_id) {
if ($database->get_row("SELECT 1 FROM images WHERE id = :pid", ["pid" => $event->parent_id])) { if ($database->get_row("SELECT 1 FROM images WHERE id = :pid", ["pid" => $event->parent_id])) {
$result = $database->execute("UPDATE images SET parent_id = :pid WHERE id = :cid", ["pid" => $event->parent_id, "cid" => $event->child_id]); $result = $database->execute("UPDATE images SET parent_id = :pid WHERE id = :cid", ["pid" => $event->parent_id, "cid" => $event->child_id]);
if ($result->rowCount() > 0) { if ($result->rowCount() > 0) {
@ -184,9 +183,7 @@ class Relationships extends Extension
$database->execute( $database->execute(
"UPDATE images SET has_children = EXISTS (SELECT 1 FROM images WHERE parent_id = :pid) WHERE id = :pid", "UPDATE images SET has_children = EXISTS (SELECT 1 FROM images WHERE parent_id = :pid) WHERE id = :pid",
["pid"=>$parent_id]); ["pid"=>$parent_id]
);
} }
} }

View file

@ -72,6 +72,5 @@ class RelationshipsTheme extends Themelet
<p>Returns images that have no children.</p> <p>Returns images that have no children.</p>
</div> </div>
'; ';
} }
} }

View file

@ -19,5 +19,4 @@ class RSS_CommentsInfo extends ExtensionInfo
public $license = self::LICENSE_GPLV2; public $license = self::LICENSE_GPLV2;
public $description = "Self explanatory"; public $description = "Self explanatory";
public $db_support = [DatabaseDriver::MYSQL, DatabaseDriver::SQLITE]; // pgsql has no UNIX_TIMESTAMP public $db_support = [DatabaseDriver::MYSQL, DatabaseDriver::SQLITE]; // pgsql has no UNIX_TIMESTAMP
} }

View file

@ -77,5 +77,4 @@ EOD;
$event->add_nav_link("comment_rss", new Link('rss/comments'), "Feed"); $event->add_nav_link("comment_rss", new Link('rss/comments'), "Feed");
} }
} }
} }

View file

@ -9,7 +9,6 @@ if ( // kill these glitched requests immediately
class Rule34 extends Extension class Rule34 extends Extension
{ {
public function onImageDeletion(ImageDeletionEvent $event) public function onImageDeletion(ImageDeletionEvent $event)
{ {
global $database; global $database;

View file

@ -136,20 +136,33 @@ class SetupBlock extends Block
private function format_option(string $name, $html, ?string $label, bool $table_row) { private function format_option(string $name, $html, ?string $label, bool $table_row)
{
global $config; global $config;
if($table_row) $this->start_table_row(); if ($table_row) {
if($table_row) $this->start_table_header_cell(); $this->start_table_row();
}
if ($table_row) {
$this->start_table_header_cell();
}
if (!is_null($label)) { if (!is_null($label)) {
$this->body .= "<label for='{$name}'>{$label}</label>"; $this->body .= "<label for='{$name}'>{$label}</label>";
} }
if($table_row) $this->end_table_header_cell(); if ($table_row) {
$this->end_table_header_cell();
}
if($table_row) $this->start_table_cell(); if ($table_row) {
$this->start_table_cell();
}
$this->body .= $html; $this->body .= $html;
if($table_row) $this->end_table_cell(); if ($table_row) {
if($table_row) $this->end_table_row(); $this->end_table_cell();
}
if ($table_row) {
$this->end_table_row();
}
} }
public function add_text_option(string $name, string $label=null, bool $table_row = false) public function add_text_option(string $name, string $label=null, bool $table_row = false)
@ -210,7 +223,6 @@ class SetupBlock extends Block
$html .= "<input type='hidden' name='_type_$name' value='int'>\n"; $html .= "<input type='hidden' name='_type_$name' value='int'>\n";
$this->format_option($name, $html, $label, $table_row); $this->format_option($name, $html, $label, $table_row);
} }
public function add_shorthand_int_option(string $name, string $label=null, bool $table_row = false) public function add_shorthand_int_option(string $name, string $label=null, bool $table_row = false)

View file

@ -20,6 +20,4 @@ class System extends Extension
{ {
$event->add_nav_link("system", new Link('system'), "System"); $event->add_nav_link("system", new Link('system'), "System");
} }
} }

View file

@ -70,7 +70,8 @@ class TagCategories extends Extension
$count = $matches[3]; $count = $matches[3];
$types = $database->get_col( $types = $database->get_col(
$database->scoreql_to_sql('SELECT SCORE_STRNORM(category) FROM image_tag_categories')); $database->scoreql_to_sql('SELECT SCORE_STRNORM(category) FROM image_tag_categories')
);
if (in_array($type, $types)) { if (in_array($type, $types)) {
$event->add_querylet( $event->add_querylet(
new Querylet($database->scoreql_to_sql("EXISTS ( new Querylet($database->scoreql_to_sql("EXISTS (

View file

@ -113,6 +113,5 @@ class TagCategoriesTheme extends Themelet
<p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p> <p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p>
<p>Category name is not case sensitive, category must exist for search to work.</p> <p>Category name is not case sensitive, category must exist for search to work.</p>
'; ';
} }
} }

View file

@ -5,7 +5,7 @@ class TagListConfig
{ {
public const LENGTH = "tag_list_length"; public const LENGTH = "tag_list_length";
public const POPULAR_TAG_LIST_LENGTH = "popular_tag_list_length"; public const POPULAR_TAG_LIST_LENGTH = "popular_tag_list_length";
public CONSt TAGS_MIN = "tags_min"; public const TAGS_MIN = "tags_min";
public const INFO_LINK = "info_link"; public const INFO_LINK = "info_link";
public const IMAGE_TYPE = "tag_list_image_type"; public const IMAGE_TYPE = "tag_list_image_type";
public const RELATED_SORT = "tag_list_related_sort"; public const RELATED_SORT = "tag_list_related_sort";

View file

@ -137,15 +137,24 @@ class TagList extends Extension
$sb->start_table(); $sb->start_table();
$sb->add_text_option(TagListConfig::INFO_LINK, "Tag info link", true); $sb->add_text_option(TagListConfig::INFO_LINK, "Tag info link", true);
$sb->add_text_option(TagListConfig::OMIT_TAGS, "Omit tags", true); $sb->add_text_option(TagListConfig::OMIT_TAGS, "Omit tags", true);
$sb->add_choice_option(TagListConfig::IMAGE_TYPE, $sb->add_choice_option(
TagListConfig::IMAGE_TYPE,
TagListConfig::TYPE_CHOICES, TagListConfig::TYPE_CHOICES,
"Image tag list", true); "Image tag list",
$sb->add_choice_option(TagListConfig::RELATED_SORT, true
);
$sb->add_choice_option(
TagListConfig::RELATED_SORT,
TagListConfig::SORT_CHOICES, TagListConfig::SORT_CHOICES,
"Sort related list by", true); "Sort related list by",
$sb->add_choice_option(TagListConfig::POPULAR_SORT, true
);
$sb->add_choice_option(
TagListConfig::POPULAR_SORT,
TagListConfig::SORT_CHOICES, TagListConfig::SORT_CHOICES,
"Sort popular list by", true); "Sort popular list by",
true
);
$sb->add_bool_option("tag_list_numbers", "Show tag counts", true); $sb->add_bool_option("tag_list_numbers", "Show tag counts", true);
$sb->end_table(); $sb->end_table();
$event->panel->add_block($sb); $event->panel->add_block($sb);
@ -200,13 +209,11 @@ class TagList extends Extension
} else { } else {
$where[] = " tag LIKE :$arg "; $where[] = " tag LIKE :$arg ";
} }
} }
$results = $database->get_col("SELECT id FROM tags WHERE " . implode(" OR ", $where), $args); $results = $database->get_col("SELECT id FROM tags WHERE " . implode(" OR ", $where), $args);
$database->cache->set("tag_list_omitted_tags:" . $tags_config, $results, 600); $database->cache->set("tag_list_omitted_tags:" . $tags_config, $results, 600);
} }
return $results; return $results;
} }
@ -538,7 +545,6 @@ class TagList extends Extension
ORDER BY count DESC ORDER BY count DESC
LIMIT :popular_tag_list_length LIMIT :popular_tag_list_length
"; ";
} else { } else {
$query = " $query = "
SELECT tag, count SELECT tag, count
@ -643,14 +649,12 @@ class TagList extends Extension
$related_tags = $database->get_all($query, $args); $related_tags = $database->get_all($query, $args);
$database->cache->set("related_tags:$str_search", $related_tags, 60 * 60); $database->cache->set("related_tags:$str_search", $related_tags, 60 * 60);
} }
} }
if ($related_tags === false) { if ($related_tags === false) {
return []; return [];
} else { } else {
return $related_tags; return $related_tags;
} }
} }

View file

@ -2,7 +2,6 @@
class Tips extends Extension class Tips extends Extension
{ {
public function onInitExt(InitExtEvent $event) public function onInitExt(InitExtEvent $event)
{ {
global $config, $database; global $config, $database;

View file

@ -10,8 +10,13 @@ class TranscodeImageTheme extends Themelet
global $config; global $config;
$html = " $html = "
".make_form(make_link("transcode/{$image->id}"), 'POST', false, "", ".make_form(
"return transcodeSubmit()")." make_link("transcode/{$image->id}"),
'POST',
false,
"",
"return transcodeSubmit()"
)."
<input type='hidden' name='image_id' value='{$image->id}'> <input type='hidden' name='image_id' value='{$image->id}'>
<input type='hidden' id='image_lossless' name='image_lossless' value='{$image->lossless}'> <input type='hidden' id='image_lossless' name='image_lossless' value='{$image->lossless}'>
".$this->get_transcode_picker_html($options)." ".$this->get_transcode_picker_html($options)."

View file

@ -7,7 +7,6 @@ abstract class TrashConfig
class Trash extends Extension class Trash extends Extension
{ {
public function get_priority(): int public function get_priority(): int
{ {
// Needs to be early to intercept delete events // Needs to be early to intercept delete events
@ -108,13 +107,14 @@ class Trash extends Extension
return true; return true;
} }
public static function set_trash($image_id, $trash) { public static function set_trash($image_id, $trash)
{
global $database; global $database;
$database->execute("UPDATE images SET trash = :trash WHERE id = :id", $database->execute(
["trash"=>$database->scoresql_value_prepare($trash),"id"=>$image_id]); "UPDATE images SET trash = :trash WHERE id = :id",
["trash"=>$database->scoresql_value_prepare($trash),"id"=>$image_id]
);
} }
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
{ {
@ -163,7 +163,5 @@ class Trash extends Extension
$database->Execute("CREATE INDEX images_trash_idx ON images(trash)"); $database->Execute("CREATE INDEX images_trash_idx ON images(trash)");
$config->set_int(TrashConfig::VERSION, 1); $config->set_int(TrashConfig::VERSION, 1);
} }
} }
} }

View file

@ -2,7 +2,8 @@
class TrashTheme extends Themelet class TrashTheme extends Themelet
{ {
function get_image_admin_html(int $image_id) { public function get_image_admin_html(int $image_id)
{
$html = " $html = "
".make_form(make_link('trash_restore/'.$image_id), 'POST')." ".make_form(make_link('trash_restore/'.$image_id), 'POST')."
<input type='hidden' name='image_id' value='$image_id'> <input type='hidden' name='image_id' value='$image_id'>
@ -10,7 +11,8 @@ class TrashTheme extends Themelet
</form> </form>
"; ";
return $html; } return $html;
}
public function get_help_html() public function get_help_html()
@ -21,6 +23,5 @@ class TrashTheme extends Themelet
<p>Returns images that are in the trash.</p> <p>Returns images that are in the trash.</p>
</div> </div>
'; ';
} }
} }

View file

@ -213,7 +213,6 @@ class Upgrade extends Extension
log_info("upgrade", "Database at version 17"); log_info("upgrade", "Database at version 17");
$config->set_bool("in_upgrade", false); $config->set_bool("in_upgrade", false);
} }
} }
public function get_priority(): int public function get_priority(): int

View file

@ -242,7 +242,6 @@ class UserPageTheme extends Themelet
$page->set_heading(html_escape($duser->name)."'s Page"); $page->set_heading(html_escape($duser->name)."'s Page");
$page->add_block(new NavBlock()); $page->add_block(new NavBlock());
$page->add_block(new Block("Stats", join("<br>", $stats), "main", 10)); $page->add_block(new Block("Stats", join("<br>", $stats), "main", 10));
} }
public function build_options(User $duser, UserOptionsBuildingEvent $event) public function build_options(User $duser, UserOptionsBuildingEvent $event)
@ -337,7 +336,6 @@ class UserPageTheme extends Themelet
foreach ($event->parts as $part) { foreach ($event->parts as $part) {
$html .= $part; $html .= $part;
} }
} }
return $html; return $html;
} }

View file

@ -44,7 +44,6 @@ class UserConfig extends Extension
global $config, $database; global $config, $database;
if ($config->get_int(self::VERSION, 0) < 1) { if ($config->get_int(self::VERSION, 0) < 1) {
log_info("upgrade", "Adding user config table"); log_info("upgrade", "Adding user config table");
$database->create_table("user_config", " $database->create_table("user_config", "

View file

@ -26,7 +26,8 @@ class DisplayingImageEvent extends Event
return $this->image; return $this->image;
} }
public function set_title(String $title) { public function set_title(String $title)
{
$this->title = $title; $this->title = $title;
} }
} }