drop php7.3 support, make use of 7.4 features

This commit is contained in:
Shish 2021-03-14 23:43:50 +00:00
parent c558ee3bdb
commit 77f7121e26
296 changed files with 1571 additions and 2039 deletions

View File

@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.3', '7.4', '8.0']
php: ['7.4', '8.0']
database: ['pgsql', 'mysql', 'sqlite']
runs-on: ubuntu-latest

View File

@ -31,7 +31,7 @@
],
"require" : {
"php" : "^7.3 | ^8.0",
"php" : "^7.4 | ^8.0",
"ext-pdo": "*",
"ext-json": "*",
"ext-fileinfo": "*",

View File

@ -20,10 +20,8 @@ abstract class PageMode
*/
class BasePage
{
/** @var string */
public $mode = PageMode::PAGE;
/** @var string */
private $mime;
public string $mode = PageMode::PAGE;
private string $mime;
/**
* Set what this page should do; "page", "data", or "redirect".
@ -52,19 +50,11 @@ class BasePage
// ==============================================
/** @var string; public only for unit test */
public $data = "";
/** @var string */
private $file = null;
/** @var bool */
private $file_delete = false;
/** @var string */
private $filename = null;
private $disposition = null;
public string $data = ""; // public only for unit test
private ?string $file = null;
private bool $file_delete = false;
private ?string $filename = null;
private ?string $disposition = null;
/**
* Set the raw data to be sent.
@ -91,8 +81,7 @@ class BasePage
// ==============================================
/** @var string */
public $redirect = "";
public string $redirect = "";
/**
* Set the URL to redirect to (remember to use make_link() if linking
@ -105,32 +94,25 @@ class BasePage
// ==============================================
/** @var int */
public $code = 200;
/** @var string */
public $title = "";
/** @var string */
public $heading = "";
/** @var string */
public $subheading = "";
public int $code = 200;
public string $title = "";
public string $heading = "";
public string $subheading = "";
/** @var string[] */
public $html_headers = [];
public array $html_headers = [];
/** @var string[] */
public $http_headers = [];
public array $http_headers = [];
/** @var string[][] */
public $cookies = [];
public array $cookies = [];
/** @var Block[] */
public $blocks = [];
public array $blocks = [];
/** @var string[] */
public $flash = [];
public array $flash = [];
/**
* Set the HTTP status code
@ -428,7 +410,7 @@ class BasePage
$this->add_html_header("<script defer src='$data_href/$js_cache_file' type='text/javascript'></script>", 44);
}
protected function get_nav_links()
protected function get_nav_links(): array
{
$pnbe = send_event(new PageNavBuildingEvent());
@ -574,7 +556,7 @@ EOD;
class PageNavBuildingEvent extends Event
{
public $links = [];
public array $links = [];
public function add_nav_link(string $name, Link $link, string $desc, ?bool $active = null, int $order = 50)
{
@ -584,9 +566,9 @@ class PageNavBuildingEvent extends Event
class PageSubNavBuildingEvent extends Event
{
public $parent;
public string $parent;
public $links = [];
public array $links = [];
public function __construct(string $parent)
{
@ -602,11 +584,11 @@ class PageSubNavBuildingEvent extends Event
class NavLink
{
public $name;
public $link;
public $description;
public $order;
public $active = false;
public string $name;
public Link $link;
public string $description;
public int $order;
public bool $active = false;
public function __construct(String $name, Link $link, String $description, ?bool $active = null, int $order = 50)
{
@ -663,7 +645,7 @@ class NavLink
}
}
function sort_nav_links(NavLink $a, NavLink $b)
function sort_nav_links(NavLink $a, NavLink $b): int
{
return $a->order - $b->order;
}

View File

@ -9,49 +9,37 @@ class Block
{
/**
* The block's title.
*
* @var string
*/
public $header;
public ?string $header;
/**
* The content of the block.
*
* @var string
*/
public $body;
public ?string $body;
/**
* Where the block should be placed. The default theme supports
* "main" and "left", other themes can add their own areas.
*
* @var string
*/
public $section;
public string $section;
/**
* How far down the section the block should appear, higher
* numbers appear lower. The scale is 0-100 by convention,
* though any number will work.
*
* @var int
*/
public $position;
public int $position;
/**
* A unique ID for the block.
*
* @var string
*/
public $id;
public string $id;
/**
* Should this block count as content for the sake of
* the 404 handler
*
* @var boolean
*/
public $is_content = true;
public bool $is_content = true;
public function __construct(string $header=null, string $body=null, string $section="main", int $position=50, string $id=null)
{
@ -63,7 +51,9 @@ class Block
if (is_null($id)) {
$id = (empty($header) ? md5($body ?? '') : $header) . $section;
}
$this->id = preg_replace('/[^\w-]/', '', str_replace(' ', '_', $id));
$str_id = preg_replace('/[^\w-]/', '', str_replace(' ', '_', $id));
assert(is_string($str_id));
$this->id = $str_id;
}
/**

View File

@ -2,8 +2,8 @@
interface CacheEngine
{
public function get(string $key);
public function set(string $key, $val, int $time=0);
public function delete(string $key);
public function set(string $key, $val, int $time=0): void;
public function delete(string $key): void;
}
class NoCache implements CacheEngine
@ -12,18 +12,17 @@ class NoCache implements CacheEngine
{
return false;
}
public function set(string $key, $val, int $time=0)
public function set(string $key, $val, int $time=0): void
{
}
public function delete(string $key)
public function delete(string $key): void
{
}
}
class MemcachedCache implements CacheEngine
{
/** @var ?Memcached */
public $memcache=null;
public ?Memcached $memcache=null;
public function __construct(string $args)
{
@ -52,7 +51,7 @@ class MemcachedCache implements CacheEngine
}
}
public function set(string $key, $val, int $time=0)
public function set(string $key, $val, int $time=0): void
{
$key = urlencode($key);
@ -63,7 +62,7 @@ class MemcachedCache implements CacheEngine
}
}
public function delete(string $key)
public function delete(string $key): void
{
$key = urlencode($key);
@ -87,12 +86,12 @@ class APCCache implements CacheEngine
return apc_fetch($key);
}
public function set(string $key, $val, int $time=0)
public function set(string $key, $val, int $time=0): void
{
apc_store($key, $val, $time);
}
public function delete(string $key)
public function delete(string $key): void
{
apc_delete($key);
}
@ -100,7 +99,7 @@ class APCCache implements CacheEngine
class RedisCache implements CacheEngine
{
private $redis=null;
private Redis $redis;
public function __construct(string $args)
{
@ -116,7 +115,7 @@ class RedisCache implements CacheEngine
return $this->redis->get($key);
}
public function set(string $key, $val, int $time=0)
public function set(string $key, $val, int $time=0): void
{
if ($time > 0) {
$this->redis->setEx($key, $time, $val);
@ -125,7 +124,7 @@ class RedisCache implements CacheEngine
}
}
public function delete(string $key)
public function delete(string $key): void
{
$this->redis->del($key);
}
@ -134,9 +133,9 @@ class RedisCache implements CacheEngine
class Cache
{
public $engine;
public $hits=0;
public $misses=0;
public $time=0;
public int $hits=0;
public int $misses=0;
public int $time=0;
public function __construct(?string $dsn)
{

View File

@ -5,9 +5,9 @@
// quotes are only needed if the path to convert contains a space; some other times, quotes break things, see github bug #27
class CommandBuilder
{
private $executable;
private $args = [];
public $output;
private string $executable;
private array $args = [];
public array $output;
public function __construct(String $executable)
{

View File

@ -130,7 +130,7 @@ interface Config
*/
abstract class BaseConfig implements Config
{
public $values = [];
public array $values = [];
public function set_int(string $name, ?int $value): void
{
@ -256,12 +256,10 @@ abstract class BaseConfig implements Config
*/
class DatabaseConfig extends BaseConfig
{
/** @var Database */
private $database = null;
private $table_name;
private $sub_column;
private $sub_value;
private Database $database;
private string $table_name;
private ?string $sub_column;
private ?string $sub_value;
public function __construct(
Database $database,

View File

@ -13,30 +13,23 @@ abstract class DatabaseDriver
*/
class Database
{
/** @var string */
private $dsn;
private string $dsn;
/**
* The PDO database connection object, for anyone who wants direct access.
* @var null|PDO
*/
private $db = null;
/**
* @var float
*/
public $dbtime = 0.0;
private ?PDO $db = null;
public float $dbtime = 0.0;
/**
* Meta info about the database engine.
* @var DBEngine|null
*/
private $engine = null;
private ?DBEngine $engine = null;
/**
* How many queries this DB object has run
*/
public $query_count = 0;
public int $query_count = 0;
public function __construct(string $dsn)
{

View File

@ -7,16 +7,15 @@ abstract class SCORE
abstract class DBEngine
{
/** @var null|string */
public $name = null;
public ?string $name = null;
public function init(PDO $db)
{
}
public function scoreql_to_sql(string $scoreql): string
public function scoreql_to_sql(string $data): string
{
return $scoreql;
return $data;
}
public function create_table_sql(string $name, string $data): string
@ -33,8 +32,7 @@ abstract class DBEngine
class MySQL extends DBEngine
{
/** @var string */
public $name = DatabaseDriver::MYSQL;
public ?string $name = DatabaseDriver::MYSQL;
public function init(PDO $db)
{
@ -73,8 +71,7 @@ class MySQL extends DBEngine
class PostgreSQL extends DBEngine
{
/** @var string */
public $name = DatabaseDriver::PGSQL;
public ?string $name = DatabaseDriver::PGSQL;
public function init(PDO $db)
{
@ -122,19 +119,19 @@ class PostgreSQL extends DBEngine
}
// shimmie functions for export to sqlite
function _unix_timestamp($date)
function _unix_timestamp($date): int
{
return strtotime($date);
}
function _now()
function _now(): string
{
return date("Y-m-d H:i:s");
}
function _floor($a)
function _floor($a): float
{
return floor($a);
}
function _log($a, $b=null)
function _log($a, $b=null): float
{
if (is_null($b)) {
return log($a);
@ -142,35 +139,34 @@ function _log($a, $b=null)
return log($a, $b);
}
}
function _isnull($a)
function _isnull($a): bool
{
return is_null($a);
}
function _md5($a)
function _md5($a): string
{
return md5($a);
}
function _concat($a, $b)
function _concat($a, $b): string
{
return $a . $b;
}
function _lower($a)
function _lower($a): string
{
return strtolower($a);
}
function _rand()
function _rand(): int
{
return rand();
}
function _ln($n)
function _ln($n): float
{
return log($n);
}
class SQLite extends DBEngine
{
/** @var string */
public $name = DatabaseDriver::SQLITE;
public ?string $name = DatabaseDriver::SQLITE;
public function init(PDO $db)
{

View File

@ -6,13 +6,13 @@
*/
abstract class Event
{
public $stop_processing = false;
public bool $stop_processing = false;
public function __construct()
{
}
public function __toString()
public function __toString(): string
{
return var_export($this, true);
}
@ -42,19 +42,11 @@ class InitExtEvent extends Event
class PageRequestEvent extends Event
{
/**
* @var array
* @var string[]
*/
public $args;
/**
* @var int
*/
public $arg_count;
/**
* @var int
*/
public $part_count;
public int $arg_count;
public int $part_count;
public function __construct(string $path)
{
@ -179,15 +171,12 @@ class PageRequestEvent extends Event
*/
class CommandEvent extends Event
{
/**
* @var string
*/
public $cmd = "help";
public string $cmd = "help";
/**
* @var array
* @var string[]
*/
public $args = [];
public array $args = [];
/**
* #param string[] $args
@ -256,24 +245,18 @@ class TextFormattingEvent extends Event
{
/**
* For reference
*
* @var string
*/
public $original;
public string $original;
/**
* with formatting applied
*
* @var string
*/
public $formatted;
public string $formatted;
/**
* with formatting removed
*
* @var string
*/
public $stripped;
public string $stripped;
public function __construct(string $text)
{
@ -296,38 +279,30 @@ class LogEvent extends Event
{
/**
* a category, normally the extension name
*
* @var string
*/
public $section;
public string $section;
/**
* See python...
*
* @var int
*/
public $priority = 0;
public int $priority = 0;
/**
* Free text to be logged
*
* @var string
*/
public $message;
public string $message;
/**
* The time that the event was created
*
* @var int
*/
public $time;
public int $time;
/**
* Extra data to be held separate
*
* @var array
* @var string[]
*/
public $args;
public array $args;
public function __construct(string $section, int $priority, string $message)
{

View File

@ -7,11 +7,8 @@
*/
class SCoreException extends RuntimeException
{
/** @var string|null */
public $query;
/** @var string */
public $error;
public ?string $query;
public string $error;
public function __construct(string $msg, ?string $query=null)
{
@ -23,21 +20,16 @@ class SCoreException extends RuntimeException
class InstallerException extends RuntimeException
{
/** @var string */
public $title;
public string $title;
public string $body;
public int $exit_code;
/** @var string */
public $body;
/** @var int */
public $code;
public function __construct(string $title, string $body, int $code)
public function __construct(string $title, string $body, int $exit_code)
{
parent::__construct($body);
$this->title = $title;
$this->body = $body;
$this->code = $code;
$this->exit_code = $exit_code;
}
}

View File

@ -13,16 +13,11 @@
*/
abstract class Extension
{
/** @var string */
public $key;
public string $key;
protected ?Themelet $theme;
public ?ExtensionInfo $info;
/** @var Themelet */
protected $theme;
/** @var ExtensionInfo */
public $info;
private static $enabled_extensions = [];
private static array $enabled_extensions = [];
public function __construct($class = null)
{
@ -122,35 +117,31 @@ abstract class ExtensionInfo
public const LICENSE_MIT = "MIT";
public const LICENSE_WTFPL = "WTFPL";
public const VISIBLE_DEFAULT = "default";
public const VISIBLE_ADMIN = "admin";
public const VISIBLE_HIDDEN = "hidden";
private const VALID_VISIBILITY = [self::VISIBLE_ADMIN, self::VISIBLE_HIDDEN];
private const VALID_VISIBILITY = [self::VISIBLE_DEFAULT, self::VISIBLE_ADMIN, self::VISIBLE_HIDDEN];
public $key;
public string $key;
public $core = false;
public bool $core = false;
public bool $beta = false;
public $beta = false;
public string $name;
public string $license;
public string $description;
public array $authors = [];
public array $dependencies = [];
public array $conflicts = [];
public string $visibility = self::VISIBLE_DEFAULT;
public ?string $link = null;
public ?string $version = null;
public ?string $documentation = null;
public $name;
public $authors = [];
public $link;
public $license;
public $version;
public $dependencies = [];
public $conflicts = [];
public $visibility;
public $description;
public $documentation;
/** @var array which DBs this ext supports (blank for 'all') */
public $db_support = [];
/** @var bool */
private $supported = null;
/** @var string */
private $support_info = null;
/** @var string[] which DBs this ext supports (blank for 'all') */
public array $db_support = [];
private ?bool $supported = null;
private ?string $support_info = null;
public function is_supported(): bool
{
@ -168,9 +159,9 @@ abstract class ExtensionInfo
return $this->support_info;
}
private static $all_info_by_key = [];
private static $all_info_by_class = [];
private static $core_extensions = [];
private static array $all_info_by_key = [];
private static array $all_info_by_class = [];
private static array $core_extensions = [];
protected function __construct()
{
@ -283,7 +274,7 @@ abstract class FormatterExtension extends Extension
*/
abstract class DataHandlerExtension extends Extension
{
protected $SUPPORTED_MIME = [];
protected array $SUPPORTED_MIME = [];
protected function move_upload_to_archive(DataUploadEvent $event)
{
@ -335,7 +326,9 @@ abstract class DataHandlerExtension extends Extension
}
send_event(new ImageReplaceEvent($event->replace_id, $image));
$event->image_id = $event->replace_id;
$_id = $event->replace_id;
assert(!is_null($_id));
$event->image_id = $_id;
} else {
$image = $this->create_image_from_data(warehouse_path(Image::IMAGE_DIR, $event->hash), $event->metadata);
if (is_null($image)) {

View File

@ -5,13 +5,9 @@
*/
class ImageAdditionEvent extends Event
{
/** @var User */
public $user;
/** @var Image */
public $image;
public $merged = false;
public User $user;
public Image $image;
public bool $merged = false;
/**
* Inserts a new image into the database with its associated
@ -34,11 +30,8 @@ class ImageAdditionException extends SCoreException
*/
class ImageDeletionEvent extends Event
{
/** @var Image */
public $image;
/** @var bool */
public $force = false;
public Image $image;
public bool $force = false;
/**
* Deletes an image.
@ -59,10 +52,8 @@ class ImageDeletionEvent extends Event
*/
class ImageReplaceEvent extends Event
{
/** @var int */
public $id;
/** @var Image */
public $image;
public int $id;
public Image $image;
/**
* Replaces an image.
@ -88,15 +79,10 @@ class ImageReplaceException extends SCoreException
*/
class ThumbnailGenerationEvent extends Event
{
/** @var string */
public $hash;
/** @var string */
public $mime;
/** @var bool */
public $force;
/** @var bool */
public $generated;
public string $hash;
public string $mime;
public bool $force;
public bool $generated;
/**
* Request a thumbnail be made for an image object
@ -121,14 +107,10 @@ class ThumbnailGenerationEvent extends Event
*/
class ParseLinkTemplateEvent extends Event
{
/** @var string */
public $link;
/** @var string */
public $text;
/** @var string */
public $original;
/** @var Image */
public $image;
public string $link;
public string $text;
public string $original;
public Image $image;
public function __construct(string $link, Image $image)
{

View File

@ -13,68 +13,31 @@ class Image
public const IMAGE_DIR = "images";
public const THUMBNAIL_DIR = "thumbs";
/** @var null|int */
public $id = null;
/** @var int */
public $height;
/** @var int */
public $width;
/** @var string */
public $hash;
/** @var int */
public $filesize;
/** @var string */
public $filename;
/** @var string */
private $ext;
/** @var string */
private $mime;
public ?int $id = null;
public int $height;
public int $width;
public string $hash;
public int $filesize;
public string $filename;
private string $ext;
private string $mime;
/** @var string[]|null */
public $tag_array;
public ?array $tag_array;
public int $owner_id;
public string $owner_ip;
public string $posted;
public ?string $source;
public bool $locked = false;
public ?bool $lossless = null;
public ?bool $video = null;
public ?string $video_codec = null;
public ?bool $image = null;
public ?bool $audio = null;
public ?int $length = null;
/** @var int */
public $owner_id;
/** @var string */
public $owner_ip;
/** @var string */
public $posted;
/** @var string */
public $source;
/** @var boolean */
public $locked = false;
/** @var boolean */
public $lossless = null;
/** @var boolean */
public $video = null;
/** @var string */
public $video_codec = null;
/** @var boolean */
public $image = null;
/** @var boolean */
public $audio = null;
/** @var int */
public $length = null;
public static $bool_props = ["locked", "lossless", "video", "audio"];
public static $int_props = ["id", "owner_id", "height", "width", "filesize", "length"];
public static array $bool_props = ["locked", "lossless", "video", "audio", "image"];
public static array $int_props = ["id", "owner_id", "height", "width", "filesize", "length"];
/**
* One will very rarely construct an image directly, more common
@ -145,7 +108,7 @@ class Image
private static function find_images_internal(int $start = 0, ?int $limit = null, array $tags=[]): iterable
{
global $database, $user, $config;
global $database, $user;
if ($start < 0) {
$start = 0;
@ -161,9 +124,7 @@ class Image
}
$querylet = Image::build_search_querylet($tags, $limit, $start);
$result = $database->get_all_iterable($querylet->sql, $querylet->variables);
return $result;
return $database->get_all_iterable($querylet->sql, $querylet->variables);
}
/**
@ -625,7 +586,9 @@ class Image
public function set_mime($mime): void
{
$this->mime = $mime;
$this->ext = FileExtension::get_for_mime($this->get_mime());
$ext = FileExtension::get_for_mime($this->get_mime());
assert($ext != null);
$this->ext = $ext;
}

View File

@ -1,10 +1,8 @@
<?php declare(strict_types=1);
class Querylet
{
/** @var string */
public $sql;
/** @var array */
public $variables;
public string $sql;
public array $variables;
public function __construct(string $sql, array $variables=[])
{
@ -31,10 +29,8 @@ class Querylet
class TagCondition
{
/** @var string */
public $tag;
/** @var bool */
public $positive;
public string $tag;
public bool $positive;
public function __construct(string $tag, bool $positive)
{
@ -45,10 +41,8 @@ class TagCondition
class ImgCondition
{
/** @var Querylet */
public $qlet;
/** @var bool */
public $positive;
public Querylet $qlet;
public bool $positive;
public function __construct(Querylet $qlet, bool $positive)
{

View File

@ -68,7 +68,7 @@ function do_install($dsn)
create_tables(new Database($dsn));
write_config($dsn);
} catch (InstallerException $e) {
die_nicely($e->title, $e->body, $e->code);
die_nicely($e->title, $e->body, $e->exit_code);
}
}

View File

@ -246,21 +246,22 @@ function find_header(array $headers, string $name): ?string
if (!function_exists('mb_strlen')) {
// TODO: we should warn the admin that they are missing multibyte support
function mb_strlen($str, $encoding)
/** @noinspection PhpUnusedParameterInspection */
function mb_strlen($str, $encoding): int
{
return strlen($str);
}
function mb_internal_encoding($encoding)
function mb_internal_encoding($encoding): void
{
}
function mb_strtolower($str)
function mb_strtolower($str): string
{
return strtolower($str);
}
}
/** @noinspection PhpUnhandledExceptionInspection */
function get_subclasses_of(string $parent)
function get_subclasses_of(string $parent): array
{
$result = [];
foreach (get_declared_classes() as $class) {
@ -327,7 +328,7 @@ function get_base_href(): string
/**
* The opposite of the standard library's parse_url
*/
function unparse_url($parsed_url)
function unparse_url(array $parsed_url): string
{
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
@ -345,14 +346,14 @@ function unparse_url($parsed_url)
if (!function_exists('str_starts_with')) {
function str_starts_with(string $haystack, string $needle): bool
{
return \strncmp($haystack, $needle, \strlen($needle)) === 0;
return strncmp($haystack, $needle, strlen($needle)) === 0;
}
}
if (!function_exists('str_ends_with')) {
function str_ends_with(string $haystack, string $needle): bool
{
return $needle === '' || $needle === \substr($haystack, - \strlen($needle));
return $needle === '' || $needle === substr($haystack, - strlen($needle));
}
}
@ -520,13 +521,9 @@ function parse_shorthand_int(string $limit): int
/** @noinspection PhpMissingBreakStatementInspection */
case 't': $value *= 1024; // fall through
/** @noinspection PhpMissingBreakStatementInspection */
// no break
case 'g': $value *= 1024; // fall through
/** @noinspection PhpMissingBreakStatementInspection */
// no break
case 'm': $value *= 1024; // fall through
/** @noinspection PhpMissingBreakStatementInspection */
// no break
case 'k': $value *= 1024; break;
default: $value = -1;
}
@ -800,7 +797,7 @@ function iterator_map_to_array(callable $callback, iterator $iter): array
return iterator_to_array(iterator_map($callback, $iter));
}
function stringer($s)
function stringer($s): string
{
if (is_array($s)) {
if (isset($s[0])) {

View File

@ -2,8 +2,8 @@
class Link
{
public $page;
public $query;
public ?string $page;
public ?string $query;
public function __construct(?string $page=null, ?string $query=null)
{

View File

@ -15,22 +15,12 @@ function _new_user(array $row): User
*/
class User
{
/** @var int */
public $id;
/** @var string */
public $name;
/** @var string */
public $email;
public $join_date;
/** @var string */
public $passhash;
/** @var UserClass */
public $class;
public int $id;
public string $name;
public ?string $email;
public string $join_date;
public ?string $passhash;
public UserClass $class;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Initialisation *

View File

@ -10,21 +10,9 @@ $_shm_user_classes = [];
*/
class UserClass
{
/**
* @var ?string
*/
public $name = null;
/**
* @var ?UserClass
*/
public $parent = null;
/**
* @var array
*/
public $abilities = [];
public ?string $name = null;
public ?UserClass $parent = null;
public array $abilities = [];
public function __construct(string $name, string $parent = null, array $abilities = [])
{

View File

@ -12,6 +12,7 @@ use function MicroHTML\TFOOT;
use function MicroHTML\TR;
use function MicroHTML\TH;
use function MicroHTML\TD;
use MicroHTML\HTMLElement;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* Misc *
@ -359,7 +360,7 @@ function path_to_tags(string $path): string
}
function join_url(string $base, string ...$paths)
function join_url(string $base, string ...$paths): string
{
$output = $base;
foreach ($paths as $path) {
@ -410,7 +411,7 @@ function remove_empty_dirs(string $dir): bool
}
}
if ($result===true) {
$result = $result && rmdir($dir);
$result = rmdir($dir);
}
return $result;
}
@ -584,7 +585,6 @@ function _get_themelet_files(string $_theme): array
/**
* Used to display fatal errors to the web user.
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
function _fatal_error(Exception $e): void
{
@ -703,7 +703,7 @@ function make_form(string $target, string $method="POST", bool $multipart=false,
return '<form action="'.$target.'" method="'.$method.'" '.$extra.'>'.$extra_inputs;
}
function SHM_FORM(string $target, string $method="POST", bool $multipart=false, string $form_id="", string $onsubmit="")
function SHM_FORM(string $target, string $method="POST", bool $multipart=false, string $form_id="", string $onsubmit=""): HTMLElement
{
global $user;
@ -728,19 +728,19 @@ function SHM_FORM(string $target, string $method="POST", bool $multipart=false,
);
}
function SHM_SIMPLE_FORM($target, ...$children)
function SHM_SIMPLE_FORM($target, ...$children): HTMLElement
{
$form = SHM_FORM($target);
$form->appendChild(emptyHTML(...$children));
return $form;
}
function SHM_SUBMIT(string $text)
function SHM_SUBMIT(string $text): HTMLElement
{
return INPUT(["type"=>"submit", "value"=>$text]);
}
function SHM_COMMAND_EXAMPLE(string $ex, string $desc)
function SHM_COMMAND_EXAMPLE(string $ex, string $desc): HTMLElement
{
return DIV(
["class"=>"command_example"],
@ -749,7 +749,7 @@ function SHM_COMMAND_EXAMPLE(string $ex, string $desc)
);
}
function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot)
function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot): HTMLElement
{
if (is_string($foot)) {
$foot = TFOOT(TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>$foot]))));
@ -769,16 +769,16 @@ function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot)
}
const BYTE_DENOMINATIONS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
function human_filesize(int $bytes, $decimals = 2)
function human_filesize(int $bytes, $decimals = 2): string
{
$factor = floor((strlen(strval($bytes)) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @BYTE_DENOMINATIONS[$factor];
}
/*
/**
* Generates a unique key for the website to prevent unauthorized access.
*/
function generate_key(int $length = 20)
function generate_key(int $length = 20): string
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';

View File

@ -4,12 +4,12 @@ class AdminPageInfo extends ExtensionInfo
{
public const KEY = "admin";
public $key = self::KEY;
public $name = "Admin Controls";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $description = "Provides a base for various small admin functions";
public $core = true;
public $visibility = self::VISIBLE_HIDDEN;
public string $key = self::KEY;
public string $name = "Admin Controls";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "Provides a base for various small admin functions";
public bool $core = true;
public string $visibility = self::VISIBLE_HIDDEN;
}

View File

@ -1,13 +1,11 @@
<?php /** @noinspection PhpUnusedPrivateMethodInspection */
declare(strict_types=1);
<?php declare(strict_types=1);
/**
* Sent when the admin page is ready to be added to
*/
class AdminBuildingEvent extends Event
{
/** @var Page */
public $page;
public Page $page;
public function __construct(Page $page)
{
@ -18,10 +16,8 @@ class AdminBuildingEvent extends Event
class AdminActionEvent extends Event
{
/** @var string */
public $action;
/** @var bool */
public $redirect = true;
public string $action;
public bool $redirect = true;
public function __construct(string $action)
{
@ -33,7 +29,7 @@ class AdminActionEvent extends Event
class AdminPage extends Extension
{
/** @var AdminPageTheme */
protected $theme;
protected ?Themelet $theme;
public function onPageRequest(PageRequestEvent $event)
{

View File

@ -1,5 +1,4 @@
<?php declare(strict_types=1);
use function MicroHTML\INPUT;
class AdminPageTheme extends Themelet
{

View File

@ -4,12 +4,12 @@ class AliasEditorInfo extends ExtensionInfo
{
public const KEY = "alias_editor";
public $key = self::KEY;
public $name = "Alias Editor";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $description = "Edit the alias list";
public $documentation = 'The list is visible at <a href="$site/alias/list">/alias/list</a>; only site admins can edit it, other people can view and download it';
public $core = true;
public string $key = self::KEY;
public string $name = "Alias Editor";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "Edit the alias list";
public ?string $documentation = 'The list is visible at <a href="$site/alias/list">/alias/list</a>; only site admins can edit it, other people can view and download it';
public bool $core = true;
}

View File

@ -26,10 +26,8 @@ class AliasTable extends Table
class AddAliasEvent extends Event
{
/** @var string */
public $oldtag;
/** @var string */
public $newtag;
public string $oldtag;
public string $newtag;
public function __construct(string $oldtag, string $newtag)
{
@ -41,7 +39,7 @@ class AddAliasEvent extends Event
class DeleteAliasEvent extends Event
{
public $oldtag;
public string $oldtag;
public function __construct(string $oldtag)
{
@ -57,7 +55,7 @@ class AddAliasException extends SCoreException
class AliasEditor extends Extension
{
/** @var AliasEditorTheme */
protected $theme;
protected ?Themelet $theme;
public function onPageRequest(PageRequestEvent $event)
{

View File

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

View File

@ -10,7 +10,7 @@ abstract class ApprovalConfig
class Approval extends Extension
{
/** @var ApprovalTheme */
protected $theme;
protected ?Themelet $theme;
public function onInitExt(InitExtEvent $event)
{

View File

@ -5,7 +5,7 @@ use function MicroHTML\INPUT;
class ApprovalTheme extends Themelet
{
public function get_image_admin_html(Image $image)
public function get_image_admin_html(Image $image): string
{
if ($image->approved===true) {
$html = SHM_SIMPLE_FORM(
@ -24,8 +24,7 @@ class ApprovalTheme extends Themelet
return (string)$html;
}
public function get_help_html()
public function get_help_html(): string
{
return '<p>Search for posts that are approved/not approved.</p>
<div class="command_example">

View File

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

View File

@ -2,12 +2,9 @@
class AuthorSetEvent extends Event
{
/** @var Image */
public $image;
/** @var User */
public $user;
/** @var string */
public $author;
public Image $image;
public User $user;
public string $author;
public function __construct(Image $image, User $user, string $author)
{
@ -21,7 +18,7 @@ class AuthorSetEvent extends Event
class Artists extends Extension
{
/** @var ArtistsTheme */
protected $theme;
protected ?Themelet $theme;
public function onImageInfoSet(ImageInfoSetEvent $event)
{
@ -683,7 +680,7 @@ class Artists extends Extension
);
}
private function add_artist()
private function add_artist(): int
{
global $user;
$inputs = validate_input([

View File

@ -546,7 +546,7 @@ class ArtistsTheme extends Themelet
return $html;
}
public function get_help_html()
public function get_help_html(): string
{
return '<p>Search for posts with a particular artist.</p>
<div class="command_example">

View File

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

View File

@ -28,10 +28,8 @@ class AutoTaggerTable extends Table
class AddAutoTagEvent extends Event
{
/** @var string */
public $tag;
/** @var string */
public $additional_tags;
public string $tag;
public string $additional_tags;
public function __construct(string $tag, string $additional_tags)
{
@ -43,7 +41,7 @@ class AddAutoTagEvent extends Event
class DeleteAutoTagEvent extends Event
{
public $tag;
public string $tag;
public function __construct(string $tag)
{
@ -63,7 +61,7 @@ class AddAutoTagException extends SCoreException
class AutoTagger extends Extension
{
/** @var AutoTaggerTheme */
protected $theme;
protected ?Themelet $theme;
public function onPageRequest(PageRequestEvent $event)
{

View File

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

View File

@ -3,7 +3,7 @@
class AutoComplete extends Extension
{
/** @var AutoCompleteTheme */
protected $theme;
protected ?Themelet $theme;
public function get_priority(): int
{

View File

@ -63,12 +63,12 @@ document.addEventListener('DOMContentLoaded', () => {
var keyCode = e.keyCode || e.which;
//Stop tags containing space.
if(keyCode == 32) {
if(keyCode === 32) {
e.preventDefault();
$('.autocomplete_tags').tagit('createTag', $(this).val());
$(this).autocomplete('close');
} else if (keyCode == 9) {
} else if (keyCode === 9) {
e.preventDefault();
var tag = $('.tagit-autocomplete[style*=\"display: block\"] > li:focus, .tagit-autocomplete[style*=\"display: block\"] > li:first').first();

View File

@ -4,13 +4,13 @@ class BanWordsInfo extends ExtensionInfo
{
public const KEY = "ban_words";
public $key = self::KEY;
public $name = "Comment Word Ban";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $description = "For stopping spam and other comment abuse";
public $documentation =
public string $key = self::KEY;
public string $name = "Comment Word Ban";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "For stopping spam and other comment abuse";
public ?string $documentation =
"Allows an administrator to ban certain words
from comments. This can be a very simple but effective way
of stopping spam; just add \"viagra\", \"porn\", etc to the

View File

@ -4,14 +4,14 @@ class BBCodeInfo extends ExtensionInfo
{
public const KEY = "bbcode";
public $key = self::KEY;
public $name = "BBCode";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $core = true;
public $description = "Turns BBCode into HTML";
public $documentation =
public string $key = self::KEY;
public string $name = "BBCode";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public bool $core = true;
public string $description = "Turns BBCode into HTML";
public ?string $documentation =
" Basic formatting tags:
<ul>
<li>[b]<b>bold</b>[/b]

View File

@ -96,13 +96,13 @@ class BBCodeTest extends ShimmiePHPUnitTestCase
);
}
private function filter($in)
private function filter($in): string
{
$bb = new BBCode();
return $bb->format($in);
}
private function strip($in)
private function strip($in): string
{
$bb = new BBCode();
return $bb->strip($in);

View File

@ -4,10 +4,10 @@ class BiographyInfo extends ExtensionInfo
{
public const KEY = "biography";
public $key = self::KEY;
public $name = "User Bios";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $description = "Allow users to write a bit about themselves";
public string $key = self::KEY;
public string $name = "User Bios";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "Allow users to write a bit about themselves";
}

View File

@ -3,11 +3,11 @@
class Biography extends Extension
{
/** @var BiographyTheme */
protected $theme;
protected ?Themelet $theme;
public function onUserPageBuilding(UserPageBuildingEvent $event)
{
global $database, $page, $user;
global $page, $user;
$duser = $event->display_user;
$duser_config = UserConfig::get_for_user($event->display_user->id);
$bio = $duser_config->get_string("biography", "");
@ -21,7 +21,7 @@ class Biography extends Extension
public function onPageRequest(PageRequestEvent $event)
{
global $cache, $database, $page, $user, $user_config;
global $page, $user, $user_config;
if ($event->page_matches("biography")) {
if ($user->check_auth_token()) {
$user_config->set_string("biography", $_POST['biography']);

View File

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

View File

@ -4,10 +4,10 @@ class BlocksInfo extends ExtensionInfo
{
public const KEY = "blocks";
public $key = self::KEY;
public $name = "Generic Blocks";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $description = "Add HTML to some space (News, Ads, etc)";
public string $key = self::KEY;
public string $name = "Generic Blocks";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "Add HTML to some space (News, Ads, etc)";
}

View File

@ -3,7 +3,7 @@
class Blocks extends Extension
{
/** @var BlocksTheme */
protected $theme;
protected ?Themelet $theme;
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
{

View File

@ -4,12 +4,12 @@ class BlotterInfo extends ExtensionInfo
{
public const KEY = "blotter";
public $key = self::KEY;
public $name = "Blotter";
public $url = "http://seemslegit.com/";
public $authors = ["Zach Hall"=>"zach@sosguy.net"];
public $license = self::LICENSE_GPLV2;
public $description = "Displays brief updates about whatever you want on every page.
public string $key = self::KEY;
public string $name = "Blotter";
public string $url = "http://seemslegit.com/";
public array $authors = ["Zach Hall"=>"zach@sosguy.net"];
public string $license = self::LICENSE_GPLV2;
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.
Development TODO at https://github.com/zshall/shimmie2/issues";

View File

@ -3,7 +3,7 @@
class Blotter extends Extension
{
/** @var BlotterTheme */
protected $theme;
protected ?Themelet $theme;
public function onInitExt(InitExtEvent $event)
{

View File

@ -20,7 +20,7 @@ class BlotterTheme extends Themelet
$page->add_block(new Block("Blotter Entries", $html, "main", 10));
}
public function display_blotter($entries)
public function display_blotter(array $entries): void
{
global $page, $config;
$html = $this->get_html_for_blotter($entries);
@ -28,7 +28,7 @@ class BlotterTheme extends Themelet
$page->add_block(new Block(null, $html, $position, 20));
}
private function get_html_for_blotter_editor($entries)
private function get_html_for_blotter_editor(array $entries): string
{
global $user;
@ -99,7 +99,7 @@ class BlotterTheme extends Themelet
return $html;
}
private function get_html_for_blotter_page($entries)
private function get_html_for_blotter_page(array $entries): string
{
/**
* This one displays a list of all blotter entries.
@ -130,7 +130,7 @@ class BlotterTheme extends Themelet
return $html;
}
private function get_html_for_blotter($entries)
private function get_html_for_blotter(array $entries): string
{
global $config;
$i_color = $config->get_string("blotter_color", "#FF0000");

View File

@ -4,14 +4,14 @@ class BrowserSearchInfo extends ExtensionInfo
{
public const KEY = "browser_search";
public $key = self::KEY;
public $name = "Browser Search";
public $url = "http://atravelinggeek.com/";
public $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"];
public $license = self::LICENSE_GPLV2;
public $version = "0.1c, October 26, 2007";
public $description = "Allows the user to add a browser 'plugin' to search the site with real-time suggestions";
public $documentation =
public string $key = self::KEY;
public string $name = "Browser Search";
public string $url = "http://atravelinggeek.com/";
public array $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"];
public string $license = self::LICENSE_GPLV2;
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 $documentation =
"Once installed, users with an opensearch compatible browser should see their search box light up with whatever \"click here to add a search engine\" notification they have
Some code (and lots of help) by Artanis (Erik Youngren <artanis.00@gmail.com>) from the 'tagger' extension - Used with permission";

View File

@ -4,10 +4,10 @@ class BulkActionsInfo extends ExtensionInfo
{
public const KEY = "bulk_actions";
public $key = self::KEY;
public $name = "Bulk Actions";
public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
public $license = self::LICENSE_WTFPL;
public $description = "Provides query and selection-based bulk action support";
public $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 Christian Walde <walde.christian@googlemail.com>, contributions by Shish and Agasa.";
public string $key = self::KEY;
public string $name = "Bulk Actions";
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
public string $license = self::LICENSE_WTFPL;
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 Christian Walde <walde.christian@googlemail.com>, contributions by Shish and Agasa.";
}

View File

@ -5,10 +5,8 @@ class BulkActionException extends SCoreException
}
class BulkActionBlockBuildingEvent extends Event
{
/** @var array */
public $actions = [];
public $search_terms = [];
public array $actions = [];
public array $search_terms = [];
public function add_action(String $action, string $button_text, string $access_key = null, String $confirmation_message = "", String $block = "", int $position = 40)
{
@ -38,12 +36,9 @@ class BulkActionBlockBuildingEvent extends Event
class BulkActionEvent extends Event
{
/** @var string */
public $action;
/** @var array */
public $items;
/** @var bool */
public $redirect = true;
public string $action;
public Generator $items;
public bool $redirect = true;
public function __construct(String $action, Generator $items)
{
@ -56,7 +51,7 @@ class BulkActionEvent extends Event
class BulkActions extends Extension
{
/** @var BulkActionsTheme */
protected $theme;
protected ?Themelet $theme;
public function onPostListBuilding(PostListBuildingEvent $event)
{

View File

@ -8,13 +8,13 @@ function validate_selections(form, confirmationMessage) {
var queryOnly = false;
if(bulk_selector_active) {
var data = get_selected_items();
if(data.length==0) {
if(data.length===0) {
return false;
}
} else {
var query = $(form).find('input[name="bulk_query"]').val();
if (query == null || query == "") {
if (query == null || query === "") {
return false;
} else {
queryOnly = true;
@ -22,7 +22,7 @@ function validate_selections(form, confirmationMessage) {
}
if(confirmationMessage!=null&&confirmationMessage!="") {
if(confirmationMessage!=null&&confirmationMessage!=="") {
return confirm(confirmationMessage);
} else if(queryOnly) {
var action = $(form).find('input[name="submit_button"]').val();
@ -59,7 +59,7 @@ function deactivate_bulk_selector() {
function get_selected_items() {
var data = $('#bulk_selected_ids').val();
if(data==""||data==null) {
if(data===""||data==null) {
data = [];
} else {
data = JSON.parse(data);
@ -145,7 +145,7 @@ function select_range(start, end) {
function ( index, block ) {
block = $(block);
var id = block.data("post-id");
if(id==start)
if(id===start)
selecting = true;
if(selecting) {
@ -153,7 +153,7 @@ function select_range(start, end) {
data.push(id);
}
if(id==end) {
if(id===end) {
selecting = false;
}
}

View File

@ -45,7 +45,7 @@ class BulkActionsTheme extends Themelet
$page->add_block($block);
}
public function render_ban_reason_input()
public function render_ban_reason_input(): string
{
if (class_exists("ImageBan")) {
return "<input type='text' name='bulk_ban_reason' placeholder='Ban reason (leave blank to not ban)' />";
@ -54,13 +54,13 @@ class BulkActionsTheme extends Themelet
}
}
public function render_tag_input()
public function render_tag_input(): string
{
return "<label><input type='checkbox' style='width:13px;' name='bulk_tags_replace' value='true'/>Replace tags</label>" .
"<input type='text' name='bulk_tags' required='required' placeholder='Enter tags here' />";
}
public function render_source_input()
public function render_source_input(): string
{
return "<input type='text' name='bulk_source' required='required' placeholder='Enter source here' />";
}

View File

@ -4,13 +4,13 @@ class BulkAddInfo extends ExtensionInfo
{
public const KEY = "bulk_add";
public $key = self::KEY;
public $name = "Bulk Add";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $description = "Bulk add server-side images";
public $documentation =
public string $key = self::KEY;
public string $name = "Bulk Add";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "Bulk add server-side images";
public ?string $documentation =
"Upload the images into a new directory via ftp or similar, go to
shimmie's admin page and put that directory in the bulk add box.
If there are subdirectories, they get used as tags (eg if you

View File

@ -2,8 +2,8 @@
class BulkAddEvent extends Event
{
public $dir;
public $results;
public string $dir;
public array $results;
public function __construct(string $dir)
{
@ -16,7 +16,7 @@ class BulkAddEvent extends Event
class BulkAdd extends Extension
{
/** @var BulkAddTheme */
protected $theme;
protected ?Themelet $theme;
public function onPageRequest(PageRequestEvent $event)
{

View File

@ -2,7 +2,7 @@
class BulkAddTheme extends Themelet
{
private $messages = [];
private array $messages = [];
/*
* Show a standard page for results to be put into

View File

@ -4,13 +4,13 @@ class BulkAddCSVInfo extends ExtensionInfo
{
public const KEY = "bulk_add_csv";
public $key = self::KEY;
public $name = "Bulk Add CSV";
public $url = self::SHIMMIE_URL;
public $authors = ["velocity37"=>"velocity37@gmail.com"];
public $license = self::LICENSE_GPLV2;
public $description = "Bulk add server-side posts with metadata from CSV file";
public $documentation =
public string $key = self::KEY;
public string $name = "Bulk Add CSV";
public string $url = self::SHIMMIE_URL;
public array $authors = ["velocity37"=>"velocity37@gmail.com"];
public string $license = self::LICENSE_GPLV2;
public string $description = "Bulk add server-side posts with metadata from CSV file";
public ?string $documentation =
"Modification of \"Bulk Add\" by Shish.<br><br>
Adds posts from a CSV with the five following values: <br>
\"/path/to/image.jpg\",\"spaced tags\",\"source\",\"rating s/q/e\",\"/path/thumbnail.jpg\" <br>

View File

@ -3,7 +3,7 @@
class BulkAddCSV extends Extension
{
/** @var BulkAddCSVTheme */
protected $theme;
protected ?Themelet $theme;
public function onPageRequest(PageRequestEvent $event)
{

View File

@ -2,7 +2,7 @@
class BulkAddCSVTheme extends Themelet
{
private $messages = [];
private array $messages = [];
/*
* Show a standard page for results to be put into

View File

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

View File

@ -2,8 +2,8 @@
class BulkExportEvent extends Event
{
public $image;
public $fields = [];
public Image $image;
public array $fields = [];
public function __construct(Image $image)
{
@ -15,8 +15,8 @@ class BulkExportEvent extends Event
class BulkImportEvent extends Event
{
public $image;
public $fields = [];
public Image $image;
public array $fields = [];
public function __construct(Image $image, $fields)
{

View File

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

View File

@ -5,7 +5,7 @@ class BulkImportExport extends DataHandlerExtension
{
const EXPORT_ACTION_NAME = "bulk_export";
const EXPORT_INFO_FILE_NAME = "export.json";
protected $SUPPORTED_MIME = [MimeType::ZIP];
protected array $SUPPORTED_MIME = [MimeType::ZIP];
public function onDataUpload(DataUploadEvent $event)
@ -159,7 +159,7 @@ class BulkImportExport extends DataHandlerExtension
return false;
}
protected function create_thumb(string $hash, string $type): bool
protected function create_thumb(string $hash, string $mime): bool
{
return false;
}

View File

@ -4,12 +4,12 @@ class CommentListInfo extends ExtensionInfo
{
public const KEY = "comment";
public $key = self::KEY;
public $name = "Post Comments";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $description = "Allow users to make comments on images";
public $documentation = "Formatting is done with the standard formatting API (normally BBCode)";
public $core = true;
public string $key = self::KEY;
public string $name = "Post Comments";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "Allow users to make comments on images";
public ?string $documentation = "Formatting is done with the standard formatting API (normally BBCode)";
public bool $core = true;
}

View File

@ -4,12 +4,9 @@ require_once "vendor/ifixit/php-akismet/akismet.class.php";
class CommentPostingEvent extends Event
{
/** @var int */
public $image_id;
/** @var User */
public $user;
/** @var string */
public $comment;
public int $image_id;
public User $user;
public string $comment;
public function __construct(int $image_id, User $user, string $comment)
{
@ -27,8 +24,7 @@ class CommentPostingEvent extends Event
*/
class CommentDeletionEvent extends Event
{
/** @var int */
public $comment_id;
public int $comment_id;
public function __construct(int $comment_id)
{
@ -43,46 +39,27 @@ class CommentPostingException extends SCoreException
class Comment
{
/** @var User */
public $owner;
/** @var int */
public $owner_id;
/** @var string */
public $owner_name;
/** @var string */
public $owner_email;
/** @var string */
public $owner_class;
/** @var string */
public $comment;
/** @var int */
public $comment_id;
/** @var int */
public $image_id;
/** @var string */
public $poster_ip;
/** @var string */
public $posted;
public ?User $owner;
public int $owner_id;
public string $owner_name;
public ?string $owner_email;
public string $owner_class;
public string $comment;
public int $comment_id;
public int $image_id;
public string $poster_ip;
public string $posted;
public function __construct($row)
{
$this->owner = null;
$this->owner_id = $row['user_id'];
$this->owner_id = (int)$row['user_id'];
$this->owner_name = $row['user_name'];
$this->owner_email = $row['user_email']; // deprecated
$this->owner_class = $row['user_class'];
$this->comment = $row['comment'];
$this->comment_id = $row['comment_id'];
$this->image_id = $row['image_id'];
$this->comment_id = (int)$row['comment_id'];
$this->image_id = (int)$row['image_id'];
$this->poster_ip = $row['poster_ip'];
$this->posted = $row['posted'];
}
@ -109,7 +86,7 @@ class Comment
class CommentList extends Extension
{
/** @var CommentListTheme $theme */
public $theme;
public ?Themelet $theme;
public function onInitExt(InitExtEvent $event)
{

View File

@ -1,9 +1,9 @@
<?php declare(strict_types=1);
class CommentListTheme extends Themelet
{
private $show_anon_id = false;
private $anon_id = 1;
private $anon_map = [];
private bool $show_anon_id = false;
private int $anon_id = 1;
private array $anon_map = [];
/**
* Display a page with a list of images, and for each image, the image's comments.
@ -86,7 +86,6 @@ class CommentListTheme extends Themelet
}
}
public function display_admin_block()
{
global $page;
@ -104,7 +103,6 @@ class CommentListTheme extends Themelet
$page->add_block(new Block("Mass Comment Delete", $html));
}
/**
* Add some comments to the page, probably in a sidebar.
*
@ -122,7 +120,6 @@ class CommentListTheme extends Themelet
$page->add_block(new Block("Comments", $html, "left", 50, "comment-list-recent"));
}
/**
* Show comments for an image.
*
@ -142,7 +139,6 @@ class CommentListTheme extends Themelet
$page->add_block(new Block("Comments", $html, "main", 30, "comment-list-image"));
}
/**
* Show comments made by a user.
*
@ -287,7 +283,7 @@ class CommentListTheme extends Themelet
';
}
public function get_help_html()
public function get_help_html(): string
{
return '<p>Search for posts containing a certain number of comments, or comments by a particular individual.</p>
<div class="command_example">

View File

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

View File

@ -5,7 +5,7 @@ require_once "config.php";
class CronUploader extends Extension
{
/** @var CronUploaderTheme */
protected $theme;
protected ?Themelet $theme;
public const NAME = "cron_uploader";
@ -15,7 +15,7 @@ class CronUploader extends Extension
const UPLOADED_DIR = "uploaded";
const FAILED_DIR = "failed_to_upload";
private static $IMPORT_RUNNING = false;
private static bool $IMPORT_RUNNING = false;
public function onInitUserConfig(InitUserConfigEvent $event)
{
@ -201,7 +201,7 @@ class CronUploader extends Extension
}
private function get_cron_url()
private function get_cron_url(): string
{
global $user_config;
@ -210,12 +210,12 @@ class CronUploader extends Extension
return make_http(make_link("/cron_upload/run", "api_key=".urlencode($user_api_key)));
}
private function get_cron_cmd()
private function get_cron_cmd(): string
{
return "curl --silent " . $this->get_cron_url();
}
private function display_documentation()
private function display_documentation(): void
{
global $database;
@ -261,7 +261,7 @@ class CronUploader extends Extension
);
}
public function get_queue_dir()
public function get_queue_dir(): string
{
global $user_config;
@ -269,7 +269,7 @@ class CronUploader extends Extension
return join_path($dir, self::QUEUE_DIR);
}
public function get_uploaded_dir()
public function get_uploaded_dir(): string
{
global $user_config;
@ -277,7 +277,7 @@ class CronUploader extends Extension
return join_path($dir, self::UPLOADED_DIR);
}
public function get_failed_dir()
public function get_failed_dir(): string
{
global $user_config;
@ -499,7 +499,7 @@ class CronUploader extends Extension
private const SKIPPABLE_FILES = ['.ds_store','thumbs.db'];
private const SKIPPABLE_DIRECTORIES = ['__macosx'];
private function is_skippable_dir(string $path)
private function is_skippable_dir(string $path): bool
{
$info = pathinfo($path);
@ -510,7 +510,7 @@ class CronUploader extends Extension
return false;
}
private function is_skippable_file(string $path)
private function is_skippable_file(string $path): bool
{
$info = pathinfo($path);

View File

@ -10,8 +10,6 @@ use function MicroHTML\TD;
use function MicroHTML\INPUT;
use function MicroHTML\rawHTML;
use function MicroHTML\emptyHTML;
use function MicroHTML\SELECT;
use function MicroHTML\OPTION;
class CronUploaderTheme extends Themelet
{
@ -33,7 +31,6 @@ class CronUploaderTheme extends Themelet
if (!$config->get_bool(UserConfig::ENABLE_API_KEYS)) {
$info_html .= "<b style='color:red'>THIS EXTENSION REQUIRES USER API KEYS TO BE ENABLED IN <a href=''>BOARD ADMIN</a></b>";
} else {
}
$info_html .= "<b>Information</b>

View File

@ -4,13 +4,13 @@ class CustomHtmlHeadersInfo extends ExtensionInfo
{
public const KEY = "custom_html_headers";
public $key = self::KEY;
public $name = "Custom HTML Headers";
public $url = "http://www.drudexsoftware.com";
public $authors = ["Drudex Software"=>"support@drudexsoftware.com"];
public $license = self::LICENSE_GPLV2;
public $description = "Allows admins to modify & set custom &lt;head&gt; content";
public $documentation =
public string $key = self::KEY;
public string $name = "Custom HTML Headers";
public string $url = "http://www.drudexsoftware.com";
public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"];
public string $license = self::LICENSE_GPLV2;
public string $description = "Allows admins to modify & set custom &lt;head&gt; content";
public ?string $documentation =
"When you go to board config you can find a block named Custom HTML Headers.
In that block you can simply place any thing you can place within &lt;head&gt;&lt;/head&gt;

View File

@ -4,11 +4,11 @@ class DanbooruApiInfo extends ExtensionInfo
{
public const KEY = "danbooru_api";
public $key = self::KEY;
public $name = "Danbooru Client API";
public $authors = ["JJS"=>"jsutinen@gmail.com"];
public $description = "Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie";
public $documentation =
public string $key = self::KEY;
public string $name = "Danbooru Client API";
public array $authors = ["JJS"=>"jsutinen@gmail.com"];
public string $description = "Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie";
public ?string $documentation =
"<p>Notes:
<br>danbooru API based on documentation from danbooru 1.0 -
http://attachr.com/7569

View File

@ -2,19 +2,19 @@
use \MicroHTML\HTMLElement;
function TAGS(...$args)
function TAGS(...$args): HTMLElement
{
return new HTMLElement("tags", $args);
}
function TAG(...$args)
function TAG(...$args): HTMLElement
{
return new HTMLElement("tag", $args);
}
function POSTS(...$args)
function POSTS(...$args): HTMLElement
{
return new HTMLElement("posts", $args);
}
function POST(...$args)
function POST(...$args): HTMLElement
{
return new HTMLElement("post", $args);
}
@ -114,11 +114,14 @@ class DanbooruApi extends Extension
}
}
// Currently disabled to maintain identical functionality to danbooru 1.0's own "broken" find_tags
elseif (false && isset($_GET['tags'])) {
/*
elseif (isset($_GET['tags'])) {
$start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0;
$tags = Tag::explode($_GET['tags']);
assert(!is_null($start) && !is_null($tags));
} else {
}
*/
else {
$start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0;
$sqlresult = $database->get_all(
"SELECT id,tag,count FROM tags WHERE count > 0 AND id >= :id ORDER BY id DESC",

View File

@ -2,12 +2,12 @@
class ImageDownloadingEvent extends Event
{
public $image;
public $mime;
public $path;
public $file_modified = false;
public Image $image;
public string $mime;
public string $path;
public bool $file_modified = false;
public function __construct(Image $image, String $path, string $mime)
public function __construct(Image $image, string $path, string $mime)
{
parent::__construct();
$this->image = $image;

View File

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

View File

@ -4,13 +4,13 @@ class DowntimeInfo extends ExtensionInfo
{
public const KEY = "downtime";
public $key = self::KEY;
public $name = "Downtime";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $description = "Show a \"down for maintenance\" page";
public $documentation =
public string $key = self::KEY;
public string $name = "Downtime";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "Show a \"down for maintenance\" page";
public ?string $documentation =
"Once installed there will be some more options on the config page --
Ticking \"disable non-admin access\" will mean that regular and anonymous
users will be blocked from accessing the site, only able to view the

View File

@ -3,7 +3,7 @@
class Downtime extends Extension
{
/** @var DowntimeTheme */
protected $theme;
protected ?Themelet $theme;
public function get_priority(): int
{
@ -35,7 +35,7 @@ class Downtime extends Extension
}
}
private function is_safe_page(PageRequestEvent $event)
private function is_safe_page(PageRequestEvent $event): bool
{
if ($event->page_matches("user_admin/login")) {
return true;

View File

@ -4,14 +4,14 @@ class EmoticonsInfo extends ExtensionInfo
{
public const KEY = "emoticons";
public $key = self::KEY;
public $name = "Emoticon Filter";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $dependencies = [EmoticonListInfo::KEY];
public $description = "Lets users use graphical smilies";
public $documentation =
public string $key = self::KEY;
public string $name = "Emoticon Filter";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public array $dependencies = [EmoticonListInfo::KEY];
public string $description = "Lets users use graphical smilies";
public ?string $documentation =
"This extension will turn colon-something-colon into a link
to an image with that something as the name, eg :smile:
becomes a link to smile.gif

View File

@ -4,12 +4,12 @@ class EmoticonListInfo extends ExtensionInfo
{
public const KEY = "emoticons_list";
public $key = self::KEY;
public $name = "Emoticon List";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $description = "Lists available graphical smilies";
public string $key = self::KEY;
public string $name = "Emoticon List";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "Lists available graphical smilies";
public $visibility = self::VISIBLE_HIDDEN;
public string $visibility = self::VISIBLE_HIDDEN;
}

View File

@ -6,7 +6,7 @@
class EmoticonList extends Extension
{
/** @var EmoticonListTheme */
protected $theme;
protected ?Themelet $theme;
public function onPageRequest(PageRequestEvent $event)
{

View File

@ -4,10 +4,10 @@ class EokmInfo extends ExtensionInfo
{
public const KEY = "eokm";
public $key = self::KEY;
public $name = "EOKM Filter";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $description = "Check uploads against the EOKM blocklist";
public string $key = self::KEY;
public string $name = "EOKM Filter";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "Check uploads against the EOKM blocklist";
}

View File

@ -25,6 +25,7 @@ class Eokm extends Extension
$return = curl_exec($ch);
curl_close($ch);
/** @noinspection PhpStatementHasEmptyBodyInspection */
if ($return == "false") {
// all ok
} elseif ($return == "true") {

View File

@ -4,14 +4,14 @@ class ETInfo extends ExtensionInfo
{
public const KEY = "et";
public $key = self::KEY;
public $name = "System Info";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $core = true;
public $description = "Show various bits of system information";
public $documentation =
public string $key = self::KEY;
public string $name = "System Info";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public bool $core = true;
public string $description = "Show various bits of system information";
public ?string $documentation =
"Knowing the information that this extension shows can be very useful for debugging. There's also an option to send
your stats to my database, so I can get some idea of how shimmie is used, which servers I need to support, which
versions of PHP I should test with, etc.";

View File

@ -3,7 +3,7 @@
class ET extends Extension
{
/** @var ETTheme */
protected $theme;
protected ?Themelet $theme;
public function onPageRequest(PageRequestEvent $event)
{
@ -116,7 +116,7 @@ class ET extends Extension
return $info;
}
private function to_yaml($info)
private function to_yaml(array $info): string
{
$data = "";
foreach ($info as $title => $section) {

View File

@ -22,7 +22,7 @@ class ETTheme extends Themelet
$page->add_block(new Block("Information:", $this->build_data_form($yaml)));
}
protected function build_data_form($yaml)
protected function build_data_form($yaml): string
{
return (string)FORM(
["action"=>"https://shimmie.shishnet.org/register.php", "method"=>"POST"],

View File

@ -4,12 +4,12 @@ class ETServerInfo extends ExtensionInfo
{
public const KEY = "et_server";
public $key = self::KEY;
public $name = "System Info Registry";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $description = "Keep track of shimmie registrations";
public $documentation = "For internal use";
public $visibility = self::VISIBLE_HIDDEN;
public string $key = self::KEY;
public string $name = "System Info Registry";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "Keep track of shimmie registrations";
public ?string $documentation = "For internal use";
public string $visibility = self::VISIBLE_HIDDEN;
}

View File

@ -4,13 +4,13 @@ class ExtManagerInfo extends ExtensionInfo
{
public const KEY = "ext_manager";
public $key = self::KEY;
public $name = "Extension Manager";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $visibility = self::VISIBLE_ADMIN;
public $description = "A thing for point & click extension management";
public $documentation = "Allows the admin to view a list of all extensions and enable or disable them; also allows users to view the list of activated extensions and read their documentation";
public $core = true;
public string $key = self::KEY;
public string $name = "Extension Manager";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $visibility = self::VISIBLE_ADMIN;
public string $description = "A thing for point & click extension management";
public ?string $documentation = "Allows the admin to view a list of all extensions and enable or disable them; also allows users to view the list of activated extensions and read their documentation";
public bool $core = true;
}

View File

@ -21,8 +21,8 @@ function __extman_extactive(ExtensionInfo $a): bool
class ExtensionAuthor
{
public $name;
public $email;
public string $name;
public ?string $email;
public function __construct(string $name, ?string $email)
{
@ -34,7 +34,7 @@ class ExtensionAuthor
class ExtManager extends Extension
{
/** @var ExtManagerTheme */
protected $theme;
protected ?Themelet $theme;
public function onPageRequest(PageRequestEvent $event)
{

View File

@ -4,12 +4,12 @@ class FavoritesInfo extends ExtensionInfo
{
public const KEY = "favorites";
public $key = self::KEY;
public $name = "Favorites";
public $authors = ["Daniel Marschall"=>"info@daniel-marschall.de"];
public $license = self::LICENSE_GPLV2;
public $description = "Allow users to favorite images";
public $documentation =
public string $key = self::KEY;
public string $name = "Favorites";
public array $authors = ["Daniel Marschall"=>"info@daniel-marschall.de"];
public string $license = self::LICENSE_GPLV2;
public string $description = "Allow users to favorite images";
public ?string $documentation =
"Gives users a \"favorite this image\" button that they can press
<p>Favorites for a user can then be retrieved by searching for \"favorited_by=UserName\"
<p>Popular images can be searched for by eg. \"favorites>5\"

View File

@ -2,12 +2,9 @@
class FavoriteSetEvent extends Event
{
/** @var int */
public $image_id;
/** @var User */
public $user;
/** @var bool */
public $do_set;
public int $image_id;
public User $user;
public bool $do_set;
public function __construct(int $image_id, User $user, bool $do_set)
{
@ -24,7 +21,7 @@ class FavoriteSetEvent extends Event
class Favorites extends Extension
{
/** @var FavoritesTheme */
protected $theme;
protected ?Themelet $theme;
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
{

View File

@ -1,9 +1,10 @@
<?php declare(strict_types=1);
use function MicroHTML\INPUT;
use MicroHTML\HTMLElement;
class FavoritesTheme extends Themelet
{
public function get_voter_html(Image $image, $is_favorited)
public function get_voter_html(Image $image, bool $is_favorited): HTMLElement
{
$name = $is_favorited ? "unset" : "set";
$label = $is_favorited ? "Un-Favorite" : "Favorite";
@ -15,7 +16,7 @@ class FavoritesTheme extends Themelet
);
}
public function display_people($username_array)
public function display_people(array $username_array): void
{
global $page;
@ -32,7 +33,7 @@ class FavoritesTheme extends Themelet
$page->add_block(new Block("Favorited By", $html, "left", 25));
}
public function get_help_html()
public function get_help_html(): string
{
return '<p>Search for posts that have been favorited a certain number of times, or favorited by a particular individual.</p>
<div class="command_example">

View File

@ -4,13 +4,13 @@ class FeaturedInfo extends ExtensionInfo
{
public const KEY = "featured";
public $key = self::KEY;
public $name = "Featured Post";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $description = "Bring a specific image to the users' attentions";
public $documentation =
public string $key = self::KEY;
public string $name = "Featured Post";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "Bring a specific image to the users' attentions";
public ?string $documentation =
"Once enabled, a new \"feature this\" button will appear next
to the other post control buttons (delete, rotate, etc).
Clicking it will set the image as the site's current feature,

View File

@ -3,7 +3,7 @@
class Featured extends Extension
{
/** @var FeaturedTheme */
protected $theme;
protected ?Themelet $theme;
public function onInitExt(InitExtEvent $event)
{

View File

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

View File

@ -10,7 +10,7 @@ Todo:
class Forum extends Extension
{
/** @var ForumTheme */
protected $theme;
protected ?Themelet $theme;
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
{
@ -189,15 +189,15 @@ class Forum extends Extension
}
}
private function get_total_pages_for_thread(int $threadID)
private function get_total_pages_for_thread(int $threadID): int
{
global $database, $config;
$result = $database->get_row("SELECT COUNT(1) AS count FROM forum_posts WHERE thread_id = :thread_id", ['thread_id'=>$threadID]);
return ceil($result["count"] / $config->get_int("forumPostsPerPage"));
return (int)ceil($result["count"] / $config->get_int("forumPostsPerPage"));
}
private function sanity_check_new_thread()
private function sanity_check_new_thread(): array
{
$errors = null;
if (!array_key_exists("title", $_POST)) {
@ -217,7 +217,7 @@ class Forum extends Extension
return [$errors];
}
private function sanity_check_new_post()
private function sanity_check_new_post(): array
{
$errors = null;
if (!array_key_exists("threadID", $_POST)) {
@ -235,7 +235,7 @@ class Forum extends Extension
return [$errors];
}
private function sanity_check_viewed_thread(int $threadID)
private function sanity_check_viewed_thread(int $threadID): array
{
$errors = null;
if (!$this->threadExists($threadID)) {
@ -244,14 +244,14 @@ class Forum extends Extension
return [$errors];
}
private function get_thread_title(int $threadID)
private function get_thread_title(int $threadID): string
{
global $database;
$result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = :id ", ['id'=>$threadID]);
return $result["title"];
}
private function show_last_threads(Page $page, PageRequestEvent $event, $showAdminOptions = false)
private function show_last_threads(Page $page, PageRequestEvent $event, bool $showAdminOptions = false): void
{
global $config, $database;
$threadsPerPage = $config->get_int('forumThreadsPerPage', 15);
@ -278,7 +278,7 @@ class Forum extends Extension
$this->theme->display_thread_list($page, $threads, $showAdminOptions, $pageNumber + 1, $totalPages);
}
private function show_posts(PageRequestEvent $event, $showAdminOptions = false)
private function show_posts(PageRequestEvent $event, bool $showAdminOptions = false): void
{
global $config, $database;
$threadID = int_escape($event->get_arg(1));
@ -305,7 +305,7 @@ class Forum extends Extension
$this->theme->display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber + 1, $totalPages);
}
private function save_new_thread(User $user)
private function save_new_thread(User $user): int
{
$title = html_escape($_POST["title"]);
$sticky = !empty($_POST["sticky"]);
@ -327,7 +327,7 @@ class Forum extends Extension
return $threadID;
}
private function save_new_post(int $threadID, User $user)
private function save_new_post(int $threadID, User $user): void
{
global $config;
$userID = $user->id;
@ -349,7 +349,7 @@ class Forum extends Extension
$database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=:id", ['id'=>$threadID]);
}
private function retrieve_posts(int $threadID, int $pageNumber)
private function retrieve_posts(int $threadID, int $pageNumber): array
{
global $database, $config;
$postsPerPage = $config->get_int('forumPostsPerPage', 15);
@ -366,20 +366,20 @@ class Forum extends Extension
);
}
private function delete_thread(int $threadID)
private function delete_thread(int $threadID): void
{
global $database;
$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]);
}
private function delete_post(int $postID)
private function delete_post(int $postID): void
{
global $database;
$database->execute("DELETE FROM forum_posts WHERE id = :id", ['id'=>$postID]);
}
private function threadExists(int $threadID)
private function threadExists(int $threadID): bool
{
global $database;
$result=$database->get_one("SELECT EXISTS (SELECT * FROM forum_threads WHERE id=:id)", ['id'=>$threadID]);

View File

@ -173,7 +173,7 @@ class ForumTheme extends Themelet
private function make_thread_list($threads, $showAdminOptions)
private function make_thread_list($threads, $showAdminOptions): string
{
$html = "<table id='threadList' class='zebra'>".
"<thead><tr>".
@ -188,7 +188,6 @@ class ForumTheme extends Themelet
$html .= "</tr></thead><tbody>";
$current_post = 0;
foreach ($threads as $thread) {
$oe = ($current_post++ % 2 == 0) ? "even" : "odd";

View File

@ -4,12 +4,12 @@ class FourOhFourInfo extends ExtensionInfo
{
public const KEY = "four_oh_four";
public $key = self::KEY;
public $name = "404 Detector";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $license = self::LICENSE_GPLV2;
public $visibility = self::VISIBLE_HIDDEN;
public $description = "If no other extension puts anything onto the page, show 404";
public $core = true;
public string $key = self::KEY;
public string $name = "404 Detector";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $visibility = self::VISIBLE_HIDDEN;
public string $description = "If no other extension puts anything onto the page, show 404";
public bool $core = true;
}

View File

@ -17,7 +17,7 @@ class FourOhFour extends Extension
}
}
private function count_main($blocks)
private function count_main($blocks): int
{
$n = 0;
foreach ($blocks as $block) {

View File

@ -4,12 +4,12 @@ class GoogleAnalyticsInfo extends ExtensionInfo
{
public const KEY = "google_analytics";
public $key = self::KEY;
public $name = "Google Analytics";
public $url = "http://drudexsoftware.com";
public $authors = ["Drudex Software"=>"support@drudexsoftware.com"];
public $license = self::LICENSE_GPLV2;
public $description = "Integrates Google Analytics tracking";
public $documentation =
public string $key = self::KEY;
public string $name = "Google Analytics";
public string $url = "http://drudexsoftware.com";
public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"];
public string $license = self::LICENSE_GPLV2;
public string $description = "Integrates Google Analytics tracking";
public ?string $documentation =
"User has to enter their Google Analytics ID in the Board Config to use this extension.";
}

View File

@ -23,7 +23,7 @@ class GoogleAnalytics extends Extension
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();</script>");
}

View File

@ -4,12 +4,12 @@ class ArchiveFileHandlerInfo extends ExtensionInfo
{
public const KEY = "handle_archive";
public $key = self::KEY;
public $name = "Handle Archives";
public $url = self::SHIMMIE_URL;
public $authors = self::SHISH_AUTHOR;
public $description = "Allow users to upload archives (zip, etc)";
public $documentation =
public string $key = self::KEY;
public string $name = "Handle Archives";
public string $url = self::SHIMMIE_URL;
public array $authors = self::SHISH_AUTHOR;
public string $description = "Allow users to upload archives (zip, etc)";
public ?string $documentation =
"Note: requires exec() access and an external unzip command
<p>Any command line unzipper should work, some examples:
<p>unzip: <code>unzip -d \"%d\" \"%f\"</code>

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