diff --git a/core/cacheengine.php b/core/cacheengine.php index 002b10b4..4d5fc05f 100644 --- a/core/cacheengine.php +++ b/core/cacheengine.php @@ -192,14 +192,14 @@ class Cache $_tracer->begin("Cache Query", ["key"=>$key]); $val = $this->engine->get($key); if ($val !== false) { - $res = "hit"; + $res = "hit"; $this->hits++; } else { - $res = "miss"; + $res = "miss"; $this->misses++; } $_tracer->end(null, ["result"=>$res]); - return $val; + return $val; } public function set(string $key, $val, int $time=0) diff --git a/core/config.php b/core/config.php index 6b1ac6fa..06047a77 100644 --- a/core/config.php +++ b/core/config.php @@ -159,7 +159,7 @@ abstract class BaseConfig implements Config public function set_array(string $name, ?array $value): void { - if($value!=null) { + if ($value!=null) { $this->values[$name] = implode(",", $value); } else { $this->values[$name] = null; @@ -313,16 +313,19 @@ class DatabaseConfig extends BaseConfig private $sub_column; private $sub_value; - public function __construct(Database $database, string $table_name = "config", - string $sub_column = null, string $sub_value = null) - { + public function __construct( + Database $database, + string $table_name = "config", + string $sub_column = null, + string $sub_value = null + ) { $this->database = $database; $this->table_name = $table_name; $this->sub_value = $sub_value; $this->sub_column = $sub_column; $cache_name = "config"; - if(!empty($sub_value)) { + if (!empty($sub_value)) { $cache_name .= "_".$sub_value; } @@ -335,12 +338,12 @@ class DatabaseConfig extends BaseConfig $query = "SELECT name, value FROM {$this->table_name}"; $args = []; - if(!empty($sub_column)&&!empty($sub_value)) { + if (!empty($sub_column)&&!empty($sub_value)) { $query .= " WHERE $sub_column = :sub_value"; $args["sub_value"] = $sub_value; } - foreach ($this->database->get_all($query, $args ) as $row) { + foreach ($this->database->get_all($query, $args) as $row) { $this->values[$row["name"]] = $row["value"]; } $this->database->cache->set($cache_name, $this->values); @@ -359,7 +362,7 @@ class DatabaseConfig extends BaseConfig $args = ["name"=>$name]; $cols = ["name","value"]; $params = [":name",":value"]; - if(!empty($this->sub_column)&&!empty($this->sub_value)) { + if (!empty($this->sub_column)&&!empty($this->sub_value)) { $query .= " AND $this->sub_column = :sub_value"; $args["sub_value"] = $this->sub_value; $cols[] = $this->sub_column; @@ -370,8 +373,9 @@ class DatabaseConfig extends BaseConfig $args["value"] =$this->values[$name]; $this->database->Execute( - "INSERT INTO {$this->table_name} (".join(",",$cols).") VALUES (".join(",",$params).")", - $args); + "INSERT INTO {$this->table_name} (".join(",", $cols).") VALUES (".join(",", $params).")", + $args + ); } // rather than deleting and having some other request(s) do a thundering // herd of race-conditioned updates, just save the updated version once here diff --git a/core/database.php b/core/database.php index 2cbf077f..3bead690 100644 --- a/core/database.php +++ b/core/database.php @@ -172,9 +172,9 @@ class Database if (is_null($this->engine)) { $this->connect_engine(); } - if($input===true) { + if ($input===true) { return $this->engine->BOOL_Y; - } else if ($input===false) { + } elseif ($input===false) { return $this->engine->BOOL_N; } return $input; @@ -190,13 +190,13 @@ class Database private function count_time(string $method, float $start, string $query, ?array $args): void { - global $_tracer, $tracer_enabled; - $dur = microtime(true) - $start; - if($tracer_enabled) { + global $_tracer, $tracer_enabled; + $dur = microtime(true) - $start; + if ($tracer_enabled) { $query = trim(preg_replace('/^[\t ]+/m', '', $query)); // trim leading whitespace $_tracer->complete($start * 1000000, $dur * 1000000, "DB Query", ["query"=>$query, "args"=>$args, "method"=>$method]); } - $this->query_count++; + $this->query_count++; $this->dbtime += $dur; } @@ -226,7 +226,7 @@ class Database return $stmt; } catch (PDOException $pdoe) { throw new SCoreException($pdoe->getMessage()."
Query: ".$query);
- }
+ }
}
/**
diff --git a/core/dbengine.php b/core/dbengine.php
index 5286a8ad..7c5112c0 100644
--- a/core/dbengine.php
+++ b/core/dbengine.php
@@ -1,5 +1,6 @@
append(new Querylet(" ORDER BY ".(Image::$order_sql ?: "images.".$config->get_string("index_order"))));
- if($limit!=null) {
+ if ($limit!=null) {
$querylet->append(new Querylet(" LIMIT :limit ", ["limit" => $limit]));
}
$querylet->append(new Querylet(" OFFSET :offset ", ["offset"=>$start]));
@@ -228,7 +228,7 @@ class Image
$response = Image::query_accelerator($req);
if ($response) {
- $list = implode(",", $response);
+ $list = implode(",", $response);
$result = $database->execute("SELECT * FROM images WHERE id IN ($list) ORDER BY images.id DESC");
} else {
$result = $database->execute("SELECT * FROM images WHERE 1=0 ORDER BY images.id DESC");
@@ -253,19 +253,19 @@ class Image
public static function query_accelerator($req)
{
- global $_tracer;
+ global $_tracer;
$fp = @fsockopen("127.0.0.1", 21212);
if (!$fp) {
return null;
}
- $req_str = json_encode($req);
- $_tracer->begin("Accelerator Query", ["req"=>$req_str]);
+ $req_str = json_encode($req);
+ $_tracer->begin("Accelerator Query", ["req"=>$req_str]);
fwrite($fp, $req_str);
$data = "";
while (($buffer = fgets($fp, 4096)) !== false) {
$data .= $buffer;
}
- $_tracer->end();
+ $_tracer->end();
if (!feof($fp)) {
die("Error: unexpected fgets() fail in query_accelerator($req_str)\n");
}
@@ -299,7 +299,7 @@ class Image
["tag"=>$tags[0]]
);
} else {
- if(ext_is_live("Ratings")) {
+ if (ext_is_live("Ratings")) {
$tags[] = "rating:*";
}
list($tag_conditions, $img_conditions) = self::terms_to_conditions($tags);
@@ -833,10 +833,9 @@ class Image
$opts = $matches[2];
$post = $matches[3];
- if(isset($flexihashes[$opts])) {
+ if (isset($flexihashes[$opts])) {
$flexihash = $flexihashes[$opts];
- }
- else {
+ } else {
$flexihash = new Flexihash\Flexihash();
foreach (explode(",", $opts) as $opt) {
$parts = explode("=", $opt);
@@ -964,7 +963,7 @@ class Image
FROM images
WHERE 1=0
");
- } elseif($tag_count==1) {
+ } elseif ($tag_count==1) {
// All wildcard terms that qualify for a single tag can be treated the same as non-wildcards
$positive_tag_id_array[] = $tag_ids[0];
} else {
@@ -981,14 +980,14 @@ 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)) {
+ if (!empty($positive_tag_id_array) || !empty($positive_wildcard_id_array)) {
$inner_joins = [];
if (!empty($positive_tag_id_array)) {
- foreach($positive_tag_id_array as $tag) {
+ foreach ($positive_tag_id_array as $tag) {
$inner_joins[] = "= $tag";
}
}
- if(!empty($positive_wildcard_id_array)) {
+ if (!empty($positive_wildcard_id_array)) {
foreach ($positive_wildcard_id_array as $tags) {
$positive_tag_id_list = join(', ', $tags);
$inner_joins[] = "IN ($positive_tag_id_list)";
@@ -1002,12 +1001,12 @@ class Image
$i++;
$sub_query .= " INNER JOIN image_tags it$i ON it$i.image_id = it.image_id AND it$i.tag_id $inner_join ";
}
- if(!empty($negative_tag_id_array)) {
+ if (!empty($negative_tag_id_array)) {
$negative_tag_id_list = join(', ', $negative_tag_id_array);
$sub_query .= " LEFT JOIN image_tags negative ON negative.image_id = it.image_id AND negative.tag_id IN ($negative_tag_id_list) ";
}
$sub_query .= "WHERE it.tag_id $first ";
- if(!empty($negative_tag_id_array)) {
+ if (!empty($negative_tag_id_array)) {
$sub_query .= " AND negative.image_id IS NULL";
}
$sub_query .= " GROUP BY it.image_id ";
@@ -1018,7 +1017,7 @@ class Image
$sub_query
) a on a.image_id = images.id
";
- } elseif(!empty($negative_tag_id_array)) {
+ } elseif (!empty($negative_tag_id_array)) {
$negative_tag_id_list = join(', ', $negative_tag_id_array);
$sql = "
SELECT images.*
diff --git a/core/imageboard/misc.php b/core/imageboard/misc.php
index c82d9f98..bead57bc 100644
--- a/core/imageboard/misc.php
+++ b/core/imageboard/misc.php
@@ -124,7 +124,7 @@ function get_thumbnail_size(int $orig_width, int $orig_height, bool $use_dpi_sca
}
- if($use_dpi_scaling) {
+ if ($use_dpi_scaling) {
list($max_width, $max_height) = get_thumbnail_max_size_scaled();
} else {
$max_width = $config->get_int(ImageConfig::THUMB_WIDTH);
@@ -138,7 +138,6 @@ function get_thumbnail_size(int $orig_width, int $orig_height, bool $use_dpi_sca
} else {
return $output;
}
-
}
function get_scaled_by_aspect_ratio(int $original_width, int $original_height, int $max_width, int $max_height) : array
@@ -167,19 +166,20 @@ 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;
$inname = warehouse_path(Image::IMAGE_DIR, $hash);
$outname = warehouse_path(Image::THUMBNAIL_DIR, $hash);
$tsize = get_thumbnail_max_size_scaled();
- if(empty($engine)) {
+ if (empty($engine)) {
$engine = $config->get_string(ImageConfig::THUMB_ENGINE);
}
$output_format = $config->get_string(ImageConfig::THUMB_TYPE);
- if($output_format=="webp") {
+ if ($output_format=="webp") {
$output_format = Media::WEBP_LOSSY;
}
@@ -206,14 +206,14 @@ function format_milliseconds(int $input): string
$remainder = floor($input / 1000);
- foreach (TIME_UNITS AS $unit=>$conversion) {
+ foreach (TIME_UNITS as $unit=>$conversion) {
$count = $remainder % $conversion;
$remainder = floor($remainder / $conversion);
- if($count==0&&$remainder<1) {
+ if ($count==0&&$remainder<1) {
break;
}
$output = "$count".$unit." ".$output;
}
return trim($output);
-}
\ No newline at end of file
+}
diff --git a/core/page.php b/core/page.php
index 7efa2833..fb99f20d 100644
--- a/core/page.php
+++ b/core/page.php
@@ -307,14 +307,14 @@ class Page
$active_link = null;
// To save on event calls, we check if one of the top-level links has already been marked as active
foreach ($nav_links as $link) {
- if($link->active===true) {
+ if ($link->active===true) {
$active_link = $link;
break;
}
}
$sub_links = null;
// If one is, we just query for sub-menu options under that one tab
- if($active_link!==null) {
+ if ($active_link!==null) {
$psnbe = new PageSubNavBuildingEvent($active_link->name);
send_event($psnbe);
$sub_links = $psnbe->links;
@@ -326,13 +326,13 @@ class Page
// Now we check for a current link so we can identify the sub-links to show
foreach ($psnbe->links as $sub_link) {
- if($sub_link->active===true) {
+ if ($sub_link->active===true) {
$sub_links = $psnbe->links;
break;
}
}
// If the active link has been detected, we break out
- if($sub_links!==null) {
+ if ($sub_links!==null) {
$link->active = true;
break;
}
@@ -372,7 +372,6 @@ class Page
header('Accept-Ranges: bytes');
if (isset($_SERVER['HTTP_RANGE'])) {
-
$c_start = $start;
$c_end = $end;
list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
@@ -418,8 +417,9 @@ class Page
// 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
// then we can just stop and not waste any more resources or bandwidth.
- if (connection_status() != 0)
+ if (connection_status() != 0) {
break;
+ }
}
} finally {
fclose($fp);
@@ -541,7 +541,7 @@ class PageSubNavBuildingEvent extends Event
public function add_nav_link(string $name, Link $link, string $desc, ?bool $active = null, int $order = 50)
{
- $this->links[] = new NavLink($name, $link, $desc, $active,$order);
+ $this->links[] = new NavLink($name, $link, $desc, $active, $order);
}
}
@@ -553,7 +553,7 @@ class NavLink
public $order;
public $active = false;
- public function __construct(String $name, Link $link, String $description, ?bool $active = null, int $order = 50)
+ public function __construct(String $name, Link $link, String $description, ?bool $active = null, int $order = 50)
{
global $config;
@@ -561,7 +561,7 @@ class NavLink
$this->link = $link;
$this->description = $description;
$this->order = $order;
- if($active==null) {
+ if ($active==null) {
$query = ltrim(_get_query(), "/");
if ($query === "") {
// This indicates the front page, so we check what's set as the front page
@@ -572,15 +572,14 @@ class NavLink
} else {
$this->active = self::is_active([$link->page], $front_page);
}
- } elseif($query===$link->page) {
+ } elseif ($query===$link->page) {
$this->active = true;
- }else {
+ } else {
$this->active = self::is_active([$link->page]);
}
} else {
$this->active = $active;
}
-
}
public static function is_active(array $pages_matched, string $url = null): bool
diff --git a/core/permissions.php b/core/permissions.php
index 4378a9c0..717bd5fd 100644
--- a/core/permissions.php
+++ b/core/permissions.php
@@ -66,5 +66,4 @@ abstract class Permissions
public const VIEW_TRASH = "view_trash";
public const PERFORM_BULK_ACTIONS = "perform_bulk_actions";
-
-}
\ No newline at end of file
+}
diff --git a/core/polyfills.php b/core/polyfills.php
index 680879f4..951df919 100644
--- a/core/polyfills.php
+++ b/core/polyfills.php
@@ -759,7 +759,7 @@ function validate_input(array $inputs): array
*/
function sanitize_path(string $path): string
{
- return preg_replace('|[\\\\/]+|S',DIRECTORY_SEPARATOR,$path);
+ return preg_replace('|[\\\\/]+|S', DIRECTORY_SEPARATOR, $path);
}
/**
@@ -770,11 +770,11 @@ function join_path(string ...$paths): string
{
$output = "";
foreach ($paths as $path) {
- if(empty($path)) {
+ if (empty($path)) {
continue;
}
$path = sanitize_path($path);
- if(empty($output)) {
+ if (empty($output)) {
$output = $path;
} else {
$output = rtrim($output, DIRECTORY_SEPARATOR);
@@ -790,8 +790,8 @@ function join_path(string ...$paths): string
*/
function iterator_map(callable $callback, iterator $iter): Generator
{
- foreach($iter as $i) {
- yield call_user_func($callback,$i);
+ foreach ($iter as $i) {
+ yield call_user_func($callback, $i);
}
}
@@ -801,4 +801,4 @@ function iterator_map(callable $callback, iterator $iter): Generator
function iterator_map_to_array(callable $callback, iterator $iter): array
{
return iterator_to_array(iterator_map($callback, $iter));
-}
\ No newline at end of file
+}
diff --git a/core/send_event.php b/core/send_event.php
index 24897658..d6c92e01 100644
--- a/core/send_event.php
+++ b/core/send_event.php
@@ -26,7 +26,7 @@ function _load_event_listeners(): void
function _clear_cached_event_listeners(): void
{
if (file_exists(data_path("cache/shm_event_listeners.php"))) {
- unlink(data_path("cache/shm_event_listeners.php"));
+ unlink(data_path("cache/shm_event_listeners.php"));
}
}
@@ -118,21 +118,29 @@ function send_event(Event $event): void
// send_event() is performance sensitive, and with the number
// 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
$my_event_listeners = $_shm_event_listeners[get_class($event)];
ksort($my_event_listeners);
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)) {
$listener->$method_name($event);
}
- if ($tracer_enabled) $_tracer->end();
- if($event->stop_processing===true) {
+ if ($tracer_enabled) {
+ $_tracer->end();
+ }
+ if ($event->stop_processing===true) {
break;
}
}
$_shm_event_count++;
- if ($tracer_enabled) $_tracer->end();
+ if ($tracer_enabled) {
+ $_tracer->end();
+ }
}
diff --git a/core/tests/polyfills.test.php b/core/tests/polyfills.test.php
index 68e0d10a..e5899f0a 100644
--- a/core/tests/polyfills.test.php
+++ b/core/tests/polyfills.test.php
@@ -48,7 +48,6 @@ class PolyfillsTest extends \PHPUnit\Framework\TestCase
public function test_sanitize_path()
{
-
$this->assertEquals(
"one",
sanitize_path("one")
@@ -88,7 +87,6 @@ class PolyfillsTest extends \PHPUnit\Framework\TestCase
DIRECTORY_SEPARATOR."one".DIRECTORY_SEPARATOR."two".DIRECTORY_SEPARATOR,
sanitize_path("\\/one/\\/\\/two\\/")
);
-
}
public function test_join_path()
@@ -100,22 +98,22 @@ class PolyfillsTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(
"one".DIRECTORY_SEPARATOR."two",
- join_path("one","two")
+ join_path("one", "two")
);
$this->assertEquals(
"one".DIRECTORY_SEPARATOR."two".DIRECTORY_SEPARATOR."three",
- join_path("one","two","three")
+ join_path("one", "two", "three")
);
$this->assertEquals(
"one".DIRECTORY_SEPARATOR."two".DIRECTORY_SEPARATOR."three",
- join_path("one/two","three")
+ join_path("one/two", "three")
);
$this->assertEquals(
DIRECTORY_SEPARATOR."one".DIRECTORY_SEPARATOR."two".DIRECTORY_SEPARATOR."three".DIRECTORY_SEPARATOR,
- join_path("\\/////\\\\one/\///"."\\//two\/\\//\\//","//\/\\\/three/\\/\/")
+ join_path("\\/////\\\\one/\///"."\\//two\/\\//\\//", "//\/\\\/three/\\/\/")
);
}
}
diff --git a/core/tests/util.test.php b/core/tests/util.test.php
index 3b3381f7..e04b01ae 100644
--- a/core/tests/util.test.php
+++ b/core/tests/util.test.php
@@ -3,65 +3,63 @@ require_once "core/util.php";
class UtilTest extends \PHPUnit\Framework\TestCase
{
-
public function test_warehouse_path()
{
$hash = "7ac19c10d6859415";
$this->assertEquals(
- join_path(DATA_DIR,"base",$hash),
- warehouse_path("base",$hash,false, 0)
+ join_path(DATA_DIR, "base", $hash),
+ warehouse_path("base", $hash, false, 0)
);
$this->assertEquals(
- join_path(DATA_DIR,"base","7a",$hash),
- warehouse_path("base",$hash,false, 1)
+ join_path(DATA_DIR, "base", "7a", $hash),
+ warehouse_path("base", $hash, false, 1)
);
$this->assertEquals(
- join_path(DATA_DIR,"base","7a","c1",$hash),
- warehouse_path("base",$hash,false, 2)
+ join_path(DATA_DIR, "base", "7a", "c1", $hash),
+ warehouse_path("base", $hash, false, 2)
);
$this->assertEquals(
- join_path(DATA_DIR,"base","7a","c1","9c",$hash),
- warehouse_path("base",$hash,false, 3)
+ join_path(DATA_DIR, "base", "7a", "c1", "9c", $hash),
+ warehouse_path("base", $hash, false, 3)
);
$this->assertEquals(
- join_path(DATA_DIR,"base","7a","c1","9c","10",$hash),
- warehouse_path("base",$hash,false, 4)
+ join_path(DATA_DIR, "base", "7a", "c1", "9c", "10", $hash),
+ warehouse_path("base", $hash, false, 4)
);
$this->assertEquals(
- join_path(DATA_DIR,"base","7a","c1","9c","10","d6",$hash),
- warehouse_path("base",$hash,false, 5)
+ join_path(DATA_DIR, "base", "7a", "c1", "9c", "10", "d6", $hash),
+ warehouse_path("base", $hash, false, 5)
);
$this->assertEquals(
- join_path(DATA_DIR,"base","7a","c1","9c","10","d6","85",$hash),
- warehouse_path("base",$hash,false, 6)
+ join_path(DATA_DIR, "base", "7a", "c1", "9c", "10", "d6", "85", $hash),
+ warehouse_path("base", $hash, false, 6)
);
$this->assertEquals(
- join_path(DATA_DIR,"base","7a","c1","9c","10","d6","85","94",$hash),
- warehouse_path("base",$hash,false, 7)
+ join_path(DATA_DIR, "base", "7a", "c1", "9c", "10", "d6", "85", "94", $hash),
+ warehouse_path("base", $hash, false, 7)
);
$this->assertEquals(
- join_path(DATA_DIR,"base","7a","c1","9c","10","d6","85","94","15",$hash),
- warehouse_path("base",$hash,false, 8)
+ join_path(DATA_DIR, "base", "7a", "c1", "9c", "10", "d6", "85", "94", "15", $hash),
+ warehouse_path("base", $hash, false, 8)
);
$this->assertEquals(
- join_path(DATA_DIR,"base","7a","c1","9c","10","d6","85","94","15",$hash),
- warehouse_path("base",$hash,false, 9)
+ join_path(DATA_DIR, "base", "7a", "c1", "9c", "10", "d6", "85", "94", "15", $hash),
+ warehouse_path("base", $hash, false, 9)
);
$this->assertEquals(
- join_path(DATA_DIR,"base","7a","c1","9c","10","d6","85","94","15",$hash),
- warehouse_path("base",$hash,false, 10)
+ join_path(DATA_DIR, "base", "7a", "c1", "9c", "10", "d6", "85", "94", "15", $hash),
+ warehouse_path("base", $hash, false, 10)
);
-
}
}
diff --git a/core/util.php b/core/util.php
index 7017078d..ecec96e1 100644
--- a/core/util.php
+++ b/core/util.php
@@ -174,7 +174,7 @@ function warehouse_path(string $base, string $hash, bool $create=true, int $spli
{
$dirs =[DATA_DIR, $base];
$splits = min($splits, strlen($hash) / 2);
- for($i = 0; $i < $splits; $i++) {
+ for ($i = 0; $i < $splits; $i++) {
$dirs[] = substr($hash, $i * 2, 2);
}
$dirs[] = $hash;
@@ -343,7 +343,7 @@ function join_url(string $base, string ...$paths)
{
$output = $base;
foreach ($paths as $path) {
- $output = rtrim($output,"/");
+ $output = rtrim($output, "/");
$path = ltrim($path, "/");
$output .= "/".$path;
}
diff --git a/ext/admin/main.php b/ext/admin/main.php
index 423460c8..038d40ed 100644
--- a/ext/admin/main.php
+++ b/ext/admin/main.php
@@ -111,7 +111,7 @@ class AdminPage extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{
global $user;
- if($event->parent==="system") {
+ if ($event->parent==="system") {
if ($user->can(Permissions::MANAGE_ADMINTOOLS)) {
$event->add_nav_link("admin", new Link('admin'), "Board Admin");
}
diff --git a/ext/admin/theme.php b/ext/admin/theme.php
index 1abe6542..d6a60e6c 100644
--- a/ext/admin/theme.php
+++ b/ext/admin/theme.php
@@ -55,12 +55,11 @@ class AdminPageTheme extends Themelet
$html .= "";
$html .= "\n";
$page->add_block(new Block("Set Tag Case", $html));
-
}
public function dbq_html($terms)
{
- if(ext_is_live("Trash")) {
+ if (ext_is_live("Trash")) {
$warning = "This delete method will bypass the trash
";
}
if (class_exists("ImageBan")) {
@@ -75,6 +74,4 @@ class AdminPageTheme extends Themelet
";
return $html;
}
-
-
}
diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php
index 36edbfbb..d759d6c9 100644
--- a/ext/alias_editor/main.php
+++ b/ext/alias_editor/main.php
@@ -119,7 +119,7 @@ class AliasEditor extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{
- if($event->parent=="tags") {
+ if ($event->parent=="tags") {
$event->add_nav_link("aliases", new Link('alias/list'), "Aliases", NavLink::is_active(["alias"]));
}
}
diff --git a/ext/artists/main.php b/ext/artists/main.php
index b1f6efcc..2a98e268 100644
--- a/ext/artists/main.php
+++ b/ext/artists/main.php
@@ -55,7 +55,7 @@ class Artists extends Extension
public function onHelpPageBuilding(HelpPageBuildingEvent $event)
{
- if($event->key===HelpPages::SEARCH) {
+ if ($event->key===HelpPages::SEARCH) {
$block = new Block();
$block->header = "Artist";
$block->body = $this->theme->get_help_html();
diff --git a/ext/autocomplete/main.php b/ext/autocomplete/main.php
index 187f45e5..2bd18217 100644
--- a/ext/autocomplete/main.php
+++ b/ext/autocomplete/main.php
@@ -38,8 +38,8 @@ class AutoComplete extends Extension
//$limit = 0;
$cache_key = "autocomplete-$s";
$limitSQL = "";
- $s = str_replace('_','\_', $s);
- $s = str_replace('%','\%', $s);
+ $s = str_replace('_', '\_', $s);
+ $s = str_replace('%', '\%', $s);
$SQLarr = ["search"=>"$s%"]; #, "cat_search"=>"%:$s%"];
if (isset($_GET["limit"]) && $_GET["limit"] !== 0) {
$limitSQL = "LIMIT :limit";
diff --git a/ext/blocks/main.php b/ext/blocks/main.php
index 197b5d9f..e0f283fa 100644
--- a/ext/blocks/main.php
+++ b/ext/blocks/main.php
@@ -29,7 +29,7 @@ class Blocks extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{
global $user;
- if($event->parent==="system") {
+ if ($event->parent==="system") {
if ($user->can(Permissions::MANAGE_BLOCKS)) {
$event->add_nav_link("blocks", new Link('blocks/list'), "Blocks Editor");
}
diff --git a/ext/blotter/main.php b/ext/blotter/main.php
index 3e18b1a9..528f028e 100644
--- a/ext/blotter/main.php
+++ b/ext/blotter/main.php
@@ -59,7 +59,7 @@ class Blotter extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{
global $user;
- if($event->parent==="system") {
+ if ($event->parent==="system") {
if ($user->is_admin()) {
$event->add_nav_link("blotter", new Link('blotter/editor'), "Blotter Editor");
}
diff --git a/ext/bulk_actions/main.php b/ext/bulk_actions/main.php
index 0bfaf1da..60654701 100644
--- a/ext/bulk_actions/main.php
+++ b/ext/bulk_actions/main.php
@@ -22,10 +22,10 @@ class BulkActionBlockBuildingEvent extends Event
$block = "";
}
- if(!empty($access_key)) {
+ if (!empty($access_key)) {
assert(strlen($access_key)==1);
foreach ($this->actions as $existing) {
- if($existing["access_key"]==$access_key) {
+ if ($existing["access_key"]==$access_key) {
throw new SCoreException("Access key $access_key is already in use");
}
}
@@ -90,18 +90,18 @@ class BulkActions extends Extension
}
if ($user->can(Permissions::BULK_EDIT_IMAGE_TAG)) {
-
$event->add_action(
"bulk_tag",
"Tag",
"t",
"",
$this->theme->render_tag_input(),
- 10);
+ 10
+ );
}
if ($user->can(Permissions::BULK_EDIT_IMAGE_SOURCE)) {
- $event->add_action("bulk_source", "Set (S)ource", "s","", $this->theme->render_source_input(), 10);
+ $event->add_action("bulk_source", "Set (S)ource", "s", "", $this->theme->render_source_input(), 10);
}
}
@@ -186,7 +186,7 @@ class BulkActions extends Extension
foreach ($data as $id) {
if (is_numeric($id)) {
$image = Image::by_id($id);
- if($image!=null) {
+ if ($image!=null) {
yield $image;
}
}
@@ -246,10 +246,10 @@ class BulkActions extends Extension
}
} else {
foreach ($items as $image) {
- $img_tags = array_map("strtolower",$image->get_tag_array());
+ $img_tags = array_map("strtolower", $image->get_tag_array());
if (!empty($neg_tag_array)) {
- $neg_tag_array = array_map("strtolower",$neg_tag_array);
+ $neg_tag_array = array_map("strtolower", $neg_tag_array);
$img_tags = array_merge($pos_tag_array, $img_tags);
$img_tags = array_diff($img_tags, $neg_tag_array);
diff --git a/ext/comment/main.php b/ext/comment/main.php
index fb35da18..9f6404cd 100644
--- a/ext/comment/main.php
+++ b/ext/comment/main.php
@@ -166,7 +166,7 @@ class CommentList extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{
- if($event->parent=="comment") {
+ if ($event->parent=="comment") {
$event->add_nav_link("comment_list", new Link('comment/list'), "All");
$event->add_nav_link("comment_help", new Link('ext_doc/comment'), "Help");
}
@@ -368,7 +368,7 @@ class CommentList extends Extension
public function onHelpPageBuilding(HelpPageBuildingEvent $event)
{
- if($event->key===HelpPages::SEARCH) {
+ if ($event->key===HelpPages::SEARCH) {
$block = new Block();
$block->header = "Comments";
$block->body = $this->theme->get_help_html();
diff --git a/ext/comment/theme.php b/ext/comment/theme.php
index 7e62da6b..31b77a7d 100644
--- a/ext/comment/theme.php
+++ b/ext/comment/theme.php
@@ -312,6 +312,5 @@ class CommentListTheme extends Themelet
Returns images that have been commented on by user 123.
'; - } } diff --git a/ext/et/main.php b/ext/et/main.php index 576765dd..cecea577 100644 --- a/ext/et/main.php +++ b/ext/et/main.php @@ -28,7 +28,7 @@ class ET extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if($event->parent==="system") { + if ($event->parent==="system") { if ($user->can(Permissions::VIEW_SYSINTO)) { $event->add_nav_link("system_info", new Link('system_info'), "System Info", null, 10); } diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index 39c7f572..cc057fd8 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -165,7 +165,7 @@ class ExtManager extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if($event->parent==="system") { + if ($event->parent==="system") { if ($user->can(Permissions::MANAGE_EXTENSION_LIST)) { $event->add_nav_link("ext_manager", new Link('ext_manager'), "Extension Manager"); } else { diff --git a/ext/favorites/main.php b/ext/favorites/main.php index 950d6178..380fefa2 100644 --- a/ext/favorites/main.php +++ b/ext/favorites/main.php @@ -157,7 +157,7 @@ class Favorites extends Extension public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if($event->key===HelpPages::SEARCH) { + if ($event->key===HelpPages::SEARCH) { $block = new Block(); $block->header = "Favorites"; $block->body = $this->theme->get_help_html(); @@ -168,11 +168,11 @@ class Favorites extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if($event->parent=="posts") { + if ($event->parent=="posts") { $event->add_nav_link("posts_favorites", new Link("post/list/favorited_by={$user->name}/1"), "My Favorites"); } - if($event->parent==="user") { + if ($event->parent==="user") { if ($user->can(Permissions::MANAGE_ADMINTOOLS)) { $username = url_escape($user->name); $event->add_nav_link("favorites", new Link("post/list/favorited_by=$username/1"), "My Favorites"); diff --git a/ext/favorites/theme.php b/ext/favorites/theme.php index 22367347..cd03afbb 100644 --- a/ext/favorites/theme.php +++ b/ext/favorites/theme.php @@ -56,6 +56,5 @@ class FavoritesTheme extends ThemeletReturns images that have been favorited by user 123.
'; - } } diff --git a/ext/handle_flash/main.php b/ext/handle_flash/main.php index 3c53622d..a17abba9 100644 --- a/ext/handle_flash/main.php +++ b/ext/handle_flash/main.php @@ -8,7 +8,6 @@ class FlashFileHandler extends DataHandlerExtension { - public function onMediaCheckProperties(MediaCheckPropertiesEvent $event) { switch ($event->ext) { diff --git a/ext/handle_ico/main.php b/ext/handle_ico/main.php index f67937b6..97e3c4c6 100644 --- a/ext/handle_ico/main.php +++ b/ext/handle_ico/main.php @@ -12,7 +12,7 @@ class IcoFileHandler extends DataHandlerExtension public function onMediaCheckProperties(MediaCheckPropertiesEvent $event) { - if(in_array($event->ext, self::SUPPORTED_EXTENSIONS)) { + if (in_array($event->ext, self::SUPPORTED_EXTENSIONS)) { $event->lossless = true; $event->video = false; $event->audio = false; diff --git a/ext/handle_mp3/main.php b/ext/handle_mp3/main.php index 81fbee49..4cd943fa 100644 --- a/ext/handle_mp3/main.php +++ b/ext/handle_mp3/main.php @@ -17,7 +17,6 @@ class MP3FileHandler extends DataHandlerExtension break; } // TODO: Buff out audio format support, length scanning - } protected function create_thumb(string $hash, string $type): bool diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index 3b73bdfb..aeaa5779 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -13,14 +13,14 @@ class PixelFileHandler extends DataHandlerExtension public function onMediaCheckProperties(MediaCheckPropertiesEvent $event) { - if(in_array($event->ext, Media::LOSSLESS_FORMATS)) { + if (in_array($event->ext, Media::LOSSLESS_FORMATS)) { $event->lossless = true; - } elseif($event->ext=="webp") { + } elseif ($event->ext=="webp") { $event->lossless = Media::is_lossless_webp($event->file_name); } - if(in_array($event->ext,self::SUPPORTED_EXTENSIONS)) { - if($event->lossless==null) { + if (in_array($event->ext, self::SUPPORTED_EXTENSIONS)) { + if ($event->lossless==null) { $event->lossless = false; } $event->audio = false; @@ -117,5 +117,4 @@ class PixelFileHandler extends DataHandlerExtension ", 20); } - } diff --git a/ext/handle_svg/main.php b/ext/handle_svg/main.php index 79fd6613..4dd31926 100644 --- a/ext/handle_svg/main.php +++ b/ext/handle_svg/main.php @@ -10,7 +10,6 @@ use enshrined\svgSanitize\Sanitizer; class SVGFileHandler extends DataHandlerExtension { - public function onMediaCheckProperties(MediaCheckPropertiesEvent $event) { switch ($event->ext) { diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index 5c090faf..675134b5 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -50,19 +50,19 @@ class VideoFileHandler extends DataHandlerExtension public function onMediaCheckProperties(MediaCheckPropertiesEvent $event) { - if(in_array($event->ext, self::SUPPORTED_EXT)) { + if (in_array($event->ext, self::SUPPORTED_EXT)) { $event->video = true; try { $data = Media::get_ffprobe_data($event->file_name); - if(is_array($data)) { - if(array_key_exists("streams", $data)) { + if (is_array($data)) { + if (array_key_exists("streams", $data)) { $video = false; $audio = true; $streams = $data["streams"]; if (is_array($streams)) { foreach ($streams as $stream) { - if(is_array($stream)) { + if (is_array($stream)) { if (array_key_exists("codec_type", $stream)) { $type = $stream["codec_type"]; switch ($type) { @@ -82,22 +82,20 @@ class VideoFileHandler extends DataHandlerExtension && is_numeric($stream["height"]) && intval($stream["height"]) > ($event->height) ?? 0) { $event->height = intval($stream["height"]); } - } } $event->video = $video; $event->audio = $audio; } } - if(array_key_exists("format", $data)&& is_array($data["format"])) { + if (array_key_exists("format", $data)&& is_array($data["format"])) { $format = $data["format"]; - if(array_key_exists("duration", $format) && is_numeric($format["duration"])) { - $event->length = floor(floatval($format["duration"]) * 1000); + if (array_key_exists("duration", $format) && is_numeric($format["duration"])) { + $event->length = floor(floatval($format["duration"]) * 1000); } } } - } catch(MediaException $e) { - + } catch (MediaException $e) { } } } diff --git a/ext/handle_video/theme.php b/ext/handle_video/theme.php index c304eff7..eb4a8664 100644 --- a/ext/handle_video/theme.php +++ b/ext/handle_video/theme.php @@ -14,11 +14,11 @@ class VideoFileHandlerTheme extends Themelet $player = make_link('vendor/bower-asset/mediaelement/build/flashmediaelement.swf'); $width="auto"; - if($image->width>1) { + if ($image->width>1) { $width = $image->width."px"; } $height="auto"; - if($image->height>1) { + if ($image->height>1) { $height = $image->height."px"; } diff --git a/ext/help_pages/main.php b/ext/help_pages/main.php index d2821b00..f5f3ff41 100644 --- a/ext/help_pages/main.php +++ b/ext/help_pages/main.php @@ -14,7 +14,6 @@ class HelpPageListBuildingEvent extends Event { $this->pages[$key] = $name; } - } class HelpPageBuildingEvent extends Event @@ -27,10 +26,9 @@ class HelpPageBuildingEvent extends Event $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"][] = $block; @@ -55,7 +53,7 @@ class HelpPages extends Extension } else { $name = $event->get_arg(0); $title = $name; - if(array_key_exists($name, $e->pages)) { + if (array_key_exists($name, $e->pages)) { $title = $e->pages[$name]; } @@ -66,7 +64,7 @@ class HelpPages extends Extension asort($hpbe->blocks); foreach ($hpbe->blocks as $key=>$value) { - foreach($value as $block) { + foreach ($value as $block) { $page->add_block($block); } } @@ -89,6 +87,4 @@ class HelpPages extends Extension global $user; $event->add_link("Help", make_link("help")); } - - } diff --git a/ext/help_pages/theme.php b/ext/help_pages/theme.php index 2b3b7818..15892fb0 100644 --- a/ext/help_pages/theme.php +++ b/ext/help_pages/theme.php @@ -2,7 +2,6 @@ class HelpPagesTheme extends Themelet { - public function display_list_page(array $pages) { global $page; @@ -27,5 +26,4 @@ class HelpPagesTheme extends Themelet $page->set_title("Help - $title"); $page->set_heading("Help - $title"); } - } diff --git a/ext/image/main.php b/ext/image/main.php index 9969c3e8..fabf30fe 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -9,7 +9,8 @@ */ -abstract class ImageConfig { +abstract class ImageConfig +{ const THUMB_ENGINE = 'thumb_engine'; const THUMB_WIDTH = 'thumb_width'; const THUMB_HEIGHT = 'thumb_height'; @@ -26,7 +27,6 @@ abstract class ImageConfig { const COLLISION_MERGE = 'merge'; const COLLISION_ERROR = 'error'; - } /** @@ -34,7 +34,6 @@ abstract class ImageConfig { */ class ImageIO extends Extension { - const COLLISION_OPTIONS = ['Error'=>ImageConfig::COLLISION_ERROR, 'Merge'=>ImageConfig::COLLISION_MERGE]; const EXIF_READ_FUNCTION = "exif_read_data"; @@ -267,10 +266,9 @@ class ImageIO extends Extension try { Media::update_image_media_properties($image->hash, strtolower($image->ext)); - } catch(MediaException $e) { - log_warning("add_image","Error while running update_image_media_properties: ".$e->getMessage()); + } catch (MediaException $e) { + log_warning("add_image", "Error while running update_image_media_properties: ".$e->getMessage()); } - } // }}} end add @@ -349,7 +347,7 @@ class ImageIO extends Extension $duplicate = Image::by_hash($image->hash); - if(!is_null($duplicate) && $duplicate->id!=$id) { + if (!is_null($duplicate) && $duplicate->id!=$id) { $error = "Image {$duplicate->id} " . "already has hash {$image->hash}:" . $this->theme->build_thumb_html($duplicate); throw new ImageReplaceException($error); @@ -388,8 +386,8 @@ class ImageIO extends Extension try { Media::update_image_media_properties($image->hash, $image->ext); - } catch(MediaException $e) { - log_warning("image_replace","Error while running update_image_media_properties: ".$e->getMessage()); + } catch (MediaException $e) { + log_warning("image_replace", "Error while running update_image_media_properties: ".$e->getMessage()); } /* Generate new thumbnail */ diff --git a/ext/image_hash_ban/main.php b/ext/image_hash_ban/main.php index cc3a7ca1..40ef6efc 100644 --- a/ext/image_hash_ban/main.php +++ b/ext/image_hash_ban/main.php @@ -106,7 +106,7 @@ class ImageBan extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if($event->parent==="system") { + if ($event->parent==="system") { if ($user->can(Permissions::BAN_IMAGE)) { $event->add_nav_link("image_bans", new Link('image_hash_ban/list/1'), "Image Bans", NavLink::is_active(["image_hash_ban"])); } diff --git a/ext/index/main.php b/ext/index/main.php index 9bf22091..59a878c9 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -262,10 +262,13 @@ class Index extends Extension if (SPEED_HAX) { if (!$user->can("big_search")) { $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) { $this->theme->display_error( - 404, "Search limit hit", + 404, + "Search limit hit", "Only $fast_page_limit pages of results are searchable - " . "if you want to find older results, use more specific search terms" ); @@ -334,19 +337,19 @@ class Index extends Extension public function onPageNavBuilding(PageNavBuildingEvent $event) { - $event->add_nav_link("posts", new Link('post/list'), "Posts", NavLink::is_active(["post","view"]),20); + $event->add_nav_link("posts", new Link('post/list'), "Posts", NavLink::is_active(["post","view"]), 20); } public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if($event->parent=="posts") { + if ($event->parent=="posts") { $event->add_nav_link("posts_all", new Link('post/list'), "All"); } } public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if($event->key===HelpPages::SEARCH) { + if ($event->key===HelpPages::SEARCH) { $block = new Block(); $block->header = "General"; $block->body = $this->theme->get_help_html(); diff --git a/ext/index/theme.php b/ext/index/theme.php index e216ea06..8c881afd 100644 --- a/ext/index/theme.php +++ b/ext/index/theme.php @@ -339,6 +339,5 @@ and of course start organising your images :-)
'; - } } diff --git a/ext/ipban/main.php b/ext/ipban/main.php index 90eb198a..6d62e546 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -108,7 +108,7 @@ class IPBan extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if($event->parent==="system") { + if ($event->parent==="system") { if ($user->can(Permissions::BAN_IP)) { $event->add_nav_link("ip_bans", new Link('ip_ban/list'), "IP Bans", NavLink::is_active(["ip_ban"])); } diff --git a/ext/log_db/main.php b/ext/log_db/main.php index 4002b68c..796118e4 100644 --- a/ext/log_db/main.php +++ b/ext/log_db/main.php @@ -123,7 +123,7 @@ class LogDatabase extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if($event->parent==="system") { + if ($event->parent==="system") { if ($user->can(Permissions::VIEW_EVENTLOG)) { $event->add_nav_link("event_log", new Link('log/view'), "Event Log"); } diff --git a/ext/media/main.php b/ext/media/main.php index 012507b3..a9853e61 100644 --- a/ext/media/main.php +++ b/ext/media/main.php @@ -18,7 +18,6 @@ abstract class MediaConfig const CONVERT_PATH = "media_convert_path"; const VERSION = "ext_media_version"; const MEM_LIMIT = 'media_mem_limit'; - } abstract class MediaEngine @@ -105,14 +104,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; @@ -144,7 +148,6 @@ class MediaCheckPropertiesEvent extends Event $this->file_name = $file_name; $this->ext = $ext; } - } @@ -193,7 +196,7 @@ class Media extends Extension [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"); } @@ -293,7 +296,6 @@ class Media extends Extension $sb->end_table(); $event->panel->add_block($sb); - } public function onAdminBuilding(AdminBuildingEvent $event) @@ -375,7 +377,8 @@ class Media extends Extension $event->target_format, $event->ignore_aspect_ratio, $event->target_quality, - $event->allow_upscale); + $event->allow_upscale + ); break; case MediaEngine::IMAGICK: @@ -391,7 +394,8 @@ class Media extends Extension $event->ignore_aspect_ratio, $event->target_quality, $event->minimize, - $event->allow_upscale); + $event->allow_upscale + ); //} break; default: @@ -421,7 +425,7 @@ class Media extends Extension public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if($event->key===HelpPages::SEARCH) { + if ($event->key===HelpPages::SEARCH) { $block = new Block(); $block->header = "Media"; $block->body = $this->theme->get_help_html(); @@ -480,7 +484,8 @@ class Media extends Extension "video" => $database->scoresql_value_prepare($mcpe->video), "audio" => $database->scoresql_value_prepare($mcpe->audio), "length" => $mcpe->length - ]); + ] + ); } public function get_images(String $ext = null) @@ -736,11 +741,12 @@ class Media extends Extension // } // } - public static function is_lossless(string $filename, string $format) { - if(in_array($format, self::LOSSLESS_FORMATS)) { + public static function is_lossless(string $filename, string $format) + { + if (in_array($format, self::LOSSLESS_FORMATS)) { return true; } - switch($format) { + switch ($format) { case "webp": return self::is_lossless_webp($filename); break; @@ -759,8 +765,7 @@ class Media extends Extension int $output_quality = 80, bool $minimize = false, bool $allow_upscale = true - ): void - { + ): void { global $config; $convert = $config->get_string(MediaConfig::CONVERT_PATH); @@ -773,7 +778,7 @@ class Media extends Extension $output_type = $input_type; } - if($output_type=="webp" && self::is_lossless($input_path, $input_type)) { + if ($output_type=="webp" && self::is_lossless($input_path, $input_type)) { $output_type = self::WEBP_LOSSLESS; } @@ -847,8 +852,7 @@ class Media extends Extension bool $ignore_aspect_ratio = false, int $output_quality = 80, bool $allow_upscale = true - ) - { + ) { $width = $info[0]; $height = $info[1]; @@ -949,16 +953,16 @@ class Media extends Extension // Actually resize the image. if (imagecopyresampled( - $image_resized, - $image, - 0, - 0, - 0, - 0, - $new_width, - $new_height, - $width, - $height + $image_resized, + $image, + 0, + 0, + 0, + 0, + $new_width, + $new_height, + $width, + $height ) === false) { throw new MediaException("Unable to copy resized image data to new image"); } @@ -1047,7 +1051,6 @@ class Media extends Extension } else { throw new MediaException("Unable to open file for byte check: $file_name"); } - } public static function is_animated_webp(String $image_filename): bool @@ -1091,7 +1094,7 @@ class Media extends Extension * @param $format * @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 ($lossless === true) { @@ -1114,7 +1117,7 @@ class Media extends Extension * @param string $filename * @return array [width, height] */ - static public function video_size(string $filename): array + public static function video_size(string $filename): array { global $config; $ffmpeg = $config->get_string(MediaConfig::FFMPEG_PATH); @@ -1139,5 +1142,4 @@ class Media extends Extension log_debug('Media', "Getting video size with `$cmd`, returns $output -- $size[0], $size[1]"); return $size; } - } diff --git a/ext/media/theme.php b/ext/media/theme.php index 7871ee69..15c3e03e 100644 --- a/ext/media/theme.php +++ b/ext/media/theme.php @@ -42,6 +42,5 @@ class MediaTheme extends ThemeletThese 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.
'; - } } diff --git a/ext/not_a_tag/main.php b/ext/not_a_tag/main.php index 369ab0ff..9c44ec6a 100644 --- a/ext/not_a_tag/main.php +++ b/ext/not_a_tag/main.php @@ -61,7 +61,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/notes/main.php b/ext/notes/main.php index 18c45f82..11c07729 100644 --- a/ext/notes/main.php +++ b/ext/notes/main.php @@ -218,7 +218,7 @@ class Notes extends Extension public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if($event->key===HelpPages::SEARCH) { + if ($event->key===HelpPages::SEARCH) { $block = new Block(); $block->header = "Notes"; $block->body = $this->theme->get_help_html(); diff --git a/ext/notes/theme.php b/ext/notes/theme.php index 6878c9c2..5d4d016b 100644 --- a/ext/notes/theme.php +++ b/ext/notes/theme.php @@ -269,7 +269,5 @@ class NotesTheme extends ThemeletReturns images with note(s) by user 123.
'; - } - } diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php index 0b93c369..30394e14 100644 --- a/ext/numeric_score/main.php +++ b/ext/numeric_score/main.php @@ -230,7 +230,7 @@ class NumericScore extends Extension public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if($event->key===HelpPages::SEARCH) { + if ($event->key===HelpPages::SEARCH) { $block = new Block(); $block->header = "Numeric Score"; $block->body = $this->theme->get_help_html(); @@ -306,11 +306,10 @@ class NumericScore extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if($event->parent=="posts") { + if ($event->parent=="posts") { $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_year", new Link('popular_by_year'), "Popular by Year"); - } } diff --git a/ext/numeric_score/theme.php b/ext/numeric_score/theme.php index e6dbe7fa..1d427322 100644 --- a/ext/numeric_score/theme.php +++ b/ext/numeric_score/theme.php @@ -132,6 +132,5 @@ class NumericScoreTheme extends ThemeletSorts the search results by score, ascending.
'; - } } diff --git a/ext/pm/main.php b/ext/pm/main.php index d2c7f44d..6d989c14 100644 --- a/ext/pm/main.php +++ b/ext/pm/main.php @@ -96,7 +96,7 @@ class PrivMsg extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if($event->parent==="user") { + if ($event->parent==="user") { if (!$user->is_anonymous()) { $count = $this->count_pms($user); $h_count = $count > 0 ? " ($count)" : ""; diff --git a/ext/pools/main.php b/ext/pools/main.php index 2fefbf73..fa8cd5d5 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -46,7 +46,6 @@ class PoolAddPostsEvent extends Event $this->pool_id = $pool_id; $this->posts = $posts; } - } class PoolCreationEvent extends Event @@ -67,7 +66,6 @@ class PoolCreationEvent extends Event $this->public = $public; $this->description = $description; } - } class Pools extends Extension @@ -152,7 +150,7 @@ class Pools extends Extension public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if($event->parent=="pool") { + if ($event->parent=="pool") { $event->add_nav_link("pool_list", new Link('pool/list'), "List"); $event->add_nav_link("pool_new", new Link('pool/new'), "Create"); $event->add_nav_link("pool_updated", new Link('pool/updated'), "Changes"); @@ -198,7 +196,8 @@ class Pools extends Extension $title, $user, $_POST["public"] === "Y", - $_POST["description"]); + $_POST["description"] + ); send_event($event); $page->set_mode(PageMode::REDIRECT); @@ -374,7 +373,7 @@ class Pools extends Extension public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if($event->key===HelpPages::SEARCH) { + if ($event->key===HelpPages::SEARCH) { $block = new Block(); $block->header = "Pools"; $block->body = $this->theme->get_help_html(); @@ -443,8 +442,8 @@ class Pools extends Extension $pools = $database->get_all("SELECT * FROM pools ORDER BY title "); - $event->add_action("bulk_pool_add_existing", "Add To (P)ool", "p","", $this->theme->get_bulk_pool_selector($pools)); - $event->add_action("bulk_pool_add_new", "Create Pool", "","", $this->theme->get_bulk_pool_input($event->search_terms)); + $event->add_action("bulk_pool_add_existing", "Add To (P)ool", "p", "", $this->theme->get_bulk_pool_selector($pools)); + $event->add_action("bulk_pool_add_new", "Create Pool", "", "", $this->theme->get_bulk_pool_input($event->search_terms)); } public function onBulkAction(BulkActionEvent $event) @@ -461,7 +460,8 @@ class Pools extends Extension if ($this->have_permission($user, $pool)) { 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; case "bulk_pool_add_new": @@ -809,7 +809,7 @@ class Pools extends Extension if (ext_is_live("Ratings")) { $query .= "AND i.rating IN (".Ratings::privs_to_sql(Ratings::get_user_class_privs($user)).")"; } - if(ext_is_live("trash")) { + if (ext_is_live("trash")) { $query .= $database->scoreql_to_sql(" AND trash = SCORE_BOOL_N "); } @@ -823,10 +823,10 @@ class Pools extends Extension ); $totalPages = ceil($database->get_one( - " + " SELECT COUNT(*) FROM pool_images p $query", - ["pid" => $poolID] + ["pid" => $poolID] ) / $imagesPerPage); diff --git a/ext/pools/theme.php b/ext/pools/theme.php index 86a2406c..bfaacb30 100644 --- a/ext/pools/theme.php +++ b/ext/pools/theme.php @@ -401,7 +401,7 @@ class PoolsTheme extends Themelet public function get_bulk_pool_input(array $search_terms) { - return ""; + return ""; } @@ -429,6 +429,5 @@ class PoolsTheme extends ThemeletReturns images in the "swimming pool" pool. Note that the underscore becomes a space
'; - } } diff --git a/ext/post_titles/config.php b/ext/post_titles/config.php index 5499bfad..cd51aa58 100644 --- a/ext/post_titles/config.php +++ b/ext/post_titles/config.php @@ -6,4 +6,4 @@ abstract class PostTitlesConfig public const VERSION = "ext_post_titles_version"; public const DEFAULT_TO_FILENAME = "post_titles_default_to_filename"; public const SHOW_IN_WINDOW_TITLE = "post_titles_show_in_window_title"; -} \ No newline at end of file +} diff --git a/ext/post_titles/events/post_title_set_event.php b/ext/post_titles/events/post_title_set_event.php index 57f942f7..94ca7476 100644 --- a/ext/post_titles/events/post_title_set_event.php +++ b/ext/post_titles/events/post_title_set_event.php @@ -10,4 +10,4 @@ class PostTitleSetEvent extends Event $this->image = $image; $this->title = $title; } -} \ No newline at end of file +} diff --git a/ext/post_titles/main.php b/ext/post_titles/main.php index 50f550c3..a5bdde2f 100644 --- a/ext/post_titles/main.php +++ b/ext/post_titles/main.php @@ -42,7 +42,7 @@ class PostTitles extends Extension { global $config; - if($config->get_bool(PostTitlesConfig::SHOW_IN_WINDOW_TITLE)) { + if ($config->get_bool(PostTitlesConfig::SHOW_IN_WINDOW_TITLE)) { $event->set_title(self::get_title($event->get_image())); } } @@ -73,8 +73,8 @@ class PostTitles extends Extension { $sb = new SetupBlock("Post Titles"); $sb->start_table(); - $sb->add_bool_option(PostTitlesConfig::DEFAULT_TO_FILENAME,"Default to filename", true); - $sb->add_bool_option(PostTitlesConfig::SHOW_IN_WINDOW_TITLE,"Show in window title", true); + $sb->add_bool_option(PostTitlesConfig::DEFAULT_TO_FILENAME, "Default to filename", true); + $sb->add_bool_option(PostTitlesConfig::SHOW_IN_WINDOW_TITLE, "Show in window title", true); $sb->end_table(); $event->panel->add_block($sb); @@ -94,9 +94,9 @@ class PostTitles extends Extension global $config; $title = $image->title??""; - if(empty($title) && $config->get_bool(PostTitlesConfig::DEFAULT_TO_FILENAME)) { + if (empty($title) && $config->get_bool(PostTitlesConfig::DEFAULT_TO_FILENAME)) { $info = pathinfo($image->filename); - if(array_key_exists("extension",$info)) { + if (array_key_exists("extension", $info)) { $title = basename($image->filename, '.' . $info['extension']); } else { $title = $image->filename; diff --git a/ext/post_titles/theme.php b/ext/post_titles/theme.php index 53a6c1b5..9776389a 100644 --- a/ext/post_titles/theme.php +++ b/ext/post_titles/theme.php @@ -3,8 +3,6 @@ class PostTitlesTheme extends Themelet { public function get_title_set_html(string $title, bool $can_set): string { - - $html = "Change | |
---|---|
To |