diff --git a/composer.json b/composer.json index 902eca86..114d990e 100644 --- a/composer.json +++ b/composer.json @@ -43,5 +43,20 @@ "require-dev" : { "phpunit/phpunit" : "6.*" + }, + + "suggest": { + "ext-memcache": "memcache caching", + "ext-memcached": "memcached caching", + "ext-apc": "apc caching", + "ext-redis": "redis caching", + "ext-dom": "some extensions", + "ext-curl": "some extensions", + "ext-ctype": "some extensions", + "ext-json": "some extensions", + "ext-zip": "self-updater extension", + "ext-zlib": "anti-spam", + "ext-xml": "some extensions", + "ext-gd": "GD-based thumbnailing" } } diff --git a/core/database.php b/core/database.php index 9234cfa5..c630c3b6 100644 --- a/core/database.php +++ b/core/database.php @@ -50,7 +50,7 @@ class Database $this->cache = new Cache(CACHE_DSN); } - private function connect_db() + private function connect_db(): void { # FIXME: detect ADODB URI, automatically translate PDO DSN @@ -88,7 +88,7 @@ class Database $this->beginTransaction(); } - private function connect_engine() + private function connect_engine(): void { if (preg_match("/^([^:]*)/", DATABASE_DSN, $matches)) { $db_proto=$matches[1]; @@ -107,7 +107,7 @@ class Database } } - public function beginTransaction() + public function beginTransaction(): void { if ($this->transaction === false) { $this->db->beginTransaction(); @@ -167,7 +167,7 @@ class Database return $this->engine->name; } - private function count_execs(string $sql, array $inputarray) + private function count_execs(string $sql, array $inputarray): void { if ((DEBUG_SQL === true) || (is_null(DEBUG_SQL) && @$_GET['DEBUG_SQL'])) { $sql = trim(preg_replace('/\s+/msi', ' ', $sql)); @@ -189,7 +189,7 @@ class Database } } - private function count_time(string $method, float $start) + private function count_time(string $method, float $start): void { if ((DEBUG_SQL === true) || (is_null(DEBUG_SQL) && @$_GET['DEBUG_SQL'])) { $text = $method.":".(microtime(true) - $start)."\n"; @@ -242,7 +242,7 @@ class Database /** * Execute an SQL query and return a single row. */ - public function get_row(string $query, array $args=[]) + public function get_row(string $query, array $args=[]): ?PDORow { $_start = microtime(true); $row = $this->execute($query, $args)->fetch(); @@ -385,7 +385,7 @@ class MockDatabase extends Database { return $this->_execute($query, $args); } - public function get_row(string $query, array $args=[]) + public function get_row(string $query, array $args=[]): ?PDORow { return $this->_execute($query, $args); } @@ -416,7 +416,7 @@ class MockDatabase extends Database { } - public function connect_engine() + public function connect_engine(): void { } } diff --git a/core/imageboard/image.php b/core/imageboard/image.php index 415d961a..a5d90979 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -71,21 +71,21 @@ class Image } } - public static function by_id(int $id) + public static function by_id(int $id): ?Image { global $database; $row = $database->get_row("SELECT * FROM images WHERE images.id=:id", ["id"=>$id]); return ($row ? new Image($row) : null); } - public static function by_hash(string $hash) + public static function by_hash(string $hash): ?Image { global $database; $row = $database->get_row("SELECT images.* FROM images WHERE hash=:hash", ["hash"=>$hash]); return ($row ? new Image($row) : null); } - public static function by_random(array $tags=[]) + public static function by_random(array $tags=[]): ?Image { $max = Image::count_images($tags); if ($max < 1) { @@ -148,7 +148,7 @@ class Image /* * Accelerator stuff */ - public static function get_acceleratable(array $tags) + public static function get_acceleratable(array $tags): ?array { $ret = [ "yays" => [], @@ -158,7 +158,7 @@ class Image $nays = 0; foreach ($tags as $tag) { if (!preg_match("/^-?[a-zA-Z0-9_-]+$/", $tag)) { - return false; + return null; } if ($tag[0] == "-") { $nays++; @@ -171,10 +171,10 @@ class Image if ($yays > 1 || $nays > 0) { return $ret; } - return false; + return null; } - public static function get_accelerated_result(array $tags, int $offset, int $limit) + public static function get_accelerated_result(array $tags, int $offset, int $limit): ?PDOStatement { global $database; @@ -195,7 +195,7 @@ class Image return $result; } - public static function get_accelerated_count(array $tags) + public static function get_accelerated_count(array $tags): ?int { $req = Image::get_acceleratable($tags); if (!$req) { @@ -336,7 +336,7 @@ class Image /** * Set the image's owner. */ - public function set_owner(User $owner) + public function set_owner(User $owner): void { global $database; if ($owner->id != $this->owner_id) { @@ -514,7 +514,7 @@ class Image return $this->locked; } - public function set_locked(bool $tf) + public function set_locked(bool $tf): void { global $database; $ln = $tf ? "Y" : "N"; @@ -566,7 +566,7 @@ class Image /** * Set the tags for this image. */ - public function set_tags(array $unfiltered_tags) + public function set_tags(array $unfiltered_tags): void { global $database; diff --git a/core/imageboard/misc.php b/core/imageboard/misc.php index cde0d981..5ae727f3 100644 --- a/core/imageboard/misc.php +++ b/core/imageboard/misc.php @@ -9,7 +9,7 @@ * * @throws UploadException */ -function move_upload_to_archive(DataUploadEvent $event) +function move_upload_to_archive(DataUploadEvent $event): void { $target = warehouse_path("images", $event->hash); if (!@copy($event->tmpname, $target)) { diff --git a/core/imageboard/search.php b/core/imageboard/search.php index 6a2bc916..e3c63940 100644 --- a/core/imageboard/search.php +++ b/core/imageboard/search.php @@ -12,18 +12,18 @@ class Querylet $this->variables = $variables; } - public function append(Querylet $querylet) + public function append(Querylet $querylet): void { $this->sql .= $querylet->sql; $this->variables = array_merge($this->variables, $querylet->variables); } - public function append_sql(string $sql) + public function append_sql(string $sql): void { $this->sql .= $sql; } - public function add_variable($var) + public function add_variable($var): void { $this->variables[] = $var; } diff --git a/core/page.php b/core/page.php index 6bd67e75..e9b3384b 100644 --- a/core/page.php +++ b/core/page.php @@ -47,7 +47,7 @@ class Page /** * Set what this page should do; "page", "data", or "redirect". */ - public function set_mode(string $mode) + public function set_mode(string $mode): void { $this->mode = $mode; } @@ -55,7 +55,7 @@ class Page /** * Set the page's MIME type. */ - public function set_type(string $type) + public function set_type(string $type): void { $this->type = $type; } @@ -75,7 +75,7 @@ class Page /** * Set the raw data to be sent. */ - public function set_data(string $data) + public function set_data(string $data): void { $this->data = $data; } @@ -83,7 +83,7 @@ class Page /** * Set the recommended download filename. */ - public function set_filename(string $filename) + public function set_filename(string $filename): void { $this->filename = $filename; } @@ -101,7 +101,7 @@ class Page * Set the URL to redirect to (remember to use make_link() if linking * to a page in the same site). */ - public function set_redirect(string $redirect) + public function set_redirect(string $redirect): void { $this->redirect = $redirect; } @@ -229,7 +229,7 @@ class Page /** * Add a Block of data to the page. */ - public function add_block(Block $block) + public function add_block(Block $block): void { $this->blocks[] = $block; } diff --git a/core/polyfills.php b/core/polyfills.php index 95866525..e543bb5a 100644 --- a/core/polyfills.php +++ b/core/polyfills.php @@ -78,7 +78,7 @@ function ip_in_range(string $IP, string $CIDR): bool * from a patch by Christian Walde; only intended for use in the * "extension manager" extension, but it seems to fit better here */ -function deltree(string $f) +function deltree(string $f): void { //Because Windows (I know, bad excuse) if (PHP_OS === 'WINNT') { @@ -117,7 +117,7 @@ function deltree(string $f) * * from a comment on http://uk.php.net/copy */ -function full_copy(string $source, string $target) +function full_copy(string $source, string $target): void { if (is_dir($source)) { @mkdir($target); diff --git a/core/send_event.php b/core/send_event.php index 52d6dadf..6903a03c 100644 --- a/core/send_event.php +++ b/core/send_event.php @@ -7,7 +7,7 @@ global $_shm_event_listeners; $_shm_event_listeners = []; -function _load_event_listeners() +function _load_event_listeners(): void { global $_shm_event_listeners, $_shm_ctx; @@ -27,7 +27,7 @@ function _load_event_listeners() $_shm_ctx->log_endok(); } -function _set_event_listeners() +function _set_event_listeners(): void { global $_shm_event_listeners; $_shm_event_listeners = []; diff --git a/core/sys_config.php b/core/sys_config.php index 4c6d648e..a2fbefee 100644 --- a/core/sys_config.php +++ b/core/sys_config.php @@ -19,7 +19,7 @@ * */ -function _d(string $name, $value) +function _d(string $name, $value): void { if (!defined($name)) { define($name, $value); diff --git a/core/user.php b/core/user.php index ae3a0a5f..098c7723 100644 --- a/core/user.php +++ b/core/user.php @@ -64,7 +64,7 @@ class User } } - public static function by_session(string $name, string $session) + public static function by_session(string $name, string $session): ?User { global $config, $database; $row = $database->cache->get("user-session:$name-$session"); @@ -80,7 +80,7 @@ class User return is_null($row) ? null : new User($row); } - public static function by_id(int $id) + public static function by_id(int $id): ?User { global $database; if ($id === 1) { @@ -96,14 +96,14 @@ class User return is_null($row) ? null : new User($row); } - public static function by_name(string $name) + public static function by_name(string $name): ?User { global $database; $row = $database->get_row($database->scoreql_to_sql("SELECT * FROM users WHERE SCORE_STRNORM(name) = SCORE_STRNORM(:name)"), ["name"=>$name]); return is_null($row) ? null : new User($row); } - public static function by_name_and_pass(string $name, string $pass) + public static function by_name_and_pass(string $name, string $pass): ?User { $user = User::by_name($name); if ($user) { @@ -149,14 +149,14 @@ class User return ($this->class->name === "admin"); } - public function set_class(string $class) + public function set_class(string $class): void { global $database; $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); } - public function set_name(string $name) + public function set_name(string $name): void { global $database; if (User::by_name($name)) { @@ -168,7 +168,7 @@ class User log_info("core-user", "Changed username for {$old_name} to {$this->name}"); } - public function set_password(string $password) + public function set_password(string $password): void { global $database; $hash = password_hash($password, PASSWORD_BCRYPT); @@ -181,7 +181,7 @@ class User } } - public function set_email(string $address) + public function set_email(string $address): void { global $database; $database->Execute("UPDATE users SET email=:email WHERE id=:id", ["email"=>$address, "id"=>$this->id]); diff --git a/core/util.php b/core/util.php index 4481729e..63e4f725 100644 --- a/core/util.php +++ b/core/util.php @@ -137,7 +137,7 @@ function get_session_ip(Config $config): string * the action actually takes place (eg onWhateverElse) - but much of the time, actions * are taken from within onPageRequest... */ -function flash_message(string $text, string $type="info") +function flash_message(string $text, string $type="info"): void { global $page; $current = $page->get_cookie("flash_message"); @@ -332,7 +332,7 @@ function get_debug_info(): string return $debug; } -function log_slow() +function log_slow(): void { global $_shm_load_start; if (!is_null(SLOW_PAGES)) { @@ -345,7 +345,7 @@ function log_slow() } } -function score_assert_handler($file, $line, $code, $desc = null) +function score_assert_handler($file, $line, $code, $desc = null): void { $file = basename($file); print("Assertion failed at $file:$line: $code ($desc)"); @@ -363,7 +363,7 @@ function score_assert_handler($file, $line, $code, $desc = null) /** @privatesection */ -function _version_check() +function _version_check(): void { if (MIN_PHP_VERSION) { if (version_compare(phpversion(), MIN_PHP_VERSION, ">=") === false) { @@ -378,7 +378,7 @@ date and you should plan on moving elsewhere. } } -function _sanitise_environment() +function _sanitise_environment(): void { global $_shm_ctx; @@ -438,7 +438,7 @@ function _get_themelet_files(string $_theme): array /** * Used to display fatal errors to the web user. */ -function _fatal_error(Exception $e) +function _fatal_error(Exception $e): void { $version = VERSION; $message = $e->getMessage(); diff --git a/ext/artists/theme.php b/ext/artists/theme.php index 825e2f1b..aebd2757 100644 --- a/ext/artists/theme.php +++ b/ext/artists/theme.php @@ -31,38 +31,38 @@ class ArtistsTheme extends Themelet if ($mode == "editor") { $html = "
"; if ($is_admin) { $html .= ""; } $html .= " "; } @@ -297,7 +297,7 @@ class ArtistsTheme extends Themelet @@ -315,7 +315,7 @@ class ArtistsTheme extends Themelet @@ -332,8 +332,8 @@ class ArtistsTheme extends Themelet $html = ' diff --git a/ext/bulk_add/main.php b/ext/bulk_add/main.php index 9634d50e..c1379680 100644 --- a/ext/bulk_add/main.php +++ b/ext/bulk_add/main.php @@ -37,13 +37,9 @@ class BulkAdd extends Extension set_time_limit(0); $bae = new BulkAddEvent($_POST['dir']); send_event($bae); - if (is_array($bae->results)) { - foreach ($bae->results as $result) { - $this->theme->add_status("Adding files", $result); - } - } elseif (strlen($bae->results) > 0) { - $this->theme->add_status("Adding files", $bae->results); - } + foreach ($bae->results as $result) { + $this->theme->add_status("Adding files", $result); + } $this->theme->display_upload_results($page); } } diff --git a/ext/forum/theme.php b/ext/forum/theme.php index de72e63e..d5b8bb79 100644 --- a/ext/forum/theme.php +++ b/ext/forum/theme.php @@ -39,7 +39,7 @@ class ForumTheme extends Themelet$h_lastLetter
";
}
diff --git a/ext/tagger/script.js b/ext/tagger/script.js
index 2fb624a3..05206611 100644
--- a/ext/tagger/script.js
+++ b/ext/tagger/script.js
@@ -57,7 +57,7 @@ var Tagger = {
}
} else if (text) {
// create
- var t_alert = document.createElement("div");
+ t_alert = document.createElement("div");
t_alert.setAttribute("id",id);
t_alert.appendChild(document.createTextNode(text));
this.editor.statusbar.appendChild(t_alert);
diff --git a/ext/tagger/style.css b/ext/tagger/style.css
index 40c79065..799877bd 100644
--- a/ext/tagger/style.css
+++ b/ext/tagger/style.css
@@ -31,7 +31,6 @@
}
#tagger_body {
max-height:175px;
- overflow:auto;
overflow-x:hidden;
overflow-y:auto;
}
diff --git a/ext/tagger/theme.php b/ext/tagger/theme.php
index d2f65efa..6d56811d 100644
--- a/ext/tagger/theme.php
+++ b/ext/tagger/theme.php
@@ -49,15 +49,15 @@ class taggerTheme extends Themelet
Shimmie is unable to find the composer vendor directory.
Have you followed the composer setup instructions found in the
- README?>
+ README?
If you are not intending to do any development with Shimmie, it is highly recommend you use one of the pre-packaged releases diff --git a/themes/danbooru/user.theme.php b/themes/danbooru/user.theme.php index 4ba40100..bdd6a6e7 100644 --- a/themes/danbooru/user.theme.php +++ b/themes/danbooru/user.theme.php @@ -87,7 +87,7 @@ class CustomUserPageTheme extends UserPageTheme $page->add_block(new Block("Signup", $html)); } - public function display_ip_list(Page $page, array $uploads, array $comments) + public function display_ip_list(Page $page, array $uploads, array $comments, array $events) { $html = "
Uploaded from: ";
diff --git a/themes/danbooru2/user.theme.php b/themes/danbooru2/user.theme.php
index 4ba40100..bdd6a6e7 100644
--- a/themes/danbooru2/user.theme.php
+++ b/themes/danbooru2/user.theme.php
@@ -87,7 +87,7 @@ class CustomUserPageTheme extends UserPageTheme
$page->add_block(new Block("Signup", $html));
}
- public function display_ip_list(Page $page, array $uploads, array $comments)
+ public function display_ip_list(Page $page, array $uploads, array $comments, array $events)
{
$html = "
|