This commit is contained in:
Shish 2023-11-11 21:49:12 +00:00
parent 848797030e
commit fd1bb21f9d
235 changed files with 1551 additions and 1591 deletions

536
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -260,7 +260,7 @@ class BasePage
*/ */
public function display(): void public function display(): void
{ {
if ($this->mode!=PageMode::MANUAL) { if ($this->mode != PageMode::MANUAL) {
$this->send_headers(); $this->send_headers();
} }
@ -474,14 +474,14 @@ class BasePage
$active_link = null; $active_link = null;
// To save on event calls, we check if one of the top-level links has already been marked as active // 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) { foreach ($nav_links as $link) {
if ($link->active===true) { if ($link->active === true) {
$active_link = $link; $active_link = $link;
break; break;
} }
} }
$sub_links = null; $sub_links = null;
// If one is, we just query for sub-menu options under that one tab // If one is, we just query for sub-menu options under that one tab
if ($active_link!==null) { if ($active_link !== null) {
$psnbe = send_event(new PageSubNavBuildingEvent($active_link->name)); $psnbe = send_event(new PageSubNavBuildingEvent($active_link->name));
$sub_links = $psnbe->links; $sub_links = $psnbe->links;
} else { } else {
@ -491,20 +491,20 @@ class BasePage
// Now we check for a current link so we can identify the sub-links to show // Now we check for a current link so we can identify the sub-links to show
foreach ($psnbe->links as $sub_link) { foreach ($psnbe->links as $sub_link) {
if ($sub_link->active===true) { if ($sub_link->active === true) {
$sub_links = $psnbe->links; $sub_links = $psnbe->links;
break; break;
} }
} }
// If the active link has been detected, we break out // If the active link has been detected, we break out
if ($sub_links!==null) { if ($sub_links !== null) {
$link->active = true; $link->active = true;
break; break;
} }
} }
} }
$sub_links = $sub_links??[]; $sub_links = $sub_links ?? [];
usort($nav_links, "Shimmie2\sort_nav_links"); usort($nav_links, "Shimmie2\sort_nav_links");
usort($sub_links, "Shimmie2\sort_nav_links"); usort($sub_links, "Shimmie2\sort_nav_links");
@ -628,7 +628,7 @@ class PageSubNavBuildingEvent extends Event
public function __construct(string $parent) public function __construct(string $parent)
{ {
parent::__construct(); parent::__construct();
$this->parent= $parent; $this->parent = $parent;
} }
public function add_nav_link(string $name, Link $link, string|HTMLElement $desc, ?bool $active = null, int $order = 50) public function add_nav_link(string $name, Link $link, string|HTMLElement $desc, ?bool $active = null, int $order = 50)
@ -653,7 +653,7 @@ class NavLink
$this->link = $link; $this->link = $link;
$this->description = $description; $this->description = $description;
$this->order = $order; $this->order = $order;
if ($active==null) { if ($active == null) {
$query = ltrim(_get_query(), "/"); $query = ltrim(_get_query(), "/");
if ($query === "") { if ($query === "") {
// This indicates the front page, so we check what's set as the front page // This indicates the front page, so we check what's set as the front page
@ -664,7 +664,7 @@ class NavLink
} else { } else {
$this->active = self::is_active([$link->page], $front_page); $this->active = self::is_active([$link->page], $front_page);
} }
} elseif ($query===$link->page) { } elseif ($query === $link->page) {
$this->active = true; $this->active = true;
} else { } else {
$this->active = self::is_active([$link->page]); $this->active = self::is_active([$link->page]);
@ -679,18 +679,18 @@ class NavLink
/** /**
* Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.)
*/ */
$url = $url??ltrim(_get_query(), "/"); $url = $url ?? ltrim(_get_query(), "/");
$re1='.*?'; $re1 = '.*?';
$re2='((?:[a-z][a-z_]+))'; $re2 = '((?:[a-z][a-z_]+))';
if (preg_match_all("/".$re1.$re2."/is", $url, $matches)) { if (preg_match_all("/".$re1.$re2."/is", $url, $matches)) {
$url=$matches[1][0]; $url = $matches[1][0];
} }
$count_pages_matched = count($pages_matched); $count_pages_matched = count($pages_matched);
for ($i=0; $i < $count_pages_matched; $i++) { for ($i = 0; $i < $count_pages_matched; $i++) {
if ($url == $pages_matched[$i]) { if ($url == $pages_matched[$i]) {
return true; return true;
} }

View file

@ -81,22 +81,22 @@ class BaseThemelet
return A( return A(
[ [
"href"=>$view_link, "href" => $view_link,
"class"=>"thumb shm-thumb shm-thumb-link $custom_classes", "class" => "thumb shm-thumb shm-thumb-link $custom_classes",
"data-tags"=>$tags, "data-tags" => $tags,
"data-height"=>$image->height, "data-height" => $image->height,
"data-width"=>$image->width, "data-width" => $image->width,
"data-mime"=>$image->get_mime(), "data-mime" => $image->get_mime(),
"data-post-id"=>$id, "data-post-id" => $id,
], ],
IMG( IMG(
[ [
"id"=>"thumb_$id", "id" => "thumb_$id",
"title"=>$tip, "title" => $tip,
"alt"=>$tip, "alt" => $tip,
"height"=>$tsize[1], "height" => $tsize[1],
"width"=>$tsize[0], "width" => $tsize[0],
"src"=>$thumb_link, "src" => $thumb_link,
] ]
) )
); );
@ -112,18 +112,18 @@ class BaseThemelet
$page->add_html_header("<link rel='first' href='".make_http(make_link($base.'/1', $query))."'>"); $page->add_html_header("<link rel='first' href='".make_http(make_link($base.'/1', $query))."'>");
if ($page_number < $total_pages) { if ($page_number < $total_pages) {
$page->add_html_header("<link rel='prefetch' href='".make_http(make_link($base.'/'.($page_number+1), $query))."'>"); $page->add_html_header("<link rel='prefetch' href='".make_http(make_link($base.'/'.($page_number + 1), $query))."'>");
$page->add_html_header("<link rel='next' href='".make_http(make_link($base.'/'.($page_number+1), $query))."'>"); $page->add_html_header("<link rel='next' href='".make_http(make_link($base.'/'.($page_number + 1), $query))."'>");
} }
if ($page_number > 1) { if ($page_number > 1) {
$page->add_html_header("<link rel='previous' href='".make_http(make_link($base.'/'.($page_number-1), $query))."'>"); $page->add_html_header("<link rel='previous' href='".make_http(make_link($base.'/'.($page_number - 1), $query))."'>");
} }
$page->add_html_header("<link rel='last' href='".make_http(make_link($base.'/'.$total_pages, $query))."'>"); $page->add_html_header("<link rel='last' href='".make_http(make_link($base.'/'.$total_pages, $query))."'>");
} }
private function gen_page_link(string $base_url, ?string $query, int $page, string $name): HTMLElement private function gen_page_link(string $base_url, ?string $query, int $page, string $name): HTMLElement
{ {
return A(["href"=>make_link($base_url.'/'.$page, $query)], $name); return A(["href" => make_link($base_url.'/'.$page, $query)], $name);
} }
private function gen_page_link_block(string $base_url, ?string $query, int $page, int $current_page, string $name): HTMLElement private function gen_page_link_block(string $base_url, ?string $query, int $page, int $current_page, string $name): HTMLElement

View file

@ -45,7 +45,7 @@ class Block
*/ */
public bool $is_content = true; public bool $is_content = true;
public function __construct(string $header=null, string|\MicroHTML\HTMLElement $body=null, string $section="main", int $position=50, string $id=null) public function __construct(string $header = null, string|\MicroHTML\HTMLElement $body = null, string $section = "main", int $position = 50, string $id = null)
{ {
$this->header = $header; $this->header = $header;
$this->body = (string)$body; $this->body = (string)$body;
@ -63,7 +63,7 @@ class Block
/** /**
* Get the HTML for this block. * Get the HTML for this block.
*/ */
public function get_html(bool $hidable=false): string public function get_html(bool $hidable = false): string
{ {
$h = $this->header; $h = $this->header;
$b = $this->body; $b = $this->body;

View file

@ -10,8 +10,8 @@ class EventTracingCache implements CacheInterface
{ {
private CacheInterface $engine; private CacheInterface $engine;
private \EventTracer $tracer; private \EventTracer $tracer;
private int $hits=0; private int $hits = 0;
private int $misses=0; private int $misses = 0;
public function __construct(CacheInterface $engine, \EventTracer $tracer) public function __construct(CacheInterface $engine, \EventTracer $tracer)
{ {
@ -19,7 +19,7 @@ class EventTracingCache implements CacheInterface
$this->tracer = $tracer; $this->tracer = $tracer;
} }
public function get($key, $default=null) public function get($key, $default = null)
{ {
if ($key === "__etc_cache_hits") { if ($key === "__etc_cache_hits") {
return $this->hits; return $this->hits;
@ -29,7 +29,7 @@ class EventTracingCache implements CacheInterface
} }
$sentinel = "__etc_sentinel"; $sentinel = "__etc_sentinel";
$this->tracer->begin("Cache Get", ["key"=>$key]); $this->tracer->begin("Cache Get", ["key" => $key]);
$val = $this->engine->get($key, $sentinel); $val = $this->engine->get($key, $sentinel);
if ($val != $sentinel) { if ($val != $sentinel) {
$res = "hit"; $res = "hit";
@ -39,13 +39,13 @@ class EventTracingCache implements CacheInterface
$val = $default; $val = $default;
$this->misses++; $this->misses++;
} }
$this->tracer->end(null, ["result"=>$res]); $this->tracer->end(null, ["result" => $res]);
return $val; return $val;
} }
public function set($key, $value, $ttl = null) public function set($key, $value, $ttl = null)
{ {
$this->tracer->begin("Cache Set", ["key"=>$key, "ttl"=>$ttl]); $this->tracer->begin("Cache Set", ["key" => $key, "ttl" => $ttl]);
$val = $this->engine->set($key, $value, $ttl); $val = $this->engine->set($key, $value, $ttl);
$this->tracer->end(); $this->tracer->end();
return $val; return $val;
@ -53,7 +53,7 @@ class EventTracingCache implements CacheInterface
public function delete($key) public function delete($key)
{ {
$this->tracer->begin("Cache Delete", ["key"=>$key]); $this->tracer->begin("Cache Delete", ["key" => $key]);
$val = $this->engine->delete($key); $val = $this->engine->delete($key);
$this->tracer->end(); $this->tracer->end();
return $val; return $val;
@ -93,9 +93,9 @@ class EventTracingCache implements CacheInterface
public function has($key) public function has($key)
{ {
$this->tracer->begin("Cache Has", ["key"=>$key]); $this->tracer->begin("Cache Has", ["key" => $key]);
$val = $this->engine->has($key); $val = $this->engine->has($key);
$this->tracer->end(null, ["exists"=>$val]); $this->tracer->end(null, ["exists" => $val]);
return $val; return $val;
} }
} }

View file

@ -61,7 +61,7 @@ class CommandBuilder
log_debug('command_builder', "Command `$cmd` returned $ret and outputted $output"); log_debug('command_builder', "Command `$cmd` returned $ret and outputted $output");
if ($fail_on_non_zero_return&&(int)$ret!==(int)0) { if ($fail_on_non_zero_return && (int)$ret !== (int)0) {
throw new SCoreException("Command `$cmd` failed, returning $ret and outputting $output"); throw new SCoreException("Command `$cmd` failed, returning $ret and outputting $output");
} }
return $ret; return $ret;

View file

@ -16,7 +16,7 @@ interface Config
* so that the next time a page is loaded it will use the new * so that the next time a page is loaded it will use the new
* configuration. * configuration.
*/ */
public function save(string $name=null): void; public function save(string $name = null): void;
//@{ /*--------------------------------- SET ------------------------------------------------------*/ //@{ /*--------------------------------- SET ------------------------------------------------------*/
/** /**
@ -101,27 +101,27 @@ interface Config
/** /**
* Pick a value out of the table by name, cast to the appropriate data type. * Pick a value out of the table by name, cast to the appropriate data type.
*/ */
public function get_int(string $name, ?int $default=null): ?int; public function get_int(string $name, ?int $default = null): ?int;
/** /**
* Pick a value out of the table by name, cast to the appropriate data type. * Pick a value out of the table by name, cast to the appropriate data type.
*/ */
public function get_float(string $name, ?float $default=null): ?float; public function get_float(string $name, ?float $default = null): ?float;
/** /**
* Pick a value out of the table by name, cast to the appropriate data type. * Pick a value out of the table by name, cast to the appropriate data type.
*/ */
public function get_string(string $name, ?string $default=null): ?string; public function get_string(string $name, ?string $default = null): ?string;
/** /**
* Pick a value out of the table by name, cast to the appropriate data type. * Pick a value out of the table by name, cast to the appropriate data type.
*/ */
public function get_bool(string $name, ?bool $default=null): ?bool; public function get_bool(string $name, ?bool $default = null): ?bool;
/** /**
* Pick a value out of the table by name, cast to the appropriate data type. * Pick a value out of the table by name, cast to the appropriate data type.
*/ */
public function get_array(string $name, ?array $default=[]): ?array; public function get_array(string $name, ?array $default = []): ?array;
//@} /*--------------------------------------------------------------------------------------------*/ //@} /*--------------------------------------------------------------------------------------------*/
} }
@ -162,7 +162,7 @@ abstract class BaseConfig implements Config
public function set_array(string $name, ?array $value): void public function set_array(string $name, ?array $value): void
{ {
if ($value!=null) { if ($value != null) {
$this->values[$name] = implode(",", $value); $this->values[$name] = implode(",", $value);
} else { } else {
$this->values[$name] = null; $this->values[$name] = null;
@ -205,17 +205,17 @@ abstract class BaseConfig implements Config
} }
} }
public function get_int(string $name, ?int $default=null): ?int public function get_int(string $name, ?int $default = null): ?int
{ {
return (int)($this->get($name, $default)); return (int)($this->get($name, $default));
} }
public function get_float(string $name, ?float $default=null): ?float public function get_float(string $name, ?float $default = null): ?float
{ {
return (float)($this->get($name, $default)); return (float)($this->get($name, $default));
} }
public function get_string(string $name, ?string $default=null): ?string public function get_string(string $name, ?string $default = null): ?string
{ {
$val = $this->get($name, $default); $val = $this->get($name, $default);
if (!is_string($val) && !is_null($val)) { if (!is_string($val) && !is_null($val)) {
@ -224,17 +224,17 @@ abstract class BaseConfig implements Config
return $val; return $val;
} }
public function get_bool(string $name, ?bool $default=null): ?bool public function get_bool(string $name, ?bool $default = null): ?bool
{ {
return bool_escape($this->get($name, $default)); return bool_escape($this->get($name, $default));
} }
public function get_array(string $name, ?array $default=[]): ?array public function get_array(string $name, ?array $default = []): ?array
{ {
return explode(",", $this->get($name, "")); return explode(",", $this->get($name, ""));
} }
private function get(string $name, $default=null) private function get(string $name, $default = null)
{ {
if (isset($this->values[$name])) { if (isset($this->values[$name])) {
return $this->values[$name]; return $this->values[$name];
@ -289,7 +289,7 @@ class DatabaseConfig extends BaseConfig
$query = "SELECT name, value FROM {$this->table_name}"; $query = "SELECT name, value FROM {$this->table_name}";
$args = []; $args = [];
if (!empty($sub_column)&&!empty($sub_value)) { if (!empty($sub_column) && !empty($sub_value)) {
$query .= " WHERE $sub_column = :sub_value"; $query .= " WHERE $sub_column = :sub_value";
$args["sub_value"] = $sub_value; $args["sub_value"] = $sub_value;
} }
@ -301,7 +301,7 @@ class DatabaseConfig extends BaseConfig
} }
} }
public function save(string $name=null): void public function save(string $name = null): void
{ {
global $cache; global $cache;
@ -312,10 +312,10 @@ class DatabaseConfig extends BaseConfig
} }
} else { } else {
$query = "DELETE FROM {$this->table_name} WHERE name = :name"; $query = "DELETE FROM {$this->table_name} WHERE name = :name";
$args = ["name"=>$name]; $args = ["name" => $name];
$cols = ["name","value"]; $cols = ["name","value"];
$params = [":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"; $query .= " AND $this->sub_column = :sub_value";
$args["sub_value"] = $this->sub_value; $args["sub_value"] = $this->sub_value;
$cols[] = $this->sub_column; $cols[] = $this->sub_column;
@ -324,7 +324,7 @@ class DatabaseConfig extends BaseConfig
$this->database->execute($query, $args); $this->database->execute($query, $args);
$args["value"] =$this->values[$name]; $args["value"] = $this->values[$name];
$this->database->execute( $this->database->execute(
"INSERT INTO {$this->table_name} (".join(",", $cols).") VALUES (".join(",", $params).")", "INSERT INTO {$this->table_name} (".join(",", $cols).") VALUES (".join(",", $params).")",
$args $args

View file

@ -57,7 +57,7 @@ class Database
private function connect_engine(): void private function connect_engine(): void
{ {
if (preg_match("/^([^:]*)/", $this->dsn, $matches)) { if (preg_match("/^([^:]*)/", $this->dsn, $matches)) {
$db_proto=$matches[1]; $db_proto = $matches[1];
} else { } else {
throw new SCoreException("Can't figure out database engine"); throw new SCoreException("Can't figure out database engine");
} }
@ -138,7 +138,7 @@ class Database
$query = preg_replace('/ +/m', ' ', $query); $query = preg_replace('/ +/m', ' ', $query);
$query = trim($query); $query = trim($query);
if ($tracer_enabled) { if ($tracer_enabled) {
$_tracer->complete($start * 1000000, $dur * 1000000, "DB Query", ["query"=>$query, "args"=>$args, "method"=>$method]); $_tracer->complete($start * 1000000, $dur * 1000000, "DB Query", ["query" => $query, "args" => $args, "method" => $method]);
} }
$this->queries[] = $query; $this->queries[] = $query;
$this->query_count++; $this->query_count++;
@ -150,7 +150,7 @@ class Database
$this->get_engine()->set_timeout($this->get_db(), $time); $this->get_engine()->set_timeout($this->get_db(), $time);
} }
public function notify(string $channel, ?string $data=null): void public function notify(string $channel, ?string $data = null): void
{ {
$this->get_engine()->notify($this->get_db(), $channel, $data); $this->get_engine()->notify($this->get_db(), $channel, $data);
} }
@ -285,7 +285,7 @@ class Database
$_start = ftime(); $_start = ftime();
$row = $this->_execute($query, $args)->fetch(); $row = $this->_execute($query, $args)->fetch();
$this->count_time("exists", $_start, $query, $args); $this->count_time("exists", $_start, $query, $args);
if ($row==null) { if ($row == null) {
return false; return false;
} }
return true; return true;
@ -346,7 +346,7 @@ class Database
return $this->get_db(); return $this->get_db();
} }
public function standardise_boolean(string $table, string $column, bool $include_postgres=false): void public function standardise_boolean(string $table, string $column, bool $include_postgres = false): void
{ {
$d = $this->get_driver_id(); $d = $this->get_driver_id();
if ($d == DatabaseDriverID::MYSQL) { if ($d == DatabaseDriverID::MYSQL) {

View file

@ -34,7 +34,7 @@ abstract class DBEngine
abstract public function get_version(PDO $db): string; abstract public function get_version(PDO $db): string;
abstract public function notify(PDO $db, string $channel, ?string $data=null): void; abstract public function notify(PDO $db, string $channel, ?string $data = null): void;
} }
class MySQL extends DBEngine class MySQL extends DBEngine
@ -66,7 +66,7 @@ class MySQL extends DBEngine
// $db->exec("SET SESSION MAX_EXECUTION_TIME=".$time.";"); // $db->exec("SET SESSION MAX_EXECUTION_TIME=".$time.";");
} }
public function notify(PDO $db, string $channel, ?string $data=null): void public function notify(PDO $db, string $channel, ?string $data = null): void
{ {
} }
@ -113,7 +113,7 @@ class PostgreSQL extends DBEngine
$db->exec("SET statement_timeout TO ".$time.";"); $db->exec("SET statement_timeout TO ".$time.";");
} }
public function notify(PDO $db, string $channel, ?string $data=null): void public function notify(PDO $db, string $channel, ?string $data = null): void
{ {
if ($data) { if ($data) {
$db->exec("NOTIFY $channel, '$data';"); $db->exec("NOTIFY $channel, '$data';");
@ -141,7 +141,7 @@ function _floor($a): float
{ {
return floor($a); return floor($a);
} }
function _log($a, $b=null): float function _log($a, $b = null): float
{ {
if (is_null($b)) { if (is_null($b)) {
return log($a); return log($a);
@ -225,7 +225,7 @@ class SQLite extends DBEngine
// There doesn't seem to be such a thing for SQLite, so it does nothing // There doesn't seem to be such a thing for SQLite, so it does nothing
} }
public function notify(PDO $db, string $channel, ?string $data=null): void public function notify(PDO $db, string $channel, ?string $data = null): void
{ {
} }

View file

@ -87,7 +87,7 @@ class PageRequestEvent extends Event
return false; return false;
} }
for ($i=0; $i<$this->part_count; $i++) { for ($i = 0; $i < $this->part_count; $i++) {
if ($parts[$i] != $this->args[$i]) { if ($parts[$i] != $this->args[$i]) {
return false; return false;
} }
@ -114,7 +114,7 @@ class PageRequestEvent extends Event
* If page arg $n is set, then treat that as a 1-indexed page number * If page arg $n is set, then treat that as a 1-indexed page number
* and return a 0-indexed page number less than $max; else return 0 * and return a 0-indexed page number less than $max; else return 0
*/ */
public function try_page_num(int $n, ?int $max=null): int public function try_page_num(int $n, ?int $max = null): int
{ {
if ($this->count_args() > $n) { if ($this->count_args() > $n) {
$i = $this->get_arg($n); $i = $this->get_arg($n);
@ -195,7 +195,7 @@ class CommandEvent extends Event
$log_level = SCORE_LOG_WARNING; $log_level = SCORE_LOG_WARNING;
$arg_count = count($args); $arg_count = count($args);
for ($i=1; $i<$arg_count; $i++) { for ($i = 1; $i < $arg_count; $i++) {
switch ($args[$i]) { switch ($args[$i]) {
case '-u': case '-u':
$user = User::by_name($args[++$i]); $user = User::by_name($args[++$i]);

View file

@ -13,7 +13,7 @@ class SCoreException extends \RuntimeException
public string $error; public string $error;
public int $http_code = 500; public int $http_code = 500;
public function __construct(string $msg, ?string $query=null) public function __construct(string $msg, ?string $query = null)
{ {
parent::__construct($msg); parent::__construct($msg);
$this->error = $msg; $this->error = $msg;

View file

@ -69,7 +69,7 @@ abstract class Extension
$extras $extras
) as $key) { ) as $key) {
$ext = ExtensionInfo::get_by_key($key); $ext = ExtensionInfo::get_by_key($key);
if ($ext===null || !$ext->is_supported()) { if ($ext === null || !$ext->is_supported()) {
continue; continue;
} }
// FIXME: error if one of our dependencies isn't supported // FIXME: error if one of our dependencies isn't supported
@ -123,7 +123,7 @@ abstract class ExtensionInfo
public const SHISH_NAME = "Shish"; public const SHISH_NAME = "Shish";
public const SHISH_EMAIL = "webmaster@shishnet.org"; public const SHISH_EMAIL = "webmaster@shishnet.org";
public const SHIMMIE_URL = "https://code.shishnet.org/shimmie2/"; public const SHIMMIE_URL = "https://code.shishnet.org/shimmie2/";
public const SHISH_AUTHOR = [self::SHISH_NAME=>self::SHISH_EMAIL]; public const SHISH_AUTHOR = [self::SHISH_NAME => self::SHISH_EMAIL];
public const LICENSE_GPLV2 = "GPLv2"; public const LICENSE_GPLV2 = "GPLv2";
public const LICENSE_MIT = "MIT"; public const LICENSE_MIT = "MIT";
@ -152,7 +152,7 @@ abstract class ExtensionInfo
public function is_supported(): bool public function is_supported(): bool
{ {
if ($this->supported===null) { if ($this->supported === null) {
$this->check_support(); $this->check_support();
} }
return $this->supported; return $this->supported;
@ -160,7 +160,7 @@ abstract class ExtensionInfo
public function get_support_info(): string public function get_support_info(): string
{ {
if ($this->supported===null) { if ($this->supported === null) {
$this->check_support(); $this->check_support();
} }
return $this->support_info; return $this->support_info;
@ -249,7 +249,7 @@ abstract class ExtensionInfo
self::$all_info_by_key[$extension_info->key] = $extension_info; self::$all_info_by_key[$extension_info->key] = $extension_info;
self::$all_info_by_class[$class] = $extension_info; self::$all_info_by_class[$class] = $extension_info;
if ($extension_info->core===true) { if ($extension_info->core === true) {
self::$core_extensions[] = $extension_info->key; self::$core_extensions[] = $extension_info->key;
} }
} }

View file

@ -84,7 +84,7 @@ class ThumbnailGenerationEvent extends Event
public function __construct( public function __construct(
public string $hash, public string $hash,
public string $mime, public string $mime,
public bool $force=false public bool $force = false
) { ) {
parent::__construct(); parent::__construct();
$this->generated = false; $this->generated = false;

View file

@ -63,7 +63,7 @@ class Image
* One will very rarely construct an image directly, more common * One will very rarely construct an image directly, more common
* would be to use Image::by_id, Image::by_hash, etc. * would be to use Image::by_id, Image::by_hash, etc.
*/ */
public function __construct(?array $row=null) public function __construct(?array $row = null)
{ {
if (!is_null($row)) { if (!is_null($row)) {
foreach ($row as $name => $value) { foreach ($row as $name => $value) {
@ -103,11 +103,11 @@ class Image
public static function by_id(int $post_id): ?Image public static function by_id(int $post_id): ?Image
{ {
global $database; global $database;
if ($post_id > 2**32) { if ($post_id > 2 ** 32) {
// for some reason bots query huge numbers and pollute the DB error logs... // for some reason bots query huge numbers and pollute the DB error logs...
return null; return null;
} }
$row = $database->get_row("SELECT * FROM images WHERE images.id=:id", ["id"=>$post_id]); $row = $database->get_row("SELECT * FROM images WHERE images.id=:id", ["id" => $post_id]);
return ($row ? new Image($row) : null); return ($row ? new Image($row) : null);
} }
@ -115,7 +115,7 @@ class Image
{ {
global $database; global $database;
$hash = strtolower($hash); $hash = strtolower($hash);
$row = $database->get_row("SELECT images.* FROM images WHERE hash=:hash", ["hash"=>$hash]); $row = $database->get_row("SELECT images.* FROM images WHERE hash=:hash", ["hash" => $hash]);
return ($row ? new Image($row) : null); return ($row ? new Image($row) : null);
} }
@ -124,7 +124,7 @@ class Image
return (is_numeric($id) && strlen($id) != 32) ? Image::by_id((int)$id) : Image::by_hash($id); return (is_numeric($id) && strlen($id) != 32) ? Image::by_id((int)$id) : Image::by_hash($id);
} }
public static function by_random(array $tags=[], int $limit_range=0): ?Image public static function by_random(array $tags = [], int $limit_range = 0): ?Image
{ {
$max = Image::count_images($tags); $max = Image::count_images($tags);
if ($max < 1) { if ($max < 1) {
@ -133,7 +133,7 @@ class Image
if ($limit_range > 0 && $max > $limit_range) { if ($limit_range > 0 && $max > $limit_range) {
$max = $limit_range; $max = $limit_range;
} }
$rand = mt_rand(0, $max-1); $rand = mt_rand(0, $max - 1);
$set = Image::find_images($rand, 1, $tags); $set = Image::find_images($rand, 1, $tags);
if (count($set) > 0) { if (count($set) > 0) {
return $set[0]; return $set[0];
@ -142,7 +142,7 @@ class Image
} }
} }
private static function find_images_internal(int $start = 0, ?int $limit = null, array $tags=[]): iterable private static function find_images_internal(int $start = 0, ?int $limit = null, array $tags = []): iterable
{ {
global $database, $user; global $database, $user;
@ -170,7 +170,7 @@ class Image
* @return Image[] * @return Image[]
*/ */
#[Query(name: "posts", type: "[Post!]!", args: ["tags" => "[string!]"])] #[Query(name: "posts", type: "[Post!]!", args: ["tags" => "[string!]"])]
public static function find_images(int $offset = 0, ?int $limit = null, array $tags=[]): array public static function find_images(int $offset = 0, ?int $limit = null, array $tags = []): array
{ {
$result = self::find_images_internal($offset, $limit, $tags); $result = self::find_images_internal($offset, $limit, $tags);
@ -184,7 +184,7 @@ class Image
/** /**
* Search for an array of images, returning a iterable object of Image * Search for an array of images, returning a iterable object of Image
*/ */
public static function find_images_iterable(int $start = 0, ?int $limit = null, array $tags=[]): \Generator public static function find_images_iterable(int $start = 0, ?int $limit = null, array $tags = []): \Generator
{ {
$result = self::find_images_internal($start, $limit, $tags); $result = self::find_images_internal($start, $limit, $tags);
foreach ($result as $row) { foreach ($result as $row) {
@ -212,7 +212,7 @@ class Image
global $database; global $database;
return (int)$database->get_one( return (int)$database->get_one(
"SELECT count FROM tags WHERE LOWER(tag) = LOWER(:tag)", "SELECT count FROM tags WHERE LOWER(tag) = LOWER(:tag)",
["tag"=>$tag] ["tag" => $tag]
); );
} }
@ -221,7 +221,7 @@ class Image
* *
* @param string[] $tags * @param string[] $tags
*/ */
public static function count_images(array $tags=[]): int public static function count_images(array $tags = []): int
{ {
global $cache, $database; global $cache, $database;
$tag_count = count($tags); $tag_count = count($tags);
@ -266,7 +266,7 @@ class Image
* *
* @param string[] $tags * @param string[] $tags
*/ */
public static function count_pages(array $tags=[]): int public static function count_pages(array $tags = []): int
{ {
global $config; global $config;
return (int)ceil(Image::count_images($tags) / $config->get_int(IndexConfig::IMAGES)); return (int)ceil(Image::count_images($tags) / $config->get_int(IndexConfig::IMAGES));
@ -284,7 +284,7 @@ class Image
* *
* @param string[] $tags * @param string[] $tags
*/ */
public function get_next(array $tags=[], bool $next=true): ?Image public function get_next(array $tags = [], bool $next = true): ?Image
{ {
global $database; global $database;
@ -320,7 +320,7 @@ class Image
* *
* @param string[] $tags * @param string[] $tags
*/ */
public function get_prev(array $tags=[]): ?Image public function get_prev(array $tags = []): ?Image
{ {
return $this->get_next($tags, false); return $this->get_next($tags, false);
} }
@ -345,7 +345,7 @@ class Image
UPDATE images UPDATE images
SET owner_id=:owner_id SET owner_id=:owner_id
WHERE id=:id WHERE id=:id
", ["owner_id"=>$owner->id, "id"=>$this->id]); ", ["owner_id" => $owner->id, "id" => $this->id]);
log_info("core_image", "Owner for Post #{$this->id} set to {$owner->name}"); log_info("core_image", "Owner for Post #{$this->id} set to {$owner->name}");
} }
} }
@ -440,7 +440,7 @@ class Image
JOIN tags ON image_tags.tag_id = tags.id JOIN tags ON image_tags.tag_id = tags.id
WHERE image_id=:id WHERE image_id=:id
ORDER BY tag ORDER BY tag
", ["id"=>$this->id]); ", ["id" => $this->id]);
sort($this->tag_array); sort($this->tag_array);
} }
return $this->tag_array; return $this->tag_array;
@ -569,7 +569,7 @@ class Image
#[Field(name: "mime")] #[Field(name: "mime")]
public function get_mime(): ?string public function get_mime(): ?string
{ {
if ($this->mime===MimeType::WEBP&&$this->lossless) { if ($this->mime === MimeType::WEBP && $this->lossless) {
return MimeType::WEBP_LOSSLESS; return MimeType::WEBP_LOSSLESS;
} }
$m = $this->mime; $m = $this->mime;
@ -610,7 +610,7 @@ class Image
$new_source = null; $new_source = null;
} }
if ($new_source != $old_source) { if ($new_source != $old_source) {
$database->execute("UPDATE images SET source=:source WHERE id=:id", ["source"=>$new_source, "id"=>$this->id]); $database->execute("UPDATE images SET source=:source WHERE id=:id", ["source" => $new_source, "id" => $this->id]);
log_info("core_image", "Source for Post #{$this->id} set to: $new_source (was $old_source)"); log_info("core_image", "Source for Post #{$this->id} set to: $new_source (was $old_source)");
} }
} }
@ -627,7 +627,7 @@ class Image
{ {
global $database; global $database;
if ($locked !== $this->locked) { if ($locked !== $this->locked) {
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", ["yn"=>$locked, "id"=>$this->id]); $database->execute("UPDATE images SET locked=:yn WHERE id=:id", ["yn" => $locked, "id" => $this->id]);
log_info("core_image", "Setting Post #{$this->id} lock to: $locked"); log_info("core_image", "Setting Post #{$this->id} lock to: $locked");
} }
} }
@ -648,12 +648,12 @@ class Image
FROM image_tags FROM image_tags
WHERE image_id = :id WHERE image_id = :id
) )
", ["id"=>$this->id]); ", ["id" => $this->id]);
$database->execute(" $database->execute("
DELETE DELETE
FROM image_tags FROM image_tags
WHERE image_id=:id WHERE image_id=:id
", ["id"=>$this->id]); ", ["id" => $this->id]);
} }
/** /**
@ -699,7 +699,7 @@ class Image
FROM image_tags FROM image_tags
WHERE image_id = :id WHERE image_id = :id
) )
", ["id"=>$this->id]); ", ["id" => $this->id]);
log_info("core_image", "Tags for Post #{$this->id} set to: ".Tag::implode($tags)); log_info("core_image", "Tags for Post #{$this->id} set to: ".Tag::implode($tags));
$cache->delete("image-{$this->id}-tags"); $cache->delete("image-{$this->id}-tags");
@ -713,7 +713,7 @@ class Image
{ {
global $database; global $database;
$this->delete_tags_from_image(); $this->delete_tags_from_image();
$database->execute("DELETE FROM images WHERE id=:id", ["id"=>$this->id]); $database->execute("DELETE FROM images WHERE id=:id", ["id" => $this->id]);
log_info("core_image", 'Deleted Post #'.$this->id.' ('.$this->hash.')'); log_info("core_image", 'Deleted Post #'.$this->id.' ('.$this->hash.')');
unlink($this->get_image_filename()); unlink($this->get_image_filename());
@ -731,7 +731,7 @@ class Image
@unlink($this->get_thumb_filename()); @unlink($this->get_thumb_filename());
} }
public function parse_link_template(string $tmpl, int $n=0): string public function parse_link_template(string $tmpl, int $n = 0): string
{ {
$plte = send_event(new ParseLinkTemplateEvent($tmpl, $this)); $plte = send_event(new ParseLinkTemplateEvent($tmpl, $this));
$tmpl = $plte->link; $tmpl = $plte->link;
@ -753,8 +753,8 @@ class Image
*/ */
private static function build_search_querylet( private static function build_search_querylet(
array $terms, array $terms,
?int $limit=null, ?int $limit = null,
?int $offset=null ?int $offset = null
): Querylet { ): Querylet {
global $config; global $config;
@ -827,7 +827,7 @@ class Image
LIMIT :limit OFFSET :offset LIMIT :limit OFFSET :offset
) a on a.image_id = images.id ) a on a.image_id = images.id
ORDER BY images.id DESC ORDER BY images.id DESC
", ["limit"=>$limit, "offset"=>$offset]); ", ["limit" => $limit, "offset" => $offset]);
// don't offset at the image level because // don't offset at the image level because
// we already offset at the image_tags level // we already offset at the image_tags level
$order = null; $order = null;
@ -849,11 +849,11 @@ class Image
if ($tq->positive) { if ($tq->positive) {
$all_nonexistent_negatives = false; $all_nonexistent_negatives = false;
if ($tag_count== 0) { if ($tag_count == 0) {
# one of the positive tags had zero results, therefor there # one of the positive tags had zero results, therefor there
# can be no results; "where 1=0" should shortcut things # can be no results; "where 1=0" should shortcut things
return new Querylet("SELECT images.* FROM images WHERE 1=0"); return new Querylet("SELECT images.* 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 // All wildcard terms that qualify for a single tag can be treated the same as non-wildcards
$positive_tag_id_array[] = $tag_ids[0]; $positive_tag_id_array[] = $tag_ids[0];
} else { } else {

View file

@ -39,7 +39,7 @@ function add_dir(string $base): array
/** /**
* Sends a DataUploadEvent for a file. * Sends a DataUploadEvent for a file.
*/ */
function add_image(string $tmpname, string $filename, string $tags, ?string $source=null): DataUploadEvent function add_image(string $tmpname, string $filename, string $tags, ?string $source = null): DataUploadEvent
{ {
return send_event(new DataUploadEvent($tmpname, [ return send_event(new DataUploadEvent($tmpname, [
'filename' => pathinfo($filename, PATHINFO_BASENAME), 'filename' => pathinfo($filename, PATHINFO_BASENAME),
@ -111,12 +111,12 @@ function get_thumbnail_size(int $orig_width, int $orig_height, bool $use_dpi_sca
function get_scaled_by_aspect_ratio(int $original_width, int $original_height, int $max_width, int $max_height): array function get_scaled_by_aspect_ratio(int $original_width, int $original_height, int $max_width, int $max_height): array
{ {
$xscale = ($max_width/ $original_width); $xscale = ($max_width / $original_width);
$yscale = ($max_height/ $original_height); $yscale = ($max_height / $original_height);
$scale = ($yscale < $xscale) ? $yscale : $xscale ; $scale = ($yscale < $xscale) ? $yscale : $xscale ;
return [(int)($original_width*$scale), (int)($original_height*$scale), $scale]; return [(int)($original_width * $scale), (int)($original_height * $scale), $scale];
} }
/** /**
@ -129,8 +129,8 @@ function get_thumbnail_max_size_scaled(): array
global $config; global $config;
$scaling = $config->get_int(ImageConfig::THUMB_SCALING); $scaling = $config->get_int(ImageConfig::THUMB_SCALING);
$max_width = $config->get_int(ImageConfig::THUMB_WIDTH) * ($scaling/100); $max_width = $config->get_int(ImageConfig::THUMB_WIDTH) * ($scaling / 100);
$max_height = $config->get_int(ImageConfig::THUMB_HEIGHT) * ($scaling/100); $max_height = $config->get_int(ImageConfig::THUMB_HEIGHT) * ($scaling / 100);
return [$max_width, $max_height]; return [$max_width, $max_height];
} }

View file

@ -8,7 +8,7 @@ class Querylet
{ {
public function __construct( public function __construct(
public string $sql, public string $sql,
public array $variables=[], public array $variables = [],
) { ) {
} }

View file

@ -26,7 +26,7 @@ class TagUsage
* @return TagUsage[] * @return TagUsage[]
*/ */
#[Query(name: "tags", type: '[TagUsage!]!')] #[Query(name: "tags", type: '[TagUsage!]!')]
public static function tags(string $search, int $limit=10): array public static function tags(string $search, int $limit = 10): array
{ {
global $cache, $database; global $cache, $database;
@ -48,7 +48,7 @@ class TagUsage
$limitSQL = ""; $limitSQL = "";
$search = str_replace('_', '\_', $search); $search = str_replace('_', '\_', $search);
$search = str_replace('%', '\%', $search); $search = str_replace('%', '\%', $search);
$SQLarr = ["search"=>"$search%"]; #, "cat_search"=>"%:$search%"]; $SQLarr = ["search" => "$search%"]; #, "cat_search"=>"%:$search%"];
if ($limit !== 0) { if ($limit !== 0) {
$limitSQL = "LIMIT :limit"; $limitSQL = "LIMIT :limit";
$SQLarr['limit'] = $limit; $SQLarr['limit'] = $limit;
@ -104,17 +104,17 @@ class Tag
$id = $database->get_one( $id = $database->get_one(
"SELECT id FROM tags WHERE LOWER(tag) = LOWER(:tag)", "SELECT id FROM tags WHERE LOWER(tag) = LOWER(:tag)",
["tag"=>$tag] ["tag" => $tag]
); );
if (empty($id)) { if (empty($id)) {
// a new tag // a new tag
$database->execute( $database->execute(
"INSERT INTO tags(tag) VALUES (:tag)", "INSERT INTO tags(tag) VALUES (:tag)",
["tag"=>$tag] ["tag" => $tag]
); );
$id = $database->get_one( $id = $database->get_one(
"SELECT id FROM tags WHERE LOWER(tag) = LOWER(:tag)", "SELECT id FROM tags WHERE LOWER(tag) = LOWER(:tag)",
["tag"=>$tag] ["tag" => $tag]
); );
} }
@ -125,7 +125,7 @@ class Tag
/** @param string[] $tags */ /** @param string[] $tags */
public static function implode(array $tags): string public static function implode(array $tags): string
{ {
sort($tags, SORT_FLAG_CASE|SORT_STRING); sort($tags, SORT_FLAG_CASE | SORT_STRING);
return implode(' ', $tags); return implode(' ', $tags);
} }
@ -134,7 +134,7 @@ class Tag
* *
* #return string[] * #return string[]
*/ */
public static function explode(string $tags, bool $tagme=true): array public static function explode(string $tags, bool $tagme = true): array
{ {
global $database; global $database;
@ -152,7 +152,7 @@ class Tag
$new = []; $new = [];
$i = 0; $i = 0;
$tag_count = count($tag_array); $tag_count = count($tag_array);
while ($i<$tag_count) { while ($i < $tag_count) {
$tag = $tag_array[$i]; $tag = $tag_array[$i];
$negative = ''; $negative = '';
if (!empty($tag) && ($tag[0] == '-')) { if (!empty($tag) && ($tag[0] == '-')) {
@ -166,7 +166,7 @@ class Tag
FROM aliases FROM aliases
WHERE LOWER(oldtag)=LOWER(:tag) WHERE LOWER(oldtag)=LOWER(:tag)
", ",
["tag"=>$tag] ["tag" => $tag]
); );
if (empty($newtags)) { if (empty($newtags)) {
//tag has no alias, use old tag //tag has no alias, use old tag
@ -217,7 +217,7 @@ class Tag
public static function compare(array $tags1, array $tags2): bool public static function compare(array $tags1, array $tags2): bool
{ {
if (count($tags1)!==count($tags2)) { if (count($tags1) !== count($tags2)) {
return false; return false;
} }
@ -312,7 +312,7 @@ class Tag
$out = ""; $out = "";
$length = strlen($str); $length = strlen($str);
for ($i=0; $i<$length; $i++) { for ($i = 0; $i < $length; $i++) {
if ($str[$i] == "^") { if ($str[$i] == "^") {
$i++; $i++;
$out .= $from_caret[$str[$i]] ?? ''; $out .= $from_caret[$str[$i]] ?? '';

View file

@ -16,12 +16,12 @@ define("SCORE_LOG_DEBUG", 10);
define("SCORE_LOG_NOTSET", 0); define("SCORE_LOG_NOTSET", 0);
const LOGGING_LEVEL_NAMES = [ const LOGGING_LEVEL_NAMES = [
SCORE_LOG_NOTSET=>"Not Set", SCORE_LOG_NOTSET => "Not Set",
SCORE_LOG_DEBUG=>"Debug", SCORE_LOG_DEBUG => "Debug",
SCORE_LOG_INFO=>"Info", SCORE_LOG_INFO => "Info",
SCORE_LOG_WARNING=>"Warning", SCORE_LOG_WARNING => "Warning",
SCORE_LOG_ERROR=>"Error", SCORE_LOG_ERROR => "Error",
SCORE_LOG_CRITICAL=>"Critical", SCORE_LOG_CRITICAL => "Critical",
]; ];
/** /**
@ -31,7 +31,7 @@ const LOGGING_LEVEL_NAMES = [
* When taking action, a log event should be stored by the server * When taking action, a log event should be stored by the server
* Quite often, both of these happen at once, hence log_*() having $flash * Quite often, both of these happen at once, hence log_*() having $flash
*/ */
function log_msg(string $section, int $priority, string $message, ?string $flash=null) function log_msg(string $section, int $priority, string $message, ?string $flash = null)
{ {
global $page; global $page;
send_event(new LogEvent($section, $priority, $message)); send_event(new LogEvent($section, $priority, $message));
@ -47,23 +47,23 @@ function log_msg(string $section, int $priority, string $message, ?string $flash
} }
// More shorthand ways of logging // More shorthand ways of logging
function log_debug(string $section, string $message, ?string $flash=null) function log_debug(string $section, string $message, ?string $flash = null)
{ {
log_msg($section, SCORE_LOG_DEBUG, $message, $flash); log_msg($section, SCORE_LOG_DEBUG, $message, $flash);
} }
function log_info(string $section, string $message, ?string $flash=null) function log_info(string $section, string $message, ?string $flash = null)
{ {
log_msg($section, SCORE_LOG_INFO, $message, $flash); log_msg($section, SCORE_LOG_INFO, $message, $flash);
} }
function log_warning(string $section, string $message, ?string $flash=null) function log_warning(string $section, string $message, ?string $flash = null)
{ {
log_msg($section, SCORE_LOG_WARNING, $message, $flash); log_msg($section, SCORE_LOG_WARNING, $message, $flash);
} }
function log_error(string $section, string $message, ?string $flash=null) function log_error(string $section, string $message, ?string $flash = null)
{ {
log_msg($section, SCORE_LOG_ERROR, $message, $flash); log_msg($section, SCORE_LOG_ERROR, $message, $flash);
} }
function log_critical(string $section, string $message, ?string $flash=null) function log_critical(string $section, string $message, ?string $flash = null)
{ {
log_msg($section, SCORE_LOG_CRITICAL, $message, $flash); log_msg($section, SCORE_LOG_CRITICAL, $message, $flash);
} }

View file

@ -22,13 +22,13 @@ use function MicroHTML\TR;
use function MicroHTML\TH; use function MicroHTML\TH;
use function MicroHTML\TD; use function MicroHTML\TD;
function SHM_FORM(string $target, string $method="POST", bool $multipart=false, string $form_id="", string $onsubmit="", string $name=""): HTMLElement function SHM_FORM(string $target, string $method = "POST", bool $multipart = false, string $form_id = "", string $onsubmit = "", string $name = ""): HTMLElement
{ {
global $user; global $user;
$attrs = [ $attrs = [
"action"=>make_link($target), "action" => make_link($target),
"method"=>$method "method" => $method
]; ];
if ($form_id) { if ($form_id) {
@ -45,7 +45,7 @@ function SHM_FORM(string $target, string $method="POST", bool $multipart=false,
} }
return FORM( return FORM(
$attrs, $attrs,
INPUT(["type"=>"hidden", "name"=>"q", "value"=>$target]), INPUT(["type" => "hidden", "name" => "q", "value" => $target]),
$method == "GET" ? "" : $user->get_auth_microhtml() $method == "GET" ? "" : $user->get_auth_microhtml()
); );
} }
@ -57,14 +57,14 @@ function SHM_SIMPLE_FORM($target, ...$children): HTMLElement
return $form; return $form;
} }
function SHM_SUBMIT(string $text, array $args=[]): HTMLElement function SHM_SUBMIT(string $text, array $args = []): HTMLElement
{ {
$args["type"] = "submit"; $args["type"] = "submit";
$args["value"] = $text; $args["value"] = $text;
return INPUT($args); return INPUT($args);
} }
function SHM_A(string $href, string|HTMLElement $text, string $id="", string $class="", array $args=[]): HTMLElement function SHM_A(string $href, string|HTMLElement $text, string $id = "", string $class = "", array $args = []): HTMLElement
{ {
$args["href"] = make_link($href); $args["href"] = make_link($href);
@ -81,7 +81,7 @@ function SHM_A(string $href, string|HTMLElement $text, string $id="", string $cl
function SHM_COMMAND_EXAMPLE(string $ex, string $desc): HTMLElement function SHM_COMMAND_EXAMPLE(string $ex, string $desc): HTMLElement
{ {
return DIV( return DIV(
["class"=>"command_example"], ["class" => "command_example"],
PRE($ex), PRE($ex),
P($desc) P($desc)
); );
@ -90,15 +90,15 @@ function SHM_COMMAND_EXAMPLE(string $ex, string $desc): HTMLElement
function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot): HTMLElement function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot): HTMLElement
{ {
if (is_string($foot)) { if (is_string($foot)) {
$foot = TFOOT(TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>$foot])))); $foot = TFOOT(TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => $foot]))));
} }
return SHM_SIMPLE_FORM( return SHM_SIMPLE_FORM(
$target, $target,
P( P(
INPUT(["type"=>'hidden', "name"=>'id', "value"=>$duser->id]), INPUT(["type" => 'hidden', "name" => 'id', "value" => $duser->id]),
TABLE( TABLE(
["class"=>"form"], ["class" => "form"],
THEAD(TR(TH(["colspan"=>"2"], $title))), THEAD(TR(TH(["colspan" => "2"], $title))),
$body, $body,
$foot $foot
) )
@ -117,7 +117,7 @@ function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot)
* @param bool $empty_option Whether the first option should be an empty one. * @param bool $empty_option Whether the first option should be an empty one.
* @param array $attrs Additional attributes dict for <select>. Example: ["id"=>"some_id", "class"=>"some_class"]. * @param array $attrs Additional attributes dict for <select>. Example: ["id"=>"some_id", "class"=>"some_class"].
*/ */
function SHM_SELECT(string $name, array $options, array $selected_options=[], bool $required=false, bool $multiple=false, bool $empty_option=false, array $attrs=[]): HTMLElement function SHM_SELECT(string $name, array $options, array $selected_options = [], bool $required = false, bool $multiple = false, bool $empty_option = false, array $attrs = []): HTMLElement
{ {
if ($required) { if ($required) {
$attrs["required"] = ""; $attrs["required"] = "";
@ -143,13 +143,13 @@ function SHM_SELECT(string $name, array $options, array $selected_options=[], bo
return SELECT($attrs, ...$_options); return SELECT($attrs, ...$_options);
} }
function SHM_OPTION(string $value, string $text, bool $selected=false): HTMLElement function SHM_OPTION(string $value, string $text, bool $selected = false): HTMLElement
{ {
if ($selected) { if ($selected) {
return OPTION(["value"=>$value, "selected"=>""], $text); return OPTION(["value" => $value, "selected" => ""], $text);
} }
return OPTION(["value"=>$value], $text); return OPTION(["value" => $value], $text);
} }
function SHM_POST_INFO( function SHM_POST_INFO(
@ -159,11 +159,11 @@ function SHM_POST_INFO(
HTMLElement|string $edit = "", HTMLElement|string $edit = "",
): HTMLElement { ): HTMLElement {
return TR( return TR(
TH(["width"=>"50px"], $title), TH(["width" => "50px"], $title),
$can_edit ? $can_edit ?
emptyHTML( emptyHTML(
TD(["class"=>"view"], $view), TD(["class" => "view"], $view),
TD(["class"=>"edit"], $edit), TD(["class" => "edit"], $edit),
) : ) :
TD($view) TD($view)
); );

View file

@ -121,7 +121,7 @@ function full_copy(string $source, string $target): void
/** /**
* Return a list of all the regular files in a directory and subdirectories * Return a list of all the regular files in a directory and subdirectories
*/ */
function list_files(string $base, string $_sub_dir=""): array function list_files(string $base, string $_sub_dir = ""): array
{ {
assert(is_dir($base)); assert(is_dir($base));
@ -129,7 +129,7 @@ function list_files(string $base, string $_sub_dir=""): array
$files = []; $files = [];
$dir = opendir("$base/$_sub_dir"); $dir = opendir("$base/$_sub_dir");
if ($dir===false) { if ($dir === false) {
throw new SCoreException("Unable to open directory $base/$_sub_dir"); throw new SCoreException("Unable to open directory $base/$_sub_dir");
} }
try { try {
@ -439,7 +439,7 @@ function no_escape(string $input): string
* Given a 1-indexed numeric-ish thing, return a zero-indexed * Given a 1-indexed numeric-ish thing, return a zero-indexed
* number between 0 and $max * number between 0 and $max
*/ */
function page_number(string $input, ?int $max=null): int function page_number(string $input, ?int $max = null): int
{ {
if (!is_numeric($input)) { if (!is_numeric($input)) {
$pageNumber = 0; $pageNumber = 0;
@ -453,7 +453,7 @@ function page_number(string $input, ?int $max=null): int
return $pageNumber; return $pageNumber;
} }
function clamp(int $val, ?int $min=null, ?int $max=null): int function clamp(int $val, ?int $min = null, ?int $max = null): int
{ {
if (!is_null($min) && $val < $min) { if (!is_null($min) && $val < $min) {
$val = $min; $val = $min;
@ -471,7 +471,7 @@ function clamp(int $val, ?int $min=null, ?int $max=null): int
* Original PHP code by Chirp Internet: www.chirp.com.au * Original PHP code by Chirp Internet: www.chirp.com.au
* Please acknowledge use of this code by including this header. * Please acknowledge use of this code by including this header.
*/ */
function truncate(string $string, int $limit, string $break=" ", string $pad="..."): string function truncate(string $string, int $limit, string $break = " ", string $pad = "..."): string
{ {
// return with no change if string is shorter than $limit // return with no change if string is shorter than $limit
if (strlen($string) <= $limit) { if (strlen($string) <= $limit) {
@ -549,12 +549,12 @@ abstract class TIME_UNITS
public const DAYS = "d"; public const DAYS = "d";
public const YEARS = "y"; public const YEARS = "y";
public const CONVERSION = [ public const CONVERSION = [
self::MILLISECONDS=>1000, self::MILLISECONDS => 1000,
self::SECONDS=>60, self::SECONDS => 60,
self::MINUTES=>60, self::MINUTES => 60,
self::HOURS=>24, self::HOURS => 24,
self::DAYS=>365, self::DAYS => 365,
self::YEARS=>PHP_INT_MAX self::YEARS => PHP_INT_MAX
]; ];
} }
function format_milliseconds(int $input, string $min_unit = TIME_UNITS::SECONDS): string function format_milliseconds(int $input, string $min_unit = TIME_UNITS::SECONDS): string
@ -565,17 +565,17 @@ function format_milliseconds(int $input, string $min_unit = TIME_UNITS::SECONDS)
$found = false; $found = false;
foreach (TIME_UNITS::CONVERSION as $unit=>$conversion) { foreach (TIME_UNITS::CONVERSION as $unit => $conversion) {
$count = $remainder % $conversion; $count = $remainder % $conversion;
$remainder = floor($remainder / $conversion); $remainder = floor($remainder / $conversion);
if ($found||$unit==$min_unit) { if ($found || $unit == $min_unit) {
$found = true; $found = true;
} else { } else {
continue; continue;
} }
if ($count==0&&$remainder<1) { if ($count == 0 && $remainder < 1) {
break; break;
} }
$output = "$count".$unit." ".$output; $output = "$count".$unit." ".$output;
@ -596,7 +596,7 @@ function parse_to_milliseconds(string $input): int
$output += $length; $output += $length;
} }
} else { } else {
foreach (TIME_UNITS::CONVERSION as $unit=>$conversion) { foreach (TIME_UNITS::CONVERSION as $unit => $conversion) {
if (preg_match('/([0-9]+)'.$unit.'/i', $input, $match)) { if (preg_match('/([0-9]+)'.$unit.'/i', $input, $match)) {
$length = $match[1]; $length = $match[1];
if (is_numeric($length)) { if (is_numeric($length)) {
@ -613,7 +613,7 @@ function parse_to_milliseconds(string $input): int
/** /**
* Turn a date into a time, a date, an "X minutes ago...", etc * Turn a date into a time, a date, an "X minutes ago...", etc
*/ */
function autodate(string $date, bool $html=true): string function autodate(string $date, bool $html = true): string
{ {
$cpu = date('c', strtotime($date)); $cpu = date('c', strtotime($date));
$hum = date('F j, Y; H:i', strtotime($date)); $hum = date('F j, Y; H:i', strtotime($date));
@ -791,7 +791,7 @@ function stringer($s): string
return "[" . implode(", ", array_map("Shimmie2\stringer", $s)) . "]"; return "[" . implode(", ", array_map("Shimmie2\stringer", $s)) . "]";
} else { } else {
$pairs = []; $pairs = [];
foreach ($s as $k=>$v) { foreach ($s as $k => $v) {
$pairs[] = "\"$k\"=>" . stringer($v); $pairs[] = "\"$k\"=>" . stringer($v);
} }
return "[" . implode(", ", $pairs) . "]"; return "[" . implode(", ", $pairs) . "]";

View file

@ -9,7 +9,7 @@ namespace Shimmie2;
* be included right at the very start of index.php and tests/bootstrap.php * be included right at the very start of index.php and tests/bootstrap.php
*/ */
function die_nicely($title, $body, $code=0) function die_nicely($title, $body, $code = 0)
{ {
print("<!DOCTYPE html> print("<!DOCTYPE html>
<html lang='en'> <html lang='en'>

View file

@ -100,7 +100,7 @@ global $_shm_event_count;
$_shm_event_count = 0; $_shm_event_count = 0;
$_shm_timeout = null; $_shm_timeout = null;
function shm_set_timeout(?int $timeout=null): void function shm_set_timeout(?int $timeout = null): void
{ {
global $_shm_timeout; global $_shm_timeout;
if ($timeout) { if ($timeout) {
@ -155,7 +155,7 @@ function send_event(Event $event): Event
if ($tracer_enabled) { if ($tracer_enabled) {
$_tracer->end(); $_tracer->end();
} }
if ($event->stop_processing===true) { if ($event->stop_processing === true) {
break; break;
} }
} }

View file

@ -135,16 +135,16 @@ class PolyfillsTest extends TestCase
"num" => "42", "num" => "42",
]; ];
$this->assertEquals( $this->assertEquals(
["foo"=>"bar"], ["foo" => "bar"],
validate_input(["foo"=>"string,trim,lower"]) validate_input(["foo" => "string,trim,lower"])
); );
//$this->assertEquals( //$this->assertEquals(
// ["to_null"=>null], // ["to_null"=>null],
// validate_input(["to_null"=>"string,trim,nullify"]) // validate_input(["to_null"=>"string,trim,nullify"])
//); //);
$this->assertEquals( $this->assertEquals(
["num"=>42], ["num" => 42],
validate_input(["num"=>"int"]) validate_input(["num" => "int"])
); );
} }
@ -223,7 +223,7 @@ class PolyfillsTest extends TestCase
{ {
$this->assertEquals( $this->assertEquals(
'["foo"=>"bar", "baz"=>[1, 2, 3], "qux"=>["a"=>"b"]]', '["foo"=>"bar", "baz"=>[1, 2, 3], "qux"=>["a"=>"b"]]',
stringer(["foo"=>"bar", "baz"=>[1,2,3], "qux"=>["a"=>"b"]]) stringer(["foo" => "bar", "baz" => [1,2,3], "qux" => ["a" => "b"]])
); );
} }
} }

View file

@ -80,17 +80,17 @@ class UrlsTest extends TestCase
{ {
$this->assertEquals( $this->assertEquals(
"/foo/bar?a=3&b=2", "/foo/bar?a=3&b=2",
modify_url("/foo/bar?a=1&b=2", ["a"=>"3"]) modify_url("/foo/bar?a=1&b=2", ["a" => "3"])
); );
$this->assertEquals( $this->assertEquals(
"https://blah.com/foo/bar?b=2", "https://blah.com/foo/bar?b=2",
modify_url("https://blah.com/foo/bar?a=1&b=2", ["a"=>null]) modify_url("https://blah.com/foo/bar?a=1&b=2", ["a" => null])
); );
$this->assertEquals( $this->assertEquals(
"/foo/bar", "/foo/bar",
modify_url("/foo/bar?a=1&b=2", ["a"=>null, "b"=>null]) modify_url("/foo/bar?a=1&b=2", ["a" => null, "b" => null])
); );
} }

View file

@ -11,7 +11,7 @@ class Link
public ?string $page; public ?string $page;
public ?string $query; public ?string $query;
public function __construct(?string $page=null, ?string $query=null) public function __construct(?string $page = null, ?string $query = null)
{ {
$this->page = $page; $this->page = $page;
$this->query = $query; $this->query = $query;
@ -43,7 +43,7 @@ function search_link(array $terms = [], int $page = 1): string
* *
* eg make_link("foo/bar") becomes "/v2/index.php?q=foo/bar" * eg make_link("foo/bar") becomes "/v2/index.php?q=foo/bar"
*/ */
function make_link(?string $page=null, ?string $query=null, ?string $fragment=null): string function make_link(?string $page = null, ?string $query = null, ?string $fragment = null): string
{ {
global $config; global $config;
@ -118,7 +118,7 @@ function make_http(string $link): string
* If HTTP_REFERER is set, and not blacklisted, then return it * If HTTP_REFERER is set, and not blacklisted, then return it
* Else return a default $dest * Else return a default $dest
*/ */
function referer_or(string $dest, ?array $blacklist=null): string function referer_or(string $dest, ?array $blacklist = null): string
{ {
if (empty($_SERVER['HTTP_REFERER'])) { if (empty($_SERVER['HTTP_REFERER'])) {
return $dest; return $dest;

View file

@ -98,7 +98,7 @@ class User
} else { } else {
$query = "SELECT * FROM users WHERE name = :name AND md5(pass || :ip) = :sess"; $query = "SELECT * FROM users WHERE name = :name AND md5(pass || :ip) = :sess";
} }
$row = $database->get_row($query, ["name"=>$name, "ip"=>get_session_ip($config), "sess"=>$session]); $row = $database->get_row($query, ["name" => $name, "ip" => get_session_ip($config), "sess" => $session]);
$cache->set("user-session:$name-$session", $row, 600); $cache->set("user-session:$name-$session", $row, 600);
} }
return is_null($row) ? null : new User($row); return is_null($row) ? null : new User($row);
@ -113,7 +113,7 @@ class User
return new User($cached); return new User($cached);
} }
} }
$row = $database->get_row("SELECT * FROM users WHERE id = :id", ["id"=>$id]); $row = $database->get_row("SELECT * FROM users WHERE id = :id", ["id" => $id]);
if ($id === 1) { if ($id === 1) {
$cache->set('user-id:'.$id, $row, 600); $cache->set('user-id:'.$id, $row, 600);
} }
@ -124,7 +124,7 @@ class User
public static function by_name(string $name): ?User public static function by_name(string $name): ?User
{ {
global $database; global $database;
$row = $database->get_row("SELECT * FROM users WHERE LOWER(name) = LOWER(:name)", ["name"=>$name]); $row = $database->get_row("SELECT * FROM users WHERE LOWER(name) = LOWER(:name)", ["name" => $name]);
return is_null($row) ? null : new User($row); return is_null($row) ? null : new User($row);
} }
@ -188,7 +188,7 @@ class User
public function set_class(string $class): void public function set_class(string $class): void
{ {
global $database; global $database;
$database->execute("UPDATE users SET class=:class WHERE id=:id", ["class"=>$class, "id"=>$this->id]); $database->execute("UPDATE users SET class=:class WHERE id=:id", ["class" => $class, "id" => $this->id]);
log_info("core-user", 'Set class for '.$this->name.' to '.$class); log_info("core-user", 'Set class for '.$this->name.' to '.$class);
} }
@ -200,7 +200,7 @@ class User
} }
$old_name = $this->name; $old_name = $this->name;
$this->name = $name; $this->name = $name;
$database->execute("UPDATE users SET name=:name WHERE id=:id", ["name"=>$this->name, "id"=>$this->id]); $database->execute("UPDATE users SET name=:name WHERE id=:id", ["name" => $this->name, "id" => $this->id]);
log_info("core-user", "Changed username for {$old_name} to {$this->name}"); log_info("core-user", "Changed username for {$old_name} to {$this->name}");
} }
@ -210,7 +210,7 @@ class User
$hash = password_hash($password, PASSWORD_BCRYPT); $hash = password_hash($password, PASSWORD_BCRYPT);
if (is_string($hash)) { if (is_string($hash)) {
$this->passhash = $hash; $this->passhash = $hash;
$database->execute("UPDATE users SET pass=:hash WHERE id=:id", ["hash"=>$this->passhash, "id"=>$this->id]); $database->execute("UPDATE users SET pass=:hash WHERE id=:id", ["hash" => $this->passhash, "id" => $this->id]);
log_info("core-user", 'Set password for '.$this->name); log_info("core-user", 'Set password for '.$this->name);
} else { } else {
throw new SCoreException("Failed to hash password"); throw new SCoreException("Failed to hash password");
@ -220,7 +220,7 @@ class User
public function set_email(string $address): void public function set_email(string $address): void
{ {
global $database; global $database;
$database->execute("UPDATE users SET email=:email WHERE id=:id", ["email"=>$address, "id"=>$this->id]); $database->execute("UPDATE users SET email=:email WHERE id=:id", ["email" => $address, "id" => $this->id]);
log_info("core-user", 'Set email for '.$this->name); log_info("core-user", 'Set email for '.$this->name);
} }
@ -284,7 +284,7 @@ class User
public function get_auth_microhtml(): HTMLElement public function get_auth_microhtml(): HTMLElement
{ {
$at = $this->get_auth_token(); $at = $this->get_auth_token();
return INPUT(["type"=>"hidden", "name"=>"auth_token", "value"=>$at]); return INPUT(["type" => "hidden", "name" => "auth_token", "value" => $at]);
} }
public function check_auth_token(): bool public function check_auth_token(): bool

View file

@ -219,10 +219,10 @@ new UserClass("admin", "base", [
Permissions::APPROVE_COMMENT => true, Permissions::APPROVE_COMMENT => true,
Permissions::BYPASS_IMAGE_APPROVAL => true, Permissions::BYPASS_IMAGE_APPROVAL => true,
Permissions::CRON_RUN =>true, Permissions::CRON_RUN => true,
Permissions::BULK_IMPORT =>true, Permissions::BULK_IMPORT => true,
Permissions::BULK_EXPORT =>true, Permissions::BULK_EXPORT => true,
Permissions::BULK_DOWNLOAD => true, Permissions::BULK_DOWNLOAD => true,
Permissions::BULK_PARENT_CHILD => true, Permissions::BULK_PARENT_CHILD => true,

View file

@ -55,7 +55,7 @@ function is_https_enabled(): bool
{ {
// check forwarded protocol // check forwarded protocol
if (REVERSE_PROXY_X_HEADERS && !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { if (REVERSE_PROXY_X_HEADERS && !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$_SERVER['HTTPS']='on'; $_SERVER['HTTPS'] = 'on';
} }
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'); return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
} }
@ -80,10 +80,10 @@ function get_memory_limit(): int
global $config; global $config;
// thumbnail generation requires lots of memory // thumbnail generation requires lots of memory
$default_limit = 8*1024*1024; // 8 MB of memory is PHP's default. $default_limit = 8 * 1024 * 1024; // 8 MB of memory is PHP's default.
$shimmie_limit = $config->get_int(MediaConfig::MEM_LIMIT); $shimmie_limit = $config->get_int(MediaConfig::MEM_LIMIT);
if ($shimmie_limit < 3*1024*1024) { if ($shimmie_limit < 3 * 1024 * 1024) {
// we aren't going to fit, override // we aren't going to fit, override
$shimmie_limit = $default_limit; $shimmie_limit = $default_limit;
} }
@ -205,9 +205,9 @@ function format_text(string $string): string
* @param int $splits The number of octet pairs to split the hash into. Caps out at strlen($hash)/2. * @param int $splits The number of octet pairs to split the hash into. Caps out at strlen($hash)/2.
* @return string * @return string
*/ */
function warehouse_path(string $base, string $hash, bool $create=true, int $splits = WH_SPLITS): string function warehouse_path(string $base, string $hash, bool $create = true, int $splits = WH_SPLITS): string
{ {
$dirs =[DATA_DIR, $base]; $dirs = [DATA_DIR, $base];
$splits = min($splits, strlen($hash) / 2); $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[] = substr($hash, $i * 2, 2);
@ -228,13 +228,13 @@ function warehouse_path(string $base, string $hash, bool $create=true, int $spli
function data_path(string $filename, bool $create = true): string function data_path(string $filename, bool $create = true): string
{ {
$filename = join_path("data", $filename); $filename = join_path("data", $filename);
if ($create&&!file_exists(dirname($filename))) { if ($create && !file_exists(dirname($filename))) {
mkdir(dirname($filename), 0755, true); mkdir(dirname($filename), 0755, true);
} }
return $filename; return $filename;
} }
function load_balance_url(string $tmpl, string $hash, int $n=0): string function load_balance_url(string $tmpl, string $hash, int $n = 0): string
{ {
static $flexihashes = []; static $flexihashes = [];
$matches = []; $matches = [];
@ -308,7 +308,7 @@ function fetch_url(string $url, string $mfile): ?array
$s_mfile = escapeshellarg($mfile); $s_mfile = escapeshellarg($mfile);
system("wget --no-check-certificate $s_url --output-document=$s_mfile"); system("wget --no-check-certificate $s_url --output-document=$s_mfile");
return file_exists($mfile) ? ["ok"=>"true"] : null; return file_exists($mfile) ? ["ok" => "true"] : null;
} }
if ($config->get_string(UploadConfig::TRANSLOAD_ENGINE) === "fopen") { if ($config->get_string(UploadConfig::TRANSLOAD_ENGINE) === "fopen") {
@ -355,7 +355,7 @@ function path_to_tags(string $path): string
$category_to_inherit = ""; $category_to_inherit = "";
foreach (explode(" ", $dir) as $tag) { foreach (explode(" ", $dir) as $tag) {
$tag = trim($tag); $tag = trim($tag);
if ($tag=="") { if ($tag == "") {
continue; continue;
} }
if (substr_compare($tag, ":", -1) === 0) { if (substr_compare($tag, ":", -1) === 0) {
@ -363,7 +363,7 @@ function path_to_tags(string $path): string
// which is for inheriting to tags on the subfolder // which is for inheriting to tags on the subfolder
$category_to_inherit = $tag; $category_to_inherit = $tag;
} else { } else {
if ($category!="" && !str_contains($tag, ":")) { if ($category != "" && !str_contains($tag, ":")) {
// This indicates that category inheritance is active, // This indicates that category inheritance is active,
// and we've encountered a tag that does not specify a category. // and we've encountered a tag that does not specify a category.
// So we attach the inherited category to the tag. // So we attach the inherited category to the tag.
@ -420,7 +420,7 @@ function remove_empty_dirs(string $dir): bool
$result = false; $result = false;
} }
} }
if ($result===true) { if ($result === true) {
$result = rmdir($dir); $result = rmdir($dir);
} }
return $result; return $result;
@ -533,7 +533,7 @@ function get_debug_info_arr(): array
return [ return [
"time" => round(ftime() - $_shm_load_start, 2), "time" => round(ftime() - $_shm_load_start, 2),
"dbtime" => round($database->dbtime, 2), "dbtime" => round($database->dbtime, 2),
"mem_mb" => round(((memory_get_peak_usage(true)+512)/1024)/1024, 2), "mem_mb" => round(((memory_get_peak_usage(true) + 512) / 1024) / 1024, 2),
"files" => count(get_included_files()), "files" => count(get_included_files()),
"query_count" => $database->query_count, "query_count" => $database->query_count,
// "query_log" => $database->queries, // "query_log" => $database->queries,
@ -591,7 +591,7 @@ function _set_up_shimmie_environment(): void
// The trace system has a certain amount of memory consumption every time it is used, // The trace system has a certain amount of memory consumption every time it is used,
// so to prevent running out of memory during complex operations code that uses it should // so to prevent running out of memory during complex operations code that uses it should
// check if tracer output is enabled before making use of it. // check if tracer output is enabled before making use of it.
$tracer_enabled = constant('TRACE_FILE')!==null; $tracer_enabled = constant('TRACE_FILE') !== null;
} }
@ -717,7 +717,7 @@ function show_ip(string $ip, string $ban_reason): string
/** /**
* Make a form tag with relevant auth token and stuff * Make a form tag with relevant auth token and stuff
*/ */
function make_form(string $target, string $method="POST", bool $multipart=false, string $form_id="", string $onsubmit=""): string function make_form(string $target, string $method = "POST", bool $multipart = false, string $form_id = "", string $onsubmit = ""): string
{ {
global $user; global $user;
if ($method == "GET") { if ($method == "GET") {

View file

@ -137,7 +137,7 @@ class AdminPage extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{ {
global $user; global $user;
if ($event->parent==="system") { if ($event->parent === "system") {
if ($user->can(Permissions::MANAGE_ADMINTOOLS)) { if ($user->can(Permissions::MANAGE_ADMINTOOLS)) {
$event->add_nav_link("admin", new Link('admin'), "Board Admin"); $event->add_nav_link("admin", new Link('admin'), "Board Admin");
} }

View file

@ -69,7 +69,7 @@ class AliasEditor extends Extension
if ($event->get_arg(0) == "add") { if ($event->get_arg(0) == "add") {
if ($user->can(Permissions::MANAGE_ALIAS_LIST)) { if ($user->can(Permissions::MANAGE_ALIAS_LIST)) {
$user->ensure_authed(); $user->ensure_authed();
$input = validate_input(["c_oldtag"=>"string", "c_newtag"=>"string"]); $input = validate_input(["c_oldtag" => "string", "c_newtag" => "string"]);
try { try {
send_event(new AddAliasEvent($input['c_oldtag'], $input['c_newtag'])); send_event(new AddAliasEvent($input['c_oldtag'], $input['c_newtag']));
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
@ -81,7 +81,7 @@ class AliasEditor extends Extension
} elseif ($event->get_arg(0) == "remove") { } elseif ($event->get_arg(0) == "remove") {
if ($user->can(Permissions::MANAGE_ALIAS_LIST)) { if ($user->can(Permissions::MANAGE_ALIAS_LIST)) {
$user->ensure_authed(); $user->ensure_authed();
$input = validate_input(["d_oldtag"=>"string"]); $input = validate_input(["d_oldtag" => "string"]);
send_event(new DeleteAliasEvent($input['d_oldtag'])); send_event(new DeleteAliasEvent($input['d_oldtag']));
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("alias/list")); $page->set_redirect(make_link("alias/list"));
@ -126,7 +126,7 @@ class AliasEditor extends Extension
$row = $database->get_row( $row = $database->get_row(
"SELECT * FROM aliases WHERE lower(oldtag)=lower(:oldtag)", "SELECT * FROM aliases WHERE lower(oldtag)=lower(:oldtag)",
["oldtag"=>$event->oldtag] ["oldtag" => $event->oldtag]
); );
if ($row) { if ($row) {
throw new AddAliasException("{$row['oldtag']} is already an alias for {$row['newtag']}"); throw new AddAliasException("{$row['oldtag']} is already an alias for {$row['newtag']}");
@ -156,7 +156,7 @@ class AliasEditor extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) 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"])); $event->add_nav_link("aliases", new Link('alias/list'), "Aliases", NavLink::is_active(["alias"]));
} }
} }

View file

@ -18,11 +18,11 @@ class AliasEditorTheme extends Themelet
{ {
global $page, $user; global $page, $user;
$html = emptyHTML($table, BR(), $paginator, BR(), SHM_A("alias/export/aliases.csv", "Download as CSV", args: ["download"=>"aliases.csv"])); $html = emptyHTML($table, BR(), $paginator, BR(), SHM_A("alias/export/aliases.csv", "Download as CSV", args: ["download" => "aliases.csv"]));
$bulk_form = SHM_FORM("alias/import", multipart: true); $bulk_form = SHM_FORM("alias/import", multipart: true);
$bulk_form->appendChild( $bulk_form->appendChild(
INPUT(["type"=>"file", "name"=>"alias_file"]), INPUT(["type" => "file", "name" => "alias_file"]),
SHM_SUBMIT("Upload List") SHM_SUBMIT("Upload List")
); );
$bulk_html = emptyHTML($bulk_form); $bulk_html = emptyHTML($bulk_form);

View file

@ -10,7 +10,7 @@ class ApprovalInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Approval"; public string $name = "Approval";
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"];
public string $license = self::LICENSE_WTFPL; public string $license = self::LICENSE_WTFPL;
public string $description = "Adds an approval step to the upload/import process."; public string $description = "Adds an approval step to the upload/import process.";
} }

View file

@ -86,21 +86,21 @@ class Approval extends Extension
$action = $event->action; $action = $event->action;
$event->redirect = true; $event->redirect = true;
if ($action==="approval") { if ($action === "approval") {
$approval_action = $_POST["approval_action"]; $approval_action = $_POST["approval_action"];
switch ($approval_action) { switch ($approval_action) {
case "approve_all": case "approve_all":
$database->set_timeout(null); // These updates can take a little bit $database->set_timeout(null); // These updates can take a little bit
$database->execute( $database->execute(
"UPDATE images SET approved = :true, approved_by_id = :approved_by_id WHERE approved = :false", "UPDATE images SET approved = :true, approved_by_id = :approved_by_id WHERE approved = :false",
["approved_by_id"=>$user->id, "true"=>true, "false"=>false] ["approved_by_id" => $user->id, "true" => true, "false" => false]
); );
break; break;
case "disapprove_all": case "disapprove_all":
$database->set_timeout(null); // These updates can take a little bit $database->set_timeout(null); // These updates can take a little bit
$database->execute( $database->execute(
"UPDATE images SET approved = :false, approved_by_id = NULL WHERE approved = :true", "UPDATE images SET approved = :false, approved_by_id = NULL WHERE approved = :true",
["true"=>true, "false"=>false] ["true" => true, "false" => false]
); );
break; break;
default: default:
@ -123,7 +123,7 @@ class Approval extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{ {
global $user; global $user;
if ($event->parent=="posts") { if ($event->parent == "posts") {
if ($user->can(Permissions::APPROVE_IMAGE)) { if ($user->can(Permissions::APPROVE_IMAGE)) {
$event->add_nav_link("posts_unapproved", new Link('/post/list/approved%3Ano/1'), "Pending Approval", null, 60); $event->add_nav_link("posts_unapproved", new Link('/post/list/approved%3Ano/1'), "Pending Approval", null, 60);
} }
@ -147,7 +147,7 @@ class Approval extends Extension
$matches = []; $matches = [];
if (is_null($event->term) && $this->no_approval_query($event->context)) { if (is_null($event->term) && $this->no_approval_query($event->context)) {
$event->add_querylet(new Querylet("approved = :true", ["true"=>true])); $event->add_querylet(new Querylet("approved = :true", ["true" => true]));
} }
if (is_null($event->term)) { if (is_null($event->term)) {
@ -155,9 +155,9 @@ class Approval extends Extension
} }
if (preg_match(self::SEARCH_REGEXP, strtolower($event->term), $matches)) { if (preg_match(self::SEARCH_REGEXP, strtolower($event->term), $matches)) {
if ($user->can(Permissions::APPROVE_IMAGE) && $matches[1] == "no") { if ($user->can(Permissions::APPROVE_IMAGE) && $matches[1] == "no") {
$event->add_querylet(new Querylet("approved != :true", ["true"=>true])); $event->add_querylet(new Querylet("approved != :true", ["true" => true]));
} else { } else {
$event->add_querylet(new Querylet("approved = :true", ["true"=>true])); $event->add_querylet(new Querylet("approved = :true", ["true" => true]));
} }
} }
} }
@ -166,7 +166,7 @@ class Approval extends Extension
public function onHelpPageBuilding(HelpPageBuildingEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event)
{ {
global $user, $config; global $user, $config;
if ($event->key===HelpPages::SEARCH) { if ($event->key === HelpPages::SEARCH) {
if ($user->can(Permissions::APPROVE_IMAGE) && $config->get_bool(ApprovalConfig::IMAGES)) { if ($user->can(Permissions::APPROVE_IMAGE) && $config->get_bool(ApprovalConfig::IMAGES)) {
$event->add_block(new Block("Approval", $this->theme->get_help_html())); $event->add_block(new Block("Approval", $this->theme->get_help_html()));
} }
@ -190,7 +190,7 @@ class Approval extends Extension
$database->execute( $database->execute(
"UPDATE images SET approved = :true, approved_by_id = :approved_by_id WHERE id = :id AND approved = :false", "UPDATE images SET approved = :true, approved_by_id = :approved_by_id WHERE id = :id AND approved = :false",
["approved_by_id"=>$user->id, "id"=>$image_id, "true"=>true, "false"=>false] ["approved_by_id" => $user->id, "id" => $image_id, "true" => true, "false" => false]
); );
} }
@ -200,7 +200,7 @@ class Approval extends Extension
$database->execute( $database->execute(
"UPDATE images SET approved = :false, approved_by_id = NULL WHERE id = :id AND approved = :true", "UPDATE images SET approved = :false, approved_by_id = NULL WHERE id = :id AND approved = :true",
["id"=>$image_id, "true"=>true, "false"=>false] ["id" => $image_id, "true" => true, "false" => false]
); );
} }
@ -208,7 +208,7 @@ class Approval extends Extension
{ {
global $user, $config; global $user, $config;
if ($config->get_bool(ApprovalConfig::IMAGES) && $image->approved===false && !$user->can(Permissions::APPROVE_IMAGE) && $user->id!==$image->owner_id) { if ($config->get_bool(ApprovalConfig::IMAGES) && $image->approved === false && !$user->can(Permissions::APPROVE_IMAGE) && $user->id !== $image->owner_id) {
return false; return false;
} }
return true; return true;
@ -236,7 +236,7 @@ class Approval extends Extension
{ {
global $user, $config; 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)) {
if (in_array("approved:no", $event->search_terms)) { if (in_array("approved:no", $event->search_terms)) {
$event->add_action("bulk_approve_image", "Approve", "a"); $event->add_action("bulk_approve_image", "Approve", "a");
} else { } else {

View file

@ -14,16 +14,16 @@ class ApprovalTheme extends Themelet
{ {
public function get_image_admin_html(Image $image): HTMLElement public function get_image_admin_html(Image $image): HTMLElement
{ {
if ($image->approved===true) { if ($image->approved === true) {
$form = SHM_SIMPLE_FORM( $form = SHM_SIMPLE_FORM(
'disapprove_image/'.$image->id, 'disapprove_image/'.$image->id,
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image->id]), INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image->id]),
SHM_SUBMIT("Disapprove") SHM_SUBMIT("Disapprove")
); );
} else { } else {
$form = SHM_SIMPLE_FORM( $form = SHM_SIMPLE_FORM(
'approve_image/'.$image->id, 'approve_image/'.$image->id,
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image->id]), INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image->id]),
SHM_SUBMIT("Approve") SHM_SUBMIT("Approve")
); );
} }
@ -52,9 +52,9 @@ class ApprovalTheme extends Themelet
$form = SHM_SIMPLE_FORM( $form = SHM_SIMPLE_FORM(
"admin/approval", "admin/approval",
BUTTON(["name"=>'approval_action', "value"=>'approve_all'], "Approve All Posts"), BUTTON(["name" => 'approval_action', "value" => 'approve_all'], "Approve All Posts"),
" ", " ",
BUTTON(["name"=>'approval_action', "value"=>'disapprove_all'], "Disapprove All Posts"), BUTTON(["name" => 'approval_action', "value" => 'disapprove_all'], "Disapprove All Posts"),
); );
$page->add_block(new Block("Approval", $form)); $page->add_block(new Block("Approval", $form));

View file

@ -11,7 +11,7 @@ class ArtistsInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Artists System"; public string $name = "Artists System";
public string $url = self::SHIMMIE_URL; public string $url = self::SHIMMIE_URL;
public array $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"]; public array $authors = ["Sein Kraft" => "mail@seinkraft.info","Alpha" => "alpha@furries.com.ar"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public string $description = "Simple artists extension"; public string $description = "Simple artists extension";
public bool $beta = true; public bool $beta = true;

View file

@ -50,13 +50,13 @@ class Artists extends Extension
$matches = []; $matches = [];
if (preg_match("/^(author|artist)[=|:](.*)$/i", $event->term, $matches)) { if (preg_match("/^(author|artist)[=|:](.*)$/i", $event->term, $matches)) {
$char = $matches[2]; $char = $matches[2];
$event->add_querylet(new Querylet("author = :author_char", ["author_char"=>$char])); $event->add_querylet(new Querylet("author = :author_char", ["author_char" => $char]));
} }
} }
public function onHelpPageBuilding(HelpPageBuildingEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event)
{ {
if ($event->key===HelpPages::SEARCH) { if ($event->key === HelpPages::SEARCH) {
$event->add_block(new Block("Artist", $this->theme->get_help_html())); $event->add_block(new Block("Artist", $this->theme->get_help_html()));
} }
} }
@ -150,7 +150,7 @@ class Artists extends Extension
$database->execute( $database->execute(
"UPDATE images SET author = :author WHERE id = :id", "UPDATE images SET author = :author WHERE id = :id",
['author'=>$artistName, 'id'=>$event->image->id] ['author' => $artistName, 'id' => $event->image->id]
); );
} }
@ -419,28 +419,28 @@ class Artists extends Extension
private function get_artistName_by_imageID(int $imageID): string private function get_artistName_by_imageID(int $imageID): string
{ {
global $database; global $database;
$result = $database->get_row("SELECT author FROM images WHERE id = :id", ['id'=>$imageID]); $result = $database->get_row("SELECT author FROM images WHERE id = :id", ['id' => $imageID]);
return $result['author'] ?? ""; return $result['author'] ?? "";
} }
private function url_exists_by_url(string $url): bool private function url_exists_by_url(string $url): bool
{ {
global $database; global $database;
$result = $database->get_one("SELECT COUNT(1) FROM artist_urls WHERE url = :url", ['url'=>$url]); $result = $database->get_one("SELECT COUNT(1) FROM artist_urls WHERE url = :url", ['url' => $url]);
return ($result != 0); return ($result != 0);
} }
private function member_exists_by_name(string $member): bool private function member_exists_by_name(string $member): bool
{ {
global $database; global $database;
$result = $database->get_one("SELECT COUNT(1) FROM artist_members WHERE name = :name", ['name'=>$member]); $result = $database->get_one("SELECT COUNT(1) FROM artist_members WHERE name = :name", ['name' => $member]);
return ($result != 0); return ($result != 0);
} }
private function alias_exists_by_name(string $alias): bool private function alias_exists_by_name(string $alias): bool
{ {
global $database; global $database;
$result = $database->get_one("SELECT COUNT(1) FROM artist_alias WHERE alias = :alias", ['alias'=>$alias]); $result = $database->get_one("SELECT COUNT(1) FROM artist_alias WHERE alias = :alias", ['alias' => $alias]);
return ($result != 0); return ($result != 0);
} }
@ -449,7 +449,7 @@ class Artists extends Extension
global $database; global $database;
$result = $database->get_one( $result = $database->get_one(
"SELECT COUNT(1) FROM artist_alias WHERE artist_id = :artist_id AND alias = :alias", "SELECT COUNT(1) FROM artist_alias WHERE artist_id = :artist_id AND alias = :alias",
['artist_id'=>$artistID, 'alias'=>$alias] ['artist_id' => $artistID, 'alias' => $alias]
); );
return ($result != 0); return ($result != 0);
} }
@ -457,73 +457,73 @@ class Artists extends Extension
private function get_artistID_by_url(string $url): int private function get_artistID_by_url(string $url): int
{ {
global $database; global $database;
return (int)$database->get_one("SELECT artist_id FROM artist_urls WHERE url = :url", ['url'=>$url]); return (int)$database->get_one("SELECT artist_id FROM artist_urls WHERE url = :url", ['url' => $url]);
} }
private function get_artistID_by_memberName(string $member): int private function get_artistID_by_memberName(string $member): int
{ {
global $database; global $database;
return (int)$database->get_one("SELECT artist_id FROM artist_members WHERE name = :name", ['name'=>$member]); return (int)$database->get_one("SELECT artist_id FROM artist_members WHERE name = :name", ['name' => $member]);
} }
private function get_artistName_by_artistID(int $artistID): string private function get_artistName_by_artistID(int $artistID): string
{ {
global $database; global $database;
return (string)$database->get_one("SELECT name FROM artists WHERE id = :id", ['id'=>$artistID]); return (string)$database->get_one("SELECT name FROM artists WHERE id = :id", ['id' => $artistID]);
} }
private function get_artistID_by_aliasID(int $aliasID): int private function get_artistID_by_aliasID(int $aliasID): int
{ {
global $database; global $database;
return (int)$database->get_one("SELECT artist_id FROM artist_alias WHERE id = :id", ['id'=>$aliasID]); return (int)$database->get_one("SELECT artist_id FROM artist_alias WHERE id = :id", ['id' => $aliasID]);
} }
private function get_artistID_by_memberID(int $memberID): int private function get_artistID_by_memberID(int $memberID): int
{ {
global $database; global $database;
return (int)$database->get_one("SELECT artist_id FROM artist_members WHERE id = :id", ['id'=>$memberID]); return (int)$database->get_one("SELECT artist_id FROM artist_members WHERE id = :id", ['id' => $memberID]);
} }
private function get_artistID_by_urlID(int $urlID): int private function get_artistID_by_urlID(int $urlID): int
{ {
global $database; global $database;
return (int)$database->get_one("SELECT artist_id FROM artist_urls WHERE id = :id", ['id'=>$urlID]); return (int)$database->get_one("SELECT artist_id FROM artist_urls WHERE id = :id", ['id' => $urlID]);
} }
private function delete_alias(int $aliasID) private function delete_alias(int $aliasID)
{ {
global $database; global $database;
$database->execute("DELETE FROM artist_alias WHERE id = :id", ['id'=>$aliasID]); $database->execute("DELETE FROM artist_alias WHERE id = :id", ['id' => $aliasID]);
} }
private function delete_url(int $urlID) private function delete_url(int $urlID)
{ {
global $database; global $database;
$database->execute("DELETE FROM artist_urls WHERE id = :id", ['id'=>$urlID]); $database->execute("DELETE FROM artist_urls WHERE id = :id", ['id' => $urlID]);
} }
private function delete_member(int $memberID) private function delete_member(int $memberID)
{ {
global $database; global $database;
$database->execute("DELETE FROM artist_members WHERE id = :id", ['id'=>$memberID]); $database->execute("DELETE FROM artist_members WHERE id = :id", ['id' => $memberID]);
} }
private function get_alias_by_id(int $aliasID): array private function get_alias_by_id(int $aliasID): array
{ {
global $database; global $database;
return $database->get_row("SELECT * FROM artist_alias WHERE id = :id", ['id'=>$aliasID]); return $database->get_row("SELECT * FROM artist_alias WHERE id = :id", ['id' => $aliasID]);
} }
private function get_url_by_id(int $urlID): array private function get_url_by_id(int $urlID): array
{ {
global $database; global $database;
return $database->get_row("SELECT * FROM artist_urls WHERE id = :id", ['id'=>$urlID]); return $database->get_row("SELECT * FROM artist_urls WHERE id = :id", ['id' => $urlID]);
} }
private function get_member_by_id(int $memberID): array private function get_member_by_id(int $memberID): array
{ {
global $database; global $database;
return $database->get_row("SELECT * FROM artist_members WHERE id = :id", ['id'=>$memberID]); return $database->get_row("SELECT * FROM artist_members WHERE id = :id", ['id' => $memberID]);
} }
private function update_artist() private function update_artist()
@ -558,7 +558,7 @@ class Artists extends Extension
global $database; global $database;
$database->execute( $database->execute(
"UPDATE artists SET name = :name, notes = :notes, updated = now(), user_id = :user_id WHERE id = :id", "UPDATE artists SET name = :name, notes = :notes, updated = now(), user_id = :user_id WHERE id = :id",
['name'=>$name, 'notes'=>$notes, 'user_id'=>$userID, 'id'=>$artistID] ['name' => $name, 'notes' => $notes, 'user_id' => $userID, 'id' => $artistID]
); );
// ALIAS MATCHING SECTION // ALIAS MATCHING SECTION
@ -639,7 +639,7 @@ class Artists extends Extension
global $database; global $database;
$database->execute( $database->execute(
"UPDATE artist_alias SET alias = :alias, updated = now(), user_id = :user_id WHERE id = :id", "UPDATE artist_alias SET alias = :alias, updated = now(), user_id = :user_id WHERE id = :id",
['alias'=>$alias, 'user_id'=>$userID, 'id'=>$aliasID] ['alias' => $alias, 'user_id' => $userID, 'id' => $aliasID]
); );
} }
@ -658,7 +658,7 @@ class Artists extends Extension
global $database; global $database;
$database->execute( $database->execute(
"UPDATE artist_urls SET url = :url, updated = now(), user_id = :user_id WHERE id = :id", "UPDATE artist_urls SET url = :url, updated = now(), user_id = :user_id WHERE id = :id",
['url'=>$url, 'user_id'=>$userID, 'id'=>$urlID] ['url' => $url, 'user_id' => $userID, 'id' => $urlID]
); );
} }
@ -677,7 +677,7 @@ class Artists extends Extension
global $database; global $database;
$database->execute( $database->execute(
"UPDATE artist_members SET name = :name, updated = now(), user_id = :user_id WHERE id = :id", "UPDATE artist_members SET name = :name, updated = now(), user_id = :user_id WHERE id = :id",
['name'=>$memberName, 'user_id'=>$userID, 'id'=>$memberID] ['name' => $memberName, 'user_id' => $userID, 'id' => $memberID]
); );
} }
@ -753,7 +753,7 @@ class Artists extends Extension
$database->execute(" $database->execute("
INSERT INTO artists (user_id, name, notes, created, updated) INSERT INTO artists (user_id, name, notes, created, updated)
VALUES (:user_id, :name, :notes, now(), now()) VALUES (:user_id, :name, :notes, now(), now())
", ['user_id'=>$user->id, 'name'=>$name, 'notes'=>$notes]); ", ['user_id' => $user->id, 'name' => $name, 'notes' => $notes]);
return $database->get_last_insert_id('artists_id_seq'); return $database->get_last_insert_id('artists_id_seq');
} }
@ -762,7 +762,7 @@ class Artists extends Extension
global $database; global $database;
$result = $database->get_one( $result = $database->get_one(
"SELECT COUNT(1) FROM artists WHERE name = :name", "SELECT COUNT(1) FROM artists WHERE name = :name",
['name'=>$name] ['name' => $name]
); );
return ($result != 0); return ($result != 0);
} }
@ -772,7 +772,7 @@ class Artists extends Extension
global $database; global $database;
$result = $database->get_row( $result = $database->get_row(
"SELECT * FROM artists WHERE id = :id", "SELECT * FROM artists WHERE id = :id",
['id'=>$artistID] ['id' => $artistID]
); );
$result["name"] = stripslashes($result["name"]); $result["name"] = stripslashes($result["name"]);
@ -786,7 +786,7 @@ class Artists extends Extension
global $database; global $database;
$result = $database->get_all( $result = $database->get_all(
"SELECT * FROM artist_members WHERE artist_id = :artist_id", "SELECT * FROM artist_members WHERE artist_id = :artist_id",
['artist_id'=>$artistID] ['artist_id' => $artistID]
); );
$num = count($result); $num = count($result);
@ -802,7 +802,7 @@ class Artists extends Extension
global $database; global $database;
$result = $database->get_all( $result = $database->get_all(
"SELECT id, url FROM artist_urls WHERE artist_id = :artist_id", "SELECT id, url FROM artist_urls WHERE artist_id = :artist_id",
['artist_id'=>$artistID] ['artist_id' => $artistID]
); );
$num = count($result); $num = count($result);
@ -818,7 +818,7 @@ class Artists extends Extension
global $database; global $database;
return (int)$database->get_one( return (int)$database->get_one(
"SELECT id FROM artists WHERE name = :name", "SELECT id FROM artists WHERE name = :name",
['name'=>$name] ['name' => $name]
); );
} }
@ -828,7 +828,7 @@ class Artists extends Extension
return (int)$database->get_one( return (int)$database->get_one(
"SELECT artist_id FROM artist_alias WHERE alias = :alias", "SELECT artist_id FROM artist_alias WHERE alias = :alias",
['alias'=>$alias] ['alias' => $alias]
); );
} }
@ -837,7 +837,7 @@ class Artists extends Extension
global $database; global $database;
$database->execute( $database->execute(
"DELETE FROM artists WHERE id = :id", "DELETE FROM artists WHERE id = :id",
['id'=>$artistID] ['id' => $artistID]
); );
} }
@ -900,8 +900,8 @@ class Artists extends Extension
LIMIT :offset, :limit LIMIT :offset, :limit
", ",
[ [
"offset"=>$pageNumber * $artistsPerPage, "offset" => $pageNumber * $artistsPerPage,
"limit"=>$artistsPerPage "limit" => $artistsPerPage
] ]
); );
@ -953,7 +953,7 @@ class Artists extends Extension
$database->execute( $database->execute(
"INSERT INTO artist_urls (artist_id, created, updated, url, user_id) VALUES (:artist_id, now(), now(), :url, :user_id)", "INSERT INTO artist_urls (artist_id, created, updated, url, user_id) VALUES (:artist_id, now(), now(), :url, :user_id)",
['artist'=>$artistID, 'url'=>$url, 'user_id'=>$userID] ['artist' => $artistID, 'url' => $url, 'user_id' => $userID]
); );
} }
@ -980,7 +980,7 @@ class Artists extends Extension
$database->execute( $database->execute(
"INSERT INTO artist_alias (artist_id, created, updated, alias, user_id) VALUES (:artist_id, now(), now(), :alias, :user_id)", "INSERT INTO artist_alias (artist_id, created, updated, alias, user_id) VALUES (:artist_id, now(), now(), :alias, :user_id)",
['artist_id'=>$artistID, 'alias'=>$alias, 'user_id'=>$userID] ['artist_id' => $artistID, 'alias' => $alias, 'user_id' => $userID]
); );
} }
@ -1007,7 +1007,7 @@ class Artists extends Extension
$database->execute( $database->execute(
"INSERT INTO artist_members (artist_id, name, created, updated, user_id) VALUES (:artist_id, :name, now(), now(), :user_id)", "INSERT INTO artist_members (artist_id, name, created, updated, user_id) VALUES (:artist_id, :name, now(), now(), :user_id)",
['artist'=>$artistID, 'name'=>$member, 'user_id'=>$userID] ['artist' => $artistID, 'name' => $member, 'user_id' => $userID]
); );
} }
@ -1017,7 +1017,7 @@ class Artists extends Extension
$result = $database->get_one( $result = $database->get_one(
"SELECT COUNT(1) FROM artist_members WHERE artist_id = :artist_id AND name = :name", "SELECT COUNT(1) FROM artist_members WHERE artist_id = :artist_id AND name = :name",
['artist_id'=>$artistID, 'name'=>$member] ['artist_id' => $artistID, 'name' => $member]
); );
return ($result != 0); return ($result != 0);
} }
@ -1028,7 +1028,7 @@ class Artists extends Extension
$result = $database->get_one( $result = $database->get_one(
"SELECT COUNT(1) FROM artist_urls WHERE artist_id = :artist_id AND url = :url", "SELECT COUNT(1) FROM artist_urls WHERE artist_id = :artist_id AND url = :url",
['artist_id'=>$artistID, 'url'=>$url] ['artist_id' => $artistID, 'url' => $url]
); );
return ($result != 0); return ($result != 0);
} }
@ -1045,7 +1045,7 @@ class Artists extends Extension
FROM artist_alias FROM artist_alias
WHERE artist_id = :artist_id WHERE artist_id = :artist_id
ORDER BY alias ASC ORDER BY alias ASC
", ['artist_id'=>$artistID]); ", ['artist_id' => $artistID]);
$rc = count($result); $rc = count($result);
for ($i = 0 ; $i < $rc ; $i++) { for ($i = 0 ; $i < $rc ; $i++) {

View file

@ -17,11 +17,11 @@ class ArtistsTheme extends Themelet
"Author", "Author",
true, true,
$author, $author,
INPUT(["type"=>"text", "name"=>"tag_edit__author", "value"=>$author]) INPUT(["type" => "text", "name" => "tag_edit__author", "value" => $author])
); );
} }
public function sidebar_options(string $mode, ?int $artistID=null, $is_admin=false): void public function sidebar_options(string $mode, ?int $artistID = null, $is_admin = false): void
{ {
global $page, $user; global $page, $user;
@ -113,7 +113,7 @@ class ArtistsTheme extends Themelet
$urlsString .= $url["url"]."\n"; $urlsString .= $url["url"]."\n";
$urlsIDsString .= $url["id"]." "; $urlsIDsString .= $url["id"]." ";
} }
$urlsString = substr($urlsString, 0, strlen($urlsString) -1); $urlsString = substr($urlsString, 0, strlen($urlsString) - 1);
$urlsIDsString = rtrim($urlsIDsString); $urlsIDsString = rtrim($urlsIDsString);
$html = ' $html = '

View file

@ -10,7 +10,7 @@ class AutoTaggerInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Auto-Tagger"; public string $name = "Auto-Tagger";
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"];
public string $license = self::LICENSE_WTFPL; public string $license = self::LICENSE_WTFPL;
public string $description = "Provides several automatic tagging functions"; public string $description = "Provides several automatic tagging functions";
} }

View file

@ -75,7 +75,7 @@ class AutoTagger extends Extension
if ($event->get_arg(0) == "add") { if ($event->get_arg(0) == "add") {
if ($user->can(Permissions::MANAGE_AUTO_TAG)) { if ($user->can(Permissions::MANAGE_AUTO_TAG)) {
$user->ensure_authed(); $user->ensure_authed();
$input = validate_input(["c_tag"=>"string", "c_additional_tags"=>"string"]); $input = validate_input(["c_tag" => "string", "c_additional_tags" => "string"]);
try { try {
send_event(new AddAutoTagEvent($input['c_tag'], $input['c_additional_tags'])); send_event(new AddAutoTagEvent($input['c_tag'], $input['c_additional_tags']));
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
@ -87,7 +87,7 @@ class AutoTagger extends Extension
} elseif ($event->get_arg(0) == "remove") { } elseif ($event->get_arg(0) == "remove") {
if ($user->can(Permissions::MANAGE_AUTO_TAG)) { if ($user->can(Permissions::MANAGE_AUTO_TAG)) {
$user->ensure_authed(); $user->ensure_authed();
$input = validate_input(["d_tag"=>"string"]); $input = validate_input(["d_tag" => "string"]);
send_event(new DeleteAutoTagEvent($input['d_tag'])); send_event(new DeleteAutoTagEvent($input['d_tag']));
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("auto_tag/list")); $page->set_redirect(make_link("auto_tag/list"));
@ -128,7 +128,7 @@ class AutoTagger extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{ {
if ($event->parent=="tags") { if ($event->parent == "tags") {
$event->add_nav_link("auto_tag", new Link('auto_tag/list'), "Auto-Tag", NavLink::is_active(["auto_tag"])); $event->add_nav_link("auto_tag", new Link('auto_tag/list'), "Auto-Tag", NavLink::is_active(["auto_tag"]));
} }
} }
@ -212,7 +212,7 @@ class AutoTagger extends Extension
private function add_auto_tag(string $tag, string $additional_tags) private function add_auto_tag(string $tag, string $additional_tags)
{ {
global $database; global $database;
$existing_tags = $database->get_one("SELECT additional_tags FROM auto_tag WHERE LOWER(tag)=LOWER(:tag)", ["tag"=>$tag]); $existing_tags = $database->get_one("SELECT additional_tags FROM auto_tag WHERE LOWER(tag)=LOWER(:tag)", ["tag" => $tag]);
if (!is_null($existing_tags)) { if (!is_null($existing_tags)) {
// Auto Tags already exist, so we will append new tags to the existing one // Auto Tags already exist, so we will append new tags to the existing one
$tag = Tag::sanitize($tag); $tag = Tag::sanitize($tag);
@ -226,7 +226,7 @@ class AutoTagger extends Extension
$database->execute( $database->execute(
"UPDATE auto_tag set additional_tags=:existing_tags where tag=:tag", "UPDATE auto_tag set additional_tags=:existing_tags where tag=:tag",
["tag"=>$tag, "existing_tags"=>Tag::implode($existing_tags)] ["tag" => $tag, "existing_tags" => Tag::implode($existing_tags)]
); );
log_info( log_info(
AutoTaggerInfo::KEY, AutoTaggerInfo::KEY,
@ -238,7 +238,7 @@ class AutoTagger extends Extension
$database->execute( $database->execute(
"INSERT INTO auto_tag(tag, additional_tags) VALUES(:tag, :additional_tags)", "INSERT INTO auto_tag(tag, additional_tags) VALUES(:tag, :additional_tags)",
["tag"=>$tag, "additional_tags"=>Tag::implode($additional_tags)] ["tag" => $tag, "additional_tags" => Tag::implode($additional_tags)]
); );
log_info( log_info(
@ -253,9 +253,9 @@ class AutoTagger extends Extension
private function apply_new_auto_tag(string $tag) private function apply_new_auto_tag(string $tag)
{ {
global $database; global $database;
$tag_id = $database->get_one("SELECT id FROM tags WHERE LOWER(tag) = LOWER(:tag)", ["tag"=>$tag]); $tag_id = $database->get_one("SELECT id FROM tags WHERE LOWER(tag) = LOWER(:tag)", ["tag" => $tag]);
if (!empty($tag_id)) { if (!empty($tag_id)) {
$image_ids = $database->get_col_iterable("SELECT image_id FROM image_tags WHERE tag_id = :tag_id", ["tag_id"=>$tag_id]); $image_ids = $database->get_col_iterable("SELECT image_id FROM image_tags WHERE tag_id = :tag_id", ["tag_id" => $tag_id]);
foreach ($image_ids as $image_id) { foreach ($image_ids as $image_id) {
$image_id = (int) $image_id; $image_id = (int) $image_id;
$image = Image::by_id($image_id); $image = Image::by_id($image_id);

View file

@ -10,6 +10,6 @@ class AutoCompleteInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Autocomplete"; public string $name = "Autocomplete";
public array $authors = ["Daku"=>"admin@codeanimu.net"]; public array $authors = ["Daku" => "admin@codeanimu.net"];
public string $description = "Adds autocomplete to search & tagging."; public string $description = "Adds autocomplete to search & tagging.";
} }

View file

@ -55,7 +55,7 @@ class AutoComplete extends Extension
$limitSQL = ""; $limitSQL = "";
$search = str_replace('_', '\_', $search); $search = str_replace('_', '\_', $search);
$search = str_replace('%', '\%', $search); $search = str_replace('%', '\%', $search);
$SQLarr = ["search"=>"$search%"]; #, "cat_search"=>"%:$search%"]; $SQLarr = ["search" => "$search%"]; #, "cat_search"=>"%:$search%"];
if ($limit !== 0) { if ($limit !== 0) {
$limitSQL = "LIMIT :limit"; $limitSQL = "LIMIT :limit";
$SQLarr['limit'] = $limit; $SQLarr['limit'] = $limit;

View file

@ -9,7 +9,7 @@ class AutoCompleteTest extends ShimmiePHPUnitTestCase
public function testAuth() public function testAuth()
{ {
send_event(new UserLoginEvent(User::by_name(self::$anon_name))); send_event(new UserLoginEvent(User::by_name(self::$anon_name)));
$page = $this->get_page('api/internal/autocomplete', ["s"=>"not-a-tag"]); $page = $this->get_page('api/internal/autocomplete', ["s" => "not-a-tag"]);
$this->assertEquals(200, $page->code); $this->assertEquals(200, $page->code);
$this->assertEquals(PageMode::DATA, $page->mode); $this->assertEquals(PageMode::DATA, $page->mode);
$this->assertEquals("[]", $page->data); $this->assertEquals("[]", $page->data);

View file

@ -97,8 +97,8 @@ class BBCode extends FormatterExtension
} }
$beginning = substr($text, 0, $start); $beginning = substr($text, 0, $start);
$middle = str_rot13(substr($text, $start+$l1, ($end-$start-$l1))); $middle = str_rot13(substr($text, $start + $l1, ($end - $start - $l1)));
$ending = substr($text, $end + $l2, (strlen($text)-$end+$l2)); $ending = substr($text, $end + $l2, (strlen($text) - $end + $l2));
$text = $beginning . $middle . $ending; $text = $beginning . $middle . $ending;
} }
@ -131,8 +131,8 @@ class BBCode extends FormatterExtension
} }
$beginning = substr($text, 0, $start); $beginning = substr($text, 0, $start);
$middle = base64_encode(substr($text, $start+$l1, ($end-$start-$l1))); $middle = base64_encode(substr($text, $start + $l1, ($end - $start - $l1)));
$ending = substr($text, $end + $l2, (strlen($text)-$end+$l2)); $ending = substr($text, $end + $l2, (strlen($text) - $end + $l2));
$text = $beginning . "[code!]" . $middle . "[/code!]" . $ending; $text = $beginning . "[code!]" . $middle . "[/code!]" . $ending;
} }
@ -155,8 +155,8 @@ class BBCode extends FormatterExtension
} }
$beginning = substr($text, 0, $start); $beginning = substr($text, 0, $start);
$middle = base64_decode(substr($text, $start+$l1, ($end-$start-$l1))); $middle = base64_decode(substr($text, $start + $l1, ($end - $start - $l1)));
$ending = substr($text, $end + $l2, (strlen($text)-$end+$l2)); $ending = substr($text, $end + $l2, (strlen($text) - $end + $l2));
$text = $beginning . "<pre>" . $middle . "</pre>" . $ending; $text = $beginning . "<pre>" . $middle . "</pre>" . $ending;
} }

View file

@ -9,7 +9,7 @@ class BiographyTest extends ShimmiePHPUnitTestCase
public function testBio() public function testBio()
{ {
$this->log_in_as_user(); $this->log_in_as_user();
$this->post_page("biography", ["biography"=>"My bio goes here"]); $this->post_page("biography", ["biography" => "My bio goes here"]);
$this->get_page("user/" . self::$user_name); $this->get_page("user/" . self::$user_name);
$this->assert_text("My bio goes here"); $this->assert_text("My bio goes here");

View file

@ -17,7 +17,7 @@ class BiographyTheme extends Themelet
{ {
$html = SHM_SIMPLE_FORM( $html = SHM_SIMPLE_FORM(
make_link("biography"), make_link("biography"),
TEXTAREA(["style"=>"width: 100%", "rows"=>"6", "name"=>"biography"], $bio), TEXTAREA(["style" => "width: 100%", "rows" => "6", "name" => "biography"], $bio),
SHM_SUBMIT("Save") SHM_SUBMIT("Save")
); );

View file

@ -34,7 +34,7 @@ class Blocks extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{ {
global $user; global $user;
if ($event->parent==="system") { if ($event->parent === "system") {
if ($user->can(Permissions::MANAGE_BLOCKS)) { if ($user->can(Permissions::MANAGE_BLOCKS)) {
$event->add_nav_link("blocks", new Link('blocks/list'), "Blocks Editor"); $event->add_nav_link("blocks", new Link('blocks/list'), "Blocks Editor");
} }
@ -78,7 +78,7 @@ class Blocks extends Extension
$database->execute(" $database->execute("
INSERT INTO blocks (pages, title, area, priority, content, userclass) INSERT INTO blocks (pages, title, area, priority, content, userclass)
VALUES (:pages, :title, :area, :priority, :content, :userclass) VALUES (:pages, :title, :area, :priority, :content, :userclass)
", ['pages'=>$_POST['pages'], 'title'=>$_POST['title'], 'area'=>$_POST['area'], 'priority'=>(int)$_POST['priority'], 'content'=>$_POST['content'], 'userclass'=>$_POST['userclass']]); ", ['pages' => $_POST['pages'], 'title' => $_POST['title'], 'area' => $_POST['area'], 'priority' => (int)$_POST['priority'], 'content' => $_POST['content'], 'userclass' => $_POST['userclass']]);
log_info("blocks", "Added Block #".($database->get_last_insert_id('blocks_id_seq'))." (".$_POST['title'].")"); log_info("blocks", "Added Block #".($database->get_last_insert_id('blocks_id_seq'))." (".$_POST['title'].")");
$cache->delete("blocks"); $cache->delete("blocks");
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
@ -91,13 +91,13 @@ class Blocks extends Extension
$database->execute(" $database->execute("
DELETE FROM blocks DELETE FROM blocks
WHERE id=:id WHERE id=:id
", ['id'=>$_POST['id']]); ", ['id' => $_POST['id']]);
log_info("blocks", "Deleted Block #".$_POST['id']); log_info("blocks", "Deleted Block #".$_POST['id']);
} else { } else {
$database->execute(" $database->execute("
UPDATE blocks SET pages=:pages, title=:title, area=:area, priority=:priority, content=:content, userclass=:userclass UPDATE blocks SET pages=:pages, title=:title, area=:area, priority=:priority, content=:content, userclass=:userclass
WHERE id=:id WHERE id=:id
", ['pages'=>$_POST['pages'], 'title'=>$_POST['title'], 'area'=>$_POST['area'], 'priority'=>(int)$_POST['priority'], 'content'=>$_POST['content'], 'userclass'=>$_POST['userclass'], 'id'=>$_POST['id']]); ", ['pages' => $_POST['pages'], 'title' => $_POST['title'], 'area' => $_POST['area'], 'priority' => (int)$_POST['priority'], 'content' => $_POST['content'], 'userclass' => $_POST['userclass'], 'id' => $_POST['id']]);
log_info("blocks", "Updated Block #".$_POST['id']." (".$_POST['title'].")"); log_info("blocks", "Updated Block #".$_POST['id']." (".$_POST['title'].")");
} }
$cache->delete("blocks"); $cache->delete("blocks");

View file

@ -20,31 +20,31 @@ class BlocksTheme extends Themelet
{ {
global $page; global $page;
$html = TABLE(["class"=>"form", "style"=>"width: 100%;"]); $html = TABLE(["class" => "form", "style" => "width: 100%;"]);
foreach ($blocks as $block) { foreach ($blocks as $block) {
$html->appendChild(SHM_SIMPLE_FORM( $html->appendChild(SHM_SIMPLE_FORM(
"blocks/update", "blocks/update",
TR( TR(
INPUT(["type"=>"hidden", "name"=>"id", "value"=>$block['id']]), INPUT(["type" => "hidden", "name" => "id", "value" => $block['id']]),
TH("Title"), TH("Title"),
TD(INPUT(["type"=>"text", "name"=>"title", "value"=>$block['title']])), TD(INPUT(["type" => "text", "name" => "title", "value" => $block['title']])),
TH("Area"), TH("Area"),
TD(INPUT(["type"=>"text", "name"=>"area", "value"=>$block['area']])), TD(INPUT(["type" => "text", "name" => "area", "value" => $block['area']])),
TH("Priority"), TH("Priority"),
TD(INPUT(["type"=>"text", "name"=>"priority", "value"=>$block['priority']])), TD(INPUT(["type" => "text", "name" => "priority", "value" => $block['priority']])),
TH("User Class"), TH("User Class"),
TD(INPUT(["type"=>"text", "name"=>"userclass", "value"=>$block['userclass']])), TD(INPUT(["type" => "text", "name" => "userclass", "value" => $block['userclass']])),
TH("Pages"), TH("Pages"),
TD(INPUT(["type"=>"text", "name"=>"pages", "value"=>$block['pages']])), TD(INPUT(["type" => "text", "name" => "pages", "value" => $block['pages']])),
TH("Delete"), TH("Delete"),
TD(INPUT(["type"=>"checkbox", "name"=>"delete"])), TD(INPUT(["type" => "checkbox", "name" => "delete"])),
TD(INPUT(["type"=>"submit", "value"=>"Save"])) TD(INPUT(["type" => "submit", "value" => "Save"]))
), ),
TR( TR(
TD(["colspan"=>"13"], TEXTAREA(["rows"=>"5", "name"=>"content"], $block['content'])) TD(["colspan" => "13"], TEXTAREA(["rows" => "5", "name" => "content"], $block['content']))
), ),
TR( TR(
TD(["colspan"=>"13"], rawHTML("&nbsp;")) TD(["colspan" => "13"], rawHTML("&nbsp;"))
), ),
)); ));
} }
@ -53,19 +53,19 @@ class BlocksTheme extends Themelet
"blocks/add", "blocks/add",
TR( TR(
TH("Title"), TH("Title"),
TD(INPUT(["type"=>"text", "name"=>"title", "value"=>""])), TD(INPUT(["type" => "text", "name" => "title", "value" => ""])),
TH("Area"), TH("Area"),
TD(SELECT(["name"=>"area"], OPTION("left"), OPTION("main"))), TD(SELECT(["name" => "area"], OPTION("left"), OPTION("main"))),
TH("Priority"), TH("Priority"),
TD(INPUT(["type"=>"text", "name"=>"priority", "value"=>'50'])), TD(INPUT(["type" => "text", "name" => "priority", "value" => '50'])),
TH("User Class"), TH("User Class"),
TD(INPUT(["type"=>"text", "name"=>"userclass", "value"=>""])), TD(INPUT(["type" => "text", "name" => "userclass", "value" => ""])),
TH("Pages"), TH("Pages"),
TD(INPUT(["type"=>"text", "name"=>"pages", "value"=>'post/list*'])), TD(INPUT(["type" => "text", "name" => "pages", "value" => 'post/list*'])),
TD(["colspan"=>'3'], INPUT(["type"=>"submit", "value"=>"Add"])) TD(["colspan" => '3'], INPUT(["type" => "submit", "value" => "Add"]))
), ),
TR( TR(
TD(["colspan"=>"13"], TEXTAREA(["rows"=>"5", "name"=>"content"])) TD(["colspan" => "13"], TEXTAREA(["rows" => "5", "name" => "content"]))
), ),
)); ));

View file

@ -11,7 +11,7 @@ class BlotterInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Blotter"; public string $name = "Blotter";
public string $url = "http://seemslegit.com/"; public string $url = "http://seemslegit.com/";
public array $authors = ["Zach Hall"=>"zach@sosguy.net"]; public array $authors = ["Zach Hall" => "zach@sosguy.net"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public string $description = "Displays brief updates about whatever you want on every page. public string $description = "Displays brief updates about whatever you want on every page.
Colors and positioning can be configured to match your site's design. Colors and positioning can be configured to match your site's design.

View file

@ -31,7 +31,7 @@ class Blotter extends Extension
// Insert sample data: // Insert sample data:
$database->execute( $database->execute(
"INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), :text, :important)", "INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), :text, :important)",
["text"=>"Installed the blotter extension!", "important"=>true] ["text" => "Installed the blotter extension!", "important" => true]
); );
log_info("blotter", "Installed tables for blotter extension."); log_info("blotter", "Installed tables for blotter extension.");
$this->set_version("blotter_version", 2); $this->set_version("blotter_version", 2);
@ -53,7 +53,7 @@ class Blotter extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{ {
global $user; global $user;
if ($event->parent==="system") { if ($event->parent === "system") {
if ($user->can(Permissions::BLOTTER_ADMIN)) { if ($user->can(Permissions::BLOTTER_ADMIN)) {
$event->add_nav_link("blotter", new Link('blotter/editor'), "Blotter Editor"); $event->add_nav_link("blotter", new Link('blotter/editor'), "Blotter Editor");
} }
@ -100,7 +100,7 @@ class Blotter extends Extension
// Now insert into db: // Now insert into db:
$database->execute( $database->execute(
"INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), :text, :important)", "INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), :text, :important)",
["text"=>$entry_text, "important"=>$important] ["text" => $entry_text, "important" => $important]
); );
log_info("blotter", "Added Message: $entry_text"); log_info("blotter", "Added Message: $entry_text");
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
@ -115,7 +115,7 @@ class Blotter extends Extension
$this->theme->display_permission_denied(); $this->theme->display_permission_denied();
} else { } else {
$id = int_escape($_POST['id']); $id = int_escape($_POST['id']);
$database->execute("DELETE FROM blotter WHERE id=:id", ["id"=>$id]); $database->execute("DELETE FROM blotter WHERE id=:id", ["id" => $id]);
log_info("blotter", "Removed Entry #$id"); log_info("blotter", "Removed Entry #$id");
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("blotter/editor")); $page->set_redirect(make_link("blotter/editor"));

View file

@ -127,7 +127,7 @@ class BlotterTheme extends Themelet
$entry_text = $entries[$i]['entry_text']; $entry_text = $entries[$i]['entry_text'];
if ($entries[$i]['important'] == 'Y') { if ($entries[$i]['important'] == 'Y') {
$i_open = "<span style='color: #$i_color;'>"; $i_open = "<span style='color: #$i_color;'>";
$i_close="</span>"; $i_close = "</span>";
} }
$html .= "{$i_open}{$clean_date} - {$entry_text}{$i_close}<br /><br />"; $html .= "{$i_open}{$clean_date} - {$entry_text}{$i_close}<br /><br />";
} }
@ -155,7 +155,7 @@ class BlotterTheme extends Themelet
$entry_text = $entries[$i]['entry_text']; $entry_text = $entries[$i]['entry_text'];
if ($entries[$i]['important'] == 'Y') { if ($entries[$i]['important'] == 'Y') {
$i_open = "<span style='color: #$i_color'>"; $i_open = "<span style='color: #$i_color'>";
$i_close="</span>"; $i_close = "</span>";
} }
$entries_list .= "<li>{$i_open}{$clean_date} - {$entry_text}{$i_close}</li>"; $entries_list .= "<li>{$i_open}{$clean_date} - {$entry_text}{$i_close}</li>";
} }

View file

@ -11,7 +11,7 @@ class BrowserSearchInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Browser Search"; public string $name = "Browser Search";
public string $url = "http://atravelinggeek.com/"; public string $url = "http://atravelinggeek.com/";
public array $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"]; public array $authors = ["ATravelingGeek" => "atg@atravelinggeek.com"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public ?string $version = "0.1c, October 26, 2007"; public ?string $version = "0.1c, October 26, 2007";
public string $description = "Allows the user to add a browser 'plugin' to search the site with real-time suggestions"; public string $description = "Allows the user to add a browser 'plugin' to search the site with real-time suggestions";

View file

@ -65,7 +65,7 @@ class BrowserSearch extends Extension
} }
$tags = $database->get_col( $tags = $database->get_col(
"SELECT tag FROM tags WHERE tag LIKE :tag AND count > 0 ORDER BY $order LIMIT 30", "SELECT tag FROM tags WHERE tag LIKE :tag AND count > 0 ORDER BY $order LIMIT 30",
['tag'=>$tag_search."%"] ['tag' => $tag_search."%"]
); );
// And to do stuff with it. We want our output to look like: // And to do stuff with it. We want our output to look like:

View file

@ -10,7 +10,7 @@ class BulkActionsInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Bulk Actions"; public string $name = "Bulk Actions";
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"];
public string $license = self::LICENSE_WTFPL; public string $license = self::LICENSE_WTFPL;
public string $description = "Provides query and selection-based bulk action support"; public string $description = "Provides query and selection-based bulk action support";
public ?string $documentation = "Provides bulk action section in list view. Allows performing actions against a set of posts based on query or manual selection. Based on Mass Tagger by <a href='mailto:walde.christian@googlemail.com'>Christian Walde</a>, contributions by Shish and Agasa. public ?string $documentation = "Provides bulk action section in list view. Allows performing actions against a set of posts based on query or manual selection. Based on Mass Tagger by <a href='mailto:walde.christian@googlemail.com'>Christian Walde</a>, contributions by Shish and Agasa.

View file

@ -15,15 +15,15 @@ class BulkActionBlockBuildingEvent extends Event
public function add_action(string $action, string $button_text, string $access_key = null, string $confirmation_message = "", string $block = "", int $position = 40) public function add_action(string $action, string $button_text, string $access_key = null, string $confirmation_message = "", string $block = "", int $position = 40)
{ {
if (!empty($access_key)) { if (!empty($access_key)) {
assert(strlen($access_key)==1); assert(strlen($access_key) == 1);
foreach ($this->actions as $existing) { 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"); throw new SCoreException("Access key $access_key is already in use");
} }
} }
} }
$this->actions[] =[ $this->actions[] = [
"block" => $block, "block" => $block,
"access_key" => $access_key, "access_key" => $access_key,
"confirmation_message" => $confirmation_message, "confirmation_message" => $confirmation_message,
@ -137,7 +137,7 @@ class BulkActions extends Extension
$replace = true; $replace = true;
} }
$i= $this->tag_items($event->items, $tags, $replace); $i = $this->tag_items($event->items, $tags, $replace);
$page->flash("Tagged $i items"); $page->flash("Tagged $i items");
} }
break; break;
@ -204,7 +204,7 @@ class BulkActions extends Extension
foreach ($data as $id) { foreach ($data as $id) {
if (is_numeric($id)) { if (is_numeric($id)) {
$image = Image::by_id($id); $image = Image::by_id($id);
if ($image!=null) { if ($image != null) {
yield $image; yield $image;
} }
} }

View file

@ -11,7 +11,7 @@ class BulkAddCSVInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Bulk Add CSV"; public string $name = "Bulk Add CSV";
public string $url = self::SHIMMIE_URL; public string $url = self::SHIMMIE_URL;
public array $authors = ["velocity37"=>"velocity37@gmail.com"]; public array $authors = ["velocity37" => "velocity37@gmail.com"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public string $description = "Bulk add server-side posts with metadata from CSV file"; public string $description = "Bulk add server-side posts with metadata from CSV file";
public ?string $documentation = public ?string $documentation =

View file

@ -10,7 +10,7 @@ class BulkDownloadInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Bulk Download"; public string $name = "Bulk Download";
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"];
public string $license = self::LICENSE_WTFPL; public string $license = self::LICENSE_WTFPL;
public string $description = "Allows bulk downloading images."; public string $description = "Allows bulk downloading images.";
public array $dependencies = [BulkActionsInfo::KEY]; public array $dependencies = [BulkActionsInfo::KEY];

View file

@ -45,7 +45,7 @@ class BulkDownload extends Extension
{ {
global $user, $page, $config; global $user, $page, $config;
if ($user->can(Permissions::BULK_DOWNLOAD)&& if ($user->can(Permissions::BULK_DOWNLOAD) &&
($event->action == BulkDownload::DOWNLOAD_ACTION_NAME)) { ($event->action == BulkDownload::DOWNLOAD_ACTION_NAME)) {
$download_filename = $user->name . '-' . date('YmdHis') . '.zip'; $download_filename = $user->name . '-' . date('YmdHis') . '.zip';
$zip_filename = tempnam(sys_get_temp_dir(), "shimmie_bulk_download"); $zip_filename = tempnam(sys_get_temp_dir(), "shimmie_bulk_download");
@ -57,7 +57,7 @@ class BulkDownload extends Extension
foreach ($event->items as $image) { foreach ($event->items as $image) {
$img_loc = warehouse_path(Image::IMAGE_DIR, $image->hash, false); $img_loc = warehouse_path(Image::IMAGE_DIR, $image->hash, false);
$size_total += filesize($img_loc); $size_total += filesize($img_loc);
if ($size_total>$max_size) { if ($size_total > $max_size) {
throw new BulkDownloadException("Bulk download limited to ".human_filesize($max_size)); throw new BulkDownloadException("Bulk download limited to ".human_filesize($max_size));
} }

View file

@ -12,7 +12,7 @@ class BulkImportExportInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Bulk Import/Export"; public string $name = "Bulk Import/Export";
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"];
public string $license = self::LICENSE_WTFPL; public string $license = self::LICENSE_WTFPL;
public string $description = "Allows bulk exporting/importing of images and associated data."; public string $description = "Allows bulk exporting/importing of images and associated data.";
public array $dependencies = [BulkActionsInfo::KEY]; public array $dependencies = [BulkActionsInfo::KEY];

View file

@ -37,7 +37,7 @@ class BulkImportExport extends DataHandlerExtension
$database->begin_transaction(); $database->begin_transaction();
try { try {
$image = Image::by_hash($item->hash); $image = Image::by_hash($item->hash);
if ($image!=null) { if ($image != null) {
$skipped++; $skipped++;
log_info(BulkImportExportInfo::KEY, "Post $item->hash already present, skipping"); log_info(BulkImportExportInfo::KEY, "Post $item->hash already present, skipping");
$database->commit(); $database->commit();
@ -54,17 +54,17 @@ class BulkImportExport extends DataHandlerExtension
$id = add_image($tmpfile, $item->filename, Tag::implode($item->tags))->image_id; $id = add_image($tmpfile, $item->filename, Tag::implode($item->tags))->image_id;
if ($id==-1) { if ($id == -1) {
throw new SCoreException("Unable to import file $item->hash"); throw new SCoreException("Unable to import file $item->hash");
} }
$image = Image::by_id($id); $image = Image::by_id($id);
if ($image==null) { if ($image == null) {
throw new SCoreException("Unable to import file $item->hash"); throw new SCoreException("Unable to import file $item->hash");
} }
if ($item->source!=null) { if ($item->source != null) {
$image->set_source($item->source); $image->set_source($item->source);
} }
send_event(new BulkImportEvent($image, $item)); send_event(new BulkImportEvent($image, $item));

View file

@ -10,7 +10,7 @@ class BulkParentChildInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Bulk Parent Child"; public string $name = "Bulk Parent Child";
public array $authors = ["Flatty"=>""]; public array $authors = ["Flatty" => ""];
public string $license = self::LICENSE_WTFPL; public string $license = self::LICENSE_WTFPL;
public string $description = "Allows bulk setting of parent-child relationships, in order of manual selection"; public string $description = "Allows bulk setting of parent-child relationships, in order of manual selection";
public array $dependencies = [BulkActionsInfo::KEY]; public array $dependencies = [BulkActionsInfo::KEY];

View file

@ -27,7 +27,7 @@ class BulkParentChild extends Extension
public function onBulkAction(BulkActionEvent $event) public function onBulkAction(BulkActionEvent $event)
{ {
global $user, $page, $config; global $user, $page, $config;
if ($user->can(Permissions::BULK_PARENT_CHILD)&& if ($user->can(Permissions::BULK_PARENT_CHILD) &&
($event->action == BulkParentChild::PARENT_CHILD_ACTION_NAME)) { ($event->action == BulkParentChild::PARENT_CHILD_ACTION_NAME)) {
$prev_id = null; $prev_id = null;
foreach ($event->items as $image) { foreach ($event->items as $image) {

View file

@ -84,7 +84,7 @@ class Comment
SELECT COUNT(*) AS count SELECT COUNT(*) AS count
FROM comments FROM comments
WHERE owner_id=:owner_id WHERE owner_id=:owner_id
", ["owner_id"=>$user->id]); ", ["owner_id" => $user->id]);
} }
#[Field(name: "owner")] #[Field(name: "owner")]
@ -187,7 +187,7 @@ class CommentList extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) 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_list", new Link('comment/list'), "All");
$event->add_nav_link("comment_help", new Link('ext_doc/comment'), "Help"); $event->add_nav_link("comment_help", new Link('ext_doc/comment'), "Help");
} }
@ -306,7 +306,7 @@ class CommentList extends Extension
GROUP BY image_id GROUP BY image_id
ORDER BY latest DESC ORDER BY latest DESC
LIMIT :limit OFFSET :offset LIMIT :limit OFFSET :offset
", ["limit"=>$threads_per_page, "offset"=>$start]); ", ["limit" => $threads_per_page, "offset" => $start]);
$user_ratings = Extension::is_enabled(RatingsInfo::KEY) ? Ratings::get_user_class_privs($user) : ""; $user_ratings = Extension::is_enabled(RatingsInfo::KEY) ? Ratings::get_user_class_privs($user) : "";
@ -322,7 +322,7 @@ class CommentList extends Extension
if ( if (
Extension::is_enabled(ApprovalInfo::KEY) && !is_null($image) && Extension::is_enabled(ApprovalInfo::KEY) && !is_null($image) &&
$config->get_bool(ApprovalConfig::IMAGES) && $config->get_bool(ApprovalConfig::IMAGES) &&
$image->approved!==true $image->approved !== true
) { ) {
$image = null; $image = null;
} }
@ -332,7 +332,7 @@ class CommentList extends Extension
} }
} }
$this->theme->display_comment_list($images, $current_page+1, $total_pages, $user->can(Permissions::CREATE_COMMENT)); $this->theme->display_comment_list($images, $current_page + 1, $total_pages, $user->can(Permissions::CREATE_COMMENT));
} }
private function onPageRequest_beta_search(PageRequestEvent $event) private function onPageRequest_beta_search(PageRequestEvent $event)
@ -344,7 +344,7 @@ class CommentList extends Extension
$com_per_page = 50; $com_per_page = 50;
$total_pages = (int)ceil($i_comment_count / $com_per_page); $total_pages = (int)ceil($i_comment_count / $com_per_page);
$comments = $this->get_user_comments($duser->id, $com_per_page, $page_num * $com_per_page); $comments = $this->get_user_comments($duser->id, $com_per_page, $page_num * $com_per_page);
$this->theme->display_all_user_comments($comments, $page_num+1, $total_pages, $duser); $this->theme->display_all_user_comments($comments, $page_num + 1, $total_pages, $duser);
} }
public function onAdminBuilding(AdminBuildingEvent $event) public function onAdminBuilding(AdminBuildingEvent $event)
@ -401,7 +401,7 @@ class CommentList extends Extension
$database->execute(" $database->execute("
DELETE FROM comments DELETE FROM comments
WHERE id=:comment_id WHERE id=:comment_id
", ["comment_id"=>$event->comment_id]); ", ["comment_id" => $event->comment_id]);
log_info("comment", "Deleting Comment #{$event->comment_id}"); log_info("comment", "Deleting Comment #{$event->comment_id}");
} }
@ -446,7 +446,7 @@ class CommentList extends Extension
public function onHelpPageBuilding(HelpPageBuildingEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event)
{ {
if ($event->key===HelpPages::SEARCH) { if ($event->key === HelpPages::SEARCH) {
$block = new Block(); $block = new Block();
$block->header = "Comments"; $block->header = "Comments";
$block->body = $this->theme->get_help_html(); $block->body = $this->theme->get_help_html();
@ -483,13 +483,13 @@ class CommentList extends Extension
LEFT JOIN users ON comments.owner_id=users.id LEFT JOIN users ON comments.owner_id=users.id
ORDER BY comments.id DESC ORDER BY comments.id DESC
LIMIT :limit LIMIT :limit
", ["limit"=>$count]); ", ["limit" => $count]);
} }
/** /**
* #return Comment[] * #return Comment[]
*/ */
private static function get_user_comments(int $user_id, int $count, int $offset=0): array private static function get_user_comments(int $user_id, int $count, int $offset = 0): array
{ {
return CommentList::get_generic_comments(" return CommentList::get_generic_comments("
SELECT SELECT
@ -502,7 +502,7 @@ class CommentList extends Extension
WHERE users.id = :user_id WHERE users.id = :user_id
ORDER BY comments.id DESC ORDER BY comments.id DESC
LIMIT :limit OFFSET :offset LIMIT :limit OFFSET :offset
", ["user_id"=>$user_id, "offset"=>$offset, "limit"=>$count]); ", ["user_id" => $user_id, "offset" => $offset, "limit" => $count]);
} }
/** /**
@ -521,7 +521,7 @@ class CommentList extends Extension
LEFT JOIN users ON comments.owner_id=users.id LEFT JOIN users ON comments.owner_id=users.id
WHERE comments.image_id=:image_id WHERE comments.image_id=:image_id
ORDER BY comments.id ASC ORDER BY comments.id ASC
", ["image_id"=>$image_id]); ", ["image_id" => $image_id]);
} }
private function is_comment_limit_hit(): bool private function is_comment_limit_hit(): bool
@ -547,7 +547,7 @@ class CommentList extends Extension
SELECT * SELECT *
FROM comments FROM comments
WHERE owner_ip = :remote_ip AND posted > now() - $window_sql WHERE owner_ip = :remote_ip AND posted > now() - $window_sql
", ["remote_ip"=>get_real_ip()]); ", ["remote_ip" => get_real_ip()]);
return (count($result) >= $max); return (count($result) >= $max);
} }
@ -609,7 +609,7 @@ class CommentList extends Extension
SELECT * SELECT *
FROM comments FROM comments
WHERE image_id=:image_id AND comment=:comment WHERE image_id=:image_id AND comment=:comment
", ["image_id"=>$image_id, "comment"=>$comment]); ", ["image_id" => $image_id, "comment" => $comment]);
} }
// do some checks // do some checks
@ -624,12 +624,12 @@ class CommentList extends Extension
// all checks passed // all checks passed
if ($user->is_anonymous()) { if ($user->is_anonymous()) {
$page->add_cookie("nocache", "Anonymous Commenter", time()+60*60*24, "/"); $page->add_cookie("nocache", "Anonymous Commenter", time() + 60 * 60 * 24, "/");
} }
$database->execute( $database->execute(
"INSERT INTO comments(image_id, owner_id, owner_ip, posted, comment) ". "INSERT INTO comments(image_id, owner_id, owner_ip, posted, comment) ".
"VALUES(:image_id, :user_id, :remote_addr, now(), :comment)", "VALUES(:image_id, :user_id, :remote_addr, now(), :comment)",
["image_id"=>$image_id, "user_id"=>$user->id, "remote_addr"=>get_real_ip(), "comment"=>$comment] ["image_id" => $image_id, "user_id" => $user->id, "remote_addr" => get_real_ip(), "comment" => $comment]
); );
$cid = $database->get_last_insert_id('comments_id_seq'); $cid = $database->get_last_insert_id('comments_id_seq');
$snippet = substr($comment, 0, 100); $snippet = substr($comment, 0, 100);
@ -654,10 +654,10 @@ class CommentList extends Extension
} }
// advanced sanity checks // advanced sanity checks
elseif (strlen($comment)/strlen(gzcompress($comment)) > 10) { elseif (strlen($comment) / strlen(gzcompress($comment)) > 10) {
throw new CommentPostingException("Comment too repetitive~"); throw new CommentPostingException("Comment too repetitive~");
} elseif ($user->is_anonymous() && !$this->hash_match()) { } elseif ($user->is_anonymous() && !$this->hash_match()) {
$page->add_cookie("nocache", "Anonymous Commenter", time()+60*60*24, "/"); $page->add_cookie("nocache", "Anonymous Commenter", time() + 60 * 60 * 24, "/");
throw new CommentPostingException( throw new CommentPostingException(
"Comment submission form is out of date; refresh the ". "Comment submission form is out of date; refresh the ".
"comment form to show you aren't a spammer~" "comment form to show you aren't a spammer~"

View file

@ -194,7 +194,7 @@ class CommentListTheme extends Themelet
$this->display_paginator($page, "comment/beta-search/{$user->name}", null, $page_number, $total_pages); $this->display_paginator($page, "comment/beta-search/{$user->name}", null, $page_number, $total_pages);
} }
protected function comment_to_html(Comment $comment, bool $trim=false): string protected function comment_to_html(Comment $comment, bool $trim = false): string
{ {
global $config, $user; global $config, $user;

View file

@ -20,7 +20,7 @@ class CronUploaderInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Cron Uploader"; public string $name = "Cron Uploader";
public string $url = self::SHIMMIE_URL; public string $url = self::SHIMMIE_URL;
public array $authors = ["YaoiFox"=>"admin@yaoifox.com", "Matthew Barbour"=>"matthew@darkholme.net"]; public array $authors = ["YaoiFox" => "admin@yaoifox.com", "Matthew Barbour" => "matthew@darkholme.net"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public string $description = "Uploads images automatically using Cron Jobs"; public string $description = "Uploads images automatically using Cron Jobs";

View file

@ -57,7 +57,7 @@ class CronUploader extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) 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"); $event->add_nav_link("cron_docs", new Link('cron_upload'), "Cron Upload");
} }
} }
@ -71,7 +71,7 @@ class CronUploader extends Extension
global $user; global $user;
if ($event->page_matches("cron_upload")) { if ($event->page_matches("cron_upload")) {
if ($event->count_args() == 1 && $event->get_arg(0) =="run") { if ($event->count_args() == 1 && $event->get_arg(0) == "run") {
$this->process_upload(); // Start upload $this->process_upload(); // Start upload
} elseif ($user->can(Permissions::CRON_RUN)) { } elseif ($user->can(Permissions::CRON_RUN)) {
$this->display_documentation(); $this->display_documentation();
@ -127,7 +127,7 @@ class CronUploader extends Extension
if (self::$IMPORT_RUNNING) { if (self::$IMPORT_RUNNING) {
$all = $user_config->get_bool(CronUploaderConfig::INCLUDE_ALL_LOGS); $all = $user_config->get_bool(CronUploaderConfig::INCLUDE_ALL_LOGS);
if ($event->priority >= $user_config->get_int(CronUploaderConfig::LOG_LEVEL) && if ($event->priority >= $user_config->get_int(CronUploaderConfig::LOG_LEVEL) &&
($event->section==self::NAME || $all)) { ($event->section == self::NAME || $all)) {
$output = "[" . date('Y-m-d H:i:s') . "] " . ($all ? '[' . $event->section . '] ' : '') . "[" . LOGGING_LEVEL_NAMES[$event->priority] . "] " . $event->message; $output = "[" . date('Y-m-d H:i:s') . "] " . ($all ? '[' . $event->section . '] ' : '') . "[" . LOGGING_LEVEL_NAMES[$event->priority] . "] " . $event->message;
echo $output . "\r\n"; echo $output . "\r\n";
@ -157,7 +157,7 @@ class CronUploader extends Extension
$results = get_files_recursively($stage_dir); $results = get_files_recursively($stage_dir);
if (count($results) == 0) { if (count($results) == 0) {
if (remove_empty_dirs($stage_dir)===false) { if (remove_empty_dirs($stage_dir) === false) {
$page->flash("Nothing to stage from $folder, cannot remove folder"); $page->flash("Nothing to stage from $folder, cannot remove folder");
} else { } else {
$page->flash("Nothing to stage from $folder, removing folder"); $page->flash("Nothing to stage from $folder, removing folder");
@ -182,15 +182,15 @@ class CronUploader extends Extension
mkdir($dir, 0775, true); mkdir($dir, 0775, true);
} }
if (rename($result, $new_path)===false) { if (rename($result, $new_path) === false) {
$page->flash("Could not move file: " .$result); $page->flash("Could not move file: " .$result);
$success = false; $success = false;
} }
} }
if ($success===true) { if ($success === true) {
$page->flash("Re-staged $folder to queue"); $page->flash("Re-staged $folder to queue");
if (remove_empty_dirs($stage_dir)===false) { if (remove_empty_dirs($stage_dir) === false) {
$page->flash("Could not remove $folder"); $page->flash("Could not remove $folder");
} }
} }
@ -325,7 +325,7 @@ class CronUploader extends Extension
{ {
global $database, $user, $user_config, $config, $_shm_load_start; global $database, $user, $user_config, $config, $_shm_load_start;
$max_time = intval(ini_get('max_execution_time'))*.8; $max_time = intval(ini_get('max_execution_time')) * .8;
$this->set_headers(); $this->set_headers();
@ -365,7 +365,7 @@ class CronUploader extends Extension
// Upload the file(s) // Upload the file(s)
foreach ($image_queue as $img) { foreach ($image_queue as $img) {
$execution_time = ftime() - $_shm_load_start; $execution_time = ftime() - $_shm_load_start;
if ($execution_time>$max_time) { if ($execution_time > $max_time) {
break; break;
} else { } else {
$remaining = $max_time - $execution_time; $remaining = $max_time - $execution_time;
@ -405,7 +405,7 @@ class CronUploader extends Extension
} }
// Throw exception if there's nothing in the queue // Throw exception if there's nothing in the queue
if ($merged+$failed+$added === 0) { if ($merged + $failed + $added === 0) {
$this->log_message(SCORE_LOG_WARNING, "Your queue is empty so nothing could be uploaded."); $this->log_message(SCORE_LOG_WARNING, "Your queue is empty so nothing could be uploaded.");
return false; return false;
} }
@ -429,13 +429,13 @@ class CronUploader extends Extension
$rootDir = $user_config->get_string(CronUploaderConfig::DIR); $rootDir = $user_config->get_string(CronUploaderConfig::DIR);
$rootLength = strlen($rootDir); $rootLength = strlen($rootDir);
if ($rootDir[$rootLength-1]=="/"||$rootDir[$rootLength-1]=="\\") { if ($rootDir[$rootLength - 1] == "/" || $rootDir[$rootLength - 1] == "\\") {
$rootLength--; $rootLength--;
} }
$relativeDir = dirname(substr($path, $rootLength + 7)); $relativeDir = dirname(substr($path, $rootLength + 7));
if ($relativeDir==".") { if ($relativeDir == ".") {
$relativeDir = ""; $relativeDir = "";
} }

View file

@ -84,7 +84,7 @@ class CronUploaderTheme extends Themelet
</ol>"; </ol>";
$max_time = intval(ini_get('max_execution_time'))*.8; $max_time = intval(ini_get('max_execution_time')) * .8;
$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.
<br />(<b>{$queue_dirinfo['path']}</b>) <br />(<b>{$queue_dirinfo['path']}</b>)
@ -109,7 +109,7 @@ class CronUploaderTheme extends Themelet
$block = new Block("Cron Uploader", $info_html, "main", 10); $block = new Block("Cron Uploader", $info_html, "main", 10);
$block_install = new Block("Setup Guide", $install_html, "main", 30); $block_install = new Block("Setup Guide", $install_html, "main", 30);
$block_usage= new Block("Usage Guide", $usage_html, "main", 20); $block_usage = new Block("Usage Guide", $usage_html, "main", 20);
$page->add_block($block); $page->add_block($block);
$page->add_block($block_install); $page->add_block($block_install);
$page->add_block($block_usage); $page->add_block($block_usage);
@ -130,28 +130,28 @@ class CronUploaderTheme extends Themelet
$form = SHM_SIMPLE_FORM( $form = SHM_SIMPLE_FORM(
"user_admin/cron_uploader", "user_admin/cron_uploader",
TABLE( TABLE(
["class"=>"form"], ["class" => "form"],
TBODY( TBODY(
TR( TR(
TH("Cron Uploader") TH("Cron Uploader")
), ),
TR( TR(
TH("Root dir"), TH("Root dir"),
TD(INPUT(["type"=>'text', "name"=>'name', "required"=>true])) TD(INPUT(["type" => 'text', "name" => 'name', "required" => true]))
), ),
TR( TR(
TH(), TH(),
TD( TD(
LABEL(INPUT(["type"=>'checkbox', "name"=>'stop_on_error']), "Stop On Error") LABEL(INPUT(["type" => 'checkbox', "name" => 'stop_on_error']), "Stop On Error")
) )
), ),
TR( TR(
TH(rawHTML("Repeat&nbsp;Password")), TH(rawHTML("Repeat&nbsp;Password")),
TD(INPUT(["type"=>'password', "name"=>'pass2', "required"=>true])) TD(INPUT(["type" => 'password', "name" => 'pass2', "required" => true]))
) )
), ),
TFOOT( TFOOT(
TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Save Settings"]))) TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => "Save Settings"])))
) )
) )
); );

View file

@ -11,7 +11,7 @@ class CustomHtmlHeadersInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Custom HTML Headers"; public string $name = "Custom HTML Headers";
public string $url = "http://www.drudexsoftware.com"; public string $url = "http://www.drudexsoftware.com";
public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; public array $authors = ["Drudex Software" => "support@drudexsoftware.com"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public string $description = "Allows admins to modify & set custom &lt;head&gt; content"; public string $description = "Allows admins to modify & set custom &lt;head&gt; content";
public ?string $documentation = public ?string $documentation =

View file

@ -43,7 +43,7 @@ class CustomHtmlHeaders extends Extension
global $config, $page; global $config, $page;
$header = $config->get_string('custom_html_headers', ''); $header = $config->get_string('custom_html_headers', '');
if ($header!='') { if ($header != '') {
$page->add_html_header($header); $page->add_html_header($header);
} }
} }

View file

@ -10,7 +10,7 @@ class DanbooruApiInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Danbooru Client API"; public string $name = "Danbooru Client API";
public array $authors = ["JJS"=>"jsutinen@gmail.com"]; public array $authors = ["JJS" => "jsutinen@gmail.com"];
public string $description = "Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie"; public string $description = "Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie";
public ?string $documentation = public ?string $documentation =
"<b>Notes</b>: "<b>Notes</b>:

View file

@ -99,7 +99,7 @@ class DanbooruApi extends Extension
foreach ($idlist as $id) { foreach ($idlist as $id) {
$sqlresult = $database->get_all( $sqlresult = $database->get_all(
"SELECT id,tag,count FROM tags WHERE id = :id", "SELECT id,tag,count FROM tags WHERE id = :id",
['id'=>$id] ['id' => $id]
); );
foreach ($sqlresult as $row) { foreach ($sqlresult as $row) {
$results[] = [$row['count'], $row['tag'], $row['id']]; $results[] = [$row['count'], $row['tag'], $row['id']];
@ -110,7 +110,7 @@ class DanbooruApi extends Extension
foreach ($namelist as $name) { foreach ($namelist as $name) {
$sqlresult = $database->get_all( $sqlresult = $database->get_all(
"SELECT id,tag,count FROM tags WHERE LOWER(tag) = LOWER(:tag)", "SELECT id,tag,count FROM tags WHERE LOWER(tag) = LOWER(:tag)",
['tag'=>$name] ['tag' => $name]
); );
foreach ($sqlresult as $row) { foreach ($sqlresult as $row) {
$results[] = [$row['count'], $row['tag'], $row['id']]; $results[] = [$row['count'], $row['tag'], $row['id']];
@ -129,7 +129,7 @@ class DanbooruApi extends Extension
$start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0; $start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0;
$sqlresult = $database->get_all( $sqlresult = $database->get_all(
"SELECT id,tag,count FROM tags WHERE count > 0 AND id >= :id ORDER BY id DESC", "SELECT id,tag,count FROM tags WHERE count > 0 AND id >= :id ORDER BY id DESC",
['id'=>$start] ['id' => $start]
); );
foreach ($sqlresult as $row) { foreach ($sqlresult as $row) {
$results[] = [$row['count'], $row['tag'], $row['id']]; $results[] = [$row['count'], $row['tag'], $row['id']];
@ -205,7 +205,7 @@ class DanbooruApi extends Extension
// Now we have the array $results filled with Image objects // Now we have the array $results filled with Image objects
// Let's display them // Let's display them
$xml = POSTS(["count"=>$count, "offset"=>$start]); $xml = POSTS(["count" => $count, "offset" => $start]);
foreach ($results as $img) { foreach ($results as $img) {
// Sanity check to see if $img is really an image object // Sanity check to see if $img is really an image object
// If it isn't (e.g. someone requested an invalid md5 or id), break out of the this // If it isn't (e.g. someone requested an invalid md5 or id), break out of the this

View file

@ -13,13 +13,13 @@ class DanbooruApiTest extends ShimmiePHPUnitTestCase
$image_id = $this->post_image("tests/bedroom_workshop.jpg", "data"); $image_id = $this->post_image("tests/bedroom_workshop.jpg", "data");
$this->get_page("api/danbooru/find_posts"); $this->get_page("api/danbooru/find_posts");
$this->get_page("api/danbooru/find_posts", ["id"=>$image_id]); $this->get_page("api/danbooru/find_posts", ["id" => $image_id]);
$this->get_page("api/danbooru/find_posts", ["md5"=>"17fc89f372ed3636e28bd25cc7f3bac1"]); $this->get_page("api/danbooru/find_posts", ["md5" => "17fc89f372ed3636e28bd25cc7f3bac1"]);
$this->get_page("api/danbooru/find_posts", ["tags"=>"*"]); $this->get_page("api/danbooru/find_posts", ["tags" => "*"]);
$this->get_page("api/danbooru/find_tags"); $this->get_page("api/danbooru/find_tags");
$this->get_page("api/danbooru/find_tags", ["id"=>1]); $this->get_page("api/danbooru/find_tags", ["id" => 1]);
$this->get_page("api/danbooru/find_tags", ["name"=>"data"]); $this->get_page("api/danbooru/find_tags", ["name" => "data"]);
$page = $this->get_page("api/danbooru/post/show/$image_id"); $page = $this->get_page("api/danbooru/post/show/$image_id");
$this->assertEquals(302, $page->code); $this->assertEquals(302, $page->code);

View file

@ -10,7 +10,7 @@ class DownloadInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Download"; public string $name = "Download";
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"];
public string $license = self::LICENSE_WTFPL; public string $license = self::LICENSE_WTFPL;
public string $description = "System-wide download functions"; public string $description = "System-wide download functions";
public bool $core = true; public bool $core = true;

View file

@ -22,7 +22,7 @@ class ET extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{ {
global $user; global $user;
if ($event->parent==="system") { if ($event->parent === "system") {
if ($user->can(Permissions::VIEW_SYSINTO)) { if ($user->can(Permissions::VIEW_SYSINTO)) {
$event->add_nav_link("system_info", new Link('system_info'), "System Info", null, 10); $event->add_nav_link("system_info", new Link('system_info'), "System Info", null, 10);
} }
@ -105,9 +105,9 @@ class ET extends Extension
if (file_exists(".git")) { if (file_exists(".git")) {
try { try {
$commitHash = trim(exec('git log --pretty="%h" -n1 HEAD')); $commitHash = trim(exec('git log --pretty="%h" -n1 HEAD'));
$commitBranch= trim(exec('git rev-parse --abbrev-ref HEAD')); $commitBranch = trim(exec('git rev-parse --abbrev-ref HEAD'));
$commitOrigin= trim(exec('git config --get remote.origin.url')); $commitOrigin = trim(exec('git config --get remote.origin.url'));
$commitOrigin= preg_replace("#//.*@#", "//xxx@", $commitOrigin); $commitOrigin = preg_replace("#//.*@#", "//xxx@", $commitOrigin);
$info['git'] = [ $info['git'] = [
'commit' => $commitHash, 'commit' => $commitHash,
'branch' => $commitBranch, 'branch' => $commitBranch,

View file

@ -29,18 +29,18 @@ class ETTheme extends Themelet
protected function build_data_form($yaml): \MicroHTML\HTMLElement protected function build_data_form($yaml): \MicroHTML\HTMLElement
{ {
return FORM( return FORM(
["action"=>"https://shimmie.shishnet.org/register.php", "method"=>"POST"], ["action" => "https://shimmie.shishnet.org/register.php", "method" => "POST"],
INPUT(["type"=>"hidden", "name"=>"registration_api", "value"=>"2"]), INPUT(["type" => "hidden", "name" => "registration_api", "value" => "2"]),
P( P(
"Your stats are useful so that I know which combinations of ". "Your stats are useful so that I know which combinations of ".
"web servers / databases / etc I need to support :)" "web servers / databases / etc I need to support :)"
), ),
P(TEXTAREA( P(TEXTAREA(
["name"=>'data', "style"=>"width: 100%; height: 20em;"], ["name" => 'data', "style" => "width: 100%; height: 20em;"],
$yaml $yaml
)), )),
P(INPUT( P(INPUT(
["type"=>'submit', "value"=>'Click to send to Shish', "style"=>"width: 100%; padding: 1em;"] ["type" => 'submit', "value" => 'Click to send to Shish', "style" => "width: 100%; padding: 1em;"]
)), )),
); );
} }

View file

@ -16,7 +16,7 @@ class ETServer extends Extension
if (isset($_POST["data"])) { if (isset($_POST["data"])) {
$database->execute( $database->execute(
"INSERT INTO registration(data) VALUES(:data)", "INSERT INTO registration(data) VALUES(:data)",
["data"=>$_POST["data"]] ["data" => $_POST["data"]]
); );
$page->set_title("Thanks!"); $page->set_title("Thanks!");
$page->set_heading("Thanks!"); $page->set_heading("Thanks!");
@ -28,7 +28,7 @@ class ETServer extends Extension
foreach ($database->get_all("SELECT responded, data FROM registration ORDER BY responded DESC") as $row) { foreach ($database->get_all("SELECT responded, data FROM registration ORDER BY responded DESC") as $row) {
$page->add_block(new Block( $page->add_block(new Block(
$row["responded"], $row["responded"],
PRE(["style"=>"text-align: left; overflow: scroll;"], $row["data"]), PRE(["style" => "text-align: left; overflow: scroll;"], $row["data"]),
"main", "main",
$n++ $n++
)); ));

View file

@ -6,10 +6,10 @@ namespace Shimmie2;
function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b): int function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b): int
{ {
if ($a->beta===true&&$b->beta===false) { if ($a->beta === true && $b->beta === false) {
return 1; return 1;
} }
if ($a->beta===false&&$b->beta===true) { if ($a->beta === false && $b->beta === true) {
return -1; return -1;
} }
@ -92,7 +92,7 @@ class ExtManager extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{ {
global $user; global $user;
if ($event->parent==="system") { if ($event->parent === "system") {
if ($user->can(Permissions::MANAGE_EXTENSION_LIST)) { if ($user->can(Permissions::MANAGE_EXTENSION_LIST)) {
$event->add_nav_link("ext_manager", new Link('ext_manager'), "Extension Manager"); $event->add_nav_link("ext_manager", new Link('ext_manager'), "Extension Manager");
} else { } else {

View file

@ -34,7 +34,7 @@ class ExtManagerTheme extends Themelet
$form = SHM_SIMPLE_FORM( $form = SHM_SIMPLE_FORM(
"ext_manager/set", "ext_manager/set",
TABLE( TABLE(
["id"=>'extensions', "class"=>'zebra'], ["id" => 'extensions', "class" => 'zebra'],
THEAD(TR( THEAD(TR(
$editable ? TH("Enabled") : null, $editable ? TH("Enabled") : null,
TH("Name"), TH("Name"),
@ -42,7 +42,7 @@ class ExtManagerTheme extends Themelet
TH("Description") TH("Description")
)), )),
$tbody, $tbody,
$editable ? TFOOT(TR(TD(["colspan"=>'5'], INPUT(["type"=>'submit', "value"=>'Set Extensions'])))) : null $editable ? TFOOT(TR(TD(["colspan" => '5'], INPUT(["type" => 'submit', "value" => 'Set Extensions'])))) : null
) )
); );
@ -53,18 +53,18 @@ class ExtManagerTheme extends Themelet
} }
$tbody->appendChild(TR( $tbody->appendChild(TR(
["data-ext"=>$extension->name], ["data-ext" => $extension->name],
$editable ? TD(INPUT([ $editable ? TD(INPUT([
"type"=>'checkbox', "type" => 'checkbox',
"name"=>"ext_{$extension->key}", "name" => "ext_{$extension->key}",
"id"=>"ext_{$extension->key}", "id" => "ext_{$extension->key}",
"checked"=>($extension->is_enabled() === true), "checked" => ($extension->is_enabled() === true),
"disabled"=>($extension->is_supported()===false || $extension->core===true) "disabled" => ($extension->is_supported() === false || $extension->core === true)
])) : null, ])) : null,
TD(LABEL( TD(LABEL(
["for"=>"ext_{$extension->key}"], ["for" => "ext_{$extension->key}"],
( (
($extension->beta===true ? "[BETA] " : ""). ($extension->beta === true ? "[BETA] " : "").
(empty($extension->name) ? $extension->key : $extension->name) (empty($extension->name) ? $extension->key : $extension->name)
) )
)), )),
@ -72,16 +72,16 @@ class ExtManagerTheme extends Themelet
// TODO: A proper "docs" symbol would be preferred here. // TODO: A proper "docs" symbol would be preferred here.
$extension->documentation ? $extension->documentation ?
A( A(
["href"=>make_link("ext_doc/" . url_escape($extension->key))], ["href" => make_link("ext_doc/" . url_escape($extension->key))],
IMG(["src"=>'ext/ext_manager/baseline_open_in_new_black_18dp.png']) IMG(["src" => 'ext/ext_manager/baseline_open_in_new_black_18dp.png'])
) : ) :
null null
), ),
TD( TD(
["style"=>'text-align: left;'], ["style" => 'text-align: left;'],
$extension->description, $extension->description,
" ", " ",
B(["style"=>'color:red'], $extension->get_support_info()) B(["style" => 'color:red'], $extension->get_support_info())
), ),
)); ));
} }
@ -98,9 +98,9 @@ class ExtManagerTheme extends Themelet
if (count($info->authors) > 0) { if (count($info->authors) > 0) {
$author->appendChild(BR()); $author->appendChild(BR());
$author->appendChild(B(count($info->authors) > 1 ? "Authors: " : "Author: ")); $author->appendChild(B(count($info->authors) > 1 ? "Authors: " : "Author: "));
foreach ($info->authors as $auth=>$email) { foreach ($info->authors as $auth => $email) {
if (!empty($email)) { if (!empty($email)) {
$author->appendChild(A(["href"=>"mailto:$email"], $auth)); $author->appendChild(A(["href" => "mailto:$email"], $auth));
} else { } else {
$author->appendChild($auth); $author->appendChild($auth);
} }
@ -109,13 +109,13 @@ class ExtManagerTheme extends Themelet
} }
$html = DIV( $html = DIV(
["style"=>'margin: auto; text-align: left; width: 512px;'], ["style" => 'margin: auto; text-align: left; width: 512px;'],
$author, $author,
($info->version ? emptyHTML(BR(), B("Version: "), $info->version) : null), ($info->version ? emptyHTML(BR(), B("Version: "), $info->version) : null),
($info->link ? emptyHTML(BR(), B("Home Page"), A(["href"=>$info->link], "Link")) : null), ($info->link ? emptyHTML(BR(), B("Home Page"), A(["href" => $info->link], "Link")) : null),
P(rawHTML($info->documentation ?? "(This extension has no documentation)")), P(rawHTML($info->documentation ?? "(This extension has no documentation)")),
// <hr>, // <hr>,
P(A(["href"=>make_link("ext_manager")], "Back to the list")) P(A(["href" => make_link("ext_manager")], "Back to the list"))
); );
$page->set_title("Documentation for " . html_escape($info->name)); $page->set_title("Documentation for " . html_escape($info->name));

View file

@ -10,7 +10,7 @@ class FavoritesInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Favorites"; public string $name = "Favorites";
public array $authors = ["Daniel Marschall"=>"info@daniel-marschall.de"]; public array $authors = ["Daniel Marschall" => "info@daniel-marschall.de"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public string $description = "Allow users to favorite images"; public string $description = "Allow users to favorite images";
public ?string $documentation = public ?string $documentation =

View file

@ -36,7 +36,7 @@ class Favorites extends Extension
$is_favorited = $database->get_one( $is_favorited = $database->get_one(
"SELECT COUNT(*) AS ct FROM user_favorites WHERE user_id = :user_id AND image_id = :image_id", "SELECT COUNT(*) AS ct FROM user_favorites WHERE user_id = :user_id AND image_id = :image_id",
["user_id"=>$user_id, "image_id"=>$image_id] ["user_id" => $user_id, "image_id" => $image_id]
) > 0; ) > 0;
$event->add_part((string)$this->theme->get_voter_html($event->image, $is_favorited)); $event->add_part((string)$this->theme->get_voter_html($event->image, $is_favorited));
@ -102,7 +102,7 @@ class Favorites extends Extension
public function onImageDeletion(ImageDeletionEvent $event) public function onImageDeletion(ImageDeletionEvent $event)
{ {
global $database; global $database;
$database->execute("DELETE FROM user_favorites WHERE image_id=:image_id", ["image_id"=>$event->image->id]); $database->execute("DELETE FROM user_favorites WHERE image_id=:image_id", ["image_id" => $event->image->id]);
} }
public function onParseLinkTemplate(ParseLinkTemplateEvent $event) public function onParseLinkTemplate(ParseLinkTemplateEvent $event)
@ -144,7 +144,7 @@ class Favorites extends Extension
public function onHelpPageBuilding(HelpPageBuildingEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event)
{ {
if ($event->key===HelpPages::SEARCH) { if ($event->key === HelpPages::SEARCH) {
$event->add_block(new Block("Favorites", $this->theme->get_help_html())); $event->add_block(new Block("Favorites", $this->theme->get_help_html()));
} }
} }
@ -152,11 +152,11 @@ class Favorites extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{ {
global $user; 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"); $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)) { if ($user->can(Permissions::MANAGE_ADMINTOOLS)) {
$username = url_escape($user->name); $username = url_escape($user->name);
$event->add_nav_link("favorites", new Link("post/list/favorited_by=$username/1"), "My Favorites"); $event->add_nav_link("favorites", new Link("post/list/favorited_by=$username/1"), "My Favorites");
@ -237,21 +237,21 @@ class Favorites extends Extension
{ {
global $database; global $database;
if ($do_set) { if ($do_set) {
if (!$database->get_row("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->get_row("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( $database->execute(
"INSERT INTO user_favorites(image_id, user_id, created_at) VALUES(:image_id, :user_id, NOW())", "INSERT INTO user_favorites(image_id, user_id, created_at) VALUES(:image_id, :user_id, NOW())",
["image_id"=>$image_id, "user_id"=>$user_id] ["image_id" => $image_id, "user_id" => $user_id]
); );
} }
} else { } else {
$database->execute( $database->execute(
"DELETE FROM user_favorites WHERE image_id = :image_id AND user_id = :user_id", "DELETE FROM user_favorites WHERE image_id = :image_id AND user_id = :user_id",
["image_id"=>$image_id, "user_id"=>$user_id] ["image_id" => $image_id, "user_id" => $user_id]
); );
} }
$database->execute( $database->execute(
"UPDATE images SET favorites=(SELECT COUNT(*) FROM user_favorites WHERE image_id=:image_id) WHERE id=:user_id", "UPDATE images SET favorites=(SELECT COUNT(*) FROM user_favorites WHERE image_id=:image_id) WHERE id=:user_id",
["image_id"=>$image_id, "user_id"=>$user_id] ["image_id" => $image_id, "user_id" => $user_id]
); );
} }
@ -264,7 +264,7 @@ class Favorites extends Extension
return $database->get_col( return $database->get_col(
"SELECT name FROM users WHERE id IN (SELECT user_id FROM user_favorites WHERE image_id = :image_id) ORDER BY name", "SELECT name FROM users WHERE id IN (SELECT user_id FROM user_favorites WHERE image_id = :image_id) ORDER BY name",
["image_id"=>$image->id] ["image_id" => $image->id]
); );
} }
} }

View file

@ -16,9 +16,9 @@ class FavoritesTheme extends Themelet
$label = $is_favorited ? "Un-Favorite" : "Favorite"; $label = $is_favorited ? "Un-Favorite" : "Favorite";
return SHM_SIMPLE_FORM( return SHM_SIMPLE_FORM(
"change_favorite", "change_favorite",
INPUT(["type"=>"hidden", "name"=>"image_id", "value"=>$image->id]), INPUT(["type" => "hidden", "name" => "image_id", "value" => $image->id]),
INPUT(["type"=>"hidden", "name"=>"favorite_action", "value"=>$name]), INPUT(["type" => "hidden", "name" => "favorite_action", "value" => $name]),
INPUT(["type"=>"submit", "value"=>$label]), INPUT(["type" => "submit", "value" => $label]),
); );
} }

View file

@ -20,26 +20,26 @@ class FeaturedTheme extends Themelet
{ {
return (string)SHM_SIMPLE_FORM( return (string)SHM_SIMPLE_FORM(
"featured_image/set", "featured_image/set",
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]), INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]),
INPUT(["type"=>'submit', "value"=>'Feature This']), INPUT(["type" => 'submit', "value" => 'Feature This']),
); );
} }
public function build_featured_html(Image $image, ?string $query=null): \MicroHTML\HTMLElement public function build_featured_html(Image $image, ?string $query = null): \MicroHTML\HTMLElement
{ {
$tsize = get_thumbnail_size($image->width, $image->height); $tsize = get_thumbnail_size($image->width, $image->height);
return DIV( return DIV(
["style"=>"text-align: center;"], ["style" => "text-align: center;"],
A( A(
["href"=>make_link("post/view/{$image->id}", $query)], ["href" => make_link("post/view/{$image->id}", $query)],
IMG([ IMG([
"id"=>"thumb_rand_{$image->id}", "id" => "thumb_rand_{$image->id}",
"title"=>$image->get_tooltip(), "title" => $image->get_tooltip(),
"alt"=>$image->get_tooltip(), "alt" => $image->get_tooltip(),
"class"=>'highlighted', "class" => 'highlighted',
"style"=>"max-height: {$tsize[1]}px; max-width: 100%;", "style" => "max-height: {$tsize[1]}px; max-width: 100%;",
"src"=>$image->get_thumb_link() "src" => $image->get_thumb_link()
]) ])
) )
); );

View file

@ -10,7 +10,7 @@ class ForumInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Forum"; public string $name = "Forum";
public array $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"]; public array $authors = ["Sein Kraft" => "mail@seinkraft.info","Alpha" => "alpha@furries.com.ar"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public string $description = "Rough forum extension"; public string $description = "Rough forum extension";
} }

View file

@ -79,8 +79,8 @@ class Forum extends Extension
{ {
global $database; global $database;
$threads_count = $database->get_one("SELECT COUNT(*) FROM forum_threads WHERE user_id=:user_id", ['user_id'=>$event->display_user->id]); $threads_count = $database->get_one("SELECT COUNT(*) FROM forum_threads WHERE user_id=:user_id", ['user_id' => $event->display_user->id]);
$posts_count = $database->get_one("SELECT COUNT(*) FROM forum_posts WHERE user_id=:user_id", ['user_id'=>$event->display_user->id]); $posts_count = $database->get_one("SELECT COUNT(*) FROM forum_posts WHERE user_id=:user_id", ['user_id' => $event->display_user->id]);
$days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1; $days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1;
@ -113,7 +113,7 @@ class Forum extends Extension
// $pageNumber = int_escape($event->get_arg(2)); // $pageNumber = int_escape($event->get_arg(2));
list($errors) = $this->sanity_check_viewed_thread($threadID); list($errors) = $this->sanity_check_viewed_thread($threadID);
if ($errors!=null) { if ($errors != null) {
$this->theme->display_error(500, "Error", $errors); $this->theme->display_error(500, "Error", $errors);
break; break;
} }
@ -135,7 +135,7 @@ class Forum extends Extension
if (!$user->is_anonymous()) { if (!$user->is_anonymous()) {
list($errors) = $this->sanity_check_new_thread(); list($errors) = $this->sanity_check_new_thread();
if ($errors!=null) { if ($errors != null) {
$this->theme->display_error(500, "Error", $errors); $this->theme->display_error(500, "Error", $errors);
break; break;
} }
@ -176,7 +176,7 @@ class Forum extends Extension
if (!$user->is_anonymous()) { if (!$user->is_anonymous()) {
list($errors) = $this->sanity_check_new_post(); list($errors) = $this->sanity_check_new_post();
if ($errors!=null) { if ($errors != null) {
$this->theme->display_error(500, "Error", $errors); $this->theme->display_error(500, "Error", $errors);
break; break;
} }
@ -197,7 +197,7 @@ class Forum extends Extension
private function get_total_pages_for_thread(int $threadID): int private function get_total_pages_for_thread(int $threadID): int
{ {
global $database, $config; global $database, $config;
$result = $database->get_row("SELECT COUNT(1) AS count FROM forum_posts WHERE thread_id = :thread_id", ['thread_id'=>$threadID]); $result = $database->get_row("SELECT COUNT(1) AS count FROM forum_posts WHERE thread_id = :thread_id", ['thread_id' => $threadID]);
return (int)ceil($result["count"] / $config->get_int("forumPostsPerPage")); return (int)ceil($result["count"] / $config->get_int("forumPostsPerPage"));
} }
@ -252,7 +252,7 @@ class Forum extends Extension
private function get_thread_title(int $threadID): string private function get_thread_title(int $threadID): string
{ {
global $database; global $database;
$result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = :id ", ['id'=>$threadID]); $result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = :id ", ['id' => $threadID]);
return $result["title"]; return $result["title"];
} }
@ -277,7 +277,7 @@ class Forum extends Extension
"ON p.thread_id = f.id ". "ON p.thread_id = f.id ".
"GROUP BY f.id, f.sticky, f.title, f.date, u.name, u.email, u.class ". "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", "ORDER BY f.sticky ASC, f.uptodate DESC LIMIT :limit OFFSET :offset",
["limit"=>$threadsPerPage, "offset"=>$pageNumber * $threadsPerPage] ["limit" => $threadsPerPage, "offset" => $pageNumber * $threadsPerPage]
); );
$this->theme->display_thread_list($page, $threads, $showAdminOptions, $pageNumber + 1, $totalPages); $this->theme->display_thread_list($page, $threads, $showAdminOptions, $pageNumber + 1, $totalPages);
@ -288,7 +288,7 @@ class Forum extends Extension
global $config, $database; global $config, $database;
$threadID = int_escape($event->get_arg(1)); $threadID = int_escape($event->get_arg(1));
$postsPerPage = $config->get_int('forumPostsPerPage', 15); $postsPerPage = $config->get_int('forumPostsPerPage', 15);
$totalPages = (int)ceil($database->get_one("SELECT COUNT(*) FROM forum_posts WHERE thread_id = :id", ['id'=>$threadID]) / $postsPerPage); $totalPages = (int)ceil($database->get_one("SELECT COUNT(*) FROM forum_posts WHERE thread_id = :id", ['id' => $threadID]) / $postsPerPage);
$threadTitle = $this->get_thread_title($threadID); $threadTitle = $this->get_thread_title($threadID);
if ($event->count_args() >= 3) { if ($event->count_args() >= 3) {
@ -305,7 +305,7 @@ class Forum extends Extension
"WHERE thread_id = :thread_id ". "WHERE thread_id = :thread_id ".
"ORDER BY p.date ASC ". "ORDER BY p.date ASC ".
"LIMIT :limit OFFSET :offset", "LIMIT :limit OFFSET :offset",
["thread_id"=>$threadID, "offset"=>$pageNumber * $postsPerPage, "limit"=>$postsPerPage] ["thread_id" => $threadID, "offset" => $pageNumber * $postsPerPage, "limit" => $postsPerPage]
); );
$this->theme->display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber + 1, $totalPages); $this->theme->display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber + 1, $totalPages);
} }
@ -322,7 +322,7 @@ class Forum extends Extension
(title, sticky, user_id, date, uptodate) (title, sticky, user_id, date, uptodate)
VALUES VALUES
(:title, :sticky, :user_id, now(), now())", (:title, :sticky, :user_id, now(), now())",
['title'=>$title, 'sticky'=>$sticky, 'user_id'=>$user->id] ['title' => $title, 'sticky' => $sticky, 'user_id' => $user->id]
); );
$threadID = $database->get_last_insert_id("forum_threads_id_seq"); $threadID = $database->get_last_insert_id("forum_threads_id_seq");
@ -345,32 +345,32 @@ class Forum extends Extension
$database->execute(" $database->execute("
INSERT INTO forum_posts (thread_id, user_id, date, message) INSERT INTO forum_posts (thread_id, user_id, date, message)
VALUES (:thread_id, :user_id, now(), :message) VALUES (:thread_id, :user_id, now(), :message)
", ['thread_id'=>$threadID, 'user_id'=>$userID, 'message'=>$message]); ", ['thread_id' => $threadID, 'user_id' => $userID, 'message' => $message]);
$postID = $database->get_last_insert_id("forum_posts_id_seq"); $postID = $database->get_last_insert_id("forum_posts_id_seq");
log_info("forum", "Post {$postID} created by {$user->name}"); log_info("forum", "Post {$postID} created by {$user->name}");
$database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=:id", ['id'=>$threadID]); $database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=:id", ['id' => $threadID]);
} }
private function delete_thread(int $threadID): void private function delete_thread(int $threadID): void
{ {
global $database; global $database;
$database->execute("DELETE FROM forum_threads WHERE id = :id", ['id'=>$threadID]); $database->execute("DELETE FROM forum_threads WHERE id = :id", ['id' => $threadID]);
$database->execute("DELETE FROM forum_posts WHERE thread_id = :thread_id", ['thread_id'=>$threadID]); $database->execute("DELETE FROM forum_posts WHERE thread_id = :thread_id", ['thread_id' => $threadID]);
} }
private function delete_post(int $postID): void private function delete_post(int $postID): void
{ {
global $database; global $database;
$database->execute("DELETE FROM forum_posts WHERE id = :id", ['id'=>$postID]); $database->execute("DELETE FROM forum_posts WHERE id = :id", ['id' => $postID]);
} }
private function threadExists(int $threadID): bool private function threadExists(int $threadID): bool
{ {
global $database; global $database;
$result=$database->get_one("SELECT EXISTS (SELECT * FROM forum_threads WHERE id=:id)", ['id'=>$threadID]); $result = $database->get_one("SELECT EXISTS (SELECT * FROM forum_threads WHERE id=:id)", ['id' => $threadID]);
return $result == 1; return $result == 1;
} }
} }

View file

@ -135,7 +135,7 @@ class ForumTheme extends Themelet
$delete_link = ""; $delete_link = "";
} }
$post_number = (($pageNumber-1)*$posts_per_page)+$current_post; $post_number = (($pageNumber - 1) * $posts_per_page) + $current_post;
$html .= "<tr > $html .= "<tr >
<tr class='postHead'> <tr class='postHead'>
<td class='forumSupuser'></td> <td class='forumSupuser'></td>

View file

@ -11,7 +11,7 @@ class GoogleAnalyticsInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Google Analytics"; public string $name = "Google Analytics";
public string $url = "http://drudexsoftware.com"; public string $url = "http://drudexsoftware.com";
public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; public array $authors = ["Drudex Software" => "support@drudexsoftware.com"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public string $description = "Integrates Google Analytics tracking"; public string $description = "Integrates Google Analytics tracking";
public ?string $documentation = public ?string $documentation =

View file

@ -123,7 +123,7 @@ class GraphQL extends Extension
$common_source = $_POST['common_source']; $common_source = $_POST['common_source'];
$results = []; $results = [];
for ($n=0; $n<100; $n++) { for ($n = 0; $n < 100; $n++) {
if (empty($_POST["url$n"]) && empty($_FILES["data$n"])) { if (empty($_POST["url$n"]) && empty($_FILES["data$n"])) {
break; break;
} }
@ -191,7 +191,7 @@ class GraphQL extends Extension
$body['stats'] = get_debug_info_arr(); $body['stats'] = get_debug_info_arr();
$body['stats']['graphql_schema_time'] = round($t2 - $t1, 2); $body['stats']['graphql_schema_time'] = round($t2 - $t1, 2);
$body['stats']['graphql_execute_time'] = round($t3 - $t2, 2); $body['stats']['graphql_execute_time'] = round($t3 - $t2, 2);
echo \json_encode($body, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT); echo \json_encode($body, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
} }
if ($event->cmd == "graphql-schema") { if ($event->cmd == "graphql-schema") {
$schema = $this->get_schema(); $schema = $this->get_schema();

View file

@ -52,7 +52,7 @@ class CBZFileHandler extends DataHandlerExtension
$za = new \ZipArchive(); $za = new \ZipArchive();
$za->open($archive); $za->open($archive);
$names = []; $names = [];
for ($i=0; $i<$za->numFiles;$i++) { for ($i = 0; $i < $za->numFiles;$i++) {
$file = $za->statIndex($i); $file = $za->statIndex($i);
$names[] = $file['name']; $names[] = $file['name'];
} }

View file

@ -73,7 +73,7 @@ class SVGFileHandler extends DataHandlerExtension
protected function check_contents(string $tmpname): bool protected function check_contents(string $tmpname): bool
{ {
if (MimeType::get_for_file($tmpname)!==MimeType::SVG) { if (MimeType::get_for_file($tmpname) !== MimeType::SVG) {
return false; return false;
} }
@ -85,9 +85,9 @@ class SVGFileHandler extends DataHandlerExtension
class MiniSVGParser class MiniSVGParser
{ {
public bool $valid = false; public bool $valid = false;
public int $width=0; public int $width = 0;
public int $height=0; public int $height = 0;
private int $xml_depth=0; private int $xml_depth = 0;
public function __construct(string $file) public function __construct(string $file)
{ {

View file

@ -10,7 +10,7 @@ class VideoFileHandlerInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Handle Video"; public string $name = "Handle Video";
public array $authors = ["velocity37"=>"velocity37@gmail.com",self::SHISH_NAME=>self::SHISH_EMAIL, "jgen"=>"jeffgenovy@gmail.com", "im-mi"=>"im.mi.mail.mi@gmail.com"]; public array $authors = ["velocity37" => "velocity37@gmail.com",self::SHISH_NAME => self::SHISH_EMAIL, "jgen" => "jeffgenovy@gmail.com", "im-mi" => "im.mi.mail.mi@gmail.com"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public string $description = "Handle FLV, MP4, OGV and WEBM video files."; public string $description = "Handle FLV, MP4, OGV and WEBM video files.";
public ?string $documentation = public ?string $documentation =

View file

@ -99,7 +99,7 @@ class VideoFileHandler extends DataHandlerExtension
$event->image->video = $video; $event->image->video = $video;
$event->image->video_codec = $video_codec; $event->image->video_codec = $video_codec;
$event->image->audio = $audio; $event->image->audio = $audio;
if ($event->image->get_mime()==MimeType::MKV && if ($event->image->get_mime() == MimeType::MKV &&
VideoContainers::is_video_codec_supported(VideoContainers::WEBM, $event->image->video_codec)) { VideoContainers::is_video_codec_supported(VideoContainers::WEBM, $event->image->video_codec)) {
// WEBMs are MKVs with the VP9 or VP8 codec // WEBMs are MKVs with the VP9 or VP8 codec
// For browser-friendliness, we'll just change the mime type // For browser-friendliness, we'll just change the mime type
@ -107,7 +107,7 @@ class VideoFileHandler extends DataHandlerExtension
} }
} }
} }
if (array_key_exists("format", $data)&& is_array($data["format"])) { if (array_key_exists("format", $data) && is_array($data["format"])) {
$format = $data["format"]; $format = $data["format"];
if (array_key_exists("duration", $format) && is_numeric($format["duration"])) { if (array_key_exists("duration", $format) && is_numeric($format["duration"])) {
$event->image->length = (int)floor(floatval($format["duration"]) * 1000); $event->image->length = (int)floor(floatval($format["duration"]) * 1000);

View file

@ -16,12 +16,12 @@ class VideoFileHandlerTheme extends Themelet
$loop = $config->get_bool(VideoFileHandlerConfig::PLAYBACK_LOOP); $loop = $config->get_bool(VideoFileHandlerConfig::PLAYBACK_LOOP);
$mute = $config->get_bool(VideoFileHandlerConfig::PLAYBACK_MUTE); $mute = $config->get_bool(VideoFileHandlerConfig::PLAYBACK_MUTE);
$width="auto"; $width = "auto";
if ($image->width>1) { if ($image->width > 1) {
$width = $image->width."px"; $width = $image->width."px";
} }
$height="auto"; $height = "auto";
if ($image->height>1) { if ($image->height > 1) {
$height = $image->height."px"; $height = $image->height."px";
} }

View file

@ -10,7 +10,7 @@ class HelpPagesInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Help Pages"; public string $name = "Help Pages";
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"];
public string $license = self::LICENSE_WTFPL; public string $license = self::LICENSE_WTFPL;
public string $description = "Provides documentation screens"; public string $description = "Provides documentation screens";
public ExtensionVisibility $visibility = ExtensionVisibility::HIDDEN; public ExtensionVisibility $visibility = ExtensionVisibility::HIDDEN;

View file

@ -65,7 +65,7 @@ class HelpPages extends Extension
$hpbe = send_event(new HelpPageBuildingEvent($name)); $hpbe = send_event(new HelpPageBuildingEvent($name));
asort($hpbe->blocks); asort($hpbe->blocks);
foreach ($hpbe->blocks as $key=>$value) { foreach ($hpbe->blocks as $key => $value) {
foreach ($value as $block) { foreach ($value as $block) {
$page->add_block($block); $page->add_block($block);
} }
@ -87,9 +87,9 @@ class HelpPages extends Extension
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
{ {
if ($event->parent=="help") { if ($event->parent == "help") {
$pages = send_event(new HelpPageListBuildingEvent())->pages; $pages = send_event(new HelpPageListBuildingEvent())->pages;
foreach ($pages as $key=>$value) { 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);
} }
} }
@ -102,7 +102,7 @@ class HelpPages extends Extension
public function onHelpPageBuilding(HelpPageBuildingEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event)
{ {
if ($event->key=="licenses") { if ($event->key == "licenses") {
$block = new Block("Software Licenses"); $block = new Block("Software Licenses");
$block->body = "The code in Shimmie is contributed by numerous authors under multiple licenses. For reference, these licenses are listed below. The base software is in general licensed under the GPLv2 license."; $block->body = "The code in Shimmie is contributed by numerous authors under multiple licenses. For reference, these licenses are listed below. The base software is in general licensed under the GPLv2 license.";
$event->add_block($block); $event->add_block($block);

View file

@ -14,7 +14,7 @@ class HelpPagesTheme extends Themelet
$page->set_heading("Help Pages"); $page->set_heading("Help Pages");
$nav_block = new Block("Help", "", "left", 0); $nav_block = new Block("Help", "", "left", 0);
foreach ($pages as $link=>$desc) { foreach ($pages as $link => $desc) {
$link = make_link("help/{$link}"); $link = make_link("help/{$link}");
$nav_block->body .= "<a href='{$link}'>".html_escape($desc)."</a><br/>"; $nav_block->body .= "<a href='{$link}'>".html_escape($desc)."</a><br/>";
} }

View file

@ -11,7 +11,7 @@ class HolidayInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Holiday Theme"; public string $name = "Holiday Theme";
public string $url = "http://www.codeanimu.net"; public string $url = "http://www.codeanimu.net";
public array $authors = ["DakuTree"=>"thedakutree@codeanimu.net"]; public array $authors = ["DakuTree" => "thedakutree@codeanimu.net"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public string $description = "Use an additional stylesheet on certain holidays"; public string $description = "Use an additional stylesheet on certain holidays";
} }

View file

@ -10,7 +10,7 @@ class HomeInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Home Page"; public string $name = "Home Page";
public array $authors =["Bzchan"=>"bzchan@animemahou.com"]; public array $authors = ["Bzchan" => "bzchan@animemahou.com"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public ExtensionVisibility $visibility = ExtensionVisibility::ADMIN; public ExtensionVisibility $visibility = ExtensionVisibility::ADMIN;
public string $description = "Displays a front page with logo, search box and post count"; public string $description = "Displays a front page with logo, search box and post count";

View file

@ -61,7 +61,7 @@ class Home extends Extension
if ($counter_dir != 'text-only') { if ($counter_dir != 'text-only') {
$strtotal = "$total"; $strtotal = "$total";
$length = strlen($strtotal); $length = strlen($strtotal);
for ($n=0; $n<$length; $n++) { for ($n = 0; $n < $length; $n++) {
$cur = $strtotal[$n]; $cur = $strtotal[$n];
$counter_text .= "<img alt='$cur' src='$base_href/ext/home/counters/$counter_dir/$cur.gif' />"; $counter_text .= "<img alt='$cur' src='$base_href/ext/home/counters/$counter_dir/$cur.gif' />";
} }

View file

@ -15,7 +15,7 @@ abstract class ImageConfig
public const THUMB_QUALITY = 'thumb_quality'; public const THUMB_QUALITY = 'thumb_quality';
public const THUMB_MIME = 'thumb_mime'; public const THUMB_MIME = 'thumb_mime';
public const THUMB_FIT = 'thumb_fit'; public const THUMB_FIT = 'thumb_fit';
public const THUMB_ALPHA_COLOR ='thumb_alpha_color'; public const THUMB_ALPHA_COLOR = 'thumb_alpha_color';
public const SHOW_META = 'image_show_meta'; public const SHOW_META = 'image_show_meta';
public const ILINK = 'image_ilink'; public const ILINK = 'image_ilink';

View file

@ -11,7 +11,7 @@ class ImageIOInfo extends ExtensionInfo
public string $key = self::KEY; public string $key = self::KEY;
public string $name = "Post Manager"; public string $name = "Post Manager";
public string $url = self::SHIMMIE_URL; public string $url = self::SHIMMIE_URL;
public array $authors = [self::SHISH_NAME=> self::SHISH_EMAIL, "jgen"=>"jgen.tech@gmail.com"]; public array $authors = [self::SHISH_NAME => self::SHISH_EMAIL, "jgen" => "jgen.tech@gmail.com"];
public string $license = self::LICENSE_GPLV2; public string $license = self::LICENSE_GPLV2;
public string $description = "Handle the image database"; public string $description = "Handle the image database";
public ExtensionVisibility $visibility = ExtensionVisibility::HIDDEN; public ExtensionVisibility $visibility = ExtensionVisibility::HIDDEN;

View file

@ -15,13 +15,13 @@ class ImageIO extends Extension
protected Themelet $theme; protected Themelet $theme;
public const COLLISION_OPTIONS = [ public const COLLISION_OPTIONS = [
'Error'=>ImageConfig::COLLISION_ERROR, 'Error' => ImageConfig::COLLISION_ERROR,
'Merge'=>ImageConfig::COLLISION_MERGE 'Merge' => ImageConfig::COLLISION_MERGE
]; ];
public const ON_DELETE_OPTIONS = [ public const ON_DELETE_OPTIONS = [
'Return to post list'=>ImageConfig::ON_DELETE_LIST, 'Return to post list' => ImageConfig::ON_DELETE_LIST,
'Go to next post'=>ImageConfig::ON_DELETE_NEXT 'Go to next post' => ImageConfig::ON_DELETE_NEXT
]; ];
public const EXIF_READ_FUNCTION = "exif_read_data"; public const EXIF_READ_FUNCTION = "exif_read_data";
@ -55,7 +55,7 @@ class ImageIO extends Extension
$config->set_default_string(ImageConfig::TLINK, ''); $config->set_default_string(ImageConfig::TLINK, '');
$config->set_default_string(ImageConfig::TIP, '$tags // $size // $filesize'); $config->set_default_string(ImageConfig::TIP, '$tags // $size // $filesize');
$config->set_default_string(ImageConfig::UPLOAD_COLLISION_HANDLER, ImageConfig::COLLISION_ERROR); $config->set_default_string(ImageConfig::UPLOAD_COLLISION_HANDLER, ImageConfig::COLLISION_ERROR);
$config->set_default_int(ImageConfig::EXPIRES, (60*60*24*31)); // defaults to one month $config->set_default_int(ImageConfig::EXPIRES, (60 * 60 * 24 * 31)); // defaults to one month
} }
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
@ -87,7 +87,7 @@ class ImageIO extends Extension
if ($image) { if ($image) {
send_event(new ImageDeletionEvent($image)); send_event(new ImageDeletionEvent($image));
if ($config->get_string(ImageConfig::ON_DELETE)===ImageConfig::ON_DELETE_NEXT) { if ($config->get_string(ImageConfig::ON_DELETE) === ImageConfig::ON_DELETE_NEXT) {
redirect_to_next_image($image); redirect_to_next_image($image);
} else { } else {
$page->set_mode(PageMode::REDIRECT); $page->set_mode(PageMode::REDIRECT);
@ -227,7 +227,7 @@ class ImageIO extends Extension
} }
$duplicate = Image::by_hash($image->hash); $duplicate = Image::by_hash($image->hash);
if (!is_null($duplicate) && $duplicate->id!=$id) { if (!is_null($duplicate) && $duplicate->id != $id) {
$error = "Post <a href='" . make_link("post/view/{$duplicate->id}") . "'>{$duplicate->id}</a> " . $error = "Post <a href='" . make_link("post/view/{$duplicate->id}") . "'>{$duplicate->id}</a> " .
"already has hash {$image->hash}:<p>" . $this->theme->build_thumb_html($duplicate); "already has hash {$image->hash}:<p>" . $this->theme->build_thumb_html($duplicate);
throw new ImageReplaceException($error); throw new ImageReplaceException($error);
@ -306,7 +306,7 @@ class ImageIO extends Extension
$sb->add_int_option(ImageConfig::THUMB_QUALITY, "Quality", true); $sb->add_int_option(ImageConfig::THUMB_QUALITY, "Quality", true);
$sb->add_int_option(ImageConfig::THUMB_SCALING, "High-DPI Scale %", true); $sb->add_int_option(ImageConfig::THUMB_SCALING, "High-DPI Scale %", true);
if ($config->get_string(ImageConfig::THUMB_MIME)===MimeType::JPEG) { if ($config->get_string(ImageConfig::THUMB_MIME) === MimeType::JPEG) {
$sb->add_color_option(ImageConfig::THUMB_ALPHA_COLOR, "Alpha Conversion Color", true); $sb->add_color_option(ImageConfig::THUMB_ALPHA_COLOR, "Alpha Conversion Color", true);
} }

Some files were not shown because too many files have changed in this diff Show more