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']} )
Any sub-folders will be turned into tags.
@@ -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 .= "{$entry["date_sent"]} {$entry["message"]} ";
}
$log_html .= "
";
@@ -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