diff --git a/core/database.php b/core/database.php index a68acdd3..535548a7 100644 --- a/core/database.php +++ b/core/database.php @@ -186,7 +186,7 @@ class Database public function execute(string $query, array $args=[], bool $scoreql = false): PDOStatement { try { - if($scoreql===true) { + if ($scoreql===true) { $query = $this->scoreql_to_sql($query); } @@ -222,7 +222,7 @@ class Database */ public function get_all(string $query, array $args=[], bool $scoreql = false): array { - if($scoreql===true) { + if ($scoreql===true) { $query = $this->scoreql_to_sql($query); } @@ -237,7 +237,7 @@ class Database */ public function get_all_iterable(string $query, array $args=[], bool $scoreql = false): PDOStatement { - if($scoreql===true) { + if ($scoreql===true) { $query = $this->scoreql_to_sql($query); } $_start = microtime(true); @@ -251,7 +251,7 @@ class Database */ public function get_row(string $query, array $args=[], bool $scoreql = false): ?array { - if($scoreql===true) { + if ($scoreql===true) { $query = $this->scoreql_to_sql($query); } $_start = microtime(true); @@ -266,7 +266,7 @@ class Database */ public function exists(string $query, array $args=[], bool $scoreql = false): bool { - if($scoreql===true) { + if ($scoreql===true) { $query = $this->scoreql_to_sql($query); } $_start = microtime(true); @@ -280,7 +280,7 @@ class Database */ public function get_col(string $query, array $args=[], bool $scoreql = false): array { - if($scoreql===true) { + if ($scoreql===true) { $query = $this->scoreql_to_sql($query); } $_start = microtime(true); @@ -294,7 +294,7 @@ class Database */ public function get_col_iterable(string $query, array $args=[], bool $scoreql = false): Generator { - if($scoreql===true) { + if ($scoreql===true) { $query = $this->scoreql_to_sql($query); } $_start = microtime(true); @@ -310,7 +310,7 @@ class Database */ public function get_pairs(string $query, array $args=[], bool $scoreql = false): array { - if($scoreql===true) { + if ($scoreql===true) { $query = $this->scoreql_to_sql($query); } $_start = microtime(true); @@ -324,7 +324,7 @@ class Database */ public function get_one(string $query, array $args=[], bool $scoreql = false) { - if($scoreql===true) { + if ($scoreql===true) { $query = $this->scoreql_to_sql($query); } $_start = microtime(true); diff --git a/core/dbengine.php b/core/dbengine.php index e72c734b..86b1a9d6 100644 --- a/core/dbengine.php +++ b/core/dbengine.php @@ -34,7 +34,7 @@ abstract class DBEngine return 'CREATE TABLE '.$name.' ('.$data.')'; } - public abstract function set_timeout(PDO $db, int $time); + abstract public function set_timeout(PDO $db, int $time); } class MySQL extends DBEngine @@ -76,7 +76,6 @@ class MySQL extends DBEngine // These only apply to read-only queries, which appears to be the best we can to mysql-wise $db->exec("SET SESSION MAX_EXECUTION_TIME=".$time.";"); } - } class PostgreSQL extends DBEngine @@ -123,7 +122,6 @@ class PostgreSQL extends DBEngine { $db->exec("SET statement_timeout TO ".$time.";"); } - } // shimmie functions for export to sqlite diff --git a/core/imageboard/image.php b/core/imageboard/image.php index f5c84011..7a66ec04 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -151,7 +151,7 @@ class Image if (!$result) { $querylet = Image::build_search_querylet($tag_conditions, $img_conditions); $querylet->append(new Querylet(" ORDER BY ".(Image::$order_sql ?: "images.".$config->get_string(IndexConfig::ORDER)))); - if($limit!=null) { + if ($limit!=null) { $querylet->append(new Querylet(" LIMIT :limit ", ["limit" => $limit])); $querylet->append(new Querylet(" OFFSET :offset ", ["offset"=>$start])); } @@ -730,9 +730,11 @@ class Image "INSERT INTO tags(tag) VALUES (:tag)", ["tag"=>$tag] ); - $database->execute($database->scoreql_to_sql( + $database->execute( + $database->scoreql_to_sql( "INSERT INTO image_tags(image_id, tag_id) - VALUES(:id, (SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)))"), + VALUES(:id, (SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)))" + ), ["id"=>$this->id, "tag"=>$tag] ); } else { diff --git a/core/imageboard/tag.php b/core/imageboard/tag.php index ae1146cd..0deeeef7 100644 --- a/core/imageboard/tag.php +++ b/core/imageboard/tag.php @@ -101,18 +101,18 @@ class Tag public static function compare(array $tags1, array $tags2): bool { - if(count($tags1)!==count($tags2)) { + if (count($tags1)!==count($tags2)) { return false; } - $tags1 = array_map("strtolower",$tags1); - $tags2 = array_map("strtolower",$tags2); + $tags1 = array_map("strtolower", $tags1); + $tags2 = array_map("strtolower", $tags2); natcasesort($tags1); natcasesort($tags2); - for($i = 0; $i < count($tags1); $i++) { - if($tags1[$i]!==$tags2[$i]) { + for ($i = 0; $i < count($tags1); $i++) { + if ($tags1[$i]!==$tags2[$i]) { var_dump($tags1); var_dump($tags2); return false; @@ -140,7 +140,7 @@ class Tag foreach ($tags as $tag) { try { $tag = Tag::sanitize($tag); - } catch(Exception $e) { + } catch (Exception $e) { flash_message($e->getMessage()); continue; } diff --git a/core/permissions.php b/core/permissions.php index 66b92b7c..84eb292e 100644 --- a/core/permissions.php +++ b/core/permissions.php @@ -83,5 +83,4 @@ abstract class Permissions public const CRON_ADMIN = "cron_admin"; public const APPROVE_IMAGE = "approve_image"; public const APPROVE_COMMENT = "approve_comment"; - } diff --git a/core/util.php b/core/util.php index b79a2238..44f05c6c 100644 --- a/core/util.php +++ b/core/util.php @@ -352,16 +352,18 @@ function join_url(string $base, string ...$paths) function get_dir_contents(string $dir): array { - if(empty($dir)) { + if (empty($dir)) { throw new Exception("dir required"); } - if(!is_dir($dir)) { + if (!is_dir($dir)) { return []; } $results = array_diff( scandir( - $dir), - ['..', '.']); + $dir + ), + ['..', '.'] + ); return $results; } @@ -378,7 +380,8 @@ function scan_dir(string $path): array $path, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | - FilesystemIterator::SKIP_DOTS); + FilesystemIterator::SKIP_DOTS + ); foreach (new RecursiveIteratorIterator($ite) as $filename => $cur) { try { $filesize = $cur->getSize(); diff --git a/ext/approval/main.php b/ext/approval/main.php index 05e7b426..f012b2e0 100644 --- a/ext/approval/main.php +++ b/ext/approval/main.php @@ -74,20 +74,23 @@ class Approval extends Extension $action = $event->action; $event->redirect = true; - if($action==="approval") { + if ($action==="approval") { $approval_action = $_POST["approval_action"]; switch ($approval_action) { case "approve_all": $database->set_timeout(300000); // These updates can take a little bit - $database->execute($database->scoreql_to_sql( - "UPDATE images SET approved = SCORE_BOOL_Y, approved_by_id = :approved_by_id WHERE approved = SCORE_BOOL_N"), + $database->execute( + $database->scoreql_to_sql( + "UPDATE images SET approved = SCORE_BOOL_Y, approved_by_id = :approved_by_id WHERE approved = SCORE_BOOL_N" + ), ["approved_by_id"=>$user->id] ); break; case "disapprove_all": $database->set_timeout(300000); // These updates can take a little bit $database->execute($database->scoreql_to_sql( - "UPDATE images SET approved = SCORE_BOOL_N, approved_by_id = NULL WHERE approved = SCORE_BOOL_Y")); + "UPDATE images SET approved = SCORE_BOOL_N, approved_by_id = NULL WHERE approved = SCORE_BOOL_Y" + )); break; default: @@ -100,7 +103,7 @@ class Approval extends Extension { global $user, $page, $config; - if ( $config->get_bool(ApprovalConfig::IMAGES) && $event->image->approved===false && !$user->can(Permissions::APPROVE_IMAGE)) { + if ($config->get_bool(ApprovalConfig::IMAGES) && $event->image->approved===false && !$user->can(Permissions::APPROVE_IMAGE)) { $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link("post/list")); } @@ -109,9 +112,9 @@ class Approval extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if($event->parent=="posts") { - if($user->can(Permissions::APPROVE_IMAGE)) { - $event->add_nav_link("posts_unapproved", new Link('/post/list/approved%3Ano/1'), "Pending Approval",null, 60); + if ($event->parent=="posts") { + if ($user->can(Permissions::APPROVE_IMAGE)) { + $event->add_nav_link("posts_unapproved", new Link('/post/list/approved%3Ano/1'), "Pending Approval", null, 60); } } } @@ -122,7 +125,7 @@ class Approval extends Extension { global $user, $database, $config; - if($config->get_bool(ApprovalConfig::IMAGES)) { + if ($config->get_bool(ApprovalConfig::IMAGES)) { $matches = []; if (is_null($event->term) && $this->no_approval_query($event->context)) { @@ -168,8 +171,10 @@ class Approval extends Extension { global $database, $user; - $database->execute($database->scoreql_to_sql( - "UPDATE images SET approved = SCORE_BOOL_Y, approved_by_id = :approved_by_id WHERE id = :id AND approved = SCORE_BOOL_N"), + $database->execute( + $database->scoreql_to_sql( + "UPDATE images SET approved = SCORE_BOOL_Y, approved_by_id = :approved_by_id WHERE id = :id AND approved = SCORE_BOOL_N" + ), ["approved_by_id"=>$user->id, "id"=>$image_id] ); } @@ -178,8 +183,10 @@ class Approval extends Extension { global $database, $user; - $database->execute($database->scoreql_to_sql( - "UPDATE images SET approved = SCORE_BOOL_N, approved_by_id = NULL WHERE id = :id AND approved = SCORE_BOOL_Y"), + $database->execute( + $database->scoreql_to_sql( + "UPDATE images SET approved = SCORE_BOOL_N, approved_by_id = NULL WHERE id = :id AND approved = SCORE_BOOL_Y" + ), ["id"=>$image_id] ); } @@ -187,7 +194,7 @@ class Approval extends Extension public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { global $user, $config; - if($user->can(Permissions::APPROVE_IMAGE) && $config->get_bool(ApprovalConfig::IMAGES)) { + if ($user->can(Permissions::APPROVE_IMAGE) && $config->get_bool(ApprovalConfig::IMAGES)) { $event->add_part($this->theme->get_image_admin_html($event->image)); } } @@ -197,7 +204,7 @@ class Approval extends Extension global $user, $config; if ($user->can(Permissions::APPROVE_IMAGE)&& $config->get_bool(ApprovalConfig::IMAGES)) { - if(in_array("approved:no", $event->search_terms)) { + if (in_array("approved:no", $event->search_terms)) { $event->add_action("bulk_approve_image", "Approve", "a"); } else { $event->add_action("bulk_disapprove_image", "Disapprove"); diff --git a/ext/approval/theme.php b/ext/approval/theme.php index 0879d1b1..b7ca5b23 100644 --- a/ext/approval/theme.php +++ b/ext/approval/theme.php @@ -4,7 +4,7 @@ class ApprovalTheme extends Themelet { public function get_image_admin_html(Image $image) { - if($image->approved===true) { + if ($image->approved===true) { $html = " ".make_form(make_link('disapprove_image/'.$image->id), 'POST')." diff --git a/ext/artists/main.php b/ext/artists/main.php index e0a4cf7e..2fbd3500 100644 --- a/ext/artists/main.php +++ b/ext/artists/main.php @@ -905,7 +905,7 @@ class Artists extends Extension $pageNumber * $artistsPerPage , $artistsPerPage ] - ); + ); $number_of_listings = count($listing); diff --git a/ext/bulk_remove/main.php b/ext/bulk_remove/main.php index 1d2517b3..50ea8edb 100644 --- a/ext/bulk_remove/main.php +++ b/ext/bulk_remove/main.php @@ -123,7 +123,7 @@ class BulkRemove extends Extension $page->add_block(new Block( "Bulk Remove Error", "Please use Board Admin to use bulk remove." - )); + )); } // diff --git a/ext/cron_uploader/config.php b/ext/cron_uploader/config.php index c749d635..aa6637dc 100644 --- a/ext/cron_uploader/config.php +++ b/ext/cron_uploader/config.php @@ -22,7 +22,6 @@ abstract class CronUploaderConfig $config->set_string(self::KEY, $upload_key); } - } public static function get_user(): int diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index 38ff3e8c..49f4f171 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -22,7 +22,7 @@ class CronUploader extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if($event->parent=="system") { + if ($event->parent=="system") { $event->add_nav_link("cron_docs", new Link('cron_upload'), "Cron Upload"); } } @@ -58,7 +58,7 @@ class CronUploader extends Extension $sb->add_int_option(CronUploaderConfig::COUNT, "Upload per run", true); $sb->add_text_option(CronUploaderConfig::DIR, "Root dir", true); $sb->add_text_option(CronUploaderConfig::KEY, "Key", true); - $sb->add_choice_option(CronUploaderConfig::USER, $users,"User", true); + $sb->add_choice_option(CronUploaderConfig::USER, $users, "User", true); $sb->end_table(); $sb->add_label("Read the documentation for cron setup instructions."); @@ -130,7 +130,7 @@ class CronUploader extends Extension $results = get_dir_contents($stage_dir); if (count($results) == 0) { - if(rmdir($stage_dir)===false) { + if (rmdir($stage_dir)===false) { flash_message("Nothing to stage from $folder, cannot remove folder"); } else { flash_message("Nothing to stage from $folder, removing folder"); @@ -203,24 +203,29 @@ class CronUploader extends Extension } $this->theme->display_documentation( - $running, $queue_dirinfo, $uploaded_dirinfo, $failed_dirinfo, - $this->get_cron_cmd(), $this->get_cron_url(), $logs + $running, + $queue_dirinfo, + $uploaded_dirinfo, + $failed_dirinfo, + $this->get_cron_cmd(), + $this->get_cron_url(), + $logs ); } - function get_queue_dir() + public function get_queue_dir() { $dir = CronUploaderConfig::get_dir(); return join_path($dir, self::QUEUE_DIR); } - function get_uploaded_dir() + public function get_uploaded_dir() { $dir = CronUploaderConfig::get_dir(); return join_path($dir, self::UPLOADED_DIR); } - function get_failed_dir() + public function get_failed_dir() { $dir = CronUploaderConfig::get_dir(); return join_path($dir, self::FAILED_DIR); @@ -262,7 +267,7 @@ class CronUploader extends Extension throw new SCoreException("Cron upload key incorrect"); } $user_id = CronUploaderConfig::get_user(); - if(empty($user_id)) { + if (empty($user_id)) { throw new SCoreException("Cron upload user not set"); } $user = User::by_id($user_id); @@ -329,8 +334,6 @@ class CronUploader extends Extension $this->move_uploaded($img[0], $img[1], $output_subdir, true); $this->log_message(SCORE_LOG_ERROR, "(" . gettype($e) . ") " . $e->getMessage()); $this->log_message(SCORE_LOG_ERROR, $e->getTraceAsString()); - - } } @@ -348,14 +351,13 @@ class CronUploader extends Extension flock($lockfile, LOCK_UN); fclose($lockfile); } - } private function move_uploaded(string $path, string $filename, string $output_subdir, bool $corrupt = false) { $relativeDir = dirname(substr($path, strlen(CronUploaderConfig::get_dir()) + 7)); - if($relativeDir==".") { + if ($relativeDir==".") { $relativeDir = ""; } @@ -424,10 +426,11 @@ class CronUploader extends Extension private const PARTIAL_DOWNLOAD_EXTENSIONS = ['crdownload','part']; - private function is_skippable_file(string $path) { + private function is_skippable_file(string $path) + { $info = pathinfo($path); - if(in_array(strtolower($info['extension']),self::PARTIAL_DOWNLOAD_EXTENSIONS)) { + if (in_array(strtolower($info['extension']), self::PARTIAL_DOWNLOAD_EXTENSIONS)) { return true; } @@ -499,4 +502,3 @@ class CronUploader extends Extension $page->set_data(implode("\r\n", $this->output_buffer)); } } - diff --git a/ext/cron_uploader/theme.php b/ext/cron_uploader/theme.php index 8c438d23..0b53dbf8 100644 --- a/ext/cron_uploader/theme.php +++ b/ext/cron_uploader/theme.php @@ -2,9 +2,15 @@ class CronUploaderTheme extends Themelet { - public function display_documentation(bool $running, array $queue_dirinfo, array $uploaded_dirinfo, array $failed_dirinfo, - string $cron_cmd, string $cron_url, ?array $log_entries) - { + public function display_documentation( + bool $running, + array $queue_dirinfo, + array $uploaded_dirinfo, + array $failed_dirinfo, + string $cron_cmd, + string $cron_url, + ?array $log_entries + ) { global $page; @@ -51,7 +57,7 @@ class CronUploaderTheme extends Themelet
When you create the cron job, you choose when to upload new images. "; - $usage_html = "Upload your images you want to be uploaded to the queue directory using your FTP client or other means. + $usage_html = "Upload your images you want to be uploaded to the queue directory using your FTP client or other means.
({$queue_dirinfo['path']})
  1. Any sub-folders will be turned into tags.
  2. @@ -81,9 +87,9 @@ class CronUploaderTheme extends Themelet $page->add_block($block_install); $page->add_block($block_usage); - if(!empty($log_entries)) { + if (!empty($log_entries)) { $log_html = ""; - foreach($log_entries as $entry) { + foreach ($log_entries as $entry) { $log_html .= ""; } $log_html .= "
    {$entry["date_sent"]}{$entry["message"]}
    "; @@ -111,13 +117,13 @@ class CronUploaderTheme extends Themelet $html .= ""; $html .= ""; - $html .= make_form(make_link("admin/cron_uploader_clear_queue"), "POST",false,"","return confirm('Are you sure you want to delete everything in the queue folder?');") + $html .= make_form(make_link("admin/cron_uploader_clear_queue"), "POST", false, "", "return confirm('Are you sure you want to delete everything in the queue folder?');") ."
    " ."
    "; - $html .= make_form(make_link("admin/cron_uploader_clear_uploaded"), "POST",false,"","return confirm('Are you sure you want to delete everything in the uploaded folder?');") + $html .= make_form(make_link("admin/cron_uploader_clear_uploaded"), "POST", false, "", "return confirm('Are you sure you want to delete everything in the uploaded folder?');") ."
    " ."
    "; - $html .= make_form(make_link("admin/cron_uploader_clear_failed"), "POST",false,"","return confirm('Are you sure you want to delete everything in the failed folder?');") + $html .= make_form(make_link("admin/cron_uploader_clear_failed"), "POST", false, "", "return confirm('Are you sure you want to delete everything in the failed folder?');") ."
    " ."
    "; $html .= "\n"; diff --git a/ext/danbooru_api/main.php b/ext/danbooru_api/main.php index b7aa61ea..dfbce69a 100644 --- a/ext/danbooru_api/main.php +++ b/ext/danbooru_api/main.php @@ -90,8 +90,10 @@ class DanbooruApi extends Extension } elseif (isset($_GET['name'])) { $namelist = explode(",", $_GET['name']); foreach ($namelist as $name) { - $sqlresult = $database->get_all($database->scoreql_to_sql( - "SELECT id,tag,count FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(?)"), + $sqlresult = $database->get_all( + $database->scoreql_to_sql( + "SELECT id,tag,count FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(?)" + ), [$name] ); foreach ($sqlresult as $row) { diff --git a/ext/downtime/theme.php b/ext/downtime/theme.php index 99c4cffc..1399dbbb 100644 --- a/ext/downtime/theme.php +++ b/ext/downtime/theme.php @@ -66,6 +66,6 @@ class DowntimeTheme extends Themelet EOD -); + ); } } diff --git a/ext/favorites/main.php b/ext/favorites/main.php index c213c283..66200eaf 100644 --- a/ext/favorites/main.php +++ b/ext/favorites/main.php @@ -242,7 +242,7 @@ class Favorites extends Extension { global $database; if ($do_set) { - if(!$database->exists("select 1 from user_favorites where image_id=:image_id and user_id=:user_id",["image_id"=>$image_id, "user_id"=>$user_id])) { + if (!$database->exists("select 1 from user_favorites where image_id=:image_id and user_id=:user_id", ["image_id"=>$image_id, "user_id"=>$user_id])) { $database->Execute( "INSERT INTO user_favorites(image_id, user_id, created_at) VALUES(:image_id, :user_id, NOW())", ["image_id"=>$image_id, "user_id"=>$user_id] diff --git a/ext/forum/main.php b/ext/forum/main.php index e4c60df4..a1c5d410 100644 --- a/ext/forum/main.php +++ b/ext/forum/main.php @@ -269,7 +269,7 @@ class Forum extends Extension "GROUP BY f.id, f.sticky, f.title, f.date, u.name, u.email, u.class ". "ORDER BY f.sticky ASC, f.uptodate DESC LIMIT :limit OFFSET :offset", ["limit"=>$threadsPerPage, "offset"=>$pageNumber * $threadsPerPage] - ); + ); $this->theme->display_thread_list($page, $threads, $showAdminOptions, $pageNumber + 1, $totalPages); } @@ -302,7 +302,7 @@ class Forum extends Extension "ORDER BY p.date ASC ". "LIMIT :limit OFFSET :offset", ["thread_id"=>$threadID, "offset"=>$pageNumber * $postsPerPage, "limit"=>$postsPerPage] - ); + ); $this->theme->display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber + 1, $totalPages); } diff --git a/ext/help_pages/main.php b/ext/help_pages/main.php index 90206d00..8238f875 100644 --- a/ext/help_pages/main.php +++ b/ext/help_pages/main.php @@ -37,7 +37,7 @@ class HelpPages extends Extension private function get_pages(): array { - if($this->pages==null) { + if ($this->pages==null) { $e = new HelpPageListBuildingEvent(); send_event($e); $this->pages = $e->pages; @@ -52,8 +52,6 @@ class HelpPages extends Extension $pages = $this->get_pages(); if ($event->page_matches("help")) { - - if ($event->count_args() == 0) { $name = array_key_first($pages); $page->set_mode(PageMode::REDIRECT); @@ -63,7 +61,7 @@ class HelpPages extends Extension $page->set_mode(PageMode::PAGE); $name = $event->get_arg(0); $title = $name; - if(array_key_exists($name, $pages)) { + if (array_key_exists($name, $pages)) { $title = $pages[$name]; } else { return; @@ -97,10 +95,10 @@ class HelpPages extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if($event->parent=="help") { + if ($event->parent=="help") { $pages = $this->get_pages(); foreach ($pages as $key=>$value) { - $event->add_nav_link("help_".$key, new Link('help/'.$key),$value); + $event->add_nav_link("help_".$key, new Link('help/'.$key), $value); } } } diff --git a/ext/home/theme.php b/ext/home/theme.php index 8dfc666d..d0ec1f2d 100644 --- a/ext/home/theme.php +++ b/ext/home/theme.php @@ -22,7 +22,7 @@ class HomeTheme extends Themelet EOD -); + ); } public function build_body(string $sitename, string $main_links, string $main_text, string $contact_link, $num_comma, string $counter_text) diff --git a/ext/media/config.php b/ext/media/config.php index 32814594..99a18aab 100644 --- a/ext/media/config.php +++ b/ext/media/config.php @@ -6,5 +6,4 @@ abstract class MediaConfig const CONVERT_PATH = "media_convert_path"; const VERSION = "ext_media_version"; const MEM_LIMIT = 'media_mem_limit'; - } diff --git a/ext/media/events.php b/ext/media/events.php index d996e43e..d33afa97 100644 --- a/ext/media/events.php +++ b/ext/media/events.php @@ -14,14 +14,19 @@ class MediaResizeEvent extends Event public $ignore_aspect_ratio; public $allow_upscale; - public function __construct(String $engine, string $input_path, string $input_type, string $output_path, - int $target_width, int $target_height, - bool $ignore_aspect_ratio = false, - string $target_format = null, - int $target_quality = 80, - bool $minimize = false, - bool $allow_upscale = true) - { + public function __construct( + String $engine, + string $input_path, + string $input_type, + string $output_path, + int $target_width, + int $target_height, + bool $ignore_aspect_ratio = false, + string $target_format = null, + int $target_quality = 80, + bool $minimize = false, + bool $allow_upscale = true + ) { assert(in_array($engine, MediaEngine::ALL)); $this->engine = $engine; $this->input_path = $input_path; @@ -54,5 +59,4 @@ class MediaCheckPropertiesEvent extends Event $this->file_name = $file_name; $this->ext = $ext; } - } diff --git a/ext/media/main.php b/ext/media/main.php index 9c1eb5c0..25f2ddde 100644 --- a/ext/media/main.php +++ b/ext/media/main.php @@ -265,7 +265,7 @@ class Media extends Extension $matches = []; if (preg_match(self::CONTENT_SEARCH_TERM_REGEX, $event->term, $matches)) { $field = $matches[1]; - if($field==="unknown") { + if ($field==="unknown") { $event->add_querylet(new Querylet($database->scoreql_to_sql("video IS NULL OR audio IS NULL OR image IS NULL"))); } else { $event->add_querylet(new Querylet($database->scoreql_to_sql("$field = SCORE_BOOL_Y"))); @@ -814,7 +814,7 @@ class Media extends Extension $new_height, $width, $height - ) === false) { + ) === false) { throw new MediaException("Unable to copy resized image data to new image"); } @@ -1039,7 +1039,7 @@ class Media extends Extension "ALTER TABLE images ADD COLUMN image SCORE_BOOL NULL" )); - switch($database->get_driver_name()) { + switch ($database->get_driver_name()) { case DatabaseDriver::PGSQL: case DatabaseDriver::SQLITE: $database->execute('CREATE INDEX images_image_idx ON images(image) WHERE image IS NOT NULL'); @@ -1052,7 +1052,7 @@ class Media extends Extension $database->set_timeout(300000); // These updates can take a little bit if ($database->transaction === true) { - $database->commit(); // Each of these commands could hit a lot of data, combining them into one big transaction would not be a good idea. + $database->commit(); // Each of these commands could hit a lot of data, combining them into one big transaction would not be a good idea. } log_info("upgrade", "Setting predictable media values for known file types"); $database->execute($database->scoreql_to_sql("UPDATE images SET image = SCORE_BOOL_N WHERE ext IN ('swf','mp3','ani','flv','mp4','m4v','ogv','webm')")); diff --git a/ext/not_a_tag/main.php b/ext/not_a_tag/main.php index c788077c..83004f49 100644 --- a/ext/not_a_tag/main.php +++ b/ext/not_a_tag/main.php @@ -55,7 +55,7 @@ class NotATag extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if($event->parent==="tags") { + if ($event->parent==="tags") { if ($user->can(Permissions::BAN_IMAGE)) { $event->add_nav_link("untags", new Link('untag/list/1'), "UnTags"); } diff --git a/ext/ouroboros_api/main.php b/ext/ouroboros_api/main.php index dfc4aa5c..4766950b 100644 --- a/ext/ouroboros_api/main.php +++ b/ext/ouroboros_api/main.php @@ -472,7 +472,7 @@ class OuroborosAPI extends Extension if (empty($post->file) && !empty($post->file_url) && filter_var( $post->file_url, FILTER_VALIDATE_URL - ) !== false + ) !== false ) { // Transload from source $meta['file'] = tempnam('/tmp', 'shimmie_transload_' . $config->get_string('transload_engine')); diff --git a/ext/pools/main.php b/ext/pools/main.php index 15e36c99..6205a8f2 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -818,7 +818,7 @@ class Pools extends Extension SELECT COUNT(*) FROM pool_images p $query", ["pid" => $poolID] - ) / $imagesPerPage); + ) / $imagesPerPage); diff --git a/ext/rating/main.php b/ext/rating/main.php index 2386c3b0..c939b00b 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -341,7 +341,7 @@ class Ratings extends Extension $old = $_POST["rating_old"]; $new = $_POST["rating_new"]; - if($user->can(Permissions::BULK_EDIT_IMAGE_RATING)) { + if ($user->can(Permissions::BULK_EDIT_IMAGE_RATING)) { $database->execute("UPDATE images SET rating = :new WHERE rating = :old", ["new"=>$new, "old"=>$old ]); } diff --git a/ext/trash/main.php b/ext/trash/main.php index 8d29dd62..d3772a68 100644 --- a/ext/trash/main.php +++ b/ext/trash/main.php @@ -63,9 +63,9 @@ class Trash extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if($event->parent=="posts") { - if($user->can(Permissions::VIEW_TRASH)) { - $event->add_nav_link("posts_trash", new Link('/post/list/in%3Atrash/1'), "Trash",null, 60); + if ($event->parent=="posts") { + if ($user->can(Permissions::VIEW_TRASH)) { + $event->add_nav_link("posts_trash", new Link('/post/list/in%3Atrash/1'), "Trash", null, 60); } } } diff --git a/ext/upload/main.php b/ext/upload/main.php index 9c7879ad..25a0daf9 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -35,6 +35,9 @@ class DataUploadEvent extends Event assert(is_array($metadata["tags"])); assert(is_string($metadata["source"]) || is_null($metadata["source"])); + // DB limits to 64 char filenames + $metadata['filename'] = substr($metadata['filename'], 0, 63); + $this->metadata = $metadata; $this->set_tmpname($tmpname); diff --git a/themes/material/home.theme.php b/themes/material/home.theme.php index ada70b17..c878d3c2 100644 --- a/themes/material/home.theme.php +++ b/themes/material/home.theme.php @@ -25,7 +25,7 @@ class CustomHomeTheme extends HomeTheme EOD -); + ); } public function build_body(string $sitename, string $main_links, string $main_text, string $contact_link, $num_comma, string $counter_text)