diff --git a/composer.lock b/composer.lock index dfaed67ff..b288870e4 100644 --- a/composer.lock +++ b/composer.lock @@ -203,7 +203,7 @@ "version": "1.12.4", "source": { "type": "git", - "url": "https://github.com/jquery/jquery-dist.git", + "url": "git@github.com:jquery/jquery-dist.git", "reference": "5e89585e0121e72ff47de177c5ef604f3089a53d" }, "dist": { @@ -242,7 +242,7 @@ "version": "v2.2.1", "source": { "type": "git", - "url": "https://github.com/js-cookie/js-cookie.git", + "url": "git@github.com:js-cookie/js-cookie.git", "reference": "54962f884e9ae33f93e13ac903ffaf1d5a523598" }, "dist": { @@ -602,12 +602,12 @@ "source": { "type": "git", "url": "https://github.com/predis/predis.git", - "reference": "bb8cce7bcf0d790dd17dde01922230d411efb99b" + "reference": "deee2b6d605eb6401446f6f6354414ab7571a5a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/predis/predis/zipball/bb8cce7bcf0d790dd17dde01922230d411efb99b", - "reference": "bb8cce7bcf0d790dd17dde01922230d411efb99b", + "url": "https://api.github.com/repos/predis/predis/zipball/deee2b6d605eb6401446f6f6354414ab7571a5a0", + "reference": "deee2b6d605eb6401446f6f6354414ab7571a5a0", "shasum": "" }, "require": { @@ -660,7 +660,7 @@ "type": "github" } ], - "time": "2023-01-10T16:48:39+00:00" + "time": "2023-09-19T16:11:21+00:00" }, { "name": "psr/simple-cache", @@ -830,16 +830,16 @@ }, { "name": "shish/ffsphp", - "version": "v1.1.0", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/shish/ffsphp.git", - "reference": "47d7e96a129502275fb8a4ae0c4f36bd3f59e95b" + "reference": "a2a1f0fe59606b90460513b48bacb442630dd253" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/shish/ffsphp/zipball/47d7e96a129502275fb8a4ae0c4f36bd3f59e95b", - "reference": "47d7e96a129502275fb8a4ae0c4f36bd3f59e95b", + "url": "https://api.github.com/repos/shish/ffsphp/zipball/a2a1f0fe59606b90460513b48bacb442630dd253", + "reference": "a2a1f0fe59606b90460513b48bacb442630dd253", "shasum": "" }, "require": { @@ -873,9 +873,9 @@ "homepage": "https://github.com/shish/ffsphp", "support": { "issues": "https://github.com/shish/ffsphp/issues", - "source": "https://github.com/shish/ffsphp/tree/v1.1.0" + "source": "https://github.com/shish/ffsphp/tree/v1.2.0" }, - "time": "2023-02-04T12:34:44+00:00" + "time": "2023-08-28T15:51:16+00:00" }, { "name": "shish/gqla", @@ -932,16 +932,16 @@ }, { "name": "shish/microcrud", - "version": "v2.1.0", + "version": "v2.1.1", "source": { "type": "git", "url": "https://github.com/shish/microcrud.git", - "reference": "c7398edf6b1ed0ee508769a73d656deca8f6a4be" + "reference": "8f0c38af61e2543c2e11ad6face37ae34e4571cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/shish/microcrud/zipball/c7398edf6b1ed0ee508769a73d656deca8f6a4be", - "reference": "c7398edf6b1ed0ee508769a73d656deca8f6a4be", + "url": "https://api.github.com/repos/shish/microcrud/zipball/8f0c38af61e2543c2e11ad6face37ae34e4571cf", + "reference": "8f0c38af61e2543c2e11ad6face37ae34e4571cf", "shasum": "" }, "require": { @@ -981,9 +981,9 @@ ], "support": { "issues": "https://github.com/shish/microcrud/issues", - "source": "https://github.com/shish/microcrud/tree/v2.1.0" + "source": "https://github.com/shish/microcrud/tree/v2.1.1" }, - "time": "2023-02-04T13:09:53+00:00" + "time": "2023-11-11T21:25:53+00:00" }, { "name": "shish/microhtml", @@ -1121,16 +1121,16 @@ }, { "name": "webonyx/graphql-php", - "version": "v15.4.0", + "version": "v15.7.0", "source": { "type": "git", "url": "https://github.com/webonyx/graphql-php.git", - "reference": "99290f7945a5b39ad823f7600fa196de62597e9d" + "reference": "44ff70977ee020c0b24bfdfaf947be56943de505" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/99290f7945a5b39ad823f7600fa196de62597e9d", - "reference": "99290f7945a5b39ad823f7600fa196de62597e9d", + "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/44ff70977ee020c0b24bfdfaf947be56943de505", + "reference": "44ff70977ee020c0b24bfdfaf947be56943de505", "shasum": "" }, "require": { @@ -1141,20 +1141,21 @@ "require-dev": { "amphp/amp": "^2.6", "amphp/http-server": "^2.1", - "dms/phpunit-arraysubset-asserts": "^0.4", + "dms/phpunit-arraysubset-asserts": "dev-master", "ergebnis/composer-normalize": "^2.28", - "mll-lab/php-cs-fixer-config": "^5.0", + "friendsofphp/php-cs-fixer": "3.30.0", + "mll-lab/php-cs-fixer-config": "^5", "nyholm/psr7": "^1.5", "phpbench/phpbench": "^1.2", "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "1.10.15", - "phpstan/phpstan-phpunit": "1.3.11", + "phpstan/phpstan": "1.10.37", + "phpstan/phpstan-phpunit": "1.3.14", "phpstan/phpstan-strict-rules": "1.5.1", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^9.5 || ^10", "psr/http-message": "^1 || ^2", "react/http": "^1.6", "react/promise": "^2.9", - "rector/rector": "^0.16.0", + "rector/rector": "^0.18", "symfony/polyfill-php81": "^1.23", "symfony/var-exporter": "^5 || ^6", "thecodingmachine/safe": "^1.3 || ^2" @@ -1182,7 +1183,7 @@ ], "support": { "issues": "https://github.com/webonyx/graphql-php/issues", - "source": "https://github.com/webonyx/graphql-php/tree/v15.4.0" + "source": "https://github.com/webonyx/graphql-php/tree/v15.7.0" }, "funding": [ { @@ -1190,7 +1191,7 @@ "type": "open_collective" } ], - "time": "2023-05-11T10:26:08+00:00" + "time": "2023-10-04T09:10:34+00:00" } ], "packages-dev": [ @@ -1200,12 +1201,12 @@ "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9", + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9", "shasum": "" }, "require": { @@ -1248,7 +1249,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.0" + "source": "https://github.com/composer/pcre/tree/3.1.1" }, "funding": [ { @@ -1264,7 +1265,7 @@ "type": "tidelift" } ], - "time": "2022-11-17T09:50:14+00:00" + "time": "2023-10-11T07:11:09+00:00" }, { "name": "composer/semver", @@ -1272,12 +1273,12 @@ "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "fa1ec24f0ab1efe642671ec15c51a3ab879f59bf" + "reference": "1d09200268e7d1052ded8e5da9c73c96a63d18f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/fa1ec24f0ab1efe642671ec15c51a3ab879f59bf", - "reference": "fa1ec24f0ab1efe642671ec15c51a3ab879f59bf", + "url": "https://api.github.com/repos/composer/semver/zipball/1d09200268e7d1052ded8e5da9c73c96a63d18f5", + "reference": "1d09200268e7d1052ded8e5da9c73c96a63d18f5", "shasum": "" }, "require": { @@ -1346,7 +1347,7 @@ "type": "tidelift" } ], - "time": "2023-01-13T15:47:53+00:00" + "time": "2023-08-31T12:20:31+00:00" }, { "name": "composer/xdebug-handler", @@ -1420,12 +1421,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "4b68cf86b766ec429f4f68af648817cdfb360582" + "reference": "94f40ad7ecbc6931958faa8a57c48dce5da2b468" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/4b68cf86b766ec429f4f68af648817cdfb360582", - "reference": "4b68cf86b766ec429f4f68af648817cdfb360582", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/94f40ad7ecbc6931958faa8a57c48dce5da2b468", + "reference": "94f40ad7ecbc6931958faa8a57c48dce5da2b468", "shasum": "" }, "require": { @@ -1489,78 +1490,36 @@ "issues": "https://github.com/doctrine/annotations/issues", "source": "https://github.com/doctrine/annotations/tree/2.0.x" }, - "time": "2023-03-27T17:43:32+00:00" - }, - { - "name": "doctrine/deprecations", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/deprecations.git", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", - "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", - "shasum": "" - }, - "require": { - "php": "^7.1|^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9", - "phpunit/phpunit": "^7.5|^8.5|^9.5", - "psr/log": "^1|^2|^3" - }, - "suggest": { - "psr/log": "Allows logging deprecations via PSR-3 logger implementation" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", - "homepage": "https://www.doctrine-project.org/", - "support": { - "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.0.0" - }, - "time": "2022-05-02T15:47:09+00:00" + "time": "2023-08-23T17:36:07+00:00" }, { "name": "doctrine/instantiator", - "version": "1.5.x-dev", + "version": "2.0.x-dev", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + "reference": "f49f6a836a816609c853718ba2ea422dc18a8e4a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f49f6a836a816609c853718ba2ea422dc18a8e4a", + "reference": "f49f6a836a816609c853718ba2ea422dc18a8e4a", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^11", + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.30 || ^5.4" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^10.1.0", + "vimeo/psalm": "^5.4" }, + "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -1586,7 +1545,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + "source": "https://github.com/doctrine/instantiator/tree/2.0.x" }, "funding": [ { @@ -1602,34 +1561,32 @@ "type": "tidelift" } ], - "time": "2022-12-30T00:15:36+00:00" + "time": "2023-08-24T20:23:35+00:00" }, { "name": "doctrine/lexer", - "version": "2.1.x-dev", + "version": "3.1.x-dev", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "e74756f7517d72c238b9163fcd1ed54eb1f92bd0" + "reference": "0d54c073afb397d5896df60cc34170cf37dfad5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/e74756f7517d72c238b9163fcd1ed54eb1f92bd0", - "reference": "e74756f7517d72c238b9163fcd1ed54eb1f92bd0", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/0d54c073afb397d5896df60cc34170cf37dfad5e", + "reference": "0d54c073afb397d5896df60cc34170cf37dfad5e", "shasum": "" }, "require": { - "doctrine/deprecations": "^1.0", - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^10", - "phpstan/phpstan": "^1.3", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.9", + "phpunit/phpunit": "^9.5", "psalm/plugin-phpunit": "^0.18.3", - "vimeo/psalm": "^4.11 || ^5.0" + "vimeo/psalm": "^5.0" }, - "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -1665,7 +1622,7 @@ ], "support": { "issues": "https://github.com/doctrine/lexer/issues", - "source": "https://github.com/doctrine/lexer/tree/2.1.x" + "source": "https://github.com/doctrine/lexer/tree/3.1.x" }, "funding": [ { @@ -1681,27 +1638,25 @@ "type": "tidelift" } ], - "time": "2022-12-29T09:22:42+00:00" + "time": "2023-07-05T07:23:35+00:00" }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.17.0", + "version": "v3.38.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "3f0ed862f22386c55a767461ef5083bddceeed79" + "reference": "7e6070026e76aa09d77a47519625c86593fb8e31" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/3f0ed862f22386c55a767461ef5083bddceeed79", - "reference": "3f0ed862f22386c55a767461ef5083bddceeed79", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/7e6070026e76aa09d77a47519625c86593fb8e31", + "reference": "7e6070026e76aa09d77a47519625c86593fb8e31", "shasum": "" }, "require": { "composer/semver": "^3.3", "composer/xdebug-handler": "^3.0.3", - "doctrine/annotations": "^2", - "doctrine/lexer": "^2 || ^3", "ext-json": "*", "ext-tokenizer": "*", "php": "^7.4 || ^8.0", @@ -1718,6 +1673,7 @@ "symfony/stopwatch": "^5.4 || ^6.0" }, "require-dev": { + "facile-it/paraunit": "^1.3 || ^2.0", "justinrainbow/json-schema": "^5.2", "keradus/cli-executor": "^2.0", "mikey179/vfsstream": "^1.6.11", @@ -1728,8 +1684,6 @@ "phpspec/prophecy": "^1.16", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.5", - "phpunitgoodpractices/polyfill": "^1.6", - "phpunitgoodpractices/traits": "^1.9.2", "symfony/phpunit-bridge": "^6.2.3", "symfony/yaml": "^5.4 || ^6.0" }, @@ -1769,7 +1723,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.17.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.38.0" }, "funding": [ { @@ -1777,26 +1731,26 @@ "type": "github" } ], - "time": "2023-05-22T19:59:32+00:00" + "time": "2023-11-07T08:44:54+00:00" }, { "name": "guzzlehttp/guzzle", - "version": "7.7.x-dev", + "version": "7.9.x-dev", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5" + "reference": "d95d9ab74822c2ca06b31477cd6775a4a299b8e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/fb7566caccf22d74d1ab270de3551f72a58399f5", - "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d95d9ab74822c2ca06b31477cd6775a4a299b8e8", + "reference": "d95d9ab74822c2ca06b31477cd6775a4a299b8e8", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.5.3 || ^2.0", - "guzzlehttp/psr7": "^1.9.1 || ^2.4.5", + "guzzlehttp/promises": "^1.5.3 || ^2.0.1", + "guzzlehttp/psr7": "^1.9.1 || ^2.5.1", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", "symfony/deprecation-contracts": "^2.2 || ^3.0" @@ -1817,7 +1771,6 @@ "ext-intl": "Required for Internationalized Domain Name (IDN) support", "psr/log": "Required for using the Log middleware" }, - "default-branch": true, "type": "library", "extra": { "bamarni-bin": { @@ -1888,7 +1841,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.7.0" + "source": "https://github.com/guzzle/guzzle/tree/7.8" }, "funding": [ { @@ -1904,7 +1857,7 @@ "type": "tidelift" } ], - "time": "2023-05-21T14:04:53+00:00" + "time": "2023-09-11T09:12:01+00:00" }, { "name": "guzzlehttp/promises", @@ -1912,12 +1865,12 @@ "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "4a94655427efd6906ed3eb628c79693291264713" + "reference": "71b12f952d8be69a239989db2fe08314a5189e3b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/4a94655427efd6906ed3eb628c79693291264713", - "reference": "4a94655427efd6906ed3eb628c79693291264713", + "url": "https://api.github.com/repos/guzzle/promises/zipball/71b12f952d8be69a239989db2fe08314a5189e3b", + "reference": "71b12f952d8be69a239989db2fe08314a5189e3b", "shasum": "" }, "require": { @@ -1988,7 +1941,7 @@ "type": "tidelift" } ], - "time": "2023-05-21T19:15:14+00:00" + "time": "2023-08-27T10:15:36+00:00" }, { "name": "guzzlehttp/psr7", @@ -1996,12 +1949,12 @@ "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "b635f279edd83fc275f822a1188157ffea568ff6" + "reference": "38ef514a6c21335f29d9be64b097d2582ecbf8e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/b635f279edd83fc275f822a1188157ffea568ff6", - "reference": "b635f279edd83fc275f822a1188157ffea568ff6", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/38ef514a6c21335f29d9be64b097d2582ecbf8e4", + "reference": "38ef514a6c21335f29d9be64b097d2582ecbf8e4", "shasum": "" }, "require": { @@ -2022,6 +1975,7 @@ "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, + "default-branch": true, "type": "library", "extra": { "bamarni-bin": { @@ -2088,7 +2042,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.5.0" + "source": "https://github.com/guzzle/psr7/tree/2.6" }, "funding": [ { @@ -2104,7 +2058,7 @@ "type": "tidelift" } ], - "time": "2023-04-17T16:11:26+00:00" + "time": "2023-09-10T16:11:14+00:00" }, { "name": "jms/metadata", @@ -2112,19 +2066,19 @@ "source": { "type": "git", "url": "https://github.com/schmittjoh/metadata.git", - "reference": "7ca240dcac0c655eb15933ee55736ccd2ea0d7a6" + "reference": "1e72a1482cb6faa15915ba79086fa42a0ed2ec54" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/metadata/zipball/7ca240dcac0c655eb15933ee55736ccd2ea0d7a6", - "reference": "7ca240dcac0c655eb15933ee55736ccd2ea0d7a6", + "url": "https://api.github.com/repos/schmittjoh/metadata/zipball/1e72a1482cb6faa15915ba79086fa42a0ed2ec54", + "reference": "1e72a1482cb6faa15915ba79086fa42a0ed2ec54", "shasum": "" }, "require": { "php": "^7.2|^8.0" }, "require-dev": { - "doctrine/cache": "^1.0", + "doctrine/cache": "^1.0|^2.0", "doctrine/coding-standard": "^8.0", "mikey179/vfsstream": "^1.6.7", "phpunit/phpunit": "^8.5|^9.0", @@ -2167,9 +2121,9 @@ ], "support": { "issues": "https://github.com/schmittjoh/metadata/issues", - "source": "https://github.com/schmittjoh/metadata/tree/2.8.0" + "source": "https://github.com/schmittjoh/metadata/tree/master" }, - "time": "2023-02-15T13:44:18+00:00" + "time": "2023-08-04T08:12:29+00:00" }, { "name": "jms/serializer", @@ -2177,43 +2131,43 @@ "source": { "type": "git", "url": "https://github.com/schmittjoh/serializer.git", - "reference": "d5cc4674015e362370cbd370948e2ae03496a7cc" + "reference": "f24027583f8ad3c1789bff412b039013132316ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/d5cc4674015e362370cbd370948e2ae03496a7cc", - "reference": "d5cc4674015e362370cbd370948e2ae03496a7cc", + "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/f24027583f8ad3c1789bff412b039013132316ac", + "reference": "f24027583f8ad3c1789bff412b039013132316ac", "shasum": "" }, "require": { - "doctrine/annotations": "^1.13 || ^2.0", - "doctrine/instantiator": "^1.0.3", - "doctrine/lexer": "^1.1 || ^2", + "doctrine/annotations": "^1.14 || ^2.0", + "doctrine/instantiator": "^1.3.1 || ^2.0", + "doctrine/lexer": "^2.0 || ^3.0", "jms/metadata": "^2.6", - "php": "^7.2||^8.0", - "phpstan/phpdoc-parser": "^0.4 || ^0.5 || ^1.0" + "php": "^7.2 || ^8.0", + "phpstan/phpdoc-parser": "^1.20" }, "require-dev": { - "doctrine/coding-standard": "^8.1", - "doctrine/orm": "~2.1", - "doctrine/persistence": "^1.3.3|^2.0|^3.0", - "doctrine/phpcr-odm": "^1.3|^2.0", + "doctrine/coding-standard": "^12.0", + "doctrine/orm": "^2.14", + "doctrine/persistence": "^2.5.2 || ^3.0", + "doctrine/phpcr-odm": "^1.5.2 || ^2.0", "ext-pdo_sqlite": "*", - "jackalope/jackalope-doctrine-dbal": "^1.1.5", - "ocramius/proxy-manager": "^1.0|^2.0", + "jackalope/jackalope-doctrine-dbal": "^1.3", + "ocramius/proxy-manager": "^1.0 || ^2.0", "phpbench/phpbench": "^1.0", "phpstan/phpstan": "^1.0.2", - "phpunit/phpunit": "^8.5.21||^9.0||^10.0", - "psr/container": "^1.0|^2.0", - "symfony/dependency-injection": "^3.0|^4.0|^5.0|^6.0", - "symfony/expression-language": "^3.2|^4.0|^5.0|^6.0", - "symfony/filesystem": "^3.0|^4.0|^5.0|^6.0", - "symfony/form": "^3.0|^4.0|^5.0|^6.0", - "symfony/translation": "^3.0|^4.0|^5.0|^6.0", - "symfony/uid": "^5.1|^6.0", - "symfony/validator": "^3.1.9|^4.0|^5.0|^6.0", - "symfony/yaml": "^3.3|^4.0|^5.0|^6.0", - "twig/twig": "~1.34|~2.4|^3.0" + "phpunit/phpunit": "^8.5.21 || ^9.0 || ^10.0", + "psr/container": "^1.0 || ^2.0", + "symfony/dependency-injection": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/expression-language": "^3.2 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/filesystem": "^4.2 || ^5.0 || ^6.0 || ^7.0", + "symfony/form": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/translation": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/uid": "^5.1 || ^6.0 || ^7.0", + "symfony/validator": "^3.1.9 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "twig/twig": "^1.34 || ^2.4 || ^3.0" }, "suggest": { "doctrine/collections": "Required if you like to use doctrine collection types as ArrayCollection.", @@ -2266,7 +2220,7 @@ "type": "github" } ], - "time": "2023-05-18T04:58:29+00:00" + "time": "2023-10-29T15:36:01+00:00" }, { "name": "myclabs/deep-copy", @@ -2274,12 +2228,12 @@ "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "928a96f585b86224ebc78f8f09d0482cf15b04f5" + "reference": "202aaf6b7c2e1e0a622b0298e9f3f537e4d84018" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/928a96f585b86224ebc78f8f09d0482cf15b04f5", - "reference": "928a96f585b86224ebc78f8f09d0482cf15b04f5", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/202aaf6b7c2e1e0a622b0298e9f3f537e4d84018", + "reference": "202aaf6b7c2e1e0a622b0298e9f3f537e4d84018", "shasum": "" }, "require": { @@ -2327,7 +2281,7 @@ "type": "tidelift" } ], - "time": "2023-03-08T17:24:01+00:00" + "time": "2023-11-01T08:01:43+00:00" }, { "name": "nikic/php-parser", @@ -2335,12 +2289,12 @@ "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "c9e5a13d68486e9fd75f9be1b4639644e54e7f4f" + "reference": "402b6cf3452c21c58aa11d9549cee6205d14e347" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c9e5a13d68486e9fd75f9be1b4639644e54e7f4f", - "reference": "c9e5a13d68486e9fd75f9be1b4639644e54e7f4f", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/402b6cf3452c21c58aa11d9549cee6205d14e347", + "reference": "402b6cf3452c21c58aa11d9549cee6205d14e347", "shasum": "" }, "require": { @@ -2351,7 +2305,6 @@ "ircmaxell/php-yacc": "^0.0.7", "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" }, - "default-branch": true, "bin": [ "bin/php-parse" ], @@ -2384,7 +2337,7 @@ "issues": "https://github.com/nikic/PHP-Parser/issues", "source": "https://github.com/nikic/PHP-Parser/tree/4.x" }, - "time": "2023-05-21T19:22:47+00:00" + "time": "2023-11-01T20:31:02+00:00" }, { "name": "phar-io/manifest", @@ -2392,12 +2345,12 @@ "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "36d8a21e851a9512db2b086dc5ac2c61308f0138" + "reference": "67729272c564ab9f953c81f48db44e8b1cb1e1c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/36d8a21e851a9512db2b086dc5ac2c61308f0138", - "reference": "36d8a21e851a9512db2b086dc5ac2c61308f0138", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/67729272c564ab9f953c81f48db44e8b1cb1e1c3", + "reference": "67729272c564ab9f953c81f48db44e8b1cb1e1c3", "shasum": "" }, "require": { @@ -2406,7 +2359,7 @@ "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", - "php": "^7.2 || ^8.0" + "php": "^7.3 || ^8.0" }, "default-branch": true, "type": "library", @@ -2452,7 +2405,7 @@ "type": "github" } ], - "time": "2022-02-21T19:55:33+00:00" + "time": "2023-06-01T14:19:47+00:00" }, { "name": "phar-io/version", @@ -2583,22 +2536,23 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.21.x-dev", + "version": "1.24.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "7f78fd1ff463a7884a331fdb84a25f724dbfd9ea" + "reference": "bcad8d995980440892759db0c32acae7c8e79442" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/7f78fd1ff463a7884a331fdb84a25f724dbfd9ea", - "reference": "7f78fd1ff463a7884a331fdb84a25f724dbfd9ea", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442", + "reference": "bcad8d995980440892759db0c32acae7c8e79442", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "require-dev": { + "doctrine/annotations": "^2.0", "nikic/php-parser": "^4.15", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", @@ -2608,7 +2562,6 @@ "phpunit/phpunit": "^9.5", "symfony/process": "^5.2" }, - "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -2624,9 +2577,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.21.x" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2" }, - "time": "2023-05-17T16:44:57+00:00" + "time": "2023-09-26T12:28:12+00:00" }, { "name": "phpstan/phpstan", @@ -2634,12 +2587,12 @@ "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "42afb02dce13d12623865f068f32ad340ee8ed6f" + "reference": "2fa2aa0de39a1ac2d44d3a0a03f7586720882635" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/42afb02dce13d12623865f068f32ad340ee8ed6f", - "reference": "42afb02dce13d12623865f068f32ad340ee8ed6f", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2fa2aa0de39a1ac2d44d3a0a03f7586720882635", + "reference": "2fa2aa0de39a1ac2d44d3a0a03f7586720882635", "shasum": "" }, "require": { @@ -2688,7 +2641,7 @@ "type": "tidelift" } ], - "time": "2023-05-25T11:20:07+00:00" + "time": "2023-11-11T20:39:57+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2696,12 +2649,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "100663232669bdacd3ac18f4cc12c38beec9aff1" + "reference": "00bc23209e885ae1aab33c9a2303b0eb8ebd5c28" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/100663232669bdacd3ac18f4cc12c38beec9aff1", - "reference": "100663232669bdacd3ac18f4cc12c38beec9aff1", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/00bc23209e885ae1aab33c9a2303b0eb8ebd5c28", + "reference": "00bc23209e885ae1aab33c9a2303b0eb8ebd5c28", "shasum": "" }, "require": { @@ -2766,7 +2719,7 @@ "type": "github" } ], - "time": "2023-05-25T06:20:28+00:00" + "time": "2023-11-09T06:48:38+00:00" }, { "name": "phpunit/php-file-iterator", @@ -3015,12 +2968,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9d8ffd638716761de07b60262fceb553cb4afcd9" + "reference": "3e2444b311b9bcca7c8b5294dc0c27a3fec0832a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9d8ffd638716761de07b60262fceb553cb4afcd9", - "reference": "9d8ffd638716761de07b60262fceb553cb4afcd9", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3e2444b311b9bcca7c8b5294dc0c27a3fec0832a", + "reference": "3e2444b311b9bcca7c8b5294dc0c27a3fec0832a", "shasum": "" }, "require": { @@ -3035,7 +2988,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-code-coverage": "^9.2.28", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -3110,7 +3063,7 @@ "type": "tidelift" } ], - "time": "2023-05-25T06:23:23+00:00" + "time": "2023-11-09T06:47:38+00:00" }, { "name": "psr/cache", @@ -3171,12 +3124,12 @@ "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "90db7b9ac2a2c5b849fcb69dde58f3ae182c68f5" + "reference": "707984727bd5b2b670e59559d3ed2500240cf875" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/90db7b9ac2a2c5b849fcb69dde58f3ae182c68f5", - "reference": "90db7b9ac2a2c5b849fcb69dde58f3ae182c68f5", + "url": "https://api.github.com/repos/php-fig/container/zipball/707984727bd5b2b670e59559d3ed2500240cf875", + "reference": "707984727bd5b2b670e59559d3ed2500240cf875", "shasum": "" }, "require": { @@ -3215,9 +3168,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/master" + "source": "https://github.com/php-fig/container" }, - "time": "2022-07-19T17:36:59+00:00" + "time": "2023-09-22T11:11:30+00:00" }, { "name": "psr/event-dispatcher", @@ -3225,12 +3178,12 @@ "source": { "type": "git", "url": "https://github.com/php-fig/event-dispatcher.git", - "reference": "e275e2d67d53964a3f13e056886ecd769edee021" + "reference": "977ffcf551e3bfb73d90aac3e8e1583fd8d2f89a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/e275e2d67d53964a3f13e056886ecd769edee021", - "reference": "e275e2d67d53964a3f13e056886ecd769edee021", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/977ffcf551e3bfb73d90aac3e8e1583fd8d2f89a", + "reference": "977ffcf551e3bfb73d90aac3e8e1583fd8d2f89a", "shasum": "" }, "require": { @@ -3268,9 +3221,9 @@ "psr-14" ], "support": { - "source": "https://github.com/php-fig/event-dispatcher/tree/master" + "source": "https://github.com/php-fig/event-dispatcher" }, - "time": "2022-06-29T17:22:39+00:00" + "time": "2023-09-22T11:10:57+00:00" }, { "name": "psr/http-client", @@ -3278,12 +3231,12 @@ "source": { "type": "git", "url": "https://github.com/php-fig/http-client.git", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31" + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/0955afe48220520692d2d09f7ab7e0f93ffd6a31", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", "shasum": "" }, "require": { @@ -3321,9 +3274,9 @@ "psr-18" ], "support": { - "source": "https://github.com/php-fig/http-client/tree/1.0.2" + "source": "https://github.com/php-fig/http-client" }, - "time": "2023-04-10T20:12:12+00:00" + "time": "2023-09-23T14:17:50+00:00" }, { "name": "psr/http-factory", @@ -3331,12 +3284,12 @@ "source": { "type": "git", "url": "https://github.com/php-fig/http-factory.git", - "reference": "6d70f402f0eddb2b154b22950b5381bbf5b28469" + "reference": "7037f4b0950474e9d1350e8df89b15f1842085f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/6d70f402f0eddb2b154b22950b5381bbf5b28469", - "reference": "6d70f402f0eddb2b154b22950b5381bbf5b28469", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/7037f4b0950474e9d1350e8df89b15f1842085f6", + "reference": "7037f4b0950474e9d1350e8df89b15f1842085f6", "shasum": "" }, "require": { @@ -3377,9 +3330,9 @@ "response" ], "support": { - "source": "https://github.com/php-fig/http-factory/tree/master" + "source": "https://github.com/php-fig/http-factory" }, - "time": "2023-05-17T18:32:11+00:00" + "time": "2023-09-22T11:16:44+00:00" }, { "name": "psr/http-message", @@ -4086,12 +4039,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" + "reference": "bde739e7565280bda77be70044ac1047bc007e34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", + "reference": "bde739e7565280bda77be70044ac1047bc007e34", "shasum": "" }, "require": { @@ -4134,7 +4087,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0" }, "funding": [ { @@ -4142,7 +4095,7 @@ "type": "github" } ], - "time": "2022-02-14T08:28:10+00:00" + "time": "2023-08-02T09:26:13+00:00" }, { "name": "sebastian/lines-of-code", @@ -4546,12 +4499,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "6d340bfbfc082c9ed7eec4844f12132a26b2d344" + "reference": "380ae25f02e34809fba16fa387191f1da9852778" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/6d340bfbfc082c9ed7eec4844f12132a26b2d344", - "reference": "6d340bfbfc082c9ed7eec4844f12132a26b2d344", + "url": "https://api.github.com/repos/symfony/console/zipball/380ae25f02e34809fba16fa387191f1da9852778", + "reference": "380ae25f02e34809fba16fa387191f1da9852778", "shasum": "" }, "require": { @@ -4576,8 +4529,12 @@ "symfony/config": "^5.4|^6.0|^7.0", "symfony/dependency-injection": "^5.4|^6.0|^7.0", "symfony/event-dispatcher": "^5.4|^6.0|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", "symfony/lock": "^5.4|^6.0|^7.0", + "symfony/messenger": "^5.4|^6.0|^7.0", "symfony/process": "^5.4|^6.0|^7.0", + "symfony/stopwatch": "^5.4|^6.0|^7.0", "symfony/var-dumper": "^5.4|^6.0|^7.0" }, "type": "library", @@ -4628,11 +4585,11 @@ "type": "tidelift" } ], - "time": "2023-05-23T16:34:37+00:00" + "time": "2023-11-02T13:23:55+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "3.4.x-dev", + "version": "dev-main", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", @@ -4647,6 +4604,7 @@ "require": { "php": ">=8.1" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -4679,7 +4637,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/3.4" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" }, "funding": [ { @@ -4703,12 +4661,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "9ebe352542105f5f7186610a83deb18b90fae3d3" + "reference": "d76d2632cfc2206eecb5ad2b26cd5934082941b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9ebe352542105f5f7186610a83deb18b90fae3d3", - "reference": "9ebe352542105f5f7186610a83deb18b90fae3d3", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d76d2632cfc2206eecb5ad2b26cd5934082941b6", + "reference": "d76d2632cfc2206eecb5ad2b26cd5934082941b6", "shasum": "" }, "require": { @@ -4775,11 +4733,11 @@ "type": "tidelift" } ], - "time": "2023-05-23T16:34:37+00:00" + "time": "2023-07-27T06:52:43+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "3.4.x-dev", + "version": "dev-main", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", @@ -4795,6 +4753,7 @@ "php": ">=8.1", "psr/event-dispatcher": "^1" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -4835,7 +4794,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/3.4" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.3.0" }, "funding": [ { @@ -4859,12 +4818,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "c2196aa8b563ed0bc645ee316c40ead823adfead" + "reference": "952a8cb588c3bc6ce76f6023000fb932f16a6e59" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/c2196aa8b563ed0bc645ee316c40ead823adfead", - "reference": "c2196aa8b563ed0bc645ee316c40ead823adfead", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/952a8cb588c3bc6ce76f6023000fb932f16a6e59", + "reference": "952a8cb588c3bc6ce76f6023000fb932f16a6e59", "shasum": "" }, "require": { @@ -4898,7 +4857,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.3.0-RC1" + "source": "https://github.com/symfony/filesystem/tree/6.4" }, "funding": [ { @@ -4914,7 +4873,7 @@ "type": "tidelift" } ], - "time": "2023-04-28T16:05:33+00:00" + "time": "2023-07-26T17:27:13+00:00" }, { "name": "symfony/finder", @@ -4922,12 +4881,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "1bb60aa99f06979e6078007a812eb7c5ffc8efc2" + "reference": "11d736e97f116ac375a81f96e662911a34cd50ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/1bb60aa99f06979e6078007a812eb7c5ffc8efc2", - "reference": "1bb60aa99f06979e6078007a812eb7c5ffc8efc2", + "url": "https://api.github.com/repos/symfony/finder/zipball/11d736e97f116ac375a81f96e662911a34cd50ce", + "reference": "11d736e97f116ac375a81f96e662911a34cd50ce", "shasum": "" }, "require": { @@ -4978,7 +4937,7 @@ "type": "tidelift" } ], - "time": "2023-05-23T16:34:37+00:00" + "time": "2023-10-31T17:30:12+00:00" }, { "name": "symfony/options-resolver", @@ -4986,12 +4945,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "a10f19f5198d589d5c33333cffe98dc9820332dd" + "reference": "22301f0e7fdeaacc14318928612dee79be99860e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/a10f19f5198d589d5c33333cffe98dc9820332dd", - "reference": "a10f19f5198d589d5c33333cffe98dc9820332dd", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/22301f0e7fdeaacc14318928612dee79be99860e", + "reference": "22301f0e7fdeaacc14318928612dee79be99860e", "shasum": "" }, "require": { @@ -5029,7 +4988,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v6.3.0-RC1" + "source": "https://github.com/symfony/options-resolver/tree/6.4" }, "funding": [ { @@ -5045,11 +5004,11 @@ "type": "tidelift" } ], - "time": "2023-05-12T14:21:09+00:00" + "time": "2023-08-08T10:16:24+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "dev-main", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -5112,7 +5071,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/main" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" }, "funding": [ { @@ -5132,7 +5091,7 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "dev-main", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", @@ -5194,7 +5153,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/main" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.28.0" }, "funding": [ { @@ -5214,7 +5173,7 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "dev-main", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -5279,7 +5238,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/main" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" }, "funding": [ { @@ -5299,16 +5258,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "dev-main", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "f9c7affe77a00ae32ca127ca6833d034e6d33f25" + "reference": "42292d99c55abe617799667f454222c54c60e229" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f9c7affe77a00ae32ca127ca6833d034e6d33f25", - "reference": "f9c7affe77a00ae32ca127ca6833d034e6d33f25", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", + "reference": "42292d99c55abe617799667f454222c54c60e229", "shasum": "" }, "require": { @@ -5363,7 +5322,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/main" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" }, "funding": [ { @@ -5379,11 +5338,11 @@ "type": "tidelift" } ], - "time": "2023-01-30T17:25:47+00:00" + "time": "2023-07-28T09:04:16+00:00" }, { "name": "symfony/polyfill-php80", - "version": "dev-main", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", @@ -5447,7 +5406,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/main" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" }, "funding": [ { @@ -5467,7 +5426,7 @@ }, { "name": "symfony/polyfill-php81", - "version": "dev-main", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", @@ -5527,7 +5486,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/main" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.28.0" }, "funding": [ { @@ -5551,12 +5510,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "8741e3ed7fe2e91ec099e02446fb86667a0f1628" + "reference": "a91571ff5df8825fcc74569d99cddc7242f479b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/8741e3ed7fe2e91ec099e02446fb86667a0f1628", - "reference": "8741e3ed7fe2e91ec099e02446fb86667a0f1628", + "url": "https://api.github.com/repos/symfony/process/zipball/a91571ff5df8825fcc74569d99cddc7242f479b7", + "reference": "a91571ff5df8825fcc74569d99cddc7242f479b7", "shasum": "" }, "require": { @@ -5588,7 +5547,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.3.0-RC1" + "source": "https://github.com/symfony/process/tree/6.4" }, "funding": [ { @@ -5604,20 +5563,20 @@ "type": "tidelift" } ], - "time": "2023-05-19T08:06:44+00:00" + "time": "2023-11-04T20:16:32+00:00" }, { "name": "symfony/service-contracts", - "version": "3.4.x-dev", + "version": "dev-main", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4" + "reference": "a4025a1c812c231d88ed0780e866b0cc644f4a84" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", - "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a4025a1c812c231d88ed0780e866b0cc644f4a84", + "reference": "a4025a1c812c231d88ed0780e866b0cc644f4a84", "shasum": "" }, "require": { @@ -5627,6 +5586,7 @@ "conflict": { "ext-psr": "<1.1|>=2" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -5670,7 +5630,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/3.4" + "source": "https://github.com/symfony/service-contracts/tree/main" }, "funding": [ { @@ -5686,7 +5646,7 @@ "type": "tidelift" } ], - "time": "2023-05-23T14:45:45+00:00" + "time": "2023-07-29T13:12:44+00:00" }, { "name": "symfony/stopwatch", @@ -5756,12 +5716,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "89bc6d5dcc94c89781e1f986e4d01b7ee91d684b" + "reference": "afab7ffd61240b6fee63ea207b2b98c84f12791e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/89bc6d5dcc94c89781e1f986e4d01b7ee91d684b", - "reference": "89bc6d5dcc94c89781e1f986e4d01b7ee91d684b", + "url": "https://api.github.com/repos/symfony/string/zipball/afab7ffd61240b6fee63ea207b2b98c84f12791e", + "reference": "afab7ffd61240b6fee63ea207b2b98c84f12791e", "shasum": "" }, "require": { @@ -5834,7 +5794,7 @@ "type": "tidelift" } ], - "time": "2023-05-23T16:34:37+00:00" + "time": "2023-11-09T08:51:37+00:00" }, { "name": "theseer/tokenizer", diff --git a/core/basepage.php b/core/basepage.php index c17289557..a691336a8 100644 --- a/core/basepage.php +++ b/core/basepage.php @@ -260,7 +260,7 @@ public function send_headers(): void */ public function display(): void { - if ($this->mode!=PageMode::MANUAL) { + if ($this->mode != PageMode::MANUAL) { $this->send_headers(); } @@ -474,14 +474,14 @@ protected function get_nav_links(): array $active_link = null; // To save on event calls, we check if one of the top-level links has already been marked as active foreach ($nav_links as $link) { - if ($link->active===true) { + if ($link->active === true) { $active_link = $link; break; } } $sub_links = null; // If one is, we just query for sub-menu options under that one tab - if ($active_link!==null) { + if ($active_link !== null) { $psnbe = send_event(new PageSubNavBuildingEvent($active_link->name)); $sub_links = $psnbe->links; } else { @@ -491,20 +491,20 @@ protected function get_nav_links(): array // Now we check for a current link so we can identify the sub-links to show foreach ($psnbe->links as $sub_link) { - if ($sub_link->active===true) { + if ($sub_link->active === true) { $sub_links = $psnbe->links; break; } } // If the active link has been detected, we break out - if ($sub_links!==null) { + if ($sub_links !== null) { $link->active = true; break; } } } - $sub_links = $sub_links??[]; + $sub_links = $sub_links ?? []; usort($nav_links, "Shimmie2\sort_nav_links"); usort($sub_links, "Shimmie2\sort_nav_links"); @@ -628,7 +628,7 @@ class PageSubNavBuildingEvent extends Event public function __construct(string $parent) { parent::__construct(); - $this->parent= $parent; + $this->parent = $parent; } public function add_nav_link(string $name, Link $link, string|HTMLElement $desc, ?bool $active = null, int $order = 50) @@ -653,7 +653,7 @@ public function __construct(string $name, Link $link, string|HTMLElement $descri $this->link = $link; $this->description = $description; $this->order = $order; - if ($active==null) { + if ($active == null) { $query = ltrim(_get_query(), "/"); if ($query === "") { // This indicates the front page, so we check what's set as the front page @@ -664,7 +664,7 @@ public function __construct(string $name, Link $link, string|HTMLElement $descri } else { $this->active = self::is_active([$link->page], $front_page); } - } elseif ($query===$link->page) { + } elseif ($query === $link->page) { $this->active = true; } else { $this->active = self::is_active([$link->page]); @@ -679,18 +679,18 @@ public static function is_active(array $pages_matched, string $url = null): bool /** * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) */ - $url = $url??ltrim(_get_query(), "/"); + $url = $url ?? ltrim(_get_query(), "/"); - $re1='.*?'; - $re2='((?:[a-z][a-z_]+))'; + $re1 = '.*?'; + $re2 = '((?:[a-z][a-z_]+))'; if (preg_match_all("/".$re1.$re2."/is", $url, $matches)) { - $url=$matches[1][0]; + $url = $matches[1][0]; } $count_pages_matched = count($pages_matched); - for ($i=0; $i < $count_pages_matched; $i++) { + for ($i = 0; $i < $count_pages_matched; $i++) { if ($url == $pages_matched[$i]) { return true; } diff --git a/core/basethemelet.php b/core/basethemelet.php index 11c9e2dcc..30fc6372c 100644 --- a/core/basethemelet.php +++ b/core/basethemelet.php @@ -81,22 +81,22 @@ public function build_thumb_html(Image $image): HTMLElement return A( [ - "href"=>$view_link, - "class"=>"thumb shm-thumb shm-thumb-link $custom_classes", - "data-tags"=>$tags, - "data-height"=>$image->height, - "data-width"=>$image->width, - "data-mime"=>$image->get_mime(), - "data-post-id"=>$id, + "href" => $view_link, + "class" => "thumb shm-thumb shm-thumb-link $custom_classes", + "data-tags" => $tags, + "data-height" => $image->height, + "data-width" => $image->width, + "data-mime" => $image->get_mime(), + "data-post-id" => $id, ], IMG( [ - "id"=>"thumb_$id", - "title"=>$tip, - "alt"=>$tip, - "height"=>$tsize[1], - "width"=>$tsize[0], - "src"=>$thumb_link, + "id" => "thumb_$id", + "title" => $tip, + "alt" => $tip, + "height" => $tsize[1], + "width" => $tsize[0], + "src" => $thumb_link, ] ) ); @@ -112,18 +112,18 @@ public function display_paginator(Page $page, string $base, ?string $query, int $page->add_html_header(""); if ($page_number < $total_pages) { - $page->add_html_header(""); - $page->add_html_header(""); + $page->add_html_header(""); + $page->add_html_header(""); } if ($page_number > 1) { - $page->add_html_header(""); + $page->add_html_header(""); } $page->add_html_header(""); } private function gen_page_link(string $base_url, ?string $query, int $page, string $name): HTMLElement { - return A(["href"=>make_link($base_url.'/'.$page, $query)], $name); + return A(["href" => make_link($base_url.'/'.$page, $query)], $name); } private function gen_page_link_block(string $base_url, ?string $query, int $page, int $current_page, string $name): HTMLElement diff --git a/core/block.php b/core/block.php index 0242656af..bd4332292 100644 --- a/core/block.php +++ b/core/block.php @@ -45,7 +45,7 @@ class Block */ public bool $is_content = true; - public function __construct(string $header=null, string|\MicroHTML\HTMLElement $body=null, string $section="main", int $position=50, string $id=null) + public function __construct(string $header = null, string|\MicroHTML\HTMLElement $body = null, string $section = "main", int $position = 50, string $id = null) { $this->header = $header; $this->body = (string)$body; @@ -63,7 +63,7 @@ public function __construct(string $header=null, string|\MicroHTML\HTMLElement $ /** * Get the HTML for this block. */ - public function get_html(bool $hidable=false): string + public function get_html(bool $hidable = false): string { $h = $this->header; $b = $this->body; diff --git a/core/cacheengine.php b/core/cacheengine.php index 01a66f90d..0d7b3cc36 100644 --- a/core/cacheengine.php +++ b/core/cacheengine.php @@ -10,8 +10,8 @@ class EventTracingCache implements CacheInterface { private CacheInterface $engine; private \EventTracer $tracer; - private int $hits=0; - private int $misses=0; + private int $hits = 0; + private int $misses = 0; public function __construct(CacheInterface $engine, \EventTracer $tracer) { @@ -19,7 +19,7 @@ public function __construct(CacheInterface $engine, \EventTracer $tracer) $this->tracer = $tracer; } - public function get($key, $default=null) + public function get($key, $default = null) { if ($key === "__etc_cache_hits") { return $this->hits; @@ -29,7 +29,7 @@ public function get($key, $default=null) } $sentinel = "__etc_sentinel"; - $this->tracer->begin("Cache Get", ["key"=>$key]); + $this->tracer->begin("Cache Get", ["key" => $key]); $val = $this->engine->get($key, $sentinel); if ($val != $sentinel) { $res = "hit"; @@ -39,13 +39,13 @@ public function get($key, $default=null) $val = $default; $this->misses++; } - $this->tracer->end(null, ["result"=>$res]); + $this->tracer->end(null, ["result" => $res]); return $val; } public function set($key, $value, $ttl = null) { - $this->tracer->begin("Cache Set", ["key"=>$key, "ttl"=>$ttl]); + $this->tracer->begin("Cache Set", ["key" => $key, "ttl" => $ttl]); $val = $this->engine->set($key, $value, $ttl); $this->tracer->end(); return $val; @@ -53,7 +53,7 @@ public function set($key, $value, $ttl = null) public function delete($key) { - $this->tracer->begin("Cache Delete", ["key"=>$key]); + $this->tracer->begin("Cache Delete", ["key" => $key]); $val = $this->engine->delete($key); $this->tracer->end(); return $val; @@ -93,9 +93,9 @@ public function deleteMultiple($keys) public function has($key) { - $this->tracer->begin("Cache Has", ["key"=>$key]); + $this->tracer->begin("Cache Has", ["key" => $key]); $val = $this->engine->has($key); - $this->tracer->end(null, ["exists"=>$val]); + $this->tracer->end(null, ["exists" => $val]); return $val; } } diff --git a/core/command_builder.php b/core/command_builder.php index cd912bb33..4908a492d 100644 --- a/core/command_builder.php +++ b/core/command_builder.php @@ -61,7 +61,7 @@ public function execute(bool $fail_on_non_zero_return = false): int log_debug('command_builder', "Command `$cmd` returned $ret and outputted $output"); - if ($fail_on_non_zero_return&&(int)$ret!==(int)0) { + if ($fail_on_non_zero_return && (int)$ret !== (int)0) { throw new SCoreException("Command `$cmd` failed, returning $ret and outputting $output"); } return $ret; diff --git a/core/config.php b/core/config.php index 3372bf177..85c3a2a1e 100644 --- a/core/config.php +++ b/core/config.php @@ -16,7 +16,7 @@ interface Config * so that the next time a page is loaded it will use the new * configuration. */ - public function save(string $name=null): void; + public function save(string $name = null): void; //@{ /*--------------------------------- SET ------------------------------------------------------*/ /** @@ -101,27 +101,27 @@ public function set_default_array(string $name, array $value): void; /** * Pick a value out of the table by name, cast to the appropriate data type. */ - public function get_int(string $name, ?int $default=null): ?int; + public function get_int(string $name, ?int $default = null): ?int; /** * Pick a value out of the table by name, cast to the appropriate data type. */ - public function get_float(string $name, ?float $default=null): ?float; + public function get_float(string $name, ?float $default = null): ?float; /** * Pick a value out of the table by name, cast to the appropriate data type. */ - public function get_string(string $name, ?string $default=null): ?string; + public function get_string(string $name, ?string $default = null): ?string; /** * Pick a value out of the table by name, cast to the appropriate data type. */ - public function get_bool(string $name, ?bool $default=null): ?bool; + public function get_bool(string $name, ?bool $default = null): ?bool; /** * Pick a value out of the table by name, cast to the appropriate data type. */ - public function get_array(string $name, ?array $default=[]): ?array; + public function get_array(string $name, ?array $default = []): ?array; //@} /*--------------------------------------------------------------------------------------------*/ } @@ -162,7 +162,7 @@ public function set_bool(string $name, ?bool $value): void public function set_array(string $name, ?array $value): void { - if ($value!=null) { + if ($value != null) { $this->values[$name] = implode(",", $value); } else { $this->values[$name] = null; @@ -205,17 +205,17 @@ public function set_default_array(string $name, array $value): void } } - public function get_int(string $name, ?int $default=null): ?int + public function get_int(string $name, ?int $default = null): ?int { return (int)($this->get($name, $default)); } - public function get_float(string $name, ?float $default=null): ?float + public function get_float(string $name, ?float $default = null): ?float { return (float)($this->get($name, $default)); } - public function get_string(string $name, ?string $default=null): ?string + public function get_string(string $name, ?string $default = null): ?string { $val = $this->get($name, $default); if (!is_string($val) && !is_null($val)) { @@ -224,17 +224,17 @@ public function get_string(string $name, ?string $default=null): ?string return $val; } - public function get_bool(string $name, ?bool $default=null): ?bool + public function get_bool(string $name, ?bool $default = null): ?bool { return bool_escape($this->get($name, $default)); } - public function get_array(string $name, ?array $default=[]): ?array + public function get_array(string $name, ?array $default = []): ?array { return explode(",", $this->get($name, "")); } - private function get(string $name, $default=null) + private function get(string $name, $default = null) { if (isset($this->values[$name])) { return $this->values[$name]; @@ -289,7 +289,7 @@ public function __construct( $query = "SELECT name, value FROM {$this->table_name}"; $args = []; - if (!empty($sub_column)&&!empty($sub_value)) { + if (!empty($sub_column) && !empty($sub_value)) { $query .= " WHERE $sub_column = :sub_value"; $args["sub_value"] = $sub_value; } @@ -301,7 +301,7 @@ public function __construct( } } - public function save(string $name=null): void + public function save(string $name = null): void { global $cache; @@ -312,10 +312,10 @@ public function save(string $name=null): void } } else { $query = "DELETE FROM {$this->table_name} WHERE name = :name"; - $args = ["name"=>$name]; + $args = ["name" => $name]; $cols = ["name","value"]; $params = [":name",":value"]; - if (!empty($this->sub_column)&&!empty($this->sub_value)) { + if (!empty($this->sub_column) && !empty($this->sub_value)) { $query .= " AND $this->sub_column = :sub_value"; $args["sub_value"] = $this->sub_value; $cols[] = $this->sub_column; @@ -324,7 +324,7 @@ public function save(string $name=null): void $this->database->execute($query, $args); - $args["value"] =$this->values[$name]; + $args["value"] = $this->values[$name]; $this->database->execute( "INSERT INTO {$this->table_name} (".join(",", $cols).") VALUES (".join(",", $params).")", $args diff --git a/core/database.php b/core/database.php index 72dd60a95..5d53ae698 100644 --- a/core/database.php +++ b/core/database.php @@ -57,7 +57,7 @@ private function get_db(): PDO private function connect_engine(): void { if (preg_match("/^([^:]*)/", $this->dsn, $matches)) { - $db_proto=$matches[1]; + $db_proto = $matches[1]; } else { throw new SCoreException("Can't figure out database engine"); } @@ -138,7 +138,7 @@ private function count_time(string $method, float $start, string $query, ?array $query = preg_replace('/ +/m', ' ', $query); $query = trim($query); if ($tracer_enabled) { - $_tracer->complete($start * 1000000, $dur * 1000000, "DB Query", ["query"=>$query, "args"=>$args, "method"=>$method]); + $_tracer->complete($start * 1000000, $dur * 1000000, "DB Query", ["query" => $query, "args" => $args, "method" => $method]); } $this->queries[] = $query; $this->query_count++; @@ -150,7 +150,7 @@ public function set_timeout(?int $time): void $this->get_engine()->set_timeout($this->get_db(), $time); } - public function notify(string $channel, ?string $data=null): void + public function notify(string $channel, ?string $data = null): void { $this->get_engine()->notify($this->get_db(), $channel, $data); } @@ -285,7 +285,7 @@ public function exists(string $query, array $args = []): bool $_start = ftime(); $row = $this->_execute($query, $args)->fetch(); $this->count_time("exists", $_start, $query, $args); - if ($row==null) { + if ($row == null) { return false; } return true; @@ -346,7 +346,7 @@ public function raw_db(): PDO return $this->get_db(); } - public function standardise_boolean(string $table, string $column, bool $include_postgres=false): void + public function standardise_boolean(string $table, string $column, bool $include_postgres = false): void { $d = $this->get_driver_id(); if ($d == DatabaseDriverID::MYSQL) { diff --git a/core/dbengine.php b/core/dbengine.php index bf32cd470..9c05c1a4c 100644 --- a/core/dbengine.php +++ b/core/dbengine.php @@ -34,7 +34,7 @@ abstract public function set_timeout(PDO $db, ?int $time); abstract public function get_version(PDO $db): string; - abstract public function notify(PDO $db, string $channel, ?string $data=null): void; + abstract public function notify(PDO $db, string $channel, ?string $data = null): void; } class MySQL extends DBEngine @@ -66,7 +66,7 @@ public function set_timeout(PDO $db, ?int $time): void // $db->exec("SET SESSION MAX_EXECUTION_TIME=".$time.";"); } - public function notify(PDO $db, string $channel, ?string $data=null): void + public function notify(PDO $db, string $channel, ?string $data = null): void { } @@ -113,7 +113,7 @@ public function set_timeout(PDO $db, ?int $time): void $db->exec("SET statement_timeout TO ".$time.";"); } - public function notify(PDO $db, string $channel, ?string $data=null): void + public function notify(PDO $db, string $channel, ?string $data = null): void { if ($data) { $db->exec("NOTIFY $channel, '$data';"); @@ -141,7 +141,7 @@ function _floor($a): float { return floor($a); } -function _log($a, $b=null): float +function _log($a, $b = null): float { if (is_null($b)) { return log($a); @@ -225,7 +225,7 @@ public function set_timeout(PDO $db, ?int $time): void // There doesn't seem to be such a thing for SQLite, so it does nothing } - public function notify(PDO $db, string $channel, ?string $data=null): void + public function notify(PDO $db, string $channel, ?string $data = null): void { } diff --git a/core/event.php b/core/event.php index db6798ab2..c1eec6d6f 100644 --- a/core/event.php +++ b/core/event.php @@ -87,7 +87,7 @@ public function page_matches(string $name): bool return false; } - for ($i=0; $i<$this->part_count; $i++) { + for ($i = 0; $i < $this->part_count; $i++) { if ($parts[$i] != $this->args[$i]) { return false; } @@ -114,7 +114,7 @@ public function get_arg(int $n): string * If page arg $n is set, then treat that as a 1-indexed page number * and return a 0-indexed page number less than $max; else return 0 */ - public function try_page_num(int $n, ?int $max=null): int + public function try_page_num(int $n, ?int $max = null): int { if ($this->count_args() > $n) { $i = $this->get_arg($n); @@ -195,7 +195,7 @@ public function __construct(array $args) $log_level = SCORE_LOG_WARNING; $arg_count = count($args); - for ($i=1; $i<$arg_count; $i++) { + for ($i = 1; $i < $arg_count; $i++) { switch ($args[$i]) { case '-u': $user = User::by_name($args[++$i]); diff --git a/core/exceptions.php b/core/exceptions.php index 3d1dff4fc..139b86700 100644 --- a/core/exceptions.php +++ b/core/exceptions.php @@ -13,7 +13,7 @@ class SCoreException extends \RuntimeException public string $error; public int $http_code = 500; - public function __construct(string $msg, ?string $query=null) + public function __construct(string $msg, ?string $query = null) { parent::__construct($msg); $this->error = $msg; diff --git a/core/extension.php b/core/extension.php index c5b7edecf..cf246e8cb 100644 --- a/core/extension.php +++ b/core/extension.php @@ -69,7 +69,7 @@ public static function determine_enabled_extensions(): void $extras ) as $key) { $ext = ExtensionInfo::get_by_key($key); - if ($ext===null || !$ext->is_supported()) { + if ($ext === null || !$ext->is_supported()) { continue; } // FIXME: error if one of our dependencies isn't supported @@ -123,7 +123,7 @@ abstract class ExtensionInfo public const SHISH_NAME = "Shish"; public const SHISH_EMAIL = "webmaster@shishnet.org"; public const SHIMMIE_URL = "https://code.shishnet.org/shimmie2/"; - public const SHISH_AUTHOR = [self::SHISH_NAME=>self::SHISH_EMAIL]; + public const SHISH_AUTHOR = [self::SHISH_NAME => self::SHISH_EMAIL]; public const LICENSE_GPLV2 = "GPLv2"; public const LICENSE_MIT = "MIT"; @@ -152,7 +152,7 @@ abstract class ExtensionInfo public function is_supported(): bool { - if ($this->supported===null) { + if ($this->supported === null) { $this->check_support(); } return $this->supported; @@ -160,7 +160,7 @@ public function is_supported(): bool public function get_support_info(): string { - if ($this->supported===null) { + if ($this->supported === null) { $this->check_support(); } return $this->support_info; @@ -249,7 +249,7 @@ public static function load_all_extension_info() self::$all_info_by_key[$extension_info->key] = $extension_info; self::$all_info_by_class[$class] = $extension_info; - if ($extension_info->core===true) { + if ($extension_info->core === true) { self::$core_extensions[] = $extension_info->key; } } diff --git a/core/imageboard/event.php b/core/imageboard/event.php index 1580f8480..49ed408af 100644 --- a/core/imageboard/event.php +++ b/core/imageboard/event.php @@ -84,7 +84,7 @@ class ThumbnailGenerationEvent extends Event public function __construct( public string $hash, public string $mime, - public bool $force=false + public bool $force = false ) { parent::__construct(); $this->generated = false; diff --git a/core/imageboard/image.php b/core/imageboard/image.php index b29d61ffc..ec30eb64b 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -63,7 +63,7 @@ class Image * One will very rarely construct an image directly, more common * would be to use Image::by_id, Image::by_hash, etc. */ - public function __construct(?array $row=null) + public function __construct(?array $row = null) { if (!is_null($row)) { foreach ($row as $name => $value) { @@ -103,11 +103,11 @@ public function graphql_guid(): string public static function by_id(int $post_id): ?Image { global $database; - if ($post_id > 2**32) { + if ($post_id > 2 ** 32) { // for some reason bots query huge numbers and pollute the DB error logs... return null; } - $row = $database->get_row("SELECT * FROM images WHERE images.id=:id", ["id"=>$post_id]); + $row = $database->get_row("SELECT * FROM images WHERE images.id=:id", ["id" => $post_id]); return ($row ? new Image($row) : null); } @@ -115,7 +115,7 @@ public static function by_hash(string $hash): ?Image { global $database; $hash = strtolower($hash); - $row = $database->get_row("SELECT images.* FROM images WHERE hash=:hash", ["hash"=>$hash]); + $row = $database->get_row("SELECT images.* FROM images WHERE hash=:hash", ["hash" => $hash]); return ($row ? new Image($row) : null); } @@ -124,7 +124,7 @@ public static function by_id_or_hash(string $id): ?Image return (is_numeric($id) && strlen($id) != 32) ? Image::by_id((int)$id) : Image::by_hash($id); } - public static function by_random(array $tags=[], int $limit_range=0): ?Image + public static function by_random(array $tags = [], int $limit_range = 0): ?Image { $max = Image::count_images($tags); if ($max < 1) { @@ -133,7 +133,7 @@ public static function by_random(array $tags=[], int $limit_range=0): ?Image if ($limit_range > 0 && $max > $limit_range) { $max = $limit_range; } - $rand = mt_rand(0, $max-1); + $rand = mt_rand(0, $max - 1); $set = Image::find_images($rand, 1, $tags); if (count($set) > 0) { return $set[0]; @@ -142,7 +142,7 @@ public static function by_random(array $tags=[], int $limit_range=0): ?Image } } - private static function find_images_internal(int $start = 0, ?int $limit = null, array $tags=[]): iterable + private static function find_images_internal(int $start = 0, ?int $limit = null, array $tags = []): iterable { global $database, $user; @@ -170,7 +170,7 @@ private static function find_images_internal(int $start = 0, ?int $limit = null, * @return Image[] */ #[Query(name: "posts", type: "[Post!]!", args: ["tags" => "[string!]"])] - public static function find_images(int $offset = 0, ?int $limit = null, array $tags=[]): array + public static function find_images(int $offset = 0, ?int $limit = null, array $tags = []): array { $result = self::find_images_internal($offset, $limit, $tags); @@ -184,7 +184,7 @@ public static function find_images(int $offset = 0, ?int $limit = null, array $t /** * Search for an array of images, returning a iterable object of Image */ - public static function find_images_iterable(int $start = 0, ?int $limit = null, array $tags=[]): \Generator + public static function find_images_iterable(int $start = 0, ?int $limit = null, array $tags = []): \Generator { $result = self::find_images_internal($start, $limit, $tags); foreach ($result as $row) { @@ -212,7 +212,7 @@ public static function count_tag(string $tag): int global $database; return (int)$database->get_one( "SELECT count FROM tags WHERE LOWER(tag) = LOWER(:tag)", - ["tag"=>$tag] + ["tag" => $tag] ); } @@ -221,7 +221,7 @@ public static function count_tag(string $tag): int * * @param string[] $tags */ - public static function count_images(array $tags=[]): int + public static function count_images(array $tags = []): int { global $cache, $database; $tag_count = count($tags); @@ -266,7 +266,7 @@ public static function count_images(array $tags=[]): int * * @param string[] $tags */ - public static function count_pages(array $tags=[]): int + public static function count_pages(array $tags = []): int { global $config; return (int)ceil(Image::count_images($tags) / $config->get_int(IndexConfig::IMAGES)); @@ -284,7 +284,7 @@ public static function count_pages(array $tags=[]): int * * @param string[] $tags */ - public function get_next(array $tags=[], bool $next=true): ?Image + public function get_next(array $tags = [], bool $next = true): ?Image { global $database; @@ -320,7 +320,7 @@ public function get_next(array $tags=[], bool $next=true): ?Image * * @param string[] $tags */ - public function get_prev(array $tags=[]): ?Image + public function get_prev(array $tags = []): ?Image { return $this->get_next($tags, false); } @@ -345,7 +345,7 @@ public function set_owner(User $owner): void UPDATE images SET owner_id=:owner_id WHERE id=:id - ", ["owner_id"=>$owner->id, "id"=>$this->id]); + ", ["owner_id" => $owner->id, "id" => $this->id]); log_info("core_image", "Owner for Post #{$this->id} set to {$owner->name}"); } } @@ -440,7 +440,7 @@ public function get_tag_array(): array JOIN tags ON image_tags.tag_id = tags.id WHERE image_id=:id ORDER BY tag - ", ["id"=>$this->id]); + ", ["id" => $this->id]); sort($this->tag_array); } return $this->tag_array; @@ -569,7 +569,7 @@ public function get_ext(): string #[Field(name: "mime")] public function get_mime(): ?string { - if ($this->mime===MimeType::WEBP&&$this->lossless) { + if ($this->mime === MimeType::WEBP && $this->lossless) { return MimeType::WEBP_LOSSLESS; } $m = $this->mime; @@ -610,7 +610,7 @@ public function set_source(string $new_source): void $new_source = null; } if ($new_source != $old_source) { - $database->execute("UPDATE images SET source=:source WHERE id=:id", ["source"=>$new_source, "id"=>$this->id]); + $database->execute("UPDATE images SET source=:source WHERE id=:id", ["source" => $new_source, "id" => $this->id]); log_info("core_image", "Source for Post #{$this->id} set to: $new_source (was $old_source)"); } } @@ -627,7 +627,7 @@ public function set_locked(bool $locked): void { global $database; if ($locked !== $this->locked) { - $database->execute("UPDATE images SET locked=:yn WHERE id=:id", ["yn"=>$locked, "id"=>$this->id]); + $database->execute("UPDATE images SET locked=:yn WHERE id=:id", ["yn" => $locked, "id" => $this->id]); log_info("core_image", "Setting Post #{$this->id} lock to: $locked"); } } @@ -648,12 +648,12 @@ public function delete_tags_from_image(): void FROM image_tags WHERE image_id = :id ) - ", ["id"=>$this->id]); + ", ["id" => $this->id]); $database->execute(" DELETE FROM image_tags WHERE image_id=:id - ", ["id"=>$this->id]); + ", ["id" => $this->id]); } /** @@ -699,7 +699,7 @@ public function set_tags(array $unfiltered_tags): void FROM image_tags WHERE image_id = :id ) - ", ["id"=>$this->id]); + ", ["id" => $this->id]); log_info("core_image", "Tags for Post #{$this->id} set to: ".Tag::implode($tags)); $cache->delete("image-{$this->id}-tags"); @@ -713,7 +713,7 @@ public function delete(): void { global $database; $this->delete_tags_from_image(); - $database->execute("DELETE FROM images WHERE id=:id", ["id"=>$this->id]); + $database->execute("DELETE FROM images WHERE id=:id", ["id" => $this->id]); log_info("core_image", 'Deleted Post #'.$this->id.' ('.$this->hash.')'); unlink($this->get_image_filename()); @@ -731,7 +731,7 @@ public function remove_image_only(): void @unlink($this->get_thumb_filename()); } - public function parse_link_template(string $tmpl, int $n=0): string + public function parse_link_template(string $tmpl, int $n = 0): string { $plte = send_event(new ParseLinkTemplateEvent($tmpl, $this)); $tmpl = $plte->link; @@ -753,8 +753,8 @@ private static function tag_or_wildcard_to_ids(string $tag): array */ private static function build_search_querylet( array $terms, - ?int $limit=null, - ?int $offset=null + ?int $limit = null, + ?int $offset = null ): Querylet { global $config; @@ -827,7 +827,7 @@ private static function build_search_querylet( LIMIT :limit OFFSET :offset ) a on a.image_id = images.id ORDER BY images.id DESC - ", ["limit"=>$limit, "offset"=>$offset]); + ", ["limit" => $limit, "offset" => $offset]); // don't offset at the image level because // we already offset at the image_tags level $order = null; @@ -849,11 +849,11 @@ private static function build_search_querylet( if ($tq->positive) { $all_nonexistent_negatives = false; - if ($tag_count== 0) { + if ($tag_count == 0) { # one of the positive tags had zero results, therefor there # can be no results; "where 1=0" should shortcut things return new Querylet("SELECT images.* FROM images WHERE 1=0"); - } elseif ($tag_count==1) { + } elseif ($tag_count == 1) { // All wildcard terms that qualify for a single tag can be treated the same as non-wildcards $positive_tag_id_array[] = $tag_ids[0]; } else { diff --git a/core/imageboard/misc.php b/core/imageboard/misc.php index f7bc1c62a..2fdc82a82 100644 --- a/core/imageboard/misc.php +++ b/core/imageboard/misc.php @@ -39,7 +39,7 @@ function add_dir(string $base): array /** * Sends a DataUploadEvent for a file. */ -function add_image(string $tmpname, string $filename, string $tags, ?string $source=null): DataUploadEvent +function add_image(string $tmpname, string $filename, string $tags, ?string $source = null): DataUploadEvent { return send_event(new DataUploadEvent($tmpname, [ 'filename' => pathinfo($filename, PATHINFO_BASENAME), @@ -111,12 +111,12 @@ function get_thumbnail_size(int $orig_width, int $orig_height, bool $use_dpi_sca function get_scaled_by_aspect_ratio(int $original_width, int $original_height, int $max_width, int $max_height): array { - $xscale = ($max_width/ $original_width); - $yscale = ($max_height/ $original_height); + $xscale = ($max_width / $original_width); + $yscale = ($max_height / $original_height); $scale = ($yscale < $xscale) ? $yscale : $xscale ; - return [(int)($original_width*$scale), (int)($original_height*$scale), $scale]; + return [(int)($original_width * $scale), (int)($original_height * $scale), $scale]; } /** @@ -129,8 +129,8 @@ function get_thumbnail_max_size_scaled(): array global $config; $scaling = $config->get_int(ImageConfig::THUMB_SCALING); - $max_width = $config->get_int(ImageConfig::THUMB_WIDTH) * ($scaling/100); - $max_height = $config->get_int(ImageConfig::THUMB_HEIGHT) * ($scaling/100); + $max_width = $config->get_int(ImageConfig::THUMB_WIDTH) * ($scaling / 100); + $max_height = $config->get_int(ImageConfig::THUMB_HEIGHT) * ($scaling / 100); return [$max_width, $max_height]; } diff --git a/core/imageboard/search.php b/core/imageboard/search.php index 11ac9b036..624f52237 100644 --- a/core/imageboard/search.php +++ b/core/imageboard/search.php @@ -8,7 +8,7 @@ class Querylet { public function __construct( public string $sql, - public array $variables=[], + public array $variables = [], ) { } diff --git a/core/imageboard/tag.php b/core/imageboard/tag.php index e1c437db9..547ed0f04 100644 --- a/core/imageboard/tag.php +++ b/core/imageboard/tag.php @@ -26,7 +26,7 @@ public function __construct(string $tag, int $uses) * @return TagUsage[] */ #[Query(name: "tags", type: '[TagUsage!]!')] - public static function tags(string $search, int $limit=10): array + public static function tags(string $search, int $limit = 10): array { global $cache, $database; @@ -48,7 +48,7 @@ public static function tags(string $search, int $limit=10): array $limitSQL = ""; $search = str_replace('_', '\_', $search); $search = str_replace('%', '\%', $search); - $SQLarr = ["search"=>"$search%"]; #, "cat_search"=>"%:$search%"]; + $SQLarr = ["search" => "$search%"]; #, "cat_search"=>"%:$search%"]; if ($limit !== 0) { $limitSQL = "LIMIT :limit"; $SQLarr['limit'] = $limit; @@ -104,17 +104,17 @@ public static function get_or_create_id(string $tag): int $id = $database->get_one( "SELECT id FROM tags WHERE LOWER(tag) = LOWER(:tag)", - ["tag"=>$tag] + ["tag" => $tag] ); if (empty($id)) { // a new tag $database->execute( "INSERT INTO tags(tag) VALUES (:tag)", - ["tag"=>$tag] + ["tag" => $tag] ); $id = $database->get_one( "SELECT id FROM tags WHERE LOWER(tag) = LOWER(:tag)", - ["tag"=>$tag] + ["tag" => $tag] ); } @@ -125,7 +125,7 @@ public static function get_or_create_id(string $tag): int /** @param string[] $tags */ public static function implode(array $tags): string { - sort($tags, SORT_FLAG_CASE|SORT_STRING); + sort($tags, SORT_FLAG_CASE | SORT_STRING); return implode(' ', $tags); } @@ -134,7 +134,7 @@ public static function implode(array $tags): string * * #return string[] */ - public static function explode(string $tags, bool $tagme=true): array + public static function explode(string $tags, bool $tagme = true): array { global $database; @@ -152,7 +152,7 @@ public static function explode(string $tags, bool $tagme=true): array $new = []; $i = 0; $tag_count = count($tag_array); - while ($i<$tag_count) { + while ($i < $tag_count) { $tag = $tag_array[$i]; $negative = ''; if (!empty($tag) && ($tag[0] == '-')) { @@ -166,7 +166,7 @@ public static function explode(string $tags, bool $tagme=true): array FROM aliases WHERE LOWER(oldtag)=LOWER(:tag) ", - ["tag"=>$tag] + ["tag" => $tag] ); if (empty($newtags)) { //tag has no alias, use old tag @@ -217,7 +217,7 @@ public static function sanitize(string $tag): string public static function compare(array $tags1, array $tags2): bool { - if (count($tags1)!==count($tags2)) { + if (count($tags1) !== count($tags2)) { return false; } @@ -312,7 +312,7 @@ public static function decaret(string $str): string $out = ""; $length = strlen($str); - for ($i=0; $i<$length; $i++) { + for ($i = 0; $i < $length; $i++) { if ($str[$i] == "^") { $i++; $out .= $from_caret[$str[$i]] ?? ''; diff --git a/core/logging.php b/core/logging.php index 7b5c3694e..a558e3c5b 100644 --- a/core/logging.php +++ b/core/logging.php @@ -16,12 +16,12 @@ define("SCORE_LOG_NOTSET", 0); const LOGGING_LEVEL_NAMES = [ - SCORE_LOG_NOTSET=>"Not Set", - SCORE_LOG_DEBUG=>"Debug", - SCORE_LOG_INFO=>"Info", - SCORE_LOG_WARNING=>"Warning", - SCORE_LOG_ERROR=>"Error", - SCORE_LOG_CRITICAL=>"Critical", + SCORE_LOG_NOTSET => "Not Set", + SCORE_LOG_DEBUG => "Debug", + SCORE_LOG_INFO => "Info", + SCORE_LOG_WARNING => "Warning", + SCORE_LOG_ERROR => "Error", + SCORE_LOG_CRITICAL => "Critical", ]; /** @@ -31,7 +31,7 @@ * When taking action, a log event should be stored by the server * Quite often, both of these happen at once, hence log_*() having $flash */ -function log_msg(string $section, int $priority, string $message, ?string $flash=null) +function log_msg(string $section, int $priority, string $message, ?string $flash = null) { global $page; send_event(new LogEvent($section, $priority, $message)); @@ -47,23 +47,23 @@ function log_msg(string $section, int $priority, string $message, ?string $flash } // More shorthand ways of logging -function log_debug(string $section, string $message, ?string $flash=null) +function log_debug(string $section, string $message, ?string $flash = null) { log_msg($section, SCORE_LOG_DEBUG, $message, $flash); } -function log_info(string $section, string $message, ?string $flash=null) +function log_info(string $section, string $message, ?string $flash = null) { log_msg($section, SCORE_LOG_INFO, $message, $flash); } -function log_warning(string $section, string $message, ?string $flash=null) +function log_warning(string $section, string $message, ?string $flash = null) { log_msg($section, SCORE_LOG_WARNING, $message, $flash); } -function log_error(string $section, string $message, ?string $flash=null) +function log_error(string $section, string $message, ?string $flash = null) { log_msg($section, SCORE_LOG_ERROR, $message, $flash); } -function log_critical(string $section, string $message, ?string $flash=null) +function log_critical(string $section, string $message, ?string $flash = null) { log_msg($section, SCORE_LOG_CRITICAL, $message, $flash); } diff --git a/core/microhtml.php b/core/microhtml.php index 23c895aa1..aadd633df 100644 --- a/core/microhtml.php +++ b/core/microhtml.php @@ -22,13 +22,13 @@ use function MicroHTML\TH; use function MicroHTML\TD; -function SHM_FORM(string $target, string $method="POST", bool $multipart=false, string $form_id="", string $onsubmit="", string $name=""): HTMLElement +function SHM_FORM(string $target, string $method = "POST", bool $multipart = false, string $form_id = "", string $onsubmit = "", string $name = ""): HTMLElement { global $user; $attrs = [ - "action"=>make_link($target), - "method"=>$method + "action" => make_link($target), + "method" => $method ]; if ($form_id) { @@ -45,7 +45,7 @@ function SHM_FORM(string $target, string $method="POST", bool $multipart=false, } return FORM( $attrs, - INPUT(["type"=>"hidden", "name"=>"q", "value"=>$target]), + INPUT(["type" => "hidden", "name" => "q", "value" => $target]), $method == "GET" ? "" : $user->get_auth_microhtml() ); } @@ -57,14 +57,14 @@ function SHM_SIMPLE_FORM($target, ...$children): HTMLElement return $form; } -function SHM_SUBMIT(string $text, array $args=[]): HTMLElement +function SHM_SUBMIT(string $text, array $args = []): HTMLElement { $args["type"] = "submit"; $args["value"] = $text; return INPUT($args); } -function SHM_A(string $href, string|HTMLElement $text, string $id="", string $class="", array $args=[]): HTMLElement +function SHM_A(string $href, string|HTMLElement $text, string $id = "", string $class = "", array $args = []): HTMLElement { $args["href"] = make_link($href); @@ -81,7 +81,7 @@ function SHM_A(string $href, string|HTMLElement $text, string $id="", string $cl function SHM_COMMAND_EXAMPLE(string $ex, string $desc): HTMLElement { return DIV( - ["class"=>"command_example"], + ["class" => "command_example"], PRE($ex), P($desc) ); @@ -90,15 +90,15 @@ function SHM_COMMAND_EXAMPLE(string $ex, string $desc): HTMLElement function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot): HTMLElement { if (is_string($foot)) { - $foot = TFOOT(TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>$foot])))); + $foot = TFOOT(TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => $foot])))); } return SHM_SIMPLE_FORM( $target, P( - INPUT(["type"=>'hidden', "name"=>'id', "value"=>$duser->id]), + INPUT(["type" => 'hidden', "name" => 'id', "value" => $duser->id]), TABLE( - ["class"=>"form"], - THEAD(TR(TH(["colspan"=>"2"], $title))), + ["class" => "form"], + THEAD(TR(TH(["colspan" => "2"], $title))), $body, $foot ) @@ -117,7 +117,7 @@ function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot) * @param bool $empty_option Whether the first option should be an empty one. * @param array $attrs Additional attributes dict for . Example: ["id"=>"some_id", "class"=>"some_class"]. */ -function SHM_SELECT(string $name, array $options, array $selected_options=[], bool $required=false, bool $multiple=false, bool $empty_option=false, array $attrs=[]): HTMLElement +function SHM_SELECT(string $name, array $options, array $selected_options = [], bool $required = false, bool $multiple = false, bool $empty_option = false, array $attrs = []): HTMLElement { if ($required) { $attrs["required"] = ""; @@ -143,13 +143,13 @@ function SHM_SELECT(string $name, array $options, array $selected_options=[], bo return SELECT($attrs, ...$_options); } -function SHM_OPTION(string $value, string $text, bool $selected=false): HTMLElement +function SHM_OPTION(string $value, string $text, bool $selected = false): HTMLElement { if ($selected) { - return OPTION(["value"=>$value, "selected"=>""], $text); + return OPTION(["value" => $value, "selected" => ""], $text); } - return OPTION(["value"=>$value], $text); + return OPTION(["value" => $value], $text); } function SHM_POST_INFO( @@ -159,11 +159,11 @@ function SHM_POST_INFO( HTMLElement|string $edit = "", ): HTMLElement { return TR( - TH(["width"=>"50px"], $title), + TH(["width" => "50px"], $title), $can_edit ? emptyHTML( - TD(["class"=>"view"], $view), - TD(["class"=>"edit"], $edit), + TD(["class" => "view"], $view), + TD(["class" => "edit"], $edit), ) : TD($view) ); diff --git a/core/polyfills.php b/core/polyfills.php index 1b6b9cfc6..bcecda02b 100644 --- a/core/polyfills.php +++ b/core/polyfills.php @@ -121,7 +121,7 @@ function full_copy(string $source, string $target): void /** * Return a list of all the regular files in a directory and subdirectories */ -function list_files(string $base, string $_sub_dir=""): array +function list_files(string $base, string $_sub_dir = ""): array { assert(is_dir($base)); @@ -129,7 +129,7 @@ function list_files(string $base, string $_sub_dir=""): array $files = []; $dir = opendir("$base/$_sub_dir"); - if ($dir===false) { + if ($dir === false) { throw new SCoreException("Unable to open directory $base/$_sub_dir"); } try { @@ -439,7 +439,7 @@ function no_escape(string $input): string * Given a 1-indexed numeric-ish thing, return a zero-indexed * number between 0 and $max */ -function page_number(string $input, ?int $max=null): int +function page_number(string $input, ?int $max = null): int { if (!is_numeric($input)) { $pageNumber = 0; @@ -453,7 +453,7 @@ function page_number(string $input, ?int $max=null): int return $pageNumber; } -function clamp(int $val, ?int $min=null, ?int $max=null): int +function clamp(int $val, ?int $min = null, ?int $max = null): int { if (!is_null($min) && $val < $min) { $val = $min; @@ -471,7 +471,7 @@ function clamp(int $val, ?int $min=null, ?int $max=null): int * Original PHP code by Chirp Internet: www.chirp.com.au * Please acknowledge use of this code by including this header. */ -function truncate(string $string, int $limit, string $break=" ", string $pad="..."): string +function truncate(string $string, int $limit, string $break = " ", string $pad = "..."): string { // return with no change if string is shorter than $limit if (strlen($string) <= $limit) { @@ -549,12 +549,12 @@ abstract class TIME_UNITS public const DAYS = "d"; public const YEARS = "y"; public const CONVERSION = [ - self::MILLISECONDS=>1000, - self::SECONDS=>60, - self::MINUTES=>60, - self::HOURS=>24, - self::DAYS=>365, - self::YEARS=>PHP_INT_MAX + self::MILLISECONDS => 1000, + self::SECONDS => 60, + self::MINUTES => 60, + self::HOURS => 24, + self::DAYS => 365, + self::YEARS => PHP_INT_MAX ]; } function format_milliseconds(int $input, string $min_unit = TIME_UNITS::SECONDS): string @@ -565,17 +565,17 @@ function format_milliseconds(int $input, string $min_unit = TIME_UNITS::SECONDS) $found = false; - foreach (TIME_UNITS::CONVERSION as $unit=>$conversion) { + foreach (TIME_UNITS::CONVERSION as $unit => $conversion) { $count = $remainder % $conversion; $remainder = floor($remainder / $conversion); - if ($found||$unit==$min_unit) { + if ($found || $unit == $min_unit) { $found = true; } else { continue; } - if ($count==0&&$remainder<1) { + if ($count == 0 && $remainder < 1) { break; } $output = "$count".$unit." ".$output; @@ -596,7 +596,7 @@ function parse_to_milliseconds(string $input): int $output += $length; } } else { - foreach (TIME_UNITS::CONVERSION as $unit=>$conversion) { + foreach (TIME_UNITS::CONVERSION as $unit => $conversion) { if (preg_match('/([0-9]+)'.$unit.'/i', $input, $match)) { $length = $match[1]; if (is_numeric($length)) { @@ -613,7 +613,7 @@ function parse_to_milliseconds(string $input): int /** * Turn a date into a time, a date, an "X minutes ago...", etc */ -function autodate(string $date, bool $html=true): string +function autodate(string $date, bool $html = true): string { $cpu = date('c', strtotime($date)); $hum = date('F j, Y; H:i', strtotime($date)); @@ -791,7 +791,7 @@ function stringer($s): string return "[" . implode(", ", array_map("Shimmie2\stringer", $s)) . "]"; } else { $pairs = []; - foreach ($s as $k=>$v) { + foreach ($s as $k => $v) { $pairs[] = "\"$k\"=>" . stringer($v); } return "[" . implode(", ", $pairs) . "]"; diff --git a/core/sanitize_php.php b/core/sanitize_php.php index c6f702d98..fca039152 100644 --- a/core/sanitize_php.php +++ b/core/sanitize_php.php @@ -9,7 +9,7 @@ * be included right at the very start of index.php and tests/bootstrap.php */ -function die_nicely($title, $body, $code=0) +function die_nicely($title, $body, $code = 0) { print(" diff --git a/core/send_event.php b/core/send_event.php index 33eed65f4..e8ee335cd 100644 --- a/core/send_event.php +++ b/core/send_event.php @@ -100,7 +100,7 @@ function _dump_event_listeners(array $event_listeners, string $path): void $_shm_event_count = 0; $_shm_timeout = null; -function shm_set_timeout(?int $timeout=null): void +function shm_set_timeout(?int $timeout = null): void { global $_shm_timeout; if ($timeout) { @@ -155,7 +155,7 @@ function send_event(Event $event): Event if ($tracer_enabled) { $_tracer->end(); } - if ($event->stop_processing===true) { + if ($event->stop_processing === true) { break; } } diff --git a/core/tests/polyfills.test.php b/core/tests/polyfills.test.php index a196da3b8..649ca68af 100644 --- a/core/tests/polyfills.test.php +++ b/core/tests/polyfills.test.php @@ -135,16 +135,16 @@ public function test_validate_input() "num" => "42", ]; $this->assertEquals( - ["foo"=>"bar"], - validate_input(["foo"=>"string,trim,lower"]) + ["foo" => "bar"], + validate_input(["foo" => "string,trim,lower"]) ); //$this->assertEquals( // ["to_null"=>null], // validate_input(["to_null"=>"string,trim,nullify"]) //); $this->assertEquals( - ["num"=>42], - validate_input(["num"=>"int"]) + ["num" => 42], + validate_input(["num" => "int"]) ); } @@ -223,7 +223,7 @@ public function test_stringer() { $this->assertEquals( '["foo"=>"bar", "baz"=>[1, 2, 3], "qux"=>["a"=>"b"]]', - stringer(["foo"=>"bar", "baz"=>[1,2,3], "qux"=>["a"=>"b"]]) + stringer(["foo" => "bar", "baz" => [1,2,3], "qux" => ["a" => "b"]]) ); } } diff --git a/core/tests/urls.test.php b/core/tests/urls.test.php index e607726a1..5d939c84a 100644 --- a/core/tests/urls.test.php +++ b/core/tests/urls.test.php @@ -80,17 +80,17 @@ public function test_modify_url() { $this->assertEquals( "/foo/bar?a=3&b=2", - modify_url("/foo/bar?a=1&b=2", ["a"=>"3"]) + modify_url("/foo/bar?a=1&b=2", ["a" => "3"]) ); $this->assertEquals( "https://blah.com/foo/bar?b=2", - modify_url("https://blah.com/foo/bar?a=1&b=2", ["a"=>null]) + modify_url("https://blah.com/foo/bar?a=1&b=2", ["a" => null]) ); $this->assertEquals( "/foo/bar", - modify_url("/foo/bar?a=1&b=2", ["a"=>null, "b"=>null]) + modify_url("/foo/bar?a=1&b=2", ["a" => null, "b" => null]) ); } diff --git a/core/urls.php b/core/urls.php index 40261458b..e2fbf864d 100644 --- a/core/urls.php +++ b/core/urls.php @@ -11,7 +11,7 @@ class Link public ?string $page; public ?string $query; - public function __construct(?string $page=null, ?string $query=null) + public function __construct(?string $page = null, ?string $query = null) { $this->page = $page; $this->query = $query; @@ -43,7 +43,7 @@ function search_link(array $terms = [], int $page = 1): string * * eg make_link("foo/bar") becomes "/v2/index.php?q=foo/bar" */ -function make_link(?string $page=null, ?string $query=null, ?string $fragment=null): string +function make_link(?string $page = null, ?string $query = null, ?string $fragment = null): string { global $config; @@ -118,7 +118,7 @@ function make_http(string $link): string * If HTTP_REFERER is set, and not blacklisted, then return it * Else return a default $dest */ -function referer_or(string $dest, ?array $blacklist=null): string +function referer_or(string $dest, ?array $blacklist = null): string { if (empty($_SERVER['HTTP_REFERER'])) { return $dest; diff --git a/core/user.php b/core/user.php index 4692699dc..521e35f26 100644 --- a/core/user.php +++ b/core/user.php @@ -98,7 +98,7 @@ public static function by_session(string $name, string $session): ?User } else { $query = "SELECT * FROM users WHERE name = :name AND md5(pass || :ip) = :sess"; } - $row = $database->get_row($query, ["name"=>$name, "ip"=>get_session_ip($config), "sess"=>$session]); + $row = $database->get_row($query, ["name" => $name, "ip" => get_session_ip($config), "sess" => $session]); $cache->set("user-session:$name-$session", $row, 600); } return is_null($row) ? null : new User($row); @@ -113,7 +113,7 @@ public static function by_id(int $id): ?User return new User($cached); } } - $row = $database->get_row("SELECT * FROM users WHERE id = :id", ["id"=>$id]); + $row = $database->get_row("SELECT * FROM users WHERE id = :id", ["id" => $id]); if ($id === 1) { $cache->set('user-id:'.$id, $row, 600); } @@ -124,7 +124,7 @@ public static function by_id(int $id): ?User public static function by_name(string $name): ?User { global $database; - $row = $database->get_row("SELECT * FROM users WHERE LOWER(name) = LOWER(:name)", ["name"=>$name]); + $row = $database->get_row("SELECT * FROM users WHERE LOWER(name) = LOWER(:name)", ["name" => $name]); return is_null($row) ? null : new User($row); } @@ -188,7 +188,7 @@ public function is_logged_in(): bool public function set_class(string $class): void { global $database; - $database->execute("UPDATE users SET class=:class WHERE id=:id", ["class"=>$class, "id"=>$this->id]); + $database->execute("UPDATE users SET class=:class WHERE id=:id", ["class" => $class, "id" => $this->id]); log_info("core-user", 'Set class for '.$this->name.' to '.$class); } @@ -200,7 +200,7 @@ public function set_name(string $name): void } $old_name = $this->name; $this->name = $name; - $database->execute("UPDATE users SET name=:name WHERE id=:id", ["name"=>$this->name, "id"=>$this->id]); + $database->execute("UPDATE users SET name=:name WHERE id=:id", ["name" => $this->name, "id" => $this->id]); log_info("core-user", "Changed username for {$old_name} to {$this->name}"); } @@ -210,7 +210,7 @@ public function set_password(string $password): void $hash = password_hash($password, PASSWORD_BCRYPT); if (is_string($hash)) { $this->passhash = $hash; - $database->execute("UPDATE users SET pass=:hash WHERE id=:id", ["hash"=>$this->passhash, "id"=>$this->id]); + $database->execute("UPDATE users SET pass=:hash WHERE id=:id", ["hash" => $this->passhash, "id" => $this->id]); log_info("core-user", 'Set password for '.$this->name); } else { throw new SCoreException("Failed to hash password"); @@ -220,7 +220,7 @@ public function set_password(string $password): void public function set_email(string $address): void { global $database; - $database->execute("UPDATE users SET email=:email WHERE id=:id", ["email"=>$address, "id"=>$this->id]); + $database->execute("UPDATE users SET email=:email WHERE id=:id", ["email" => $address, "id" => $this->id]); log_info("core-user", 'Set email for '.$this->name); } @@ -284,7 +284,7 @@ public function get_auth_html(): string public function get_auth_microhtml(): HTMLElement { $at = $this->get_auth_token(); - return INPUT(["type"=>"hidden", "name"=>"auth_token", "value"=>$at]); + return INPUT(["type" => "hidden", "name" => "auth_token", "value" => $at]); } public function check_auth_token(): bool diff --git a/core/userclass.php b/core/userclass.php index 8677cc780..2473e9549 100644 --- a/core/userclass.php +++ b/core/userclass.php @@ -219,10 +219,10 @@ public function can(string $ability): bool Permissions::APPROVE_COMMENT => true, Permissions::BYPASS_IMAGE_APPROVAL => true, - Permissions::CRON_RUN =>true, + Permissions::CRON_RUN => true, - Permissions::BULK_IMPORT =>true, - Permissions::BULK_EXPORT =>true, + Permissions::BULK_IMPORT => true, + Permissions::BULK_EXPORT => true, Permissions::BULK_DOWNLOAD => true, Permissions::BULK_PARENT_CHILD => true, diff --git a/core/util.php b/core/util.php index 25d83ae45..2e0e197e1 100644 --- a/core/util.php +++ b/core/util.php @@ -55,7 +55,7 @@ function is_https_enabled(): bool { // check forwarded protocol if (REVERSE_PROXY_X_HEADERS && !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { - $_SERVER['HTTPS']='on'; + $_SERVER['HTTPS'] = 'on'; } return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'); } @@ -80,10 +80,10 @@ function get_memory_limit(): int global $config; // thumbnail generation requires lots of memory - $default_limit = 8*1024*1024; // 8 MB of memory is PHP's default. + $default_limit = 8 * 1024 * 1024; // 8 MB of memory is PHP's default. $shimmie_limit = $config->get_int(MediaConfig::MEM_LIMIT); - if ($shimmie_limit < 3*1024*1024) { + if ($shimmie_limit < 3 * 1024 * 1024) { // we aren't going to fit, override $shimmie_limit = $default_limit; } @@ -205,9 +205,9 @@ function format_text(string $string): string * @param int $splits The number of octet pairs to split the hash into. Caps out at strlen($hash)/2. * @return string */ -function warehouse_path(string $base, string $hash, bool $create=true, int $splits = WH_SPLITS): string +function warehouse_path(string $base, string $hash, bool $create = true, int $splits = WH_SPLITS): string { - $dirs =[DATA_DIR, $base]; + $dirs = [DATA_DIR, $base]; $splits = min($splits, strlen($hash) / 2); for ($i = 0; $i < $splits; $i++) { $dirs[] = substr($hash, $i * 2, 2); @@ -228,13 +228,13 @@ function warehouse_path(string $base, string $hash, bool $create=true, int $spli function data_path(string $filename, bool $create = true): string { $filename = join_path("data", $filename); - if ($create&&!file_exists(dirname($filename))) { + if ($create && !file_exists(dirname($filename))) { mkdir(dirname($filename), 0755, true); } return $filename; } -function load_balance_url(string $tmpl, string $hash, int $n=0): string +function load_balance_url(string $tmpl, string $hash, int $n = 0): string { static $flexihashes = []; $matches = []; @@ -308,7 +308,7 @@ function fetch_url(string $url, string $mfile): ?array $s_mfile = escapeshellarg($mfile); system("wget --no-check-certificate $s_url --output-document=$s_mfile"); - return file_exists($mfile) ? ["ok"=>"true"] : null; + return file_exists($mfile) ? ["ok" => "true"] : null; } if ($config->get_string(UploadConfig::TRANSLOAD_ENGINE) === "fopen") { @@ -355,7 +355,7 @@ function path_to_tags(string $path): string $category_to_inherit = ""; foreach (explode(" ", $dir) as $tag) { $tag = trim($tag); - if ($tag=="") { + if ($tag == "") { continue; } if (substr_compare($tag, ":", -1) === 0) { @@ -363,7 +363,7 @@ function path_to_tags(string $path): string // which is for inheriting to tags on the subfolder $category_to_inherit = $tag; } else { - if ($category!="" && !str_contains($tag, ":")) { + if ($category != "" && !str_contains($tag, ":")) { // This indicates that category inheritance is active, // and we've encountered a tag that does not specify a category. // So we attach the inherited category to the tag. @@ -420,7 +420,7 @@ function remove_empty_dirs(string $dir): bool $result = false; } } - if ($result===true) { + if ($result === true) { $result = rmdir($dir); } return $result; @@ -533,7 +533,7 @@ function get_debug_info_arr(): array return [ "time" => round(ftime() - $_shm_load_start, 2), "dbtime" => round($database->dbtime, 2), - "mem_mb" => round(((memory_get_peak_usage(true)+512)/1024)/1024, 2), + "mem_mb" => round(((memory_get_peak_usage(true) + 512) / 1024) / 1024, 2), "files" => count(get_included_files()), "query_count" => $database->query_count, // "query_log" => $database->queries, @@ -591,7 +591,7 @@ function _set_up_shimmie_environment(): void // The trace system has a certain amount of memory consumption every time it is used, // so to prevent running out of memory during complex operations code that uses it should // check if tracer output is enabled before making use of it. - $tracer_enabled = constant('TRACE_FILE')!==null; + $tracer_enabled = constant('TRACE_FILE') !== null; } @@ -717,7 +717,7 @@ function show_ip(string $ip, string $ban_reason): string /** * Make a form tag with relevant auth token and stuff */ -function make_form(string $target, string $method="POST", bool $multipart=false, string $form_id="", string $onsubmit=""): string +function make_form(string $target, string $method = "POST", bool $multipart = false, string $form_id = "", string $onsubmit = ""): string { global $user; if ($method == "GET") { diff --git a/ext/admin/main.php b/ext/admin/main.php index 43783a831..f564d971e 100644 --- a/ext/admin/main.php +++ b/ext/admin/main.php @@ -137,7 +137,7 @@ public function onAdminBuilding(AdminBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::MANAGE_ADMINTOOLS)) { $event->add_nav_link("admin", new Link('admin'), "Board Admin"); } diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php index 4692c0e36..f6bd3c028 100644 --- a/ext/alias_editor/main.php +++ b/ext/alias_editor/main.php @@ -114,7 +114,7 @@ public function onPageRequest(PageRequestEvent $event) if ($event->get_arg(0) == "add") { if ($user->can(Permissions::MANAGE_ALIAS_LIST)) { $user->ensure_authed(); - $input = validate_input(["c_oldtag"=>"string", "c_newtag"=>"string"]); + $input = validate_input(["c_oldtag" => "string", "c_newtag" => "string"]); try { send_event(new AddAliasEvent($input['c_oldtag'], $input['c_newtag'])); $page->set_mode(PageMode::REDIRECT); @@ -126,7 +126,7 @@ public function onPageRequest(PageRequestEvent $event) } elseif ($event->get_arg(0) == "remove") { if ($user->can(Permissions::MANAGE_ALIAS_LIST)) { $user->ensure_authed(); - $input = validate_input(["d_oldtag"=>"string"]); + $input = validate_input(["d_oldtag" => "string"]); send_event(new DeleteAliasEvent($input['d_oldtag'])); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link("alias/list")); @@ -181,7 +181,7 @@ public function onAddAlias(AddAliasEvent $event) $row = $database->get_row( "SELECT * FROM aliases WHERE lower(oldtag)=lower(:oldtag)", - ["oldtag"=>$event->oldtag] + ["oldtag" => $event->oldtag] ); if ($row) { throw new AddAliasException("{$row['oldtag']} is already an alias for {$row['newtag']}"); @@ -211,7 +211,7 @@ public function onDeleteAlias(DeleteAliasEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="tags") { + if ($event->parent == "tags") { $event->add_nav_link("aliases", new Link('alias/list'), "Aliases", NavLink::is_active(["alias"])); } } diff --git a/ext/alias_editor/theme.php b/ext/alias_editor/theme.php index dd9b1009c..d29d8dd45 100644 --- a/ext/alias_editor/theme.php +++ b/ext/alias_editor/theme.php @@ -18,11 +18,11 @@ public function display_aliases(HTMLElement $table, HTMLElement $paginator): voi { global $page, $user; - $html = emptyHTML($table, BR(), $paginator, BR(), SHM_A("alias/export/aliases.csv", "Download as CSV", args: ["download"=>"aliases.csv"])); - + $html = emptyHTML($table, BR(), $paginator, BR(), SHM_A("alias/export/aliases.csv", "Download as CSV", args: ["download" => "aliases.csv"])); + $bulk_form = SHM_FORM("alias/import", multipart: true); $bulk_form->appendChild( - INPUT(["type"=>"file", "name"=>"alias_file"]), + INPUT(["type" => "file", "name" => "alias_file"]), SHM_SUBMIT("Upload List") ); $bulk_html = emptyHTML($bulk_form); diff --git a/ext/approval/info.php b/ext/approval/info.php index 3ed711a4a..b5f51db2a 100644 --- a/ext/approval/info.php +++ b/ext/approval/info.php @@ -10,7 +10,7 @@ class ApprovalInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Approval"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Adds an approval step to the upload/import process."; } diff --git a/ext/approval/main.php b/ext/approval/main.php index 8c4080e54..baa02ffdd 100644 --- a/ext/approval/main.php +++ b/ext/approval/main.php @@ -86,21 +86,21 @@ public function onAdminAction(AdminActionEvent $event) $action = $event->action; $event->redirect = true; - if ($action==="approval") { + if ($action === "approval") { $approval_action = $_POST["approval_action"]; switch ($approval_action) { case "approve_all": $database->set_timeout(null); // These updates can take a little bit $database->execute( "UPDATE images SET approved = :true, approved_by_id = :approved_by_id WHERE approved = :false", - ["approved_by_id"=>$user->id, "true"=>true, "false"=>false] + ["approved_by_id" => $user->id, "true" => true, "false" => false] ); break; case "disapprove_all": $database->set_timeout(null); // These updates can take a little bit $database->execute( "UPDATE images SET approved = :false, approved_by_id = NULL WHERE approved = :true", - ["true"=>true, "false"=>false] + ["true" => true, "false" => false] ); break; default: @@ -123,7 +123,7 @@ public function onDisplayingImage(DisplayingImageEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent=="posts") { + if ($event->parent == "posts") { if ($user->can(Permissions::APPROVE_IMAGE)) { $event->add_nav_link("posts_unapproved", new Link('/post/list/approved%3Ano/1'), "Pending Approval", null, 60); } @@ -147,7 +147,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) $matches = []; if (is_null($event->term) && $this->no_approval_query($event->context)) { - $event->add_querylet(new Querylet("approved = :true", ["true"=>true])); + $event->add_querylet(new Querylet("approved = :true", ["true" => true])); } if (is_null($event->term)) { @@ -155,9 +155,9 @@ public function onSearchTermParse(SearchTermParseEvent $event) } if (preg_match(self::SEARCH_REGEXP, strtolower($event->term), $matches)) { if ($user->can(Permissions::APPROVE_IMAGE) && $matches[1] == "no") { - $event->add_querylet(new Querylet("approved != :true", ["true"=>true])); + $event->add_querylet(new Querylet("approved != :true", ["true" => true])); } else { - $event->add_querylet(new Querylet("approved = :true", ["true"=>true])); + $event->add_querylet(new Querylet("approved = :true", ["true" => true])); } } } @@ -166,7 +166,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { global $user, $config; - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { if ($user->can(Permissions::APPROVE_IMAGE) && $config->get_bool(ApprovalConfig::IMAGES)) { $event->add_block(new Block("Approval", $this->theme->get_help_html())); } @@ -190,7 +190,7 @@ public static function approve_image($image_id) $database->execute( "UPDATE images SET approved = :true, approved_by_id = :approved_by_id WHERE id = :id AND approved = :false", - ["approved_by_id"=>$user->id, "id"=>$image_id, "true"=>true, "false"=>false] + ["approved_by_id" => $user->id, "id" => $image_id, "true" => true, "false" => false] ); } @@ -200,7 +200,7 @@ public static function disapprove_image($image_id) $database->execute( "UPDATE images SET approved = :false, approved_by_id = NULL WHERE id = :id AND approved = :true", - ["id"=>$image_id, "true"=>true, "false"=>false] + ["id" => $image_id, "true" => true, "false" => false] ); } @@ -208,7 +208,7 @@ private function check_permissions(Image $image): bool { global $user, $config; - if ($config->get_bool(ApprovalConfig::IMAGES) && $image->approved===false && !$user->can(Permissions::APPROVE_IMAGE) && $user->id!==$image->owner_id) { + if ($config->get_bool(ApprovalConfig::IMAGES) && $image->approved === false && !$user->can(Permissions::APPROVE_IMAGE) && $user->id !== $image->owner_id) { return false; } return true; @@ -236,7 +236,7 @@ public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event) { global $user, $config; - if ($user->can(Permissions::APPROVE_IMAGE)&& $config->get_bool(ApprovalConfig::IMAGES)) { + if ($user->can(Permissions::APPROVE_IMAGE) && $config->get_bool(ApprovalConfig::IMAGES)) { if (in_array("approved:no", $event->search_terms)) { $event->add_action("bulk_approve_image", "Approve", "a"); } else { diff --git a/ext/approval/theme.php b/ext/approval/theme.php index 07c063bdb..6701e41b9 100644 --- a/ext/approval/theme.php +++ b/ext/approval/theme.php @@ -14,16 +14,16 @@ class ApprovalTheme extends Themelet { public function get_image_admin_html(Image $image): HTMLElement { - if ($image->approved===true) { + if ($image->approved === true) { $form = SHM_SIMPLE_FORM( 'disapprove_image/'.$image->id, - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image->id]), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image->id]), SHM_SUBMIT("Disapprove") ); } else { $form = SHM_SIMPLE_FORM( 'approve_image/'.$image->id, - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image->id]), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image->id]), SHM_SUBMIT("Approve") ); } @@ -52,9 +52,9 @@ public function display_admin_form() $form = SHM_SIMPLE_FORM( "admin/approval", - BUTTON(["name"=>'approval_action', "value"=>'approve_all'], "Approve All Posts"), + BUTTON(["name" => 'approval_action', "value" => 'approve_all'], "Approve All Posts"), " ", - BUTTON(["name"=>'approval_action', "value"=>'disapprove_all'], "Disapprove All Posts"), + BUTTON(["name" => 'approval_action', "value" => 'disapprove_all'], "Disapprove All Posts"), ); $page->add_block(new Block("Approval", $form)); diff --git a/ext/artists/info.php b/ext/artists/info.php index 2cd267526..870ece6d4 100644 --- a/ext/artists/info.php +++ b/ext/artists/info.php @@ -11,7 +11,7 @@ class ArtistsInfo extends ExtensionInfo 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 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; diff --git a/ext/artists/main.php b/ext/artists/main.php index 0c1cb1586..51be763be 100644 --- a/ext/artists/main.php +++ b/ext/artists/main.php @@ -50,13 +50,13 @@ public function onSearchTermParse(SearchTermParseEvent $event) $matches = []; if (preg_match("/^(author|artist)[=|:](.*)$/i", $event->term, $matches)) { $char = $matches[2]; - $event->add_querylet(new Querylet("author = :author_char", ["author_char"=>$char])); + $event->add_querylet(new Querylet("author = :author_char", ["author_char" => $char])); } } public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $event->add_block(new Block("Artist", $this->theme->get_help_html())); } } @@ -150,7 +150,7 @@ public function onAuthorSet(AuthorSetEvent $event) $database->execute( "UPDATE images SET author = :author WHERE id = :id", - ['author'=>$artistName, 'id'=>$event->image->id] + ['author' => $artistName, 'id' => $event->image->id] ); } @@ -419,28 +419,28 @@ public function onPageRequest(PageRequestEvent $event) private function get_artistName_by_imageID(int $imageID): string { global $database; - $result = $database->get_row("SELECT author FROM images WHERE id = :id", ['id'=>$imageID]); + $result = $database->get_row("SELECT author FROM images WHERE id = :id", ['id' => $imageID]); return $result['author'] ?? ""; } private function url_exists_by_url(string $url): bool { global $database; - $result = $database->get_one("SELECT COUNT(1) FROM artist_urls WHERE url = :url", ['url'=>$url]); + $result = $database->get_one("SELECT COUNT(1) FROM artist_urls WHERE url = :url", ['url' => $url]); return ($result != 0); } private function member_exists_by_name(string $member): bool { global $database; - $result = $database->get_one("SELECT COUNT(1) FROM artist_members WHERE name = :name", ['name'=>$member]); + $result = $database->get_one("SELECT COUNT(1) FROM artist_members WHERE name = :name", ['name' => $member]); return ($result != 0); } private function alias_exists_by_name(string $alias): bool { global $database; - $result = $database->get_one("SELECT COUNT(1) FROM artist_alias WHERE alias = :alias", ['alias'=>$alias]); + $result = $database->get_one("SELECT COUNT(1) FROM artist_alias WHERE alias = :alias", ['alias' => $alias]); return ($result != 0); } @@ -449,7 +449,7 @@ private function alias_exists(int $artistID, string $alias): bool global $database; $result = $database->get_one( "SELECT COUNT(1) FROM artist_alias WHERE artist_id = :artist_id AND alias = :alias", - ['artist_id'=>$artistID, 'alias'=>$alias] + ['artist_id' => $artistID, 'alias' => $alias] ); return ($result != 0); } @@ -457,73 +457,73 @@ private function alias_exists(int $artistID, string $alias): bool private function get_artistID_by_url(string $url): int { global $database; - return (int)$database->get_one("SELECT artist_id FROM artist_urls WHERE url = :url", ['url'=>$url]); + return (int)$database->get_one("SELECT artist_id FROM artist_urls WHERE url = :url", ['url' => $url]); } private function get_artistID_by_memberName(string $member): int { global $database; - return (int)$database->get_one("SELECT artist_id FROM artist_members WHERE name = :name", ['name'=>$member]); + return (int)$database->get_one("SELECT artist_id FROM artist_members WHERE name = :name", ['name' => $member]); } private function get_artistName_by_artistID(int $artistID): string { global $database; - return (string)$database->get_one("SELECT name FROM artists WHERE id = :id", ['id'=>$artistID]); + return (string)$database->get_one("SELECT name FROM artists WHERE id = :id", ['id' => $artistID]); } private function get_artistID_by_aliasID(int $aliasID): int { global $database; - return (int)$database->get_one("SELECT artist_id FROM artist_alias WHERE id = :id", ['id'=>$aliasID]); + return (int)$database->get_one("SELECT artist_id FROM artist_alias WHERE id = :id", ['id' => $aliasID]); } private function get_artistID_by_memberID(int $memberID): int { global $database; - return (int)$database->get_one("SELECT artist_id FROM artist_members WHERE id = :id", ['id'=>$memberID]); + return (int)$database->get_one("SELECT artist_id FROM artist_members WHERE id = :id", ['id' => $memberID]); } private function get_artistID_by_urlID(int $urlID): int { global $database; - return (int)$database->get_one("SELECT artist_id FROM artist_urls WHERE id = :id", ['id'=>$urlID]); + return (int)$database->get_one("SELECT artist_id FROM artist_urls WHERE id = :id", ['id' => $urlID]); } private function delete_alias(int $aliasID) { global $database; - $database->execute("DELETE FROM artist_alias WHERE id = :id", ['id'=>$aliasID]); + $database->execute("DELETE FROM artist_alias WHERE id = :id", ['id' => $aliasID]); } private function delete_url(int $urlID) { global $database; - $database->execute("DELETE FROM artist_urls WHERE id = :id", ['id'=>$urlID]); + $database->execute("DELETE FROM artist_urls WHERE id = :id", ['id' => $urlID]); } private function delete_member(int $memberID) { global $database; - $database->execute("DELETE FROM artist_members WHERE id = :id", ['id'=>$memberID]); + $database->execute("DELETE FROM artist_members WHERE id = :id", ['id' => $memberID]); } private function get_alias_by_id(int $aliasID): array { global $database; - return $database->get_row("SELECT * FROM artist_alias WHERE id = :id", ['id'=>$aliasID]); + return $database->get_row("SELECT * FROM artist_alias WHERE id = :id", ['id' => $aliasID]); } private function get_url_by_id(int $urlID): array { global $database; - return $database->get_row("SELECT * FROM artist_urls WHERE id = :id", ['id'=>$urlID]); + return $database->get_row("SELECT * FROM artist_urls WHERE id = :id", ['id' => $urlID]); } private function get_member_by_id(int $memberID): array { global $database; - return $database->get_row("SELECT * FROM artist_members WHERE id = :id", ['id'=>$memberID]); + return $database->get_row("SELECT * FROM artist_members WHERE id = :id", ['id' => $memberID]); } private function update_artist() @@ -558,7 +558,7 @@ private function update_artist() global $database; $database->execute( "UPDATE artists SET name = :name, notes = :notes, updated = now(), user_id = :user_id WHERE id = :id", - ['name'=>$name, 'notes'=>$notes, 'user_id'=>$userID, 'id'=>$artistID] + ['name' => $name, 'notes' => $notes, 'user_id' => $userID, 'id' => $artistID] ); // ALIAS MATCHING SECTION @@ -639,7 +639,7 @@ private function save_existing_alias(int $aliasID, string $alias, int $userID) global $database; $database->execute( "UPDATE artist_alias SET alias = :alias, updated = now(), user_id = :user_id WHERE id = :id", - ['alias'=>$alias, 'user_id'=>$userID, 'id'=>$aliasID] + ['alias' => $alias, 'user_id' => $userID, 'id' => $aliasID] ); } @@ -658,7 +658,7 @@ private function save_existing_url(int $urlID, string $url, int $userID) global $database; $database->execute( "UPDATE artist_urls SET url = :url, updated = now(), user_id = :user_id WHERE id = :id", - ['url'=>$url, 'user_id'=>$userID, 'id'=>$urlID] + ['url' => $url, 'user_id' => $userID, 'id' => $urlID] ); } @@ -677,7 +677,7 @@ private function save_existing_member(int $memberID, string $memberName, int $us global $database; $database->execute( "UPDATE artist_members SET name = :name, updated = now(), user_id = :user_id WHERE id = :id", - ['name'=>$memberName, 'user_id'=>$userID, 'id'=>$memberID] + ['name' => $memberName, 'user_id' => $userID, 'id' => $memberID] ); } @@ -753,7 +753,7 @@ private function save_new_artist(string $name, string $notes): int $database->execute(" INSERT INTO artists (user_id, name, notes, created, updated) VALUES (:user_id, :name, :notes, now(), now()) - ", ['user_id'=>$user->id, 'name'=>$name, 'notes'=>$notes]); + ", ['user_id' => $user->id, 'name' => $name, 'notes' => $notes]); return $database->get_last_insert_id('artists_id_seq'); } @@ -762,7 +762,7 @@ private function artist_exists(string $name): bool global $database; $result = $database->get_one( "SELECT COUNT(1) FROM artists WHERE name = :name", - ['name'=>$name] + ['name' => $name] ); return ($result != 0); } @@ -772,7 +772,7 @@ private function get_artist(int $artistID): array global $database; $result = $database->get_row( "SELECT * FROM artists WHERE id = :id", - ['id'=>$artistID] + ['id' => $artistID] ); $result["name"] = stripslashes($result["name"]); @@ -786,7 +786,7 @@ private function get_members(int $artistID): array global $database; $result = $database->get_all( "SELECT * FROM artist_members WHERE artist_id = :artist_id", - ['artist_id'=>$artistID] + ['artist_id' => $artistID] ); $num = count($result); @@ -802,7 +802,7 @@ private function get_urls(int $artistID): array global $database; $result = $database->get_all( "SELECT id, url FROM artist_urls WHERE artist_id = :artist_id", - ['artist_id'=>$artistID] + ['artist_id' => $artistID] ); $num = count($result); @@ -818,7 +818,7 @@ private function get_artist_id(string $name): int global $database; return (int)$database->get_one( "SELECT id FROM artists WHERE name = :name", - ['name'=>$name] + ['name' => $name] ); } @@ -828,7 +828,7 @@ private function get_artistID_by_aliasName(string $alias): int return (int)$database->get_one( "SELECT artist_id FROM artist_alias WHERE alias = :alias", - ['alias'=>$alias] + ['alias' => $alias] ); } @@ -837,7 +837,7 @@ private function delete_artist(int $artistID) global $database; $database->execute( "DELETE FROM artists WHERE id = :id", - ['id'=>$artistID] + ['id' => $artistID] ); } @@ -900,8 +900,8 @@ private function get_listing(PageRequestEvent $event) LIMIT :offset, :limit ", [ - "offset"=>$pageNumber * $artistsPerPage, - "limit"=>$artistsPerPage + "offset" => $pageNumber * $artistsPerPage, + "limit" => $artistsPerPage ] ); @@ -953,7 +953,7 @@ private function save_new_url(int $artistID, string $url, int $userID) $database->execute( "INSERT INTO artist_urls (artist_id, created, updated, url, user_id) VALUES (:artist_id, now(), now(), :url, :user_id)", - ['artist'=>$artistID, 'url'=>$url, 'user_id'=>$userID] + ['artist' => $artistID, 'url' => $url, 'user_id' => $userID] ); } @@ -980,7 +980,7 @@ private function save_new_alias(int $artistID, string $alias, int $userID) $database->execute( "INSERT INTO artist_alias (artist_id, created, updated, alias, user_id) VALUES (:artist_id, now(), now(), :alias, :user_id)", - ['artist_id'=>$artistID, 'alias'=>$alias, 'user_id'=>$userID] + ['artist_id' => $artistID, 'alias' => $alias, 'user_id' => $userID] ); } @@ -1007,7 +1007,7 @@ private function save_new_member(int $artistID, string $member, int $userID) $database->execute( "INSERT INTO artist_members (artist_id, name, created, updated, user_id) VALUES (:artist_id, :name, now(), now(), :user_id)", - ['artist'=>$artistID, 'name'=>$member, 'user_id'=>$userID] + ['artist' => $artistID, 'name' => $member, 'user_id' => $userID] ); } @@ -1017,7 +1017,7 @@ private function member_exists(int $artistID, string $member): bool $result = $database->get_one( "SELECT COUNT(1) FROM artist_members WHERE artist_id = :artist_id AND name = :name", - ['artist_id'=>$artistID, 'name'=>$member] + ['artist_id' => $artistID, 'name' => $member] ); return ($result != 0); } @@ -1028,7 +1028,7 @@ private function url_exists(int $artistID, string $url): bool $result = $database->get_one( "SELECT COUNT(1) FROM artist_urls WHERE artist_id = :artist_id AND url = :url", - ['artist_id'=>$artistID, 'url'=>$url] + ['artist_id' => $artistID, 'url' => $url] ); return ($result != 0); } @@ -1045,7 +1045,7 @@ private function get_alias(int $artistID): array FROM artist_alias WHERE artist_id = :artist_id ORDER BY alias ASC - ", ['artist_id'=>$artistID]); + ", ['artist_id' => $artistID]); $rc = count($result); for ($i = 0 ; $i < $rc ; $i++) { diff --git a/ext/artists/theme.php b/ext/artists/theme.php index ed36eb3f9..5db8f1e61 100644 --- a/ext/artists/theme.php +++ b/ext/artists/theme.php @@ -17,11 +17,11 @@ public function get_author_editor_html(string $author): HTMLElement "Author", true, $author, - INPUT(["type"=>"text", "name"=>"tag_edit__author", "value"=>$author]) + INPUT(["type" => "text", "name" => "tag_edit__author", "value" => $author]) ); } - public function sidebar_options(string $mode, ?int $artistID=null, $is_admin=false): void + public function sidebar_options(string $mode, ?int $artistID = null, $is_admin = false): void { global $page, $user; @@ -113,7 +113,7 @@ public function show_artist_editor($artist, $aliases, $members, $urls) $urlsString .= $url["url"]."\n"; $urlsIDsString .= $url["id"]." "; } - $urlsString = substr($urlsString, 0, strlen($urlsString) -1); + $urlsString = substr($urlsString, 0, strlen($urlsString) - 1); $urlsIDsString = rtrim($urlsIDsString); $html = ' diff --git a/ext/auto_tagger/info.php b/ext/auto_tagger/info.php index ad1a7969a..a1c8697d9 100644 --- a/ext/auto_tagger/info.php +++ b/ext/auto_tagger/info.php @@ -10,7 +10,7 @@ class AutoTaggerInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Auto-Tagger"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Provides several automatic tagging functions"; } diff --git a/ext/auto_tagger/main.php b/ext/auto_tagger/main.php index 08530e300..677df69b7 100644 --- a/ext/auto_tagger/main.php +++ b/ext/auto_tagger/main.php @@ -120,7 +120,7 @@ public function onPageRequest(PageRequestEvent $event) if ($event->get_arg(0) == "add") { if ($user->can(Permissions::MANAGE_AUTO_TAG)) { $user->ensure_authed(); - $input = validate_input(["c_tag"=>"string", "c_additional_tags"=>"string"]); + $input = validate_input(["c_tag" => "string", "c_additional_tags" => "string"]); try { send_event(new AddAutoTagEvent($input['c_tag'], $input['c_additional_tags'])); $page->set_mode(PageMode::REDIRECT); @@ -132,7 +132,7 @@ public function onPageRequest(PageRequestEvent $event) } elseif ($event->get_arg(0) == "remove") { if ($user->can(Permissions::MANAGE_AUTO_TAG)) { $user->ensure_authed(); - $input = validate_input(["d_tag"=>"string"]); + $input = validate_input(["d_tag" => "string"]); send_event(new DeleteAutoTagEvent($input['d_tag'])); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link("auto_tag/list")); @@ -183,7 +183,7 @@ public function onPageRequest(PageRequestEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="tags") { + if ($event->parent == "tags") { $event->add_nav_link("auto_tag", new Link('auto_tag/list'), "Auto-Tag", NavLink::is_active(["auto_tag"])); } } @@ -267,21 +267,22 @@ private function add_auto_tag_csv(string $csv): int private function add_auto_tag(string $tag, string $additional_tags) { global $database; - $existing_tags = $database->get_one("SELECT additional_tags FROM auto_tag WHERE LOWER(tag)=LOWER(:tag)", ["tag"=>$tag]); - if (!is_null($existing_tags)) { - // Auto Tags already exist, so we will append new tags to the existing one - $tag = Tag::sanitize($tag); + + $existing_tags = $database->get_one("SELECT additional_tags FROM auto_tag WHERE LOWER(tag)=LOWER(:tag)", ["tag" => $tag]); + if (!is_null($existing_tags)) { + // Auto Tags already exist, so we will append new tags to the existing one + $tag = Tag::sanitize($tag); $additional_tags = Tag::explode($additional_tags); - $existing_tags = Tag::explode($existing_tags); - foreach ($additional_tags as $t) { - if (!in_array(strtolower($t), $existing_tags)) { - array_push($existing_tags, strtolower($t)); - } - } + $existing_tags = Tag::explode($existing_tags); + foreach ($additional_tags as $t) { + if (!in_array(strtolower($t), $existing_tags)) { + array_push($existing_tags, strtolower($t)); + } + } $database->execute( "UPDATE auto_tag set additional_tags=:existing_tags where tag=:tag", - ["tag"=>$tag, "existing_tags"=>Tag::implode($existing_tags)] + ["tag" => $tag, "existing_tags" => Tag::implode($existing_tags)] ); log_info( AutoTaggerInfo::KEY, @@ -293,7 +294,7 @@ private function add_auto_tag(string $tag, string $additional_tags) $database->execute( "INSERT INTO auto_tag(tag, additional_tags) VALUES(:tag, :additional_tags)", - ["tag"=>$tag, "additional_tags"=>Tag::implode($additional_tags)] + ["tag" => $tag, "additional_tags" => Tag::implode($additional_tags)] ); log_info( @@ -308,9 +309,9 @@ private function add_auto_tag(string $tag, string $additional_tags) private function apply_new_auto_tag(string $tag) { global $database; - $tag_id = $database->get_one("SELECT id FROM tags WHERE LOWER(tag) = LOWER(:tag)", ["tag"=>$tag]); + $tag_id = $database->get_one("SELECT id FROM tags WHERE LOWER(tag) = LOWER(:tag)", ["tag" => $tag]); if (!empty($tag_id)) { - $image_ids = $database->get_col_iterable("SELECT image_id FROM image_tags WHERE tag_id = :tag_id", ["tag_id"=>$tag_id]); + $image_ids = $database->get_col_iterable("SELECT image_id FROM image_tags WHERE tag_id = :tag_id", ["tag_id" => $tag_id]); foreach ($image_ids as $image_id) { $image_id = (int) $image_id; $image = Image::by_id($image_id); diff --git a/ext/autocomplete/info.php b/ext/autocomplete/info.php index bf8539762..dd1ce7d24 100644 --- a/ext/autocomplete/info.php +++ b/ext/autocomplete/info.php @@ -10,6 +10,6 @@ class AutoCompleteInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Autocomplete"; - public array $authors = ["Daku"=>"admin@codeanimu.net"]; + public array $authors = ["Daku" => "admin@codeanimu.net"]; public string $description = "Adds autocomplete to search & tagging."; } diff --git a/ext/autocomplete/main.php b/ext/autocomplete/main.php index 35b379c87..a350c00d9 100644 --- a/ext/autocomplete/main.php +++ b/ext/autocomplete/main.php @@ -55,7 +55,7 @@ private function complete(string $search, int $limit): array $limitSQL = ""; $search = str_replace('_', '\_', $search); $search = str_replace('%', '\%', $search); - $SQLarr = ["search"=>"$search%"]; #, "cat_search"=>"%:$search%"]; + $SQLarr = ["search" => "$search%"]; #, "cat_search"=>"%:$search%"]; if ($limit !== 0) { $limitSQL = "LIMIT :limit"; $SQLarr['limit'] = $limit; diff --git a/ext/autocomplete/test.php b/ext/autocomplete/test.php index 8378e5840..ff82aa63e 100644 --- a/ext/autocomplete/test.php +++ b/ext/autocomplete/test.php @@ -9,7 +9,7 @@ class AutoCompleteTest extends ShimmiePHPUnitTestCase public function testAuth() { send_event(new UserLoginEvent(User::by_name(self::$anon_name))); - $page = $this->get_page('api/internal/autocomplete', ["s"=>"not-a-tag"]); + $page = $this->get_page('api/internal/autocomplete', ["s" => "not-a-tag"]); $this->assertEquals(200, $page->code); $this->assertEquals(PageMode::DATA, $page->mode); $this->assertEquals("[]", $page->data); diff --git a/ext/bbcode/main.php b/ext/bbcode/main.php index f2739441b..5d39b6f45 100644 --- a/ext/bbcode/main.php +++ b/ext/bbcode/main.php @@ -97,8 +97,8 @@ private function strip_spoiler(string $text): string } $beginning = substr($text, 0, $start); - $middle = str_rot13(substr($text, $start+$l1, ($end-$start-$l1))); - $ending = substr($text, $end + $l2, (strlen($text)-$end+$l2)); + $middle = str_rot13(substr($text, $start + $l1, ($end - $start - $l1))); + $ending = substr($text, $end + $l2, (strlen($text) - $end + $l2)); $text = $beginning . $middle . $ending; } @@ -131,8 +131,8 @@ private function extract_code(string $text): string } $beginning = substr($text, 0, $start); - $middle = base64_encode(substr($text, $start+$l1, ($end-$start-$l1))); - $ending = substr($text, $end + $l2, (strlen($text)-$end+$l2)); + $middle = base64_encode(substr($text, $start + $l1, ($end - $start - $l1))); + $ending = substr($text, $end + $l2, (strlen($text) - $end + $l2)); $text = $beginning . "[code!]" . $middle . "[/code!]" . $ending; } @@ -155,8 +155,8 @@ private function insert_code(string $text): string } $beginning = substr($text, 0, $start); - $middle = base64_decode(substr($text, $start+$l1, ($end-$start-$l1))); - $ending = substr($text, $end + $l2, (strlen($text)-$end+$l2)); + $middle = base64_decode(substr($text, $start + $l1, ($end - $start - $l1))); + $ending = substr($text, $end + $l2, (strlen($text) - $end + $l2)); $text = $beginning . "" . $middle . "" . $ending; } diff --git a/ext/biography/test.php b/ext/biography/test.php index d410df72f..700febc6b 100644 --- a/ext/biography/test.php +++ b/ext/biography/test.php @@ -9,7 +9,7 @@ class BiographyTest extends ShimmiePHPUnitTestCase public function testBio() { $this->log_in_as_user(); - $this->post_page("biography", ["biography"=>"My bio goes here"]); + $this->post_page("biography", ["biography" => "My bio goes here"]); $this->get_page("user/" . self::$user_name); $this->assert_text("My bio goes here"); diff --git a/ext/biography/theme.php b/ext/biography/theme.php index f555e932d..83857d133 100644 --- a/ext/biography/theme.php +++ b/ext/biography/theme.php @@ -17,7 +17,7 @@ public function display_composer(Page $page, string $bio) { $html = SHM_SIMPLE_FORM( make_link("biography"), - TEXTAREA(["style"=>"width: 100%", "rows"=>"6", "name"=>"biography"], $bio), + TEXTAREA(["style" => "width: 100%", "rows" => "6", "name" => "biography"], $bio), SHM_SUBMIT("Save") ); diff --git a/ext/blocks/main.php b/ext/blocks/main.php index e864b3116..c7bcb2b96 100644 --- a/ext/blocks/main.php +++ b/ext/blocks/main.php @@ -34,7 +34,7 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::MANAGE_BLOCKS)) { $event->add_nav_link("blocks", new Link('blocks/list'), "Blocks Editor"); } @@ -78,7 +78,7 @@ public function onPageRequest(PageRequestEvent $event) $database->execute(" INSERT INTO blocks (pages, title, area, priority, content, userclass) VALUES (:pages, :title, :area, :priority, :content, :userclass) - ", ['pages'=>$_POST['pages'], 'title'=>$_POST['title'], 'area'=>$_POST['area'], 'priority'=>(int)$_POST['priority'], 'content'=>$_POST['content'], 'userclass'=>$_POST['userclass']]); + ", ['pages' => $_POST['pages'], 'title' => $_POST['title'], 'area' => $_POST['area'], 'priority' => (int)$_POST['priority'], 'content' => $_POST['content'], 'userclass' => $_POST['userclass']]); log_info("blocks", "Added Block #".($database->get_last_insert_id('blocks_id_seq'))." (".$_POST['title'].")"); $cache->delete("blocks"); $page->set_mode(PageMode::REDIRECT); @@ -91,13 +91,13 @@ public function onPageRequest(PageRequestEvent $event) $database->execute(" DELETE FROM blocks WHERE id=:id - ", ['id'=>$_POST['id']]); + ", ['id' => $_POST['id']]); log_info("blocks", "Deleted Block #".$_POST['id']); } else { $database->execute(" UPDATE blocks SET pages=:pages, title=:title, area=:area, priority=:priority, content=:content, userclass=:userclass WHERE id=:id - ", ['pages'=>$_POST['pages'], 'title'=>$_POST['title'], 'area'=>$_POST['area'], 'priority'=>(int)$_POST['priority'], 'content'=>$_POST['content'], 'userclass'=>$_POST['userclass'], 'id'=>$_POST['id']]); + ", ['pages' => $_POST['pages'], 'title' => $_POST['title'], 'area' => $_POST['area'], 'priority' => (int)$_POST['priority'], 'content' => $_POST['content'], 'userclass' => $_POST['userclass'], 'id' => $_POST['id']]); log_info("blocks", "Updated Block #".$_POST['id']." (".$_POST['title'].")"); } $cache->delete("blocks"); diff --git a/ext/blocks/theme.php b/ext/blocks/theme.php index 4f2961406..1757cb810 100644 --- a/ext/blocks/theme.php +++ b/ext/blocks/theme.php @@ -20,31 +20,31 @@ public function display_blocks($blocks) { global $page; - $html = TABLE(["class"=>"form", "style"=>"width: 100%;"]); + $html = TABLE(["class" => "form", "style" => "width: 100%;"]); foreach ($blocks as $block) { $html->appendChild(SHM_SIMPLE_FORM( "blocks/update", TR( - INPUT(["type"=>"hidden", "name"=>"id", "value"=>$block['id']]), + INPUT(["type" => "hidden", "name" => "id", "value" => $block['id']]), TH("Title"), - TD(INPUT(["type"=>"text", "name"=>"title", "value"=>$block['title']])), + TD(INPUT(["type" => "text", "name" => "title", "value" => $block['title']])), TH("Area"), - TD(INPUT(["type"=>"text", "name"=>"area", "value"=>$block['area']])), + TD(INPUT(["type" => "text", "name" => "area", "value" => $block['area']])), TH("Priority"), - TD(INPUT(["type"=>"text", "name"=>"priority", "value"=>$block['priority']])), + TD(INPUT(["type" => "text", "name" => "priority", "value" => $block['priority']])), TH("User Class"), - TD(INPUT(["type"=>"text", "name"=>"userclass", "value"=>$block['userclass']])), + TD(INPUT(["type" => "text", "name" => "userclass", "value" => $block['userclass']])), TH("Pages"), - TD(INPUT(["type"=>"text", "name"=>"pages", "value"=>$block['pages']])), + TD(INPUT(["type" => "text", "name" => "pages", "value" => $block['pages']])), TH("Delete"), - TD(INPUT(["type"=>"checkbox", "name"=>"delete"])), - TD(INPUT(["type"=>"submit", "value"=>"Save"])) + TD(INPUT(["type" => "checkbox", "name" => "delete"])), + TD(INPUT(["type" => "submit", "value" => "Save"])) ), TR( - TD(["colspan"=>"13"], TEXTAREA(["rows"=>"5", "name"=>"content"], $block['content'])) + TD(["colspan" => "13"], TEXTAREA(["rows" => "5", "name" => "content"], $block['content'])) ), TR( - TD(["colspan"=>"13"], rawHTML(" ")) + TD(["colspan" => "13"], rawHTML(" ")) ), )); } @@ -53,19 +53,19 @@ public function display_blocks($blocks) "blocks/add", TR( TH("Title"), - TD(INPUT(["type"=>"text", "name"=>"title", "value"=>""])), + TD(INPUT(["type" => "text", "name" => "title", "value" => ""])), TH("Area"), - TD(SELECT(["name"=>"area"], OPTION("left"), OPTION("main"))), + TD(SELECT(["name" => "area"], OPTION("left"), OPTION("main"))), TH("Priority"), - TD(INPUT(["type"=>"text", "name"=>"priority", "value"=>'50'])), + TD(INPUT(["type" => "text", "name" => "priority", "value" => '50'])), TH("User Class"), - TD(INPUT(["type"=>"text", "name"=>"userclass", "value"=>""])), + TD(INPUT(["type" => "text", "name" => "userclass", "value" => ""])), TH("Pages"), - TD(INPUT(["type"=>"text", "name"=>"pages", "value"=>'post/list*'])), - TD(["colspan"=>'3'], INPUT(["type"=>"submit", "value"=>"Add"])) + TD(INPUT(["type" => "text", "name" => "pages", "value" => 'post/list*'])), + TD(["colspan" => '3'], INPUT(["type" => "submit", "value" => "Add"])) ), TR( - TD(["colspan"=>"13"], TEXTAREA(["rows"=>"5", "name"=>"content"])) + TD(["colspan" => "13"], TEXTAREA(["rows" => "5", "name" => "content"])) ), )); diff --git a/ext/blotter/info.php b/ext/blotter/info.php index 844b3aa28..6a73a0328 100644 --- a/ext/blotter/info.php +++ b/ext/blotter/info.php @@ -11,7 +11,7 @@ class BlotterInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Blotter"; public string $url = "http://seemslegit.com/"; - public array $authors = ["Zach Hall"=>"zach@sosguy.net"]; + public array $authors = ["Zach Hall" => "zach@sosguy.net"]; public string $license = self::LICENSE_GPLV2; public string $description = "Displays brief updates about whatever you want on every page. Colors and positioning can be configured to match your site's design. diff --git a/ext/blotter/main.php b/ext/blotter/main.php index 7c7d5451e..1450d5473 100644 --- a/ext/blotter/main.php +++ b/ext/blotter/main.php @@ -31,7 +31,7 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) // Insert sample data: $database->execute( "INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), :text, :important)", - ["text"=>"Installed the blotter extension!", "important"=>true] + ["text" => "Installed the blotter extension!", "important" => true] ); log_info("blotter", "Installed tables for blotter extension."); $this->set_version("blotter_version", 2); @@ -53,7 +53,7 @@ public function onSetupBuilding(SetupBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::BLOTTER_ADMIN)) { $event->add_nav_link("blotter", new Link('blotter/editor'), "Blotter Editor"); } @@ -100,7 +100,7 @@ public function onPageRequest(PageRequestEvent $event) // Now insert into db: $database->execute( "INSERT INTO blotter (entry_date, entry_text, important) VALUES (now(), :text, :important)", - ["text"=>$entry_text, "important"=>$important] + ["text" => $entry_text, "important" => $important] ); log_info("blotter", "Added Message: $entry_text"); $page->set_mode(PageMode::REDIRECT); @@ -115,7 +115,7 @@ public function onPageRequest(PageRequestEvent $event) $this->theme->display_permission_denied(); } else { $id = int_escape($_POST['id']); - $database->execute("DELETE FROM blotter WHERE id=:id", ["id"=>$id]); + $database->execute("DELETE FROM blotter WHERE id=:id", ["id" => $id]); log_info("blotter", "Removed Entry #$id"); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link("blotter/editor")); diff --git a/ext/blotter/theme.php b/ext/blotter/theme.php index 67096a94e..e01098ee8 100644 --- a/ext/blotter/theme.php +++ b/ext/blotter/theme.php @@ -127,7 +127,7 @@ private function get_html_for_blotter_page(array $entries): string $entry_text = $entries[$i]['entry_text']; if ($entries[$i]['important'] == 'Y') { $i_open = ""; - $i_close=""; + $i_close = ""; } $html .= "{$i_open}{$clean_date} - {$entry_text}{$i_close}"; } @@ -155,7 +155,7 @@ private function get_html_for_blotter(array $entries): string $entry_text = $entries[$i]['entry_text']; if ($entries[$i]['important'] == 'Y') { $i_open = ""; - $i_close=""; + $i_close = ""; } $entries_list .= "{$i_open}{$clean_date} - {$entry_text}{$i_close}"; } diff --git a/ext/browser_search/info.php b/ext/browser_search/info.php index 0644f9bc6..b5fa37c48 100644 --- a/ext/browser_search/info.php +++ b/ext/browser_search/info.php @@ -11,7 +11,7 @@ class BrowserSearchInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Browser Search"; public string $url = "http://atravelinggeek.com/"; - public array $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"]; + public array $authors = ["ATravelingGeek" => "atg@atravelinggeek.com"]; public string $license = self::LICENSE_GPLV2; public ?string $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"; diff --git a/ext/browser_search/main.php b/ext/browser_search/main.php index 3487d78bc..4cdb35424 100644 --- a/ext/browser_search/main.php +++ b/ext/browser_search/main.php @@ -65,7 +65,7 @@ public function onPageRequest(PageRequestEvent $event) } $tags = $database->get_col( "SELECT tag FROM tags WHERE tag LIKE :tag AND count > 0 ORDER BY $order LIMIT 30", - ['tag'=>$tag_search."%"] + ['tag' => $tag_search."%"] ); // And to do stuff with it. We want our output to look like: diff --git a/ext/bulk_actions/info.php b/ext/bulk_actions/info.php index 6d2f8fe02..1c4dd33ff 100644 --- a/ext/bulk_actions/info.php +++ b/ext/bulk_actions/info.php @@ -10,7 +10,7 @@ class BulkActionsInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Bulk Actions"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $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, contributions by Shish and Agasa. diff --git a/ext/bulk_actions/main.php b/ext/bulk_actions/main.php index ae1193444..ee235eed8 100644 --- a/ext/bulk_actions/main.php +++ b/ext/bulk_actions/main.php @@ -15,15 +15,15 @@ class BulkActionBlockBuildingEvent extends Event public function add_action(string $action, string $button_text, string $access_key = null, string $confirmation_message = "", string $block = "", int $position = 40) { if (!empty($access_key)) { - assert(strlen($access_key)==1); + assert(strlen($access_key) == 1); foreach ($this->actions as $existing) { - if ($existing["access_key"]==$access_key) { + if ($existing["access_key"] == $access_key) { throw new SCoreException("Access key $access_key is already in use"); } } } - $this->actions[] =[ + $this->actions[] = [ "block" => $block, "access_key" => $access_key, "confirmation_message" => $confirmation_message, @@ -137,7 +137,7 @@ public function onBulkAction(BulkActionEvent $event) $replace = true; } - $i= $this->tag_items($event->items, $tags, $replace); + $i = $this->tag_items($event->items, $tags, $replace); $page->flash("Tagged $i items"); } break; @@ -204,7 +204,7 @@ private function yield_items(array $data): \Generator foreach ($data as $id) { if (is_numeric($id)) { $image = Image::by_id($id); - if ($image!=null) { + if ($image != null) { yield $image; } } diff --git a/ext/bulk_add_csv/info.php b/ext/bulk_add_csv/info.php index 46d131920..3575b3eef 100644 --- a/ext/bulk_add_csv/info.php +++ b/ext/bulk_add_csv/info.php @@ -11,7 +11,7 @@ class BulkAddCSVInfo extends ExtensionInfo 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 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 = diff --git a/ext/bulk_download/info.php b/ext/bulk_download/info.php index d52604591..14e1b7317 100644 --- a/ext/bulk_download/info.php +++ b/ext/bulk_download/info.php @@ -10,7 +10,7 @@ class BulkDownloadInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Bulk Download"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Allows bulk downloading images."; public array $dependencies = [BulkActionsInfo::KEY]; diff --git a/ext/bulk_download/main.php b/ext/bulk_download/main.php index 64e38025f..1947889e5 100644 --- a/ext/bulk_download/main.php +++ b/ext/bulk_download/main.php @@ -45,7 +45,7 @@ public function onBulkAction(BulkActionEvent $event) { global $user, $page, $config; - if ($user->can(Permissions::BULK_DOWNLOAD)&& + if ($user->can(Permissions::BULK_DOWNLOAD) && ($event->action == BulkDownload::DOWNLOAD_ACTION_NAME)) { $download_filename = $user->name . '-' . date('YmdHis') . '.zip'; $zip_filename = tempnam(sys_get_temp_dir(), "shimmie_bulk_download"); @@ -57,7 +57,7 @@ public function onBulkAction(BulkActionEvent $event) foreach ($event->items as $image) { $img_loc = warehouse_path(Image::IMAGE_DIR, $image->hash, false); $size_total += filesize($img_loc); - if ($size_total>$max_size) { + if ($size_total > $max_size) { throw new BulkDownloadException("Bulk download limited to ".human_filesize($max_size)); } diff --git a/ext/bulk_import_export/info.php b/ext/bulk_import_export/info.php index 6ad951b02..c36a416e7 100644 --- a/ext/bulk_import_export/info.php +++ b/ext/bulk_import_export/info.php @@ -12,7 +12,7 @@ class BulkImportExportInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Bulk Import/Export"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Allows bulk exporting/importing of images and associated data."; public array $dependencies = [BulkActionsInfo::KEY]; diff --git a/ext/bulk_import_export/main.php b/ext/bulk_import_export/main.php index 5f635784a..3dd921cb6 100644 --- a/ext/bulk_import_export/main.php +++ b/ext/bulk_import_export/main.php @@ -37,7 +37,7 @@ public function onDataUpload(DataUploadEvent $event) $database->begin_transaction(); try { $image = Image::by_hash($item->hash); - if ($image!=null) { + if ($image != null) { $skipped++; log_info(BulkImportExportInfo::KEY, "Post $item->hash already present, skipping"); $database->commit(); @@ -54,17 +54,17 @@ public function onDataUpload(DataUploadEvent $event) $id = add_image($tmpfile, $item->filename, Tag::implode($item->tags))->image_id; - if ($id==-1) { + if ($id == -1) { throw new SCoreException("Unable to import file $item->hash"); } $image = Image::by_id($id); - if ($image==null) { + if ($image == null) { throw new SCoreException("Unable to import file $item->hash"); } - if ($item->source!=null) { + if ($item->source != null) { $image->set_source($item->source); } send_event(new BulkImportEvent($image, $item)); diff --git a/ext/bulk_parent_child/info.php b/ext/bulk_parent_child/info.php index 4f30a9d8d..b01ea6e75 100644 --- a/ext/bulk_parent_child/info.php +++ b/ext/bulk_parent_child/info.php @@ -10,7 +10,7 @@ class BulkParentChildInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Bulk Parent Child"; - public array $authors = ["Flatty"=>""]; + public array $authors = ["Flatty" => ""]; public string $license = self::LICENSE_WTFPL; public string $description = "Allows bulk setting of parent-child relationships, in order of manual selection"; public array $dependencies = [BulkActionsInfo::KEY]; diff --git a/ext/bulk_parent_child/main.php b/ext/bulk_parent_child/main.php index 3e3c58bd7..4729f70c2 100644 --- a/ext/bulk_parent_child/main.php +++ b/ext/bulk_parent_child/main.php @@ -27,7 +27,7 @@ public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event) public function onBulkAction(BulkActionEvent $event) { global $user, $page, $config; - if ($user->can(Permissions::BULK_PARENT_CHILD)&& + if ($user->can(Permissions::BULK_PARENT_CHILD) && ($event->action == BulkParentChild::PARENT_CHILD_ACTION_NAME)) { $prev_id = null; foreach ($event->items as $image) { diff --git a/ext/comment/main.php b/ext/comment/main.php index 113161fbc..a16d8d643 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -84,7 +84,7 @@ public static function count_comments_by_user(User $user): int SELECT COUNT(*) AS count FROM comments WHERE owner_id=:owner_id - ", ["owner_id"=>$user->id]); + ", ["owner_id" => $user->id]); } #[Field(name: "owner")] @@ -187,7 +187,7 @@ public function onPageNavBuilding(PageNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="comment") { + if ($event->parent == "comment") { $event->add_nav_link("comment_list", new Link('comment/list'), "All"); $event->add_nav_link("comment_help", new Link('ext_doc/comment'), "Help"); } @@ -306,7 +306,7 @@ private function onPageRequest_list(PageRequestEvent $event) GROUP BY image_id ORDER BY latest DESC LIMIT :limit OFFSET :offset - ", ["limit"=>$threads_per_page, "offset"=>$start]); + ", ["limit" => $threads_per_page, "offset" => $start]); $user_ratings = Extension::is_enabled(RatingsInfo::KEY) ? Ratings::get_user_class_privs($user) : ""; @@ -322,7 +322,7 @@ private function onPageRequest_list(PageRequestEvent $event) if ( Extension::is_enabled(ApprovalInfo::KEY) && !is_null($image) && $config->get_bool(ApprovalConfig::IMAGES) && - $image->approved!==true + $image->approved !== true ) { $image = null; } @@ -332,7 +332,7 @@ private function onPageRequest_list(PageRequestEvent $event) } } - $this->theme->display_comment_list($images, $current_page+1, $total_pages, $user->can(Permissions::CREATE_COMMENT)); + $this->theme->display_comment_list($images, $current_page + 1, $total_pages, $user->can(Permissions::CREATE_COMMENT)); } private function onPageRequest_beta_search(PageRequestEvent $event) @@ -344,7 +344,7 @@ private function onPageRequest_beta_search(PageRequestEvent $event) $com_per_page = 50; $total_pages = (int)ceil($i_comment_count / $com_per_page); $comments = $this->get_user_comments($duser->id, $com_per_page, $page_num * $com_per_page); - $this->theme->display_all_user_comments($comments, $page_num+1, $total_pages, $duser); + $this->theme->display_all_user_comments($comments, $page_num + 1, $total_pages, $duser); } public function onAdminBuilding(AdminBuildingEvent $event) @@ -401,7 +401,7 @@ public function onCommentDeletion(CommentDeletionEvent $event) $database->execute(" DELETE FROM comments WHERE id=:comment_id - ", ["comment_id"=>$event->comment_id]); + ", ["comment_id" => $event->comment_id]); log_info("comment", "Deleting Comment #{$event->comment_id}"); } @@ -446,7 +446,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $block = new Block(); $block->header = "Comments"; $block->body = $this->theme->get_help_html(); @@ -483,13 +483,13 @@ private static function get_recent_comments(int $count): array LEFT JOIN users ON comments.owner_id=users.id ORDER BY comments.id DESC LIMIT :limit - ", ["limit"=>$count]); + ", ["limit" => $count]); } /** * #return Comment[] */ - private static function get_user_comments(int $user_id, int $count, int $offset=0): array + private static function get_user_comments(int $user_id, int $count, int $offset = 0): array { return CommentList::get_generic_comments(" SELECT @@ -502,7 +502,7 @@ private static function get_user_comments(int $user_id, int $count, int $offset= WHERE users.id = :user_id ORDER BY comments.id DESC LIMIT :limit OFFSET :offset - ", ["user_id"=>$user_id, "offset"=>$offset, "limit"=>$count]); + ", ["user_id" => $user_id, "offset" => $offset, "limit" => $count]); } /** @@ -521,7 +521,7 @@ public static function get_comments(int $image_id): array LEFT JOIN users ON comments.owner_id=users.id WHERE comments.image_id=:image_id ORDER BY comments.id ASC - ", ["image_id"=>$image_id]); + ", ["image_id" => $image_id]); } private function is_comment_limit_hit(): bool @@ -547,7 +547,7 @@ private function is_comment_limit_hit(): bool SELECT * FROM comments WHERE owner_ip = :remote_ip AND posted > now() - $window_sql - ", ["remote_ip"=>get_real_ip()]); + ", ["remote_ip" => get_real_ip()]); return (count($result) >= $max); } @@ -609,7 +609,7 @@ private function is_dupe(int $image_id, string $comment): bool SELECT * FROM comments WHERE image_id=:image_id AND comment=:comment - ", ["image_id"=>$image_id, "comment"=>$comment]); + ", ["image_id" => $image_id, "comment" => $comment]); } // do some checks @@ -624,12 +624,12 @@ private function add_comment_wrapper(int $image_id, User $user, string $comment) // all checks passed if ($user->is_anonymous()) { - $page->add_cookie("nocache", "Anonymous Commenter", time()+60*60*24, "/"); + $page->add_cookie("nocache", "Anonymous Commenter", time() + 60 * 60 * 24, "/"); } $database->execute( "INSERT INTO comments(image_id, owner_id, owner_ip, posted, comment) ". "VALUES(:image_id, :user_id, :remote_addr, now(), :comment)", - ["image_id"=>$image_id, "user_id"=>$user->id, "remote_addr"=>get_real_ip(), "comment"=>$comment] + ["image_id" => $image_id, "user_id" => $user->id, "remote_addr" => get_real_ip(), "comment" => $comment] ); $cid = $database->get_last_insert_id('comments_id_seq'); $snippet = substr($comment, 0, 100); @@ -654,10 +654,10 @@ private function comment_checks(int $image_id, User $user, string $comment) } // advanced sanity checks - elseif (strlen($comment)/strlen(gzcompress($comment)) > 10) { + elseif (strlen($comment) / strlen(gzcompress($comment)) > 10) { throw new CommentPostingException("Comment too repetitive~"); } elseif ($user->is_anonymous() && !$this->hash_match()) { - $page->add_cookie("nocache", "Anonymous Commenter", time()+60*60*24, "/"); + $page->add_cookie("nocache", "Anonymous Commenter", time() + 60 * 60 * 24, "/"); throw new CommentPostingException( "Comment submission form is out of date; refresh the ". "comment form to show you aren't a spammer~" diff --git a/ext/comment/theme.php b/ext/comment/theme.php index 8fe95367c..8bef60e0d 100644 --- a/ext/comment/theme.php +++ b/ext/comment/theme.php @@ -194,7 +194,7 @@ public function display_all_user_comments(array $comments, int $page_number, int $this->display_paginator($page, "comment/beta-search/{$user->name}", null, $page_number, $total_pages); } - protected function comment_to_html(Comment $comment, bool $trim=false): string + protected function comment_to_html(Comment $comment, bool $trim = false): string { global $config, $user; diff --git a/ext/cron_uploader/info.php b/ext/cron_uploader/info.php index 2113f504f..3fdefddb4 100644 --- a/ext/cron_uploader/info.php +++ b/ext/cron_uploader/info.php @@ -20,7 +20,7 @@ class CronUploaderInfo extends ExtensionInfo 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 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"; diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index 8690ce487..22ef18ed8 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -57,7 +57,7 @@ public function onUserOptionsBuilding(UserOptionsBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="system") { + if ($event->parent == "system") { $event->add_nav_link("cron_docs", new Link('cron_upload'), "Cron Upload"); } } @@ -71,7 +71,7 @@ public function onPageRequest(PageRequestEvent $event) global $user; if ($event->page_matches("cron_upload")) { - if ($event->count_args() == 1 && $event->get_arg(0) =="run") { + if ($event->count_args() == 1 && $event->get_arg(0) == "run") { $this->process_upload(); // Start upload } elseif ($user->can(Permissions::CRON_RUN)) { $this->display_documentation(); @@ -127,7 +127,7 @@ public function onLog(LogEvent $event) if (self::$IMPORT_RUNNING) { $all = $user_config->get_bool(CronUploaderConfig::INCLUDE_ALL_LOGS); if ($event->priority >= $user_config->get_int(CronUploaderConfig::LOG_LEVEL) && - ($event->section==self::NAME || $all)) { + ($event->section == self::NAME || $all)) { $output = "[" . date('Y-m-d H:i:s') . "] " . ($all ? '[' . $event->section . '] ' : '') . "[" . LOGGING_LEVEL_NAMES[$event->priority] . "] " . $event->message; echo $output . "\r\n"; @@ -157,7 +157,7 @@ private function restage_folder(string $folder) $results = get_files_recursively($stage_dir); if (count($results) == 0) { - if (remove_empty_dirs($stage_dir)===false) { + if (remove_empty_dirs($stage_dir) === false) { $page->flash("Nothing to stage from $folder, cannot remove folder"); } else { $page->flash("Nothing to stage from $folder, removing folder"); @@ -182,15 +182,15 @@ private function restage_folder(string $folder) mkdir($dir, 0775, true); } - if (rename($result, $new_path)===false) { + if (rename($result, $new_path) === false) { $page->flash("Could not move file: " .$result); $success = false; } } - if ($success===true) { + if ($success === true) { $page->flash("Re-staged $folder to queue"); - if (remove_empty_dirs($stage_dir)===false) { + if (remove_empty_dirs($stage_dir) === false) { $page->flash("Could not remove $folder"); } } @@ -325,7 +325,7 @@ public function process_upload(): bool { global $database, $user, $user_config, $config, $_shm_load_start; - $max_time = intval(ini_get('max_execution_time'))*.8; + $max_time = intval(ini_get('max_execution_time')) * .8; $this->set_headers(); @@ -365,7 +365,7 @@ public function process_upload(): bool // Upload the file(s) foreach ($image_queue as $img) { $execution_time = ftime() - $_shm_load_start; - if ($execution_time>$max_time) { + if ($execution_time > $max_time) { break; } else { $remaining = $max_time - $execution_time; @@ -405,7 +405,7 @@ public function process_upload(): bool } // Throw exception if there's nothing in the queue - if ($merged+$failed+$added === 0) { + if ($merged + $failed + $added === 0) { $this->log_message(SCORE_LOG_WARNING, "Your queue is empty so nothing could be uploaded."); return false; } @@ -429,13 +429,13 @@ private function move_uploaded(string $path, string $filename, string $output_su $rootDir = $user_config->get_string(CronUploaderConfig::DIR); $rootLength = strlen($rootDir); - if ($rootDir[$rootLength-1]=="/"||$rootDir[$rootLength-1]=="\\") { + if ($rootDir[$rootLength - 1] == "/" || $rootDir[$rootLength - 1] == "\\") { $rootLength--; } $relativeDir = dirname(substr($path, $rootLength + 7)); - if ($relativeDir==".") { + if ($relativeDir == ".") { $relativeDir = ""; } diff --git a/ext/cron_uploader/theme.php b/ext/cron_uploader/theme.php index cc293f597..e367ba195 100644 --- a/ext/cron_uploader/theme.php +++ b/ext/cron_uploader/theme.php @@ -84,7 +84,7 @@ public function display_documentation( "; - $max_time = intval(ini_get('max_execution_time'))*.8; + $max_time = intval(ini_get('max_execution_time')) * .8; $usage_html = "Upload your images you want to be uploaded to the queue directory using your FTP client or other means. ({$queue_dirinfo['path']}) @@ -109,7 +109,7 @@ public function display_documentation( $block = new Block("Cron Uploader", $info_html, "main", 10); $block_install = new Block("Setup Guide", $install_html, "main", 30); - $block_usage= new Block("Usage Guide", $usage_html, "main", 20); + $block_usage = new Block("Usage Guide", $usage_html, "main", 20); $page->add_block($block); $page->add_block($block_install); $page->add_block($block_usage); @@ -130,28 +130,28 @@ public function get_user_options(): string $form = SHM_SIMPLE_FORM( "user_admin/cron_uploader", TABLE( - ["class"=>"form"], + ["class" => "form"], TBODY( TR( TH("Cron Uploader") ), TR( TH("Root dir"), - TD(INPUT(["type"=>'text', "name"=>'name', "required"=>true])) + TD(INPUT(["type" => 'text', "name" => 'name', "required" => true])) ), TR( TH(), TD( - LABEL(INPUT(["type"=>'checkbox', "name"=>'stop_on_error']), "Stop On Error") + LABEL(INPUT(["type" => 'checkbox', "name" => 'stop_on_error']), "Stop On Error") ) ), TR( TH(rawHTML("Repeat Password")), - TD(INPUT(["type"=>'password', "name"=>'pass2', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass2', "required" => true])) ) ), TFOOT( - TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Save Settings"]))) + TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => "Save Settings"]))) ) ) ); diff --git a/ext/custom_html_headers/info.php b/ext/custom_html_headers/info.php index 6cdee477a..df49d48b9 100644 --- a/ext/custom_html_headers/info.php +++ b/ext/custom_html_headers/info.php @@ -11,7 +11,7 @@ class CustomHtmlHeadersInfo extends ExtensionInfo 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 array $authors = ["Drudex Software" => "support@drudexsoftware.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "Allows admins to modify & set custom <head> content"; public ?string $documentation = diff --git a/ext/custom_html_headers/main.php b/ext/custom_html_headers/main.php index 0cabae538..93880e3ab 100644 --- a/ext/custom_html_headers/main.php +++ b/ext/custom_html_headers/main.php @@ -43,7 +43,7 @@ private function handle_custom_html_headers() global $config, $page; $header = $config->get_string('custom_html_headers', ''); - if ($header!='') { + if ($header != '') { $page->add_html_header($header); } } diff --git a/ext/danbooru_api/info.php b/ext/danbooru_api/info.php index 06312b0f8..2c2f9e71b 100644 --- a/ext/danbooru_api/info.php +++ b/ext/danbooru_api/info.php @@ -10,7 +10,7 @@ class DanbooruApiInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Danbooru Client API"; - public array $authors = ["JJS"=>"jsutinen@gmail.com"]; + public array $authors = ["JJS" => "jsutinen@gmail.com"]; public string $description = "Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie"; public ?string $documentation = "Notes: diff --git a/ext/danbooru_api/main.php b/ext/danbooru_api/main.php index 95b56e778..569de860c 100644 --- a/ext/danbooru_api/main.php +++ b/ext/danbooru_api/main.php @@ -99,7 +99,7 @@ private function api_find_tags(): HTMLElement foreach ($idlist as $id) { $sqlresult = $database->get_all( "SELECT id,tag,count FROM tags WHERE id = :id", - ['id'=>$id] + ['id' => $id] ); foreach ($sqlresult as $row) { $results[] = [$row['count'], $row['tag'], $row['id']]; @@ -110,7 +110,7 @@ private function api_find_tags(): HTMLElement foreach ($namelist as $name) { $sqlresult = $database->get_all( "SELECT id,tag,count FROM tags WHERE LOWER(tag) = LOWER(:tag)", - ['tag'=>$name] + ['tag' => $name] ); foreach ($sqlresult as $row) { $results[] = [$row['count'], $row['tag'], $row['id']]; @@ -129,7 +129,7 @@ private function api_find_tags(): HTMLElement $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", - ['id'=>$start] + ['id' => $start] ); foreach ($sqlresult as $row) { $results[] = [$row['count'], $row['tag'], $row['id']]; @@ -205,7 +205,7 @@ private function api_find_posts(): HTMLElement // Now we have the array $results filled with Image objects // Let's display them - $xml = POSTS(["count"=>$count, "offset"=>$start]); + $xml = POSTS(["count" => $count, "offset" => $start]); foreach ($results as $img) { // Sanity check to see if $img is really an image object // If it isn't (e.g. someone requested an invalid md5 or id), break out of the this diff --git a/ext/danbooru_api/test.php b/ext/danbooru_api/test.php index 258ad8558..4b98e0956 100644 --- a/ext/danbooru_api/test.php +++ b/ext/danbooru_api/test.php @@ -13,13 +13,13 @@ public function testSearch() $image_id = $this->post_image("tests/bedroom_workshop.jpg", "data"); $this->get_page("api/danbooru/find_posts"); - $this->get_page("api/danbooru/find_posts", ["id"=>$image_id]); - $this->get_page("api/danbooru/find_posts", ["md5"=>"17fc89f372ed3636e28bd25cc7f3bac1"]); - $this->get_page("api/danbooru/find_posts", ["tags"=>"*"]); + $this->get_page("api/danbooru/find_posts", ["id" => $image_id]); + $this->get_page("api/danbooru/find_posts", ["md5" => "17fc89f372ed3636e28bd25cc7f3bac1"]); + $this->get_page("api/danbooru/find_posts", ["tags" => "*"]); $this->get_page("api/danbooru/find_tags"); - $this->get_page("api/danbooru/find_tags", ["id"=>1]); - $this->get_page("api/danbooru/find_tags", ["name"=>"data"]); + $this->get_page("api/danbooru/find_tags", ["id" => 1]); + $this->get_page("api/danbooru/find_tags", ["name" => "data"]); $page = $this->get_page("api/danbooru/post/show/$image_id"); $this->assertEquals(302, $page->code); diff --git a/ext/download/info.php b/ext/download/info.php index 4eb224162..51d5b1f8c 100644 --- a/ext/download/info.php +++ b/ext/download/info.php @@ -10,7 +10,7 @@ class DownloadInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Download"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "System-wide download functions"; public bool $core = true; diff --git a/ext/et/main.php b/ext/et/main.php index 0d919f927..03f32ee08 100644 --- a/ext/et/main.php +++ b/ext/et/main.php @@ -22,7 +22,7 @@ public function onPageRequest(PageRequestEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::VIEW_SYSINTO)) { $event->add_nav_link("system_info", new Link('system_info'), "System Info", null, 10); } @@ -105,9 +105,9 @@ private function get_info(): array if (file_exists(".git")) { try { $commitHash = trim(exec('git log --pretty="%h" -n1 HEAD')); - $commitBranch= trim(exec('git rev-parse --abbrev-ref HEAD')); - $commitOrigin= trim(exec('git config --get remote.origin.url')); - $commitOrigin= preg_replace("#//.*@#", "//xxx@", $commitOrigin); + $commitBranch = trim(exec('git rev-parse --abbrev-ref HEAD')); + $commitOrigin = trim(exec('git config --get remote.origin.url')); + $commitOrigin = preg_replace("#//.*@#", "//xxx@", $commitOrigin); $info['git'] = [ 'commit' => $commitHash, 'branch' => $commitBranch, diff --git a/ext/et/theme.php b/ext/et/theme.php index 089175b41..958075a1e 100644 --- a/ext/et/theme.php +++ b/ext/et/theme.php @@ -29,18 +29,18 @@ public function display_info_page($yaml) protected function build_data_form($yaml): \MicroHTML\HTMLElement { return FORM( - ["action"=>"https://shimmie.shishnet.org/register.php", "method"=>"POST"], - INPUT(["type"=>"hidden", "name"=>"registration_api", "value"=>"2"]), + ["action" => "https://shimmie.shishnet.org/register.php", "method" => "POST"], + INPUT(["type" => "hidden", "name" => "registration_api", "value" => "2"]), P( "Your stats are useful so that I know which combinations of ". "web servers / databases / etc I need to support :)" ), P(TEXTAREA( - ["name"=>'data', "style"=>"width: 100%; height: 20em;"], + ["name" => 'data', "style" => "width: 100%; height: 20em;"], $yaml )), P(INPUT( - ["type"=>'submit', "value"=>'Click to send to Shish', "style"=>"width: 100%; padding: 1em;"] + ["type" => 'submit', "value" => 'Click to send to Shish', "style" => "width: 100%; padding: 1em;"] )), ); } diff --git a/ext/et_server/main.php b/ext/et_server/main.php index 2c3f27627..c88ac6cc2 100644 --- a/ext/et_server/main.php +++ b/ext/et_server/main.php @@ -16,7 +16,7 @@ public function onPageRequest(PageRequestEvent $event) if (isset($_POST["data"])) { $database->execute( "INSERT INTO registration(data) VALUES(:data)", - ["data"=>$_POST["data"]] + ["data" => $_POST["data"]] ); $page->set_title("Thanks!"); $page->set_heading("Thanks!"); @@ -28,7 +28,7 @@ public function onPageRequest(PageRequestEvent $event) foreach ($database->get_all("SELECT responded, data FROM registration ORDER BY responded DESC") as $row) { $page->add_block(new Block( $row["responded"], - PRE(["style"=>"text-align: left; overflow: scroll;"], $row["data"]), + PRE(["style" => "text-align: left; overflow: scroll;"], $row["data"]), "main", $n++ )); diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index 0eeee6761..164b0e822 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -6,10 +6,10 @@ function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b): int { - if ($a->beta===true&&$b->beta===false) { + if ($a->beta === true && $b->beta === false) { return 1; } - if ($a->beta===false&&$b->beta===true) { + if ($a->beta === false && $b->beta === true) { return -1; } @@ -92,7 +92,7 @@ public function onCommand(CommandEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::MANAGE_EXTENSION_LIST)) { $event->add_nav_link("ext_manager", new Link('ext_manager'), "Extension Manager"); } else { diff --git a/ext/ext_manager/theme.php b/ext/ext_manager/theme.php index ddc01bc5f..2b5bb35c2 100644 --- a/ext/ext_manager/theme.php +++ b/ext/ext_manager/theme.php @@ -34,7 +34,7 @@ public function display_table(Page $page, array $extensions, bool $editable) $form = SHM_SIMPLE_FORM( "ext_manager/set", TABLE( - ["id"=>'extensions', "class"=>'zebra'], + ["id" => 'extensions', "class" => 'zebra'], THEAD(TR( $editable ? TH("Enabled") : null, TH("Name"), @@ -42,7 +42,7 @@ public function display_table(Page $page, array $extensions, bool $editable) TH("Description") )), $tbody, - $editable ? TFOOT(TR(TD(["colspan"=>'5'], INPUT(["type"=>'submit', "value"=>'Set Extensions'])))) : null + $editable ? TFOOT(TR(TD(["colspan" => '5'], INPUT(["type" => 'submit', "value" => 'Set Extensions'])))) : null ) ); @@ -53,18 +53,18 @@ public function display_table(Page $page, array $extensions, bool $editable) } $tbody->appendChild(TR( - ["data-ext"=>$extension->name], + ["data-ext" => $extension->name], $editable ? TD(INPUT([ - "type"=>'checkbox', - "name"=>"ext_{$extension->key}", - "id"=>"ext_{$extension->key}", - "checked"=>($extension->is_enabled() === true), - "disabled"=>($extension->is_supported()===false || $extension->core===true) + "type" => 'checkbox', + "name" => "ext_{$extension->key}", + "id" => "ext_{$extension->key}", + "checked" => ($extension->is_enabled() === true), + "disabled" => ($extension->is_supported() === false || $extension->core === true) ])) : null, TD(LABEL( - ["for"=>"ext_{$extension->key}"], + ["for" => "ext_{$extension->key}"], ( - ($extension->beta===true ? "[BETA] " : ""). + ($extension->beta === true ? "[BETA] " : ""). (empty($extension->name) ? $extension->key : $extension->name) ) )), @@ -72,16 +72,16 @@ public function display_table(Page $page, array $extensions, bool $editable) // TODO: A proper "docs" symbol would be preferred here. $extension->documentation ? A( - ["href"=>make_link("ext_doc/" . url_escape($extension->key))], - IMG(["src"=>'ext/ext_manager/baseline_open_in_new_black_18dp.png']) + ["href" => make_link("ext_doc/" . url_escape($extension->key))], + IMG(["src" => 'ext/ext_manager/baseline_open_in_new_black_18dp.png']) ) : null ), TD( - ["style"=>'text-align: left;'], + ["style" => 'text-align: left;'], $extension->description, " ", - B(["style"=>'color:red'], $extension->get_support_info()) + B(["style" => 'color:red'], $extension->get_support_info()) ), )); } @@ -98,9 +98,9 @@ public function display_doc(Page $page, ExtensionInfo $info) if (count($info->authors) > 0) { $author->appendChild(BR()); $author->appendChild(B(count($info->authors) > 1 ? "Authors: " : "Author: ")); - foreach ($info->authors as $auth=>$email) { + foreach ($info->authors as $auth => $email) { if (!empty($email)) { - $author->appendChild(A(["href"=>"mailto:$email"], $auth)); + $author->appendChild(A(["href" => "mailto:$email"], $auth)); } else { $author->appendChild($auth); } @@ -109,13 +109,13 @@ public function display_doc(Page $page, ExtensionInfo $info) } $html = DIV( - ["style"=>'margin: auto; text-align: left; width: 512px;'], + ["style" => 'margin: auto; text-align: left; width: 512px;'], $author, ($info->version ? emptyHTML(BR(), B("Version: "), $info->version) : null), - ($info->link ? emptyHTML(BR(), B("Home Page"), A(["href"=>$info->link], "Link")) : null), + ($info->link ? emptyHTML(BR(), B("Home Page"), A(["href" => $info->link], "Link")) : null), P(rawHTML($info->documentation ?? "(This extension has no documentation)")), // , - P(A(["href"=>make_link("ext_manager")], "Back to the list")) + P(A(["href" => make_link("ext_manager")], "Back to the list")) ); $page->set_title("Documentation for " . html_escape($info->name)); diff --git a/ext/favorites/info.php b/ext/favorites/info.php index d0db6ae56..e13358df7 100644 --- a/ext/favorites/info.php +++ b/ext/favorites/info.php @@ -10,7 +10,7 @@ class FavoritesInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Favorites"; - public array $authors = ["Daniel Marschall"=>"info@daniel-marschall.de"]; + public array $authors = ["Daniel Marschall" => "info@daniel-marschall.de"]; public string $license = self::LICENSE_GPLV2; public string $description = "Allow users to favorite images"; public ?string $documentation = diff --git a/ext/favorites/main.php b/ext/favorites/main.php index fb0c0f462..af2db5bc2 100644 --- a/ext/favorites/main.php +++ b/ext/favorites/main.php @@ -36,7 +36,7 @@ public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) $is_favorited = $database->get_one( "SELECT COUNT(*) AS ct FROM user_favorites WHERE user_id = :user_id AND image_id = :image_id", - ["user_id"=>$user_id, "image_id"=>$image_id] + ["user_id" => $user_id, "image_id" => $image_id] ) > 0; $event->add_part((string)$this->theme->get_voter_html($event->image, $is_favorited)); @@ -102,7 +102,7 @@ public function onFavoriteSet(FavoriteSetEvent $event) public function onImageDeletion(ImageDeletionEvent $event) { global $database; - $database->execute("DELETE FROM user_favorites WHERE image_id=:image_id", ["image_id"=>$event->image->id]); + $database->execute("DELETE FROM user_favorites WHERE image_id=:image_id", ["image_id" => $event->image->id]); } public function onParseLinkTemplate(ParseLinkTemplateEvent $event) @@ -144,7 +144,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $event->add_block(new Block("Favorites", $this->theme->get_help_html())); } } @@ -152,11 +152,11 @@ public function onHelpPageBuilding(HelpPageBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent=="posts") { + if ($event->parent == "posts") { $event->add_nav_link("posts_favorites", new Link("post/list/favorited_by={$user->name}/1"), "My Favorites"); } - if ($event->parent==="user") { + if ($event->parent === "user") { if ($user->can(Permissions::MANAGE_ADMINTOOLS)) { $username = url_escape($user->name); $event->add_nav_link("favorites", new Link("post/list/favorited_by=$username/1"), "My Favorites"); @@ -237,21 +237,21 @@ private function add_vote(int $image_id, int $user_id, bool $do_set) { global $database; if ($do_set) { - if (!$database->get_row("select 1 from user_favorites where image_id=:image_id and user_id=:user_id", ["image_id"=>$image_id, "user_id"=>$user_id])) { + if (!$database->get_row("select 1 from user_favorites where image_id=:image_id and user_id=:user_id", ["image_id" => $image_id, "user_id" => $user_id])) { $database->execute( "INSERT INTO user_favorites(image_id, user_id, created_at) VALUES(:image_id, :user_id, NOW())", - ["image_id"=>$image_id, "user_id"=>$user_id] + ["image_id" => $image_id, "user_id" => $user_id] ); } } else { $database->execute( "DELETE FROM user_favorites WHERE image_id = :image_id AND user_id = :user_id", - ["image_id"=>$image_id, "user_id"=>$user_id] + ["image_id" => $image_id, "user_id" => $user_id] ); } $database->execute( "UPDATE images SET favorites=(SELECT COUNT(*) FROM user_favorites WHERE image_id=:image_id) WHERE id=:user_id", - ["image_id"=>$image_id, "user_id"=>$user_id] + ["image_id" => $image_id, "user_id" => $user_id] ); } @@ -264,7 +264,7 @@ private function list_persons_who_have_favorited(Image $image): array return $database->get_col( "SELECT name FROM users WHERE id IN (SELECT user_id FROM user_favorites WHERE image_id = :image_id) ORDER BY name", - ["image_id"=>$image->id] + ["image_id" => $image->id] ); } } diff --git a/ext/favorites/theme.php b/ext/favorites/theme.php index c8fb5216f..0762c208f 100644 --- a/ext/favorites/theme.php +++ b/ext/favorites/theme.php @@ -16,9 +16,9 @@ public function get_voter_html(Image $image, bool $is_favorited): HTMLElement $label = $is_favorited ? "Un-Favorite" : "Favorite"; return SHM_SIMPLE_FORM( "change_favorite", - INPUT(["type"=>"hidden", "name"=>"image_id", "value"=>$image->id]), - INPUT(["type"=>"hidden", "name"=>"favorite_action", "value"=>$name]), - INPUT(["type"=>"submit", "value"=>$label]), + INPUT(["type" => "hidden", "name" => "image_id", "value" => $image->id]), + INPUT(["type" => "hidden", "name" => "favorite_action", "value" => $name]), + INPUT(["type" => "submit", "value" => $label]), ); } diff --git a/ext/featured/theme.php b/ext/featured/theme.php index dcca62835..fd9c1e42f 100644 --- a/ext/featured/theme.php +++ b/ext/featured/theme.php @@ -20,26 +20,26 @@ public function get_buttons_html(int $image_id): string { return (string)SHM_SIMPLE_FORM( "featured_image/set", - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]), - INPUT(["type"=>'submit', "value"=>'Feature This']), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), + INPUT(["type" => 'submit', "value" => 'Feature This']), ); } - public function build_featured_html(Image $image, ?string $query=null): \MicroHTML\HTMLElement + public function build_featured_html(Image $image, ?string $query = null): \MicroHTML\HTMLElement { $tsize = get_thumbnail_size($image->width, $image->height); return DIV( - ["style"=>"text-align: center;"], + ["style" => "text-align: center;"], A( - ["href"=>make_link("post/view/{$image->id}", $query)], + ["href" => make_link("post/view/{$image->id}", $query)], IMG([ - "id"=>"thumb_rand_{$image->id}", - "title"=>$image->get_tooltip(), - "alt"=>$image->get_tooltip(), - "class"=>'highlighted', - "style"=>"max-height: {$tsize[1]}px; max-width: 100%;", - "src"=>$image->get_thumb_link() + "id" => "thumb_rand_{$image->id}", + "title" => $image->get_tooltip(), + "alt" => $image->get_tooltip(), + "class" => 'highlighted', + "style" => "max-height: {$tsize[1]}px; max-width: 100%;", + "src" => $image->get_thumb_link() ]) ) ); diff --git a/ext/forum/info.php b/ext/forum/info.php index 090215508..b4e5f97c8 100644 --- a/ext/forum/info.php +++ b/ext/forum/info.php @@ -10,7 +10,7 @@ class ForumInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Forum"; - public array $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"]; + public array $authors = ["Sein Kraft" => "mail@seinkraft.info","Alpha" => "alpha@furries.com.ar"]; public string $license = self::LICENSE_GPLV2; public string $description = "Rough forum extension"; } diff --git a/ext/forum/main.php b/ext/forum/main.php index f7b70b5a4..4bba03985 100644 --- a/ext/forum/main.php +++ b/ext/forum/main.php @@ -79,8 +79,8 @@ public function onUserPageBuilding(UserPageBuildingEvent $event) { global $database; - $threads_count = $database->get_one("SELECT COUNT(*) FROM forum_threads WHERE user_id=:user_id", ['user_id'=>$event->display_user->id]); - $posts_count = $database->get_one("SELECT COUNT(*) FROM forum_posts WHERE user_id=:user_id", ['user_id'=>$event->display_user->id]); + $threads_count = $database->get_one("SELECT COUNT(*) FROM forum_threads WHERE user_id=:user_id", ['user_id' => $event->display_user->id]); + $posts_count = $database->get_one("SELECT COUNT(*) FROM forum_posts WHERE user_id=:user_id", ['user_id' => $event->display_user->id]); $days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1; @@ -113,7 +113,7 @@ public function onPageRequest(PageRequestEvent $event) // $pageNumber = int_escape($event->get_arg(2)); list($errors) = $this->sanity_check_viewed_thread($threadID); - if ($errors!=null) { + if ($errors != null) { $this->theme->display_error(500, "Error", $errors); break; } @@ -135,7 +135,7 @@ public function onPageRequest(PageRequestEvent $event) if (!$user->is_anonymous()) { list($errors) = $this->sanity_check_new_thread(); - if ($errors!=null) { + if ($errors != null) { $this->theme->display_error(500, "Error", $errors); break; } @@ -176,7 +176,7 @@ public function onPageRequest(PageRequestEvent $event) if (!$user->is_anonymous()) { list($errors) = $this->sanity_check_new_post(); - if ($errors!=null) { + if ($errors != null) { $this->theme->display_error(500, "Error", $errors); break; } @@ -197,7 +197,7 @@ public function onPageRequest(PageRequestEvent $event) 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]); + $result = $database->get_row("SELECT COUNT(1) AS count FROM forum_posts WHERE thread_id = :thread_id", ['thread_id' => $threadID]); return (int)ceil($result["count"] / $config->get_int("forumPostsPerPage")); } @@ -252,7 +252,7 @@ private function sanity_check_viewed_thread(int $threadID): array 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]); + $result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = :id ", ['id' => $threadID]); return $result["title"]; } @@ -277,7 +277,7 @@ private function show_last_threads(Page $page, PageRequestEvent $event, bool $sh "ON p.thread_id = f.id ". "GROUP BY f.id, f.sticky, f.title, f.date, u.name, u.email, u.class ". "ORDER BY f.sticky ASC, f.uptodate DESC LIMIT :limit OFFSET :offset", - ["limit"=>$threadsPerPage, "offset"=>$pageNumber * $threadsPerPage] + ["limit" => $threadsPerPage, "offset" => $pageNumber * $threadsPerPage] ); $this->theme->display_thread_list($page, $threads, $showAdminOptions, $pageNumber + 1, $totalPages); @@ -288,7 +288,7 @@ private function show_posts(PageRequestEvent $event, bool $showAdminOptions = fa global $config, $database; $threadID = int_escape($event->get_arg(1)); $postsPerPage = $config->get_int('forumPostsPerPage', 15); - $totalPages = (int)ceil($database->get_one("SELECT COUNT(*) FROM forum_posts WHERE thread_id = :id", ['id'=>$threadID]) / $postsPerPage); + $totalPages = (int)ceil($database->get_one("SELECT COUNT(*) FROM forum_posts WHERE thread_id = :id", ['id' => $threadID]) / $postsPerPage); $threadTitle = $this->get_thread_title($threadID); if ($event->count_args() >= 3) { @@ -305,7 +305,7 @@ private function show_posts(PageRequestEvent $event, bool $showAdminOptions = fa "WHERE thread_id = :thread_id ". "ORDER BY p.date ASC ". "LIMIT :limit OFFSET :offset", - ["thread_id"=>$threadID, "offset"=>$pageNumber * $postsPerPage, "limit"=>$postsPerPage] + ["thread_id" => $threadID, "offset" => $pageNumber * $postsPerPage, "limit" => $postsPerPage] ); $this->theme->display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber + 1, $totalPages); } @@ -322,7 +322,7 @@ private function save_new_thread(User $user): int (title, sticky, user_id, date, uptodate) VALUES (:title, :sticky, :user_id, now(), now())", - ['title'=>$title, 'sticky'=>$sticky, 'user_id'=>$user->id] + ['title' => $title, 'sticky' => $sticky, 'user_id' => $user->id] ); $threadID = $database->get_last_insert_id("forum_threads_id_seq"); @@ -345,32 +345,32 @@ private function save_new_post(int $threadID, User $user): void $database->execute(" INSERT INTO forum_posts (thread_id, user_id, date, message) VALUES (:thread_id, :user_id, now(), :message) - ", ['thread_id'=>$threadID, 'user_id'=>$userID, 'message'=>$message]); + ", ['thread_id' => $threadID, 'user_id' => $userID, 'message' => $message]); $postID = $database->get_last_insert_id("forum_posts_id_seq"); log_info("forum", "Post {$postID} created by {$user->name}"); - $database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=:id", ['id'=>$threadID]); + $database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=:id", ['id' => $threadID]); } private function delete_thread(int $threadID): void { 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]); + $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): void { global $database; - $database->execute("DELETE FROM forum_posts WHERE id = :id", ['id'=>$postID]); + $database->execute("DELETE FROM forum_posts WHERE id = :id", ['id' => $postID]); } private function threadExists(int $threadID): bool { global $database; - $result=$database->get_one("SELECT EXISTS (SELECT * FROM forum_threads WHERE id=:id)", ['id'=>$threadID]); + $result = $database->get_one("SELECT EXISTS (SELECT * FROM forum_threads WHERE id=:id)", ['id' => $threadID]); return $result == 1; } } diff --git a/ext/forum/theme.php b/ext/forum/theme.php index 9e7bab4ec..93def4775 100644 --- a/ext/forum/theme.php +++ b/ext/forum/theme.php @@ -135,7 +135,7 @@ public function display_thread($posts, $showAdminOptions, $threadTitle, $threadI $delete_link = ""; } - $post_number = (($pageNumber-1)*$posts_per_page)+$current_post; + $post_number = (($pageNumber - 1) * $posts_per_page) + $current_post; $html .= " diff --git a/ext/google_analytics/info.php b/ext/google_analytics/info.php index af4f5c9d8..5f9b6fdf7 100644 --- a/ext/google_analytics/info.php +++ b/ext/google_analytics/info.php @@ -11,7 +11,7 @@ class GoogleAnalyticsInfo extends ExtensionInfo 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 array $authors = ["Drudex Software" => "support@drudexsoftware.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "Integrates Google Analytics tracking"; public ?string $documentation = diff --git a/ext/graphql/main.php b/ext/graphql/main.php index 77e9b6cb8..714f8f686 100644 --- a/ext/graphql/main.php +++ b/ext/graphql/main.php @@ -123,7 +123,7 @@ private static function handle_uploads(): array $common_source = $_POST['common_source']; $results = []; - for ($n=0; $n<100; $n++) { + for ($n = 0; $n < 100; $n++) { if (empty($_POST["url$n"]) && empty($_FILES["data$n"])) { break; } @@ -191,7 +191,7 @@ public function onCommand(CommandEvent $event) $body['stats'] = get_debug_info_arr(); $body['stats']['graphql_schema_time'] = round($t2 - $t1, 2); $body['stats']['graphql_execute_time'] = round($t3 - $t2, 2); - echo \json_encode($body, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT); + echo \json_encode($body, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); } if ($event->cmd == "graphql-schema") { $schema = $this->get_schema(); diff --git a/ext/handle_cbz/main.php b/ext/handle_cbz/main.php index 1ff44636c..cbc702eda 100644 --- a/ext/handle_cbz/main.php +++ b/ext/handle_cbz/main.php @@ -52,7 +52,7 @@ private function get_representative_image(string $archive): string $za = new \ZipArchive(); $za->open($archive); $names = []; - for ($i=0; $i<$za->numFiles;$i++) { + for ($i = 0; $i < $za->numFiles;$i++) { $file = $za->statIndex($i); $names[] = $file['name']; } diff --git a/ext/handle_svg/main.php b/ext/handle_svg/main.php index be79cbb67..7484e3161 100644 --- a/ext/handle_svg/main.php +++ b/ext/handle_svg/main.php @@ -73,7 +73,7 @@ protected function create_thumb(string $hash, string $mime): bool protected function check_contents(string $tmpname): bool { - if (MimeType::get_for_file($tmpname)!==MimeType::SVG) { + if (MimeType::get_for_file($tmpname) !== MimeType::SVG) { return false; } @@ -85,9 +85,9 @@ protected function check_contents(string $tmpname): bool class MiniSVGParser { public bool $valid = false; - public int $width=0; - public int $height=0; - private int $xml_depth=0; + public int $width = 0; + public int $height = 0; + private int $xml_depth = 0; public function __construct(string $file) { diff --git a/ext/handle_video/info.php b/ext/handle_video/info.php index d200f7852..3385d2125 100644 --- a/ext/handle_video/info.php +++ b/ext/handle_video/info.php @@ -10,7 +10,7 @@ class VideoFileHandlerInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Handle Video"; - public array $authors = ["velocity37"=>"velocity37@gmail.com",self::SHISH_NAME=>self::SHISH_EMAIL, "jgen"=>"jeffgenovy@gmail.com", "im-mi"=>"im.mi.mail.mi@gmail.com"]; + public array $authors = ["velocity37" => "velocity37@gmail.com",self::SHISH_NAME => self::SHISH_EMAIL, "jgen" => "jeffgenovy@gmail.com", "im-mi" => "im.mi.mail.mi@gmail.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "Handle FLV, MP4, OGV and WEBM video files."; public ?string $documentation = diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index 9d195b9d6..f6851ff32 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -99,7 +99,7 @@ protected function media_check_properties(MediaCheckPropertiesEvent $event): voi $event->image->video = $video; $event->image->video_codec = $video_codec; $event->image->audio = $audio; - if ($event->image->get_mime()==MimeType::MKV && + if ($event->image->get_mime() == MimeType::MKV && VideoContainers::is_video_codec_supported(VideoContainers::WEBM, $event->image->video_codec)) { // WEBMs are MKVs with the VP9 or VP8 codec // For browser-friendliness, we'll just change the mime type @@ -107,7 +107,7 @@ protected function media_check_properties(MediaCheckPropertiesEvent $event): voi } } } - if (array_key_exists("format", $data)&& is_array($data["format"])) { + if (array_key_exists("format", $data) && is_array($data["format"])) { $format = $data["format"]; if (array_key_exists("duration", $format) && is_numeric($format["duration"])) { $event->image->length = (int)floor(floatval($format["duration"]) * 1000); diff --git a/ext/handle_video/theme.php b/ext/handle_video/theme.php index 874533430..cd0e54f6c 100644 --- a/ext/handle_video/theme.php +++ b/ext/handle_video/theme.php @@ -16,12 +16,12 @@ public function display_image(Page $page, Image $image) $loop = $config->get_bool(VideoFileHandlerConfig::PLAYBACK_LOOP); $mute = $config->get_bool(VideoFileHandlerConfig::PLAYBACK_MUTE); - $width="auto"; - if ($image->width>1) { + $width = "auto"; + if ($image->width > 1) { $width = $image->width."px"; } - $height="auto"; - if ($image->height>1) { + $height = "auto"; + if ($image->height > 1) { $height = $image->height."px"; } diff --git a/ext/help_pages/info.php b/ext/help_pages/info.php index e01c44ae7..f31a38373 100644 --- a/ext/help_pages/info.php +++ b/ext/help_pages/info.php @@ -10,7 +10,7 @@ class HelpPagesInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Help Pages"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Provides documentation screens"; public ExtensionVisibility $visibility = ExtensionVisibility::HIDDEN; diff --git a/ext/help_pages/main.php b/ext/help_pages/main.php index 770b0cb17..03fadbda8 100644 --- a/ext/help_pages/main.php +++ b/ext/help_pages/main.php @@ -65,7 +65,7 @@ public function onPageRequest(PageRequestEvent $event) $hpbe = send_event(new HelpPageBuildingEvent($name)); asort($hpbe->blocks); - foreach ($hpbe->blocks as $key=>$value) { + foreach ($hpbe->blocks as $key => $value) { foreach ($value as $block) { $page->add_block($block); } @@ -87,9 +87,9 @@ public function onPageNavBuilding(PageNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="help") { + if ($event->parent == "help") { $pages = send_event(new HelpPageListBuildingEvent())->pages; - foreach ($pages as $key=>$value) { + foreach ($pages as $key => $value) { $event->add_nav_link("help_".$key, new Link('help/'.$key), $value); } } @@ -102,7 +102,7 @@ public function onUserBlockBuilding(UserBlockBuildingEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key=="licenses") { + if ($event->key == "licenses") { $block = new Block("Software Licenses"); $block->body = "The code in Shimmie is contributed by numerous authors under multiple licenses. For reference, these licenses are listed below. The base software is in general licensed under the GPLv2 license."; $event->add_block($block); diff --git a/ext/help_pages/theme.php b/ext/help_pages/theme.php index 0a5fb6162..a3987c42d 100644 --- a/ext/help_pages/theme.php +++ b/ext/help_pages/theme.php @@ -14,7 +14,7 @@ public function display_list_page(array $pages) $page->set_heading("Help Pages"); $nav_block = new Block("Help", "", "left", 0); - foreach ($pages as $link=>$desc) { + foreach ($pages as $link => $desc) { $link = make_link("help/{$link}"); $nav_block->body .= "".html_escape($desc).""; } diff --git a/ext/holiday/info.php b/ext/holiday/info.php index a1963a043..c6092af7e 100644 --- a/ext/holiday/info.php +++ b/ext/holiday/info.php @@ -11,7 +11,7 @@ class HolidayInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Holiday Theme"; public string $url = "http://www.codeanimu.net"; - public array $authors = ["DakuTree"=>"thedakutree@codeanimu.net"]; + public array $authors = ["DakuTree" => "thedakutree@codeanimu.net"]; public string $license = self::LICENSE_GPLV2; public string $description = "Use an additional stylesheet on certain holidays"; } diff --git a/ext/home/info.php b/ext/home/info.php index e0b3a6cdb..c7fb1518d 100644 --- a/ext/home/info.php +++ b/ext/home/info.php @@ -10,7 +10,7 @@ class HomeInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Home Page"; - public array $authors =["Bzchan"=>"bzchan@animemahou.com"]; + public array $authors = ["Bzchan" => "bzchan@animemahou.com"]; public string $license = self::LICENSE_GPLV2; public ExtensionVisibility $visibility = ExtensionVisibility::ADMIN; public string $description = "Displays a front page with logo, search box and post count"; diff --git a/ext/home/main.php b/ext/home/main.php index 77bfb24e9..aa214ddff 100644 --- a/ext/home/main.php +++ b/ext/home/main.php @@ -61,7 +61,7 @@ private function get_body(): string if ($counter_dir != 'text-only') { $strtotal = "$total"; $length = strlen($strtotal); - for ($n=0; $n<$length; $n++) { + for ($n = 0; $n < $length; $n++) { $cur = $strtotal[$n]; $counter_text .= ""; } diff --git a/ext/image/config.php b/ext/image/config.php index 7f031131b..ce65612b8 100644 --- a/ext/image/config.php +++ b/ext/image/config.php @@ -15,7 +15,7 @@ abstract class ImageConfig public const THUMB_QUALITY = 'thumb_quality'; public const THUMB_MIME = 'thumb_mime'; public const THUMB_FIT = 'thumb_fit'; - public const THUMB_ALPHA_COLOR ='thumb_alpha_color'; + public const THUMB_ALPHA_COLOR = 'thumb_alpha_color'; public const SHOW_META = 'image_show_meta'; public const ILINK = 'image_ilink'; diff --git a/ext/image/info.php b/ext/image/info.php index 8d9b7ba62..b7202dff6 100644 --- a/ext/image/info.php +++ b/ext/image/info.php @@ -11,7 +11,7 @@ class ImageIOInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Post Manager"; public string $url = self::SHIMMIE_URL; - public array $authors = [self::SHISH_NAME=> self::SHISH_EMAIL, "jgen"=>"jgen.tech@gmail.com"]; + public array $authors = [self::SHISH_NAME => self::SHISH_EMAIL, "jgen" => "jgen.tech@gmail.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "Handle the image database"; public ExtensionVisibility $visibility = ExtensionVisibility::HIDDEN; diff --git a/ext/image/main.php b/ext/image/main.php index 9b7abc822..76cac8615 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -15,13 +15,13 @@ class ImageIO extends Extension protected Themelet $theme; public const COLLISION_OPTIONS = [ - 'Error'=>ImageConfig::COLLISION_ERROR, - 'Merge'=>ImageConfig::COLLISION_MERGE + 'Error' => ImageConfig::COLLISION_ERROR, + 'Merge' => ImageConfig::COLLISION_MERGE ]; public const ON_DELETE_OPTIONS = [ - 'Return to post list'=>ImageConfig::ON_DELETE_LIST, - 'Go to next post'=>ImageConfig::ON_DELETE_NEXT + 'Return to post list' => ImageConfig::ON_DELETE_LIST, + 'Go to next post' => ImageConfig::ON_DELETE_NEXT ]; public const EXIF_READ_FUNCTION = "exif_read_data"; @@ -55,7 +55,7 @@ public function onInitExt(InitExtEvent $event) $config->set_default_string(ImageConfig::TLINK, ''); $config->set_default_string(ImageConfig::TIP, '$tags // $size // $filesize'); $config->set_default_string(ImageConfig::UPLOAD_COLLISION_HANDLER, ImageConfig::COLLISION_ERROR); - $config->set_default_int(ImageConfig::EXPIRES, (60*60*24*31)); // defaults to one month + $config->set_default_int(ImageConfig::EXPIRES, (60 * 60 * 24 * 31)); // defaults to one month } public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) @@ -87,7 +87,7 @@ public function onPageRequest(PageRequestEvent $event) if ($image) { send_event(new ImageDeletionEvent($image)); - if ($config->get_string(ImageConfig::ON_DELETE)===ImageConfig::ON_DELETE_NEXT) { + if ($config->get_string(ImageConfig::ON_DELETE) === ImageConfig::ON_DELETE_NEXT) { redirect_to_next_image($image); } else { $page->set_mode(PageMode::REDIRECT); @@ -227,7 +227,7 @@ public function onImageReplace(ImageReplaceEvent $event) } $duplicate = Image::by_hash($image->hash); - if (!is_null($duplicate) && $duplicate->id!=$id) { + if (!is_null($duplicate) && $duplicate->id != $id) { $error = "Post {$duplicate->id} " . "already has hash {$image->hash}:" . $this->theme->build_thumb_html($duplicate); throw new ImageReplaceException($error); @@ -306,7 +306,7 @@ public function onSetupBuilding(SetupBuildingEvent $event) $sb->add_int_option(ImageConfig::THUMB_QUALITY, "Quality", true); $sb->add_int_option(ImageConfig::THUMB_SCALING, "High-DPI Scale %", true); - if ($config->get_string(ImageConfig::THUMB_MIME)===MimeType::JPEG) { + if ($config->get_string(ImageConfig::THUMB_MIME) === MimeType::JPEG) { $sb->add_color_option(ImageConfig::THUMB_ALPHA_COLOR, "Alpha Conversion Color", true); } diff --git a/ext/image/theme.php b/ext/image/theme.php index 3a016fc72..9d8fd9d47 100644 --- a/ext/image/theme.php +++ b/ext/image/theme.php @@ -16,8 +16,8 @@ public function get_deleter_html(int $image_id): string { return (string)"".SHM_SIMPLE_FORM( "image/delete", - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]), - INPUT(["type"=>'submit', "value"=>'Delete', "onclick"=>'return confirm("Delete the image?");', "id"=>"image_delete_button"]), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), + INPUT(["type" => 'submit', "value" => 'Delete', "onclick" => 'return confirm("Delete the image?");', "id" => "image_delete_button"]), ).""; } @@ -28,8 +28,8 @@ public function get_replace_html(int $image_id): string { return (string)SHM_SIMPLE_FORM( "image/replace", - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]), - INPUT(["type"=>'submit', "value"=>'Replace']), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), + INPUT(["type" => 'submit', "value" => 'Replace']), ); } } diff --git a/ext/image_hash_ban/info.php b/ext/image_hash_ban/info.php index 339fa5ce2..1feefb557 100644 --- a/ext/image_hash_ban/info.php +++ b/ext/image_hash_ban/info.php @@ -11,7 +11,7 @@ class ImageBanInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Post Hash Ban"; public string $url = "http://atravelinggeek.com/"; - public array $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"]; + public array $authors = ["ATravelingGeek" => "atg@atravelinggeek.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "Ban images based on their hash"; public ?string $version = "0.1, October 21, 2007"; diff --git a/ext/image_hash_ban/main.php b/ext/image_hash_ban/main.php index c50604cf1..810b3a8e2 100644 --- a/ext/image_hash_ban/main.php +++ b/ext/image_hash_ban/main.php @@ -79,7 +79,7 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) public function onDataUpload(DataUploadEvent $event) { global $database; - $row = $database->get_row("SELECT * FROM image_bans WHERE hash = :hash", ["hash"=>$event->hash]); + $row = $database->get_row("SELECT * FROM image_bans WHERE hash = :hash", ["hash" => $event->hash]); if ($row) { log_info("image_hash_ban", "Attempted to upload a blocked image ({$event->hash} - {$row['reason']})"); throw new UploadException("Post ".html_escape($row["hash"])." has been banned, reason: ".format_text($row["reason"])); @@ -94,7 +94,7 @@ public function onPageRequest(PageRequestEvent $event) if ($user->can(Permissions::BAN_IMAGE)) { if ($event->get_arg(0) == "add") { $user->ensure_authed(); - $input = validate_input(["c_hash"=>"optional,string", "c_reason"=>"string", "c_image_id"=>"optional,int"]); + $input = validate_input(["c_hash" => "optional,string", "c_reason" => "string", "c_image_id" => "optional,int"]); $image = isset($input['c_image_id']) ? Image::by_id($input['c_image_id']) : null; $hash = isset($input["c_hash"]) ? $input["c_hash"] : $image->hash; $reason = isset($input['c_reason']) ? $input['c_reason'] : "DNP"; @@ -113,7 +113,7 @@ public function onPageRequest(PageRequestEvent $event) } } elseif ($event->get_arg(0) == "remove") { $user->ensure_authed(); - $input = validate_input(["d_hash"=>"string"]); + $input = validate_input(["d_hash" => "string"]); send_event(new RemoveImageHashBanEvent($input['d_hash'])); $page->flash("Post ban removed"); $page->set_mode(PageMode::REDIRECT); @@ -131,7 +131,7 @@ public function onPageRequest(PageRequestEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::BAN_IMAGE)) { $event->add_nav_link("image_bans", new Link('image_hash_ban/list/1'), "Post Bans", NavLink::is_active(["image_hash_ban"])); } @@ -151,7 +151,7 @@ public function onAddImageHashBan(AddImageHashBanEvent $event) global $database; $database->execute( "INSERT INTO image_bans (hash, reason, date) VALUES (:hash, :reason, now())", - ["hash"=>$event->hash, "reason"=>$event->reason] + ["hash" => $event->hash, "reason" => $event->reason] ); log_info("image_hash_ban", "Banned hash {$event->hash} because '{$event->reason}'"); } @@ -159,7 +159,7 @@ public function onAddImageHashBan(AddImageHashBanEvent $event) public function onRemoveImageHashBan(RemoveImageHashBanEvent $event) { global $database; - $database->execute("DELETE FROM image_bans WHERE hash = :hash", ["hash"=>$event->hash]); + $database->execute("DELETE FROM image_bans WHERE hash = :hash", ["hash" => $event->hash]); } public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) diff --git a/ext/image_hash_ban/theme.php b/ext/image_hash_ban/theme.php index 723d197a1..7d347d38a 100644 --- a/ext/image_hash_ban/theme.php +++ b/ext/image_hash_ban/theme.php @@ -26,10 +26,10 @@ public function get_buttons_html(Image $image): string { return (string)SHM_SIMPLE_FORM( "image_hash_ban/add", - INPUT(["type"=>'hidden', "name"=>'c_hash', "value"=>$image->hash]), - INPUT(["type"=>'hidden', "name"=>'c_image_id', "value"=>$image->id]), - INPUT(["type"=>'text', "name"=>'c_reason']), - INPUT(["type"=>'submit', "value"=>'Ban Hash and Delete Post']), + INPUT(["type" => 'hidden', "name" => 'c_hash', "value" => $image->hash]), + INPUT(["type" => 'hidden', "name" => 'c_image_id', "value" => $image->id]), + INPUT(["type" => 'text', "name" => 'c_reason']), + INPUT(["type" => 'submit', "value" => 'Ban Hash and Delete Post']), ); } } diff --git a/ext/image_view_counter/info.php b/ext/image_view_counter/info.php index 7a4a42f4f..48558ac3d 100644 --- a/ext/image_view_counter/info.php +++ b/ext/image_view_counter/info.php @@ -11,7 +11,7 @@ class ImageViewCounterInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Post View Counter"; public string $url = "http://www.drudexsoftware.com/"; - public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; + public array $authors = ["Drudex Software" => "support@drudexsoftware.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "Tracks & displays how many times a post is viewed"; public ?string $documentation = diff --git a/ext/image_view_counter/main.php b/ext/image_view_counter/main.php index 667d74490..269bd0950 100644 --- a/ext/image_view_counter/main.php +++ b/ext/image_view_counter/main.php @@ -113,7 +113,7 @@ public function onPageRequest(PageRequestEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="posts") { + if ($event->parent == "posts") { $event->add_nav_link("sort_by_visits", new Link('popular_images'), "Popular Posts"); } } diff --git a/ext/index/events.php b/ext/index/events.php index 235cfc4e5..f89f1eb75 100644 --- a/ext/index/events.php +++ b/ext/index/events.php @@ -21,7 +21,7 @@ class SearchTermParseEvent extends Event public array $tag_conditions = []; public ?string $order = null; - public function __construct(int $id, string $term=null, array $context=[]) + public function __construct(int $id, string $term = null, array $context = []) { parent::__construct(); @@ -75,7 +75,7 @@ public function __construct(array $search) $this->search_terms = $search; } - public function add_control(string $html, int $position=50) + public function add_control(string $html, int $position = 50) { while (isset($this->parts[$position])) { $position++; diff --git a/ext/index/main.php b/ext/index/main.php index 3f6582737..d8c57900a 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -79,14 +79,14 @@ public function onPageRequest(PageRequestEvent $event) // extra caching for the first few post/list pages $images = $cache->get("post-list:$page_number"); if (is_null($images)) { - $images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms); + $images = Image::find_images(($page_number - 1) * $page_size, $page_size, $search_terms); $cache->set("post-list:$page_number", $images, 60); } } } if (!$images) { - $images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms); + $images = Image::find_images(($page_number - 1) * $page_size, $page_size, $search_terms); } } catch (PermissionDeniedException $pde) { $this->theme->display_error(403, "Permission denied", $pde->error); @@ -135,14 +135,14 @@ public function onPageNavBuilding(PageNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="posts") { + if ($event->parent == "posts") { $event->add_nav_link("posts_all", new Link('post/list'), "All"); } } public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $event->add_block(new Block("General", $this->theme->get_help_html()), 0); } } @@ -186,13 +186,13 @@ public function onSearchTermParse(SearchTermParseEvent $event) ); } elseif (preg_match("/^ratio([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+):(\d+)$/i", $event->term, $matches)) { $cmp = preg_replace('/^:/', '=', $matches[1]); - $args = ["width{$event->id}"=>int_escape($matches[2]), "height{$event->id}"=>int_escape($matches[3])]; + $args = ["width{$event->id}" => int_escape($matches[2]), "height{$event->id}" => int_escape($matches[3])]; $event->add_querylet(new Querylet("width / :width{$event->id} $cmp height / :height{$event->id}", $args)); } elseif (preg_match("/^(filesize|id)([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+[kmg]?b?)$/i", $event->term, $matches)) { $col = $matches[1]; $cmp = ltrim($matches[2], ":") ?: "="; $val = parse_shorthand_int($matches[3]); - $event->add_querylet(new Querylet("images.$col $cmp :val{$event->id}", ["val{$event->id}"=>$val])); + $event->add_querylet(new Querylet("images.$col $cmp :val{$event->id}", ["val{$event->id}" => $val])); } elseif (preg_match("/^(hash|md5)[=|:]([0-9a-fA-F]*)$/i", $event->term, $matches)) { $hash = strtolower($matches[2]); $event->add_querylet(new Querylet('images.hash = :hash', ["hash" => $hash])); @@ -201,7 +201,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) $event->add_querylet(new Querylet('images.phash = :phash', ["phash" => $phash])); } elseif (preg_match("/^(filename|name)[=|:](.+)$/i", $event->term, $matches)) { $filename = strtolower($matches[2]); - $event->add_querylet(new Querylet("lower(images.filename) LIKE :filename{$event->id}", ["filename{$event->id}"=>"%$filename%"])); + $event->add_querylet(new Querylet("lower(images.filename) LIKE :filename{$event->id}", ["filename{$event->id}" => "%$filename%"])); } elseif (preg_match("/^(source)[=|:](.*)$/i", $event->term, $matches)) { $source = strtolower($matches[2]); @@ -209,27 +209,27 @@ public function onSearchTermParse(SearchTermParseEvent $event) $not = ($source == "any" ? "NOT" : ""); $event->add_querylet(new Querylet("images.source IS $not NULL")); } else { - $event->add_querylet(new Querylet('images.source LIKE :src', ["src"=>"%$source%"])); + $event->add_querylet(new Querylet('images.source LIKE :src', ["src" => "%$source%"])); } } elseif (preg_match("/^posted([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])([0-9-]*)$/i", $event->term, $matches)) { // TODO Make this able to search = without needing a time component. $cmp = ltrim($matches[1], ":") ?: "="; $val = $matches[2]; - $event->add_querylet(new Querylet("images.posted $cmp :posted{$event->id}", ["posted{$event->id}"=>$val])); + $event->add_querylet(new Querylet("images.posted $cmp :posted{$event->id}", ["posted{$event->id}" => $val])); } elseif (preg_match("/^size([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)x(\d+)$/i", $event->term, $matches)) { $cmp = ltrim($matches[1], ":") ?: "="; - $args = ["width{$event->id}"=>int_escape($matches[2]), "height{$event->id}"=>int_escape($matches[3])]; + $args = ["width{$event->id}" => int_escape($matches[2]), "height{$event->id}" => int_escape($matches[3])]; $event->add_querylet(new Querylet("width $cmp :width{$event->id} AND height $cmp :height{$event->id}", $args)); } elseif (preg_match("/^width([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)$/i", $event->term, $matches)) { $cmp = ltrim($matches[1], ":") ?: "="; - $event->add_querylet(new Querylet("width $cmp :width{$event->id}", ["width{$event->id}"=>int_escape($matches[2])])); + $event->add_querylet(new Querylet("width $cmp :width{$event->id}", ["width{$event->id}" => int_escape($matches[2])])); } elseif (preg_match("/^height([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)$/i", $event->term, $matches)) { $cmp = ltrim($matches[1], ":") ?: "="; - $event->add_querylet(new Querylet("height $cmp :height{$event->id}", ["height{$event->id}"=>int_escape($matches[2])])); + $event->add_querylet(new Querylet("height $cmp :height{$event->id}", ["height{$event->id}" => int_escape($matches[2])])); } elseif (preg_match("/^length([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(.+)$/i", $event->term, $matches)) { $value = parse_to_milliseconds($matches[2]); $cmp = ltrim($matches[1], ":") ?: "="; - $event->add_querylet(new Querylet("length $cmp :length{$event->id}", ["length{$event->id}"=>$value])); + $event->add_querylet(new Querylet("length $cmp :length{$event->id}", ["length{$event->id}" => $value])); } elseif (preg_match("/^order[=|:](id|width|height|length|filesize|filename)[_]?(desc|asc)?$/i", $event->term, $matches)) { $ord = strtolower($matches[1]); $default_order_for_column = preg_match("/^(id|filename)$/", $matches[1]) ? "ASC" : "DESC"; diff --git a/ext/ipban/main.php b/ext/ipban/main.php index ce97c6afb..6174d02f7 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -29,10 +29,10 @@ public function __construct(\FFSPHP\PDO $db) $this->set_columns([ new InetColumn("ip", "IP"), new EnumColumn("mode", "Mode", [ - "Block"=>"block", - "Firewall"=>"firewall", - "Ghost"=>"ghost", - "Anon Ghost"=>"anon-ghost" + "Block" => "block", + "Firewall" => "firewall", + "Ghost" => "ghost", + "Anon Ghost" => "anon-ghost" ]), new TextColumn("reason", "Reason"), new StringColumn("banner", "Banner"), @@ -135,7 +135,7 @@ public function onUserLogin(UserLoginEvent $event) // If an active ban is found, act on it if (!is_null($active_ban_id)) { - $row = $database->get_row("SELECT * FROM bans WHERE id=:id", ["id"=>$active_ban_id]); + $row = $database->get_row("SELECT * FROM bans WHERE id=:id", ["id" => $active_ban_id]); if (empty($row)) { return; } @@ -159,14 +159,14 @@ public function onUserLogin(UserLoginEvent $event) $b = new Block(null, $msg, "main", 0); $b->is_content = false; $page->add_block($b); - $page->add_cookie("nocache", "Ghost Banned", time()+60*60*2, "/"); + $page->add_cookie("nocache", "Ghost Banned", time() + 60 * 60 * 2, "/"); $event->user->class = $_shm_user_classes["ghost"]; } elseif ($row["mode"] == "anon-ghost") { if ($event->user->is_anonymous()) { $b = new Block(null, $msg, "main", 0); $b->is_content = false; $page->add_block($b); - $page->add_cookie("nocache", "Ghost Banned", time()+60*60*2, "/"); + $page->add_cookie("nocache", "Ghost Banned", time() + 60 * 60 * 2, "/"); $event->user->class = $_shm_user_classes["ghost"]; } } else { @@ -184,14 +184,14 @@ public function onPageRequest(PageRequestEvent $event) if ($user->can(Permissions::BAN_IP)) { if ($event->get_arg(0) == "create") { $user->ensure_authed(); - $input = validate_input(["c_ip"=>"string", "c_mode"=>"string", "c_reason"=>"string", "c_expires"=>"optional,date"]); + $input = validate_input(["c_ip" => "string", "c_mode" => "string", "c_reason" => "string", "c_expires" => "optional,date"]); send_event(new AddIPBanEvent($input['c_ip'], $input['c_mode'], $input['c_reason'], $input['c_expires'])); $page->flash("Ban for {$input['c_ip']} added"); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link("ip_ban/list")); } elseif ($event->get_arg(0) == "delete") { $user->ensure_authed(); - $input = validate_input(["d_id"=>"int"]); + $input = validate_input(["d_id" => "int"]); send_event(new RemoveIPBanEvent($input['d_id'])); $page->flash("Ban removed"); $page->set_mode(PageMode::REDIRECT); @@ -227,7 +227,7 @@ public function onSetupBuilding(SetupBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::BAN_IP)) { $event->add_nav_link("ip_bans", new Link('ip_ban/list'), "IP Bans", NavLink::is_active(["ip_ban"])); } @@ -246,7 +246,7 @@ public function onAddIPBan(AddIPBanEvent $event) { global $cache, $user, $database; $sql = "INSERT INTO bans (ip, mode, reason, expires, banner_id) VALUES (:ip, :mode, :reason, :expires, :admin_id)"; - $database->execute($sql, ["ip"=>$event->ip, "mode"=>$event->mode, "reason"=>$event->reason, "expires"=>$event->expires, "admin_id"=>$user->id]); + $database->execute($sql, ["ip" => $event->ip, "mode" => $event->mode, "reason" => $event->reason, "expires" => $event->expires, "admin_id" => $user->id]); $cache->delete("ip_bans"); $cache->delete("network_bans"); log_info("ipban", "Banned ({$event->mode}) {$event->ip} because '{$event->reason}' until {$event->expires}"); @@ -255,9 +255,9 @@ public function onAddIPBan(AddIPBanEvent $event) public function onRemoveIPBan(RemoveIPBanEvent $event) { global $cache, $database; - $ban = $database->get_row("SELECT * FROM bans WHERE id = :id", ["id"=>$event->id]); + $ban = $database->get_row("SELECT * FROM bans WHERE id = :id", ["id" => $event->id]); if ($ban) { - $database->execute("DELETE FROM bans WHERE id = :id", ["id"=>$event->id]); + $database->execute("DELETE FROM bans WHERE id = :id", ["id" => $event->id]); $cache->delete("ip_bans"); $cache->delete("network_bans"); log_info("ipban", "Removed {$ban['ip']}'s ban"); diff --git a/ext/ipban/test.php b/ext/ipban/test.php index 4dbb9f1ee..6beb6edec 100644 --- a/ext/ipban/test.php +++ b/ext/ipban/test.php @@ -56,7 +56,7 @@ public function test_all() { // just test it doesn't crash for now $this->log_in_as_admin(); - $page = $this->get_page('ip_ban/list', ['r_all'=>'on']); + $page = $this->get_page('ip_ban/list', ['r_all' => 'on']); $this->assertEquals(200, $page->code); } } diff --git a/ext/link_image/info.php b/ext/link_image/info.php index c0cedfe52..c735b5243 100644 --- a/ext/link_image/info.php +++ b/ext/link_image/info.php @@ -10,7 +10,7 @@ class LinkImageInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Link to Post"; - public array $authors = ["Artanis"=>"artanis.00@gmail.com"]; + public array $authors = ["Artanis" => "artanis.00@gmail.com"]; public string $description = "Show various forms of link to each image, for copy & paste"; public string $license = self::LICENSE_GPLV2; public ?string $documentation = "There is one option in Board Config: Text Link Format. diff --git a/ext/link_image/theme.php b/ext/link_image/theme.php index fe4a7b68a..dfe9e4c77 100644 --- a/ext/link_image/theme.php +++ b/ext/link_image/theme.php @@ -62,7 +62,7 @@ public function links_block(Page $page, $data) protected function url(string $url, string $content, string $type): string { if (empty($content)) { - $content=$url; + $content = $url; } switch ($type) { @@ -93,7 +93,7 @@ protected function img(string $src, string $type): string return $text; } - protected function link_code(string $label, string $content, $id=null): string + protected function link_code(string $label, string $content, $id = null): string { return " diff --git a/ext/livefeed/main.php b/ext/livefeed/main.php index acaff4b37..7df0102f5 100644 --- a/ext/livefeed/main.php +++ b/ext/livefeed/main.php @@ -63,7 +63,7 @@ private function msg(string $data) $host = $parts[0]; $port = (int)$parts[1]; $fp = fsockopen("udp://$host", $port, $errno, $errstr); - if (! $fp) { + if (!$fp) { return; } fwrite($fp, "$data\n"); diff --git a/ext/log_db/main.php b/ext/log_db/main.php index fc7cea05b..e4d3ad457 100644 --- a/ext/log_db/main.php +++ b/ext/log_db/main.php @@ -26,15 +26,15 @@ public function read_input(array $inputs) { return emptyHTML( INPUT([ - "type"=>"date", - "name"=>"r_{$this->name}[]", - "value"=>@$inputs["r_{$this->name}"][0] + "type" => "date", + "name" => "r_{$this->name}[]", + "value" => @$inputs["r_{$this->name}"][0] ]), BR(), INPUT([ - "type"=>"date", - "name"=>"r_{$this->name}[]", - "value"=>@$inputs["r_{$this->name}"][1] + "type" => "date", + "name" => "r_{$this->name}[]", + "value" => @$inputs["r_{$this->name}"][1] ]) ); } @@ -94,7 +94,7 @@ public function display($row): HTMLElement { $ret = emptyHTML(); if ($row['username'] != "Anonymous") { - $ret->appendChild(A(["href"=>make_link("user/{$row['username']}"), "title"=>$row['address']], $row['username'])); + $ret->appendChild(A(["href" => make_link("user/{$row['username']}"), "title" => $row['address']], $row['username'])); $ret->appendChild(BR()); } $ret->appendChild($row['address']); @@ -125,10 +125,10 @@ public function read_input(array $inputs) { $ret = emptyHTML( INPUT([ - "type"=>"text", - "name"=>"r_{$this->name}[]", - "placeholder"=>$this->title, - "value"=>@$inputs["r_{$this->name}"][0] + "type" => "text", + "name" => "r_{$this->name}[]", + "placeholder" => $this->title, + "value" => @$inputs["r_{$this->name}"][0] ]) ); @@ -139,10 +139,10 @@ public function read_input(array $inputs) "Error" => SCORE_LOG_ERROR, "Critical" => SCORE_LOG_CRITICAL, ]; - $s = SELECT(["name"=>"r_{$this->name}[]"]); - $s->appendChild(OPTION(["value"=>""], '-')); + $s = SELECT(["name" => "r_{$this->name}[]"]); + $s->appendChild(OPTION(["value" => ""], '-')); foreach ($options as $k => $v) { - $attrs = ["value"=>$v]; + $attrs = ["value" => $v]; if ($v == @$inputs["r_{$this->name}"][1]) { $attrs["selected"] = true; } @@ -186,7 +186,7 @@ public function display($row) $c = "#F00"; break; } - return SPAN(["style"=>"color: $c"], rawHTML($this->scan_entities($row[$this->name]))); + return SPAN(["style" => "color: $c"], rawHTML($this->scan_entities($row[$this->name]))); } protected function scan_entities(string $line) @@ -282,7 +282,7 @@ public function onPageRequest(PageRequestEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::VIEW_EVENTLOG)) { $event->add_nav_link("event_log", new Link('log/view'), "Event Log"); } @@ -313,8 +313,8 @@ public function onLog(LogEvent $event) INSERT INTO score_log(date_sent, section, priority, username, address, message) VALUES(now(), :section, :priority, :username, :address, :message) ", [ - "section"=>$event->section, "priority"=>$event->priority, "username"=>$username, - "address"=>get_real_ip(), "message"=>$event->message + "section" => $event->section, "priority" => $event->priority, "username" => $username, + "address" => get_real_ip(), "message" => $event->message ]); } } diff --git a/ext/log_db/test.php b/ext/log_db/test.php index 6185d4c6c..9dac1ed05 100644 --- a/ext/log_db/test.php +++ b/ext/log_db/test.php @@ -10,11 +10,11 @@ public function testLog() { $this->log_in_as_admin(); $this->get_page("log/view"); - $this->get_page("log/view", ["r_module"=>"core-image"]); - $this->get_page("log/view", ["r_time"=>"2012-03-01"]); - $this->get_page("log/view", ["r_user"=>"demo"]); + $this->get_page("log/view", ["r_module" => "core-image"]); + $this->get_page("log/view", ["r_time" => "2012-03-01"]); + $this->get_page("log/view", ["r_user" => "demo"]); - $page = $this->get_page("log/view", ["r_priority"=>"10"]); + $page = $this->get_page("log/view", ["r_priority" => "10"]); $this->assertEquals(200, $page->code); } } diff --git a/ext/log_logstash/main.php b/ext/log_logstash/main.php index c0f0a2bb3..1ad6f5fba 100644 --- a/ext/log_logstash/main.php +++ b/ext/log_logstash/main.php @@ -53,7 +53,7 @@ private function send_data($data) $host = $parts[0]; $port = (int)$parts[1]; $fp = fsockopen("udp://$host", $port, $errno, $errstr); - if (! $fp) { + if (!$fp) { return; } fwrite($fp, json_encode($data)); diff --git a/ext/log_net/main.php b/ext/log_net/main.php index 7faa07ecf..1fec26071 100644 --- a/ext/log_net/main.php +++ b/ext/log_net/main.php @@ -45,7 +45,7 @@ private function msg($data) $host = $parts[0]; $port = (int)$parts[1]; $fp = fsockopen("udp://$host", $port, $errno, $errstr); - if (! $fp) { + if (!$fp) { return; } fwrite($fp, "$data\n"); diff --git a/ext/media/info.php b/ext/media/info.php index 5490639e8..39efc2c2a 100644 --- a/ext/media/info.php +++ b/ext/media/info.php @@ -11,7 +11,7 @@ class MediaInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Media"; public string $url = self::SHIMMIE_URL; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Provides common functions and settings used for media operations."; public bool $core = true; diff --git a/ext/media/main.php b/ext/media/main.php index f3fce63be..a5b29eb68 100644 --- a/ext/media/main.php +++ b/ext/media/main.php @@ -242,17 +242,17 @@ public function onSearchTermParse(SearchTermParseEvent $event) $matches = []; if (preg_match(self::CONTENT_SEARCH_TERM_REGEX, $event->term, $matches)) { $field = $matches[1]; - if ($field==="unknown") { + if ($field === "unknown") { $event->add_querylet(new Querylet("video IS NULL OR audio IS NULL OR image IS NULL")); } else { - $event->add_querylet(new Querylet("$field = :true", ["true"=>true])); + $event->add_querylet(new Querylet("$field = :true", ["true" => true])); } } } public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $block = new Block(); $block->header = "Media"; $block->body = $this->theme->get_help_html(); @@ -270,12 +270,12 @@ public function onTagTermCheck(TagTermCheckEvent $event) public function onParseLinkTemplate(ParseLinkTemplateEvent $event) { if ($event->image->width && $event->image->height && $event->image->length) { - $s = ((int)($event->image->length / 100))/10; + $s = ((int)($event->image->length / 100)) / 10; $event->replace('$size', "{$event->image->width}x{$event->image->height}, {$s}s"); } elseif ($event->image->width && $event->image->height) { $event->replace('$size', "{$event->image->width}x{$event->image->height}"); } elseif ($event->image->length) { - $s = ((int)($event->image->length / 100))/10; + $s = ((int)($event->image->length / 100)) / 10; $event->replace('$size', "{$s}s"); } } @@ -404,112 +404,112 @@ public static function determine_ext(string $mime): string return $ext; } -// private static function image_save_imagick(Imagick $image, string $path, string $format, int $output_quality = 80, bool $minimize) -// { -// switch ($format) { -// case FileExtension::PNG: -// $result = $image->setOption('png:compression-level', 9); -// if ($result !== true) { -// throw new GraphicsException("Could not set png compression option"); -// } -// break; -// case Graphics::WEBP_LOSSLESS: -// $result = $image->setOption('webp:lossless', true); -// if ($result !== true) { -// throw new GraphicsException("Could not set lossless webp option"); -// } -// break; -// default: -// $result = $image->setImageCompressionQuality($output_quality); -// if ($result !== true) { -// throw new GraphicsException("Could not set compression quality for $path to $output_quality"); -// } -// break; -// } -// -// if (self::supports_alpha($format)) { -// $result = $image->setImageBackgroundColor(new \ImagickPixel('transparent')); -// } else { -// $result = $image->setImageBackgroundColor(new \ImagickPixel('black')); -// } -// if ($result !== true) { -// throw new GraphicsException("Could not set background color"); -// } -// -// -// if ($minimize) { -// $profiles = $image->getImageProfiles("icc", true); -// $result = $image->stripImage(); -// if ($result !== true) { -// throw new GraphicsException("Could not strip information from image"); -// } -// if (!empty($profiles)) { -// $image->profileImage("icc", $profiles['icc']); -// } -// } -// -// $ext = self::determine_ext($format); -// -// $result = $image->writeImage($ext . ":" . $path); -// if ($result !== true) { -// throw new GraphicsException("Could not write image to $path"); -// } -// } - -// public static function image_resize_imagick( -// string $input_path, -// string $input_type, -// int $new_width, -// int $new_height, -// string $output_filename, -// string $output_type = null, -// bool $ignore_aspect_ratio = false, -// int $output_quality = 80, -// bool $minimize = false, -// bool $allow_upscale = true -// ): void -// { -// global $config; -// -// if (!empty($input_type)) { -// $input_type = self::determine_ext($input_type); -// } -// -// try { -// $image = new Imagick($input_type . ":" . $input_path); -// try { -// $result = $image->flattenImages(); -// if ($result !== true) { -// throw new GraphicsException("Could not flatten image $input_path"); -// } -// -// $height = $image->getImageHeight(); -// $width = $image->getImageWidth(); -// if (!$allow_upscale && -// ($new_width > $width || $new_height > $height)) { -// $new_height = $height; -// $new_width = $width; -// } -// -// $result = $image->resizeImage($new_width, $new_width, Imagick::FILTER_LANCZOS, 0, !$ignore_aspect_ratio); -// if ($result !== true) { -// throw new GraphicsException("Could not perform image resize on $input_path"); -// } -// -// -// if (empty($output_type)) { -// $output_type = $input_type; -// } -// -// self::image_save_imagick($image, $output_filename, $output_type, $output_quality); -// -// } finally { -// $image->destroy(); -// } -// } catch (ImagickException $e) { -// throw new GraphicsException("Error while resizing with Imagick: " . $e->getMessage(), $e->getCode(), $e); -// } -// } + // private static function image_save_imagick(Imagick $image, string $path, string $format, int $output_quality = 80, bool $minimize) + // { + // switch ($format) { + // case FileExtension::PNG: + // $result = $image->setOption('png:compression-level', 9); + // if ($result !== true) { + // throw new GraphicsException("Could not set png compression option"); + // } + // break; + // case Graphics::WEBP_LOSSLESS: + // $result = $image->setOption('webp:lossless', true); + // if ($result !== true) { + // throw new GraphicsException("Could not set lossless webp option"); + // } + // break; + // default: + // $result = $image->setImageCompressionQuality($output_quality); + // if ($result !== true) { + // throw new GraphicsException("Could not set compression quality for $path to $output_quality"); + // } + // break; + // } + // + // if (self::supports_alpha($format)) { + // $result = $image->setImageBackgroundColor(new \ImagickPixel('transparent')); + // } else { + // $result = $image->setImageBackgroundColor(new \ImagickPixel('black')); + // } + // if ($result !== true) { + // throw new GraphicsException("Could not set background color"); + // } + // + // + // if ($minimize) { + // $profiles = $image->getImageProfiles("icc", true); + // $result = $image->stripImage(); + // if ($result !== true) { + // throw new GraphicsException("Could not strip information from image"); + // } + // if (!empty($profiles)) { + // $image->profileImage("icc", $profiles['icc']); + // } + // } + // + // $ext = self::determine_ext($format); + // + // $result = $image->writeImage($ext . ":" . $path); + // if ($result !== true) { + // throw new GraphicsException("Could not write image to $path"); + // } + // } + + // public static function image_resize_imagick( + // string $input_path, + // string $input_type, + // int $new_width, + // int $new_height, + // string $output_filename, + // string $output_type = null, + // bool $ignore_aspect_ratio = false, + // int $output_quality = 80, + // bool $minimize = false, + // bool $allow_upscale = true + // ): void + // { + // global $config; + // + // if (!empty($input_type)) { + // $input_type = self::determine_ext($input_type); + // } + // + // try { + // $image = new Imagick($input_type . ":" . $input_path); + // try { + // $result = $image->flattenImages(); + // if ($result !== true) { + // throw new GraphicsException("Could not flatten image $input_path"); + // } + // + // $height = $image->getImageHeight(); + // $width = $image->getImageWidth(); + // if (!$allow_upscale && + // ($new_width > $width || $new_height > $height)) { + // $new_height = $height; + // $new_width = $width; + // } + // + // $result = $image->resizeImage($new_width, $new_width, Imagick::FILTER_LANCZOS, 0, !$ignore_aspect_ratio); + // if ($result !== true) { + // throw new GraphicsException("Could not perform image resize on $input_path"); + // } + // + // + // if (empty($output_type)) { + // $output_type = $input_type; + // } + // + // self::image_save_imagick($image, $output_filename, $output_type, $output_quality); + // + // } finally { + // $image->destroy(); + // } + // } catch (ImagickException $e) { + // throw new GraphicsException("Error while resizing with Imagick: " . $e->getMessage(), $e->getCode(), $e); + // } + // } public static function is_lossless(string $filename, string $mime): bool { @@ -548,7 +548,7 @@ public static function image_resize_convert( $output_mime = $input_mime; } - if ($output_mime==MimeType::WEBP && self::is_lossless($input_path, $input_mime)) { + if ($output_mime == MimeType::WEBP && self::is_lossless($input_path, $input_mime)) { $output_mime = MimeType::WEBP_LOSSLESS; } @@ -561,7 +561,7 @@ public static function image_resize_convert( if (!$allow_upscale) { $resize_suffix .= "\>"; } - if ($resize_type==Media::RESIZE_TYPE_STRETCH) { + if ($resize_type == Media::RESIZE_TYPE_STRETCH) { $resize_suffix .= "\!"; } @@ -576,8 +576,8 @@ public static function image_resize_convert( $file_arg = "{$input_ext}:\"{$input_path}[0]\""; - if ($resize_type===Media::RESIZE_TYPE_FIT_BLUR_PORTRAIT) { - if ($new_height>$new_width) { + if ($resize_type === Media::RESIZE_TYPE_FIT_BLUR_PORTRAIT) { + if ($new_height > $new_width) { $resize_type = Media::RESIZE_TYPE_FIT_BLUR; } else { $resize_type = Media::RESIZE_TYPE_FILL; @@ -685,7 +685,7 @@ public static function image_resize_gd( throw new InsufficientMemoryException("The image is too large to resize given the memory limits. ($memory_use > $memory_limit)"); } - if ($resize_type==Media::RESIZE_TYPE_FIT) { + if ($resize_type == Media::RESIZE_TYPE_FIT) { list($new_width, $new_height) = get_scaled_by_aspect_ratio($width, $height, $new_width, $new_height); } if (!$allow_upscale && @@ -774,18 +774,18 @@ public static function image_resize_gd( $width = imagesx($image_resized); $height = imagesy($image_resized); $new_image = imagecreatetruecolor($width, $height); - if ($new_image===false) { + if ($new_image === false) { throw new ImageTranscodeException("Could not create image with dimensions $width x $height"); } $background_color = Media::hex_color_allocate($new_image, $alpha_color); - if ($background_color===false) { + if ($background_color === false) { throw new ImageTranscodeException("Could not allocate background color"); } - if (imagefilledrectangle($new_image, 0, 0, $width, $height, $background_color)===false) { + if (imagefilledrectangle($new_image, 0, 0, $width, $height, $background_color) === false) { throw new ImageTranscodeException("Could not fill background color"); } - if (imagecopy($new_image, $image_resized, 0, 0, 0, 0, $width, $height)===false) { + if (imagecopy($new_image, $image_resized, 0, 0, 0, 0, $width, $height) === false) { throw new ImageTranscodeException("Could not copy source image to new image"); } @@ -927,8 +927,8 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) } if ($this->get_version(MediaConfig::VERSION) < 5) { - $database->execute("UPDATE images SET image = :f WHERE ext IN ('swf','mp3','ani','flv','mp4','m4v','ogv','webm')", ["f"=>false]); - $database->execute("UPDATE images SET image = :t WHERE ext IN ('jpg','jpeg','ico','cur','png')", ["t"=>true]); + $database->execute("UPDATE images SET image = :f WHERE ext IN ('swf','mp3','ani','flv','mp4','m4v','ogv','webm')", ["f" => false]); + $database->execute("UPDATE images SET image = :t WHERE ext IN ('jpg','jpeg','ico','cur','png')", ["t" => true]); $this->set_version(MediaConfig::VERSION, 5); } } diff --git a/ext/media/theme.php b/ext/media/theme.php index 00ec19229..ca0205976 100644 --- a/ext/media/theme.php +++ b/ext/media/theme.php @@ -12,7 +12,7 @@ public function get_buttons_html(int $image_id): string { return (string)SHM_SIMPLE_FORM( "media_rescan/", - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), SHM_SUBMIT('Scan Media Properties'), ); } diff --git a/ext/mime/file_extension.php b/ext/mime/file_extension.php index 52b72fe64..adbe7d0ea 100644 --- a/ext/mime/file_extension.php +++ b/ext/mime/file_extension.php @@ -77,12 +77,12 @@ public static function get_for_mime(string $mime): ?string return null; } - if ($mime==MimeType::OCTET_STREAM) { + if ($mime == MimeType::OCTET_STREAM) { return null; } $data = MimeMap::get_for_mime($mime); - if ($data!=null) { + if ($data != null) { return $data[MimeMap::MAP_EXT][0]; } return null; @@ -97,12 +97,12 @@ public static function get_all_for_mime(string $mime): array return []; } - if ($mime==MimeType::OCTET_STREAM) { + if ($mime == MimeType::OCTET_STREAM) { return []; } $data = MimeMap::get_for_mime($mime); - if ($data!=null) { + if ($data != null) { return $data[MimeMap::MAP_EXT]; } diff --git a/ext/mime/info.php b/ext/mime/info.php index fb8173e98..9818481ae 100644 --- a/ext/mime/info.php +++ b/ext/mime/info.php @@ -10,7 +10,7 @@ class MimeSystemInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "MIME"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Provides system mime-related functionality"; public bool $core = true; diff --git a/ext/mime/main.php b/ext/mime/main.php index d5fe4402d..dbd1eb698 100644 --- a/ext/mime/main.php +++ b/ext/mime/main.php @@ -42,7 +42,7 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) foreach ($extensions as $ext) { $mime = MimeType::get_for_extension($ext); - if (empty($mime) || $mime===MimeType::OCTET_STREAM) { + if (empty($mime) || $mime === MimeType::OCTET_STREAM) { throw new SCoreException("Unknown extension: $ext"); } @@ -60,7 +60,7 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $block = new Block(); $block->header = "File Types"; $block->body = $this->theme->get_help_html(); @@ -81,7 +81,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) $event->add_querylet(new Querylet('images.ext = :ext', ["ext" => $ext])); } elseif (preg_match("/^mime[=|:](.+)$/i", $event->term, $matches)) { $mime = strtolower($matches[1]); - $event->add_querylet(new Querylet("images.mime = :mime", ["mime"=>$mime])); + $event->add_querylet(new Querylet("images.mime = :mime", ["mime" => $mime])); } } } diff --git a/ext/mime/mime_map.php b/ext/mime/mime_map.php index b5f75b8c0..37db7fd46 100644 --- a/ext/mime/mime_map.php +++ b/ext/mime/mime_map.php @@ -262,7 +262,7 @@ public static function get_for_mime(string $mime): ?array public static function get_name_for_mime(string $mime): ?string { $data = self::get_for_mime($mime); - if ($data!==null) { + if ($data !== null) { return $data[self::MAP_NAME]; } return null; diff --git a/ext/mime/mime_type.php b/ext/mime/mime_type.php index e778efb04..c3e71fd42 100644 --- a/ext/mime/mime_type.php +++ b/ext/mime/mime_type.php @@ -80,7 +80,7 @@ class MimeType public static function is_mime(string $value): bool { - return preg_match(self::REGEX_MIME_TYPE, $value)===1; + return preg_match(self::REGEX_MIME_TYPE, $value) === 1; } public static function add_parameters(string $mime, string ...$parameters): string @@ -94,7 +94,7 @@ public static function add_parameters(string $mime, string ...$parameters): stri public static function remove_parameters(string $mime): string { $i = strpos($mime, ";"); - if ($i!==false) { + if ($i !== false) { return substr($mime, 0, $i); } return $mime; @@ -121,7 +121,7 @@ public static function matches(string $mime1, string $mime2, bool $exact = false $mime1 = self::remove_parameters($mime1); $mime2 = self::remove_parameters($mime2); } - return strtolower($mime1)===strtolower($mime2); + return strtolower($mime1) === strtolower($mime2); } @@ -147,7 +147,7 @@ public static function is_animated_gif(string $image_filename): bool @fclose($fh); } } - return ($is_anim_gif >=2); + return ($is_anim_gif >= 2); } @@ -202,11 +202,11 @@ public static function is_lossless_webp(string $image_filename): bool public static function get_for_extension(string $ext): ?string { $data = MimeMap::get_for_extension($ext); - if ($data!=null) { + if ($data != null) { return $data[MimeMap::MAP_MIME][0]; } // This was an old solution for differentiating lossless webps - if ($ext==="webp-lossless") { + if ($ext === "webp-lossless") { return MimeType::WEBP_LOSSLESS; } return null; @@ -239,10 +239,10 @@ public static function get_for_file(string $file, ?string $ext = null): string if (!empty($ext)) { // Here we handle the few file types that need extension-based handling $ext = strtolower($ext); - if ($type===MimeType::ZIP && $ext===FileExtension::CBZ) { + if ($type === MimeType::ZIP && $ext === FileExtension::CBZ) { $output = MimeType::COMIC_ZIP; } - if ($type===MimeType::OCTET_STREAM) { + if ($type === MimeType::OCTET_STREAM) { switch ($ext) { case FileExtension::ANI: $output = MimeType::ANI; diff --git a/ext/not_a_tag/main.php b/ext/not_a_tag/main.php index 74cb064e6..7b1028d8b 100644 --- a/ext/not_a_tag/main.php +++ b/ext/not_a_tag/main.php @@ -114,7 +114,7 @@ private function strip(array $tags): array public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="tags") { + if ($event->parent === "tags") { if ($user->can(Permissions::BAN_IMAGE)) { $event->add_nav_link("untags", new Link('untag/list/1'), "UnTags"); } @@ -137,19 +137,19 @@ public function onPageRequest(PageRequestEvent $event) if ($user->can(Permissions::BAN_IMAGE)) { if ($event->get_arg(0) == "add") { $user->ensure_authed(); - $input = validate_input(["c_tag"=>"string", "c_redirect"=>"string"]); + $input = validate_input(["c_tag" => "string", "c_redirect" => "string"]); $database->execute( "INSERT INTO untags(tag, redirect) VALUES (:tag, :redirect)", - ["tag"=>$input['c_tag'], "redirect"=>$input['c_redirect']] + ["tag" => $input['c_tag'], "redirect" => $input['c_redirect']] ); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(referer_or(make_link())); } elseif ($event->get_arg(0) == "remove") { $user->ensure_authed(); - $input = validate_input(["d_tag"=>"string"]); + $input = validate_input(["d_tag" => "string"]); $database->execute( "DELETE FROM untags WHERE LOWER(tag) = LOWER(:tag)", - ["tag"=>$input['d_tag']] + ["tag" => $input['d_tag']] ); $page->flash("Post ban removed"); $page->set_mode(PageMode::REDIRECT); diff --git a/ext/not_a_tag/test.php b/ext/not_a_tag/test.php index 3a9277c71..98202af79 100644 --- a/ext/not_a_tag/test.php +++ b/ext/not_a_tag/test.php @@ -10,7 +10,7 @@ public function testUntags() { global $database; $database->execute("DELETE FROM untags"); - $database->execute("INSERT INTO untags(tag, redirect) VALUES (:tag, :redirect)", ["tag"=>"face", "redirect"=>"no-body-parts.html"]); + $database->execute("INSERT INTO untags(tag, redirect) VALUES (:tag, :redirect)", ["tag" => "face", "redirect" => "no-body-parts.html"]); $this->log_in_as_user(); $image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx"); diff --git a/ext/notes/info.php b/ext/notes/info.php index 6ed211d0d..3d6b125b3 100644 --- a/ext/notes/info.php +++ b/ext/notes/info.php @@ -10,7 +10,7 @@ class NotesInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Notes"; - public array $authors = ["Sein Kraft"=>"mail@seinkraft.info"]; + public array $authors = ["Sein Kraft" => "mail@seinkraft.info"]; public string $license = self::LICENSE_GPLV2; public string $description = "Annotate images"; } diff --git a/ext/notes/main.php b/ext/notes/main.php index 2b1c7b8cf..e6292e0b7 100644 --- a/ext/notes/main.php +++ b/ext/notes/main.php @@ -215,7 +215,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $block = new Block(); $block->header = "Notes"; $block->body = $this->theme->get_help_html(); @@ -236,7 +236,7 @@ private function get_notes(int $imageID): array FROM notes WHERE enable = :enable AND image_id = :image_id ORDER BY date ASC - ", ['enable'=>'1', 'image_id'=>$imageID]); + ", ['enable' => '1', 'image_id' => $imageID]); } @@ -259,14 +259,14 @@ private function add_new_note() " INSERT INTO notes (enable, image_id, user_id, user_ip, date, x1, y1, height, width, note) VALUES (:enable, :image_id, :user_id, :user_ip, now(), :x1, :y1, :height, :width, :note)", - ['enable'=>1, 'image_id'=>$imageID, 'user_id'=>$user_id, 'user_ip'=>get_real_ip(), 'x1'=>$noteX1, 'y1'=>$noteY1, 'height'=>$noteHeight, 'width'=>$noteWidth, 'note'=>$noteText] + ['enable' => 1, 'image_id' => $imageID, 'user_id' => $user_id, 'user_ip' => get_real_ip(), 'x1' => $noteX1, 'y1' => $noteY1, 'height' => $noteHeight, 'width' => $noteWidth, 'note' => $noteText] ); $noteID = $database->get_last_insert_id('notes_id_seq'); log_info("notes", "Note added {$noteID} by {$user->name}"); - $database->execute("UPDATE images SET notes=(SELECT COUNT(*) FROM notes WHERE image_id=:id1) WHERE id=:id2", ['id1'=>$imageID, 'id2'=>$imageID]); + $database->execute("UPDATE images SET notes=(SELECT COUNT(*) FROM notes WHERE image_id=:id1) WHERE id=:id2", ['id1' => $imageID, 'id2' => $imageID]); $this->add_history(1, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText); } @@ -282,7 +282,7 @@ private function add_note_request() " INSERT INTO note_request (image_id, user_id, date) VALUES (:image_id, :user_id, now())", - ['image_id'=>$image_id, 'user_id'=>$user_id] + ['image_id' => $image_id, 'user_id' => $user_id] ); $resultID = $database->get_last_insert_id('note_request_id_seq'); @@ -332,7 +332,7 @@ private function delete_note() $database->execute(" UPDATE notes SET enable = :enable WHERE image_id = :image_id AND id = :id - ", ['enable'=>0, 'image_id'=>$imageID, 'id'=>$noteID]); + ", ['enable' => 0, 'image_id' => $imageID, 'id' => $noteID]); log_info("notes", "Note deleted {$noteID} by {$user->name}"); } @@ -341,7 +341,7 @@ private function nuke_notes() { global $database, $user; $image_id = int_escape($_POST["image_id"]); - $database->execute("DELETE FROM notes WHERE image_id = :image_id", ['image_id'=>$image_id]); + $database->execute("DELETE FROM notes WHERE image_id = :image_id", ['image_id' => $image_id]); log_info("notes", "Notes deleted from {$image_id} by {$user->name}"); } @@ -350,7 +350,7 @@ private function nuke_requests() global $database, $user; $image_id = int_escape($_POST["image_id"]); - $database->execute("DELETE FROM note_request WHERE image_id = :image_id", ['image_id'=>$image_id]); + $database->execute("DELETE FROM note_request WHERE image_id = :image_id", ['image_id' => $image_id]); log_info("notes", "Requests deleted from {$image_id} by {$user->name}"); } @@ -370,7 +370,7 @@ private function get_notes_list(PageRequestEvent $event) FROM notes WHERE enable = :enable ORDER BY date DESC LIMIT :limit OFFSET :offset", - ['enable'=>1, 'offset'=>$pageNumber * $notesPerPage, 'limit'=>$notesPerPage] + ['enable' => 1, 'offset' => $pageNumber * $notesPerPage, 'limit' => $notesPerPage] ); $totalPages = ceil($database->get_one("SELECT COUNT(DISTINCT image_id) FROM notes") / $notesPerPage); @@ -400,7 +400,7 @@ private function get_notes_requests(PageRequestEvent $event) SELECT DISTINCT image_id FROM note_request ORDER BY date DESC LIMIT :limit OFFSET :offset", - ["offset"=>$pageNumber * $requestsPerPage, "limit"=>$requestsPerPage] + ["offset" => $pageNumber * $requestsPerPage, "limit" => $requestsPerPage] ); $totalPages = ceil($database->get_one("SELECT COUNT(*) FROM note_request") / $requestsPerPage); @@ -417,7 +417,7 @@ private function add_history($noteEnable, $noteID, $imageID, $noteX1, $noteY1, $ { global $user, $database; - $reviewID = $database->get_one("SELECT COUNT(*) FROM note_histories WHERE note_id = :note_id", ['note_id'=>$noteID]); + $reviewID = $database->get_one("SELECT COUNT(*) FROM note_histories WHERE note_id = :note_id", ['note_id' => $noteID]); $reviewID = $reviewID + 1; $database->execute( @@ -425,8 +425,8 @@ private function add_history($noteEnable, $noteID, $imageID, $noteX1, $noteY1, $ INSERT INTO note_histories (note_enable, note_id, review_id, image_id, user_id, user_ip, date, x1, y1, height, width, note) VALUES (:note_enable, :note_id, :review_id, :image_id, :user_id, :user_ip, now(), :x1, :y1, :height, :width, :note) ", - ['note_enable'=>$noteEnable, 'note_id'=>$noteID, 'review_id'=>$reviewID, 'image_id'=>$imageID, 'user_id'=>$user->id, 'user_ip'=>get_real_ip(), - 'x1'=>$noteX1, 'y1'=>$noteY1, 'height'=>$noteHeight, 'width'=>$noteWidth, 'note'=>$noteText] + ['note_enable' => $noteEnable, 'note_id' => $noteID, 'review_id' => $reviewID, 'image_id' => $imageID, 'user_id' => $user->id, 'user_ip' => get_real_ip(), + 'x1' => $noteX1, 'y1' => $noteY1, 'height' => $noteHeight, 'width' => $noteWidth, 'note' => $noteText] ); } @@ -445,7 +445,7 @@ private function get_histories(PageRequestEvent $event) "INNER JOIN users AS u ". "ON u.id = h.user_id ". "ORDER BY date DESC LIMIT :limit OFFSET :offset", - ['offset'=>$pageNumber * $historiesPerPage, 'limit'=>$historiesPerPage] + ['offset' => $pageNumber * $historiesPerPage, 'limit' => $historiesPerPage] ); $totalPages = ceil($database->get_one("SELECT COUNT(*) FROM note_histories") / $historiesPerPage); @@ -469,10 +469,10 @@ private function get_history(PageRequestEvent $event) "ON u.id = h.user_id ". "WHERE note_id = :note_id ". "ORDER BY date DESC LIMIT :limit OFFSET :offset", - ['note_id'=>$noteID, 'offset'=>$pageNumber * $historiesPerPage, 'limit'=>$historiesPerPage] + ['note_id' => $noteID, 'offset' => $pageNumber * $historiesPerPage, 'limit' => $historiesPerPage] ); - $totalPages = ceil($database->get_one("SELECT COUNT(*) FROM note_histories WHERE note_id = :note_id", ['note_id'=>$noteID]) / $historiesPerPage); + $totalPages = ceil($database->get_one("SELECT COUNT(*) FROM note_histories WHERE note_id = :note_id", ['note_id' => $noteID]) / $historiesPerPage); $this->theme->display_history($histories, $pageNumber + 1, $totalPages); } @@ -484,7 +484,7 @@ private function revert_history(int $noteID, int $reviewID) { global $database; - $history = $database->get_row("SELECT * FROM note_histories WHERE note_id = :note_id AND review_id = :review_id", ['note_id'=>$noteID, 'review_id'=>$reviewID]); + $history = $database->get_row("SELECT * FROM note_histories WHERE note_id = :note_id AND review_id = :review_id", ['note_id' => $noteID, 'review_id' => $reviewID]); $noteEnable = $history['note_enable']; $noteID = $history['note_id']; @@ -499,7 +499,7 @@ private function revert_history(int $noteID, int $reviewID) UPDATE notes SET enable = :enable, x1 = :x1, y1 = :y1, height = :height, width = :width, note = :note WHERE image_id = :image_id AND id = :id - ", ['enable'=>1, 'x1'=>$noteX1, 'y1'=>$noteY1, 'height'=>$noteHeight, 'width'=>$noteWidth, 'note'=>$noteText, 'image_id'=>$imageID, 'id'=>$noteID]); + ", ['enable' => 1, 'x1' => $noteX1, 'y1' => $noteY1, 'height' => $noteHeight, 'width' => $noteWidth, 'note' => $noteText, 'image_id' => $imageID, 'id' => $noteID]); $this->add_history($noteEnable, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText); } diff --git a/ext/numeric_score/info.php b/ext/numeric_score/info.php index b3d8276ab..8c16b9938 100644 --- a/ext/numeric_score/info.php +++ b/ext/numeric_score/info.php @@ -14,5 +14,5 @@ class NumericScoreInfo extends ExtensionInfo public array $authors = self::SHISH_AUTHOR; public string $license = self::LICENSE_GPLV2; public string $description = "Allow users to score images"; - public ?string $documentation ="Each registered user may vote a post +1 or -1, the image's score is the sum of all votes."; + public ?string $documentation = "Each registered user may vote a post +1 or -1, the image's score is the sum of all votes."; } diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php index e2366c709..a42a25f69 100644 --- a/ext/numeric_score/main.php +++ b/ext/numeric_score/main.php @@ -38,7 +38,7 @@ public static function score(Image $post): int } return $database->get_one( "SELECT sum(score) FROM numeric_score_votes WHERE image_id=:image_id", - ['image_id'=>$post->id] + ['image_id' => $post->id] ) ?? 0; } @@ -48,7 +48,7 @@ public static function votes(Image $post): array global $database; $rows = $database->get_all( "SELECT * FROM numeric_score_votes WHERE image_id=:image_id", - ['image_id'=>$post->id] + ['image_id' => $post->id] ); $votes = []; foreach ($rows as $row) { @@ -67,7 +67,7 @@ public static function my_vote(Image $post): int global $database, $user; return $database->get_one( "SELECT score FROM numeric_score_votes WHERE image_id=:image_id AND user_id=:user_id", - ['image_id'=>$post->id, "user_id"=>$user->id] + ['image_id' => $post->id, "user_id" => $user->id] ) ?? 0; } @@ -137,7 +137,7 @@ public function onPageRequest(PageRequestEvent $event) FROM numeric_score_votes JOIN users ON numeric_score_votes.user_id=users.id WHERE image_id=:image_id", - ['image_id'=>$image_id] + ['image_id' => $image_id] ); $html = ""; foreach ($x as $vote) { @@ -152,7 +152,7 @@ public function onPageRequest(PageRequestEvent $event) if ($user->can(Permissions::CREATE_VOTE)) { $image_id = int_escape($_POST['image_id']); $score = int_escape($_POST['vote']); - if (($score == -1 || $score == 0 || $score == 1) && $image_id>0) { + if (($score == -1 || $score == 0 || $score == 1) && $image_id > 0) { send_event(new NumericScoreSetEvent($image_id, $user, $score)); } $page->set_mode(PageMode::REDIRECT); @@ -163,11 +163,11 @@ public function onPageRequest(PageRequestEvent $event) $image_id = int_escape($_POST['image_id']); $database->execute( "DELETE FROM numeric_score_votes WHERE image_id=:image_id", - ['image_id'=>$image_id] + ['image_id' => $image_id] ); $database->execute( "UPDATE images SET numeric_score=0 WHERE id=:id", - ['id'=>$image_id] + ['id' => $image_id] ); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link("post/view/$image_id")); @@ -256,7 +256,7 @@ public function delete_votes_by(int $user_id) { global $database; - $image_ids = $database->get_col("SELECT image_id FROM numeric_score_votes WHERE user_id=:user_id", ['user_id'=>$user_id]); + $image_ids = $database->get_col("SELECT image_id FROM numeric_score_votes WHERE user_id=:user_id", ['user_id' => $user_id]); if (count($image_ids) == 0) { return; @@ -268,7 +268,7 @@ public function delete_votes_by(int $user_id) $id_list = implode(",", $chunk); $database->execute( "DELETE FROM numeric_score_votes WHERE user_id=:user_id AND image_id IN (".$id_list.")", - ['user_id'=>$user_id] + ['user_id' => $user_id] ); $database->execute(" UPDATE images @@ -291,7 +291,7 @@ public function onParseLinkTemplate(ParseLinkTemplateEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $block = new Block(); $block->header = "Numeric Score"; $block->body = $this->theme->get_help_html(); @@ -319,7 +319,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) } $event->add_querylet(new Querylet( "images.id in (SELECT image_id FROM numeric_score_votes WHERE user_id=:ns_user_id AND score=1)", - ["ns_user_id"=>$duser->id] + ["ns_user_id" => $duser->id] )); } elseif (preg_match("/^downvoted_by[=|:](.*)$/i", $event->term, $matches)) { $duser = User::by_name($matches[1]); @@ -330,19 +330,19 @@ public function onSearchTermParse(SearchTermParseEvent $event) } $event->add_querylet(new Querylet( "images.id in (SELECT image_id FROM numeric_score_votes WHERE user_id=:ns_user_id AND score=-1)", - ["ns_user_id"=>$duser->id] + ["ns_user_id" => $duser->id] )); } elseif (preg_match("/^upvoted_by_id[=|:](\d+)$/i", $event->term, $matches)) { $iid = int_escape($matches[1]); $event->add_querylet(new Querylet( "images.id in (SELECT image_id FROM numeric_score_votes WHERE user_id=:ns_user_id AND score=1)", - ["ns_user_id"=>$iid] + ["ns_user_id" => $iid] )); } elseif (preg_match("/^downvoted_by_id[=|:](\d+)$/i", $event->term, $matches)) { $iid = int_escape($matches[1]); $event->add_querylet(new Querylet( "images.id in (SELECT image_id FROM numeric_score_votes WHERE user_id=:ns_user_id AND score=-1)", - ["ns_user_id"=>$iid] + ["ns_user_id" => $iid] )); } elseif (preg_match("/^order[=|:](?:numeric_)?(score)(?:_(desc|asc))?$/i", $event->term, $matches)) { $default_order_for_column = "DESC"; @@ -373,7 +373,7 @@ public function onTagTermParse(TagTermParseEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="posts") { + if ($event->parent == "posts") { $event->add_nav_link("numeric_score_day", new Link('popular_by_day'), "Popular by Day"); $event->add_nav_link("numeric_score_month", new Link('popular_by_month'), "Popular by Month"); $event->add_nav_link("numeric_score_year", new Link('popular_by_year'), "Popular by Year"); diff --git a/ext/ouroboros_api/info.php b/ext/ouroboros_api/info.php index 4c19d24a6..f63ea7d1f 100644 --- a/ext/ouroboros_api/info.php +++ b/ext/ouroboros_api/info.php @@ -10,7 +10,7 @@ class OuroborosAPIInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Ouroboros API"; - public array $authors = ["Diftraku"=>"diftraku[at]derpy.me"]; + public array $authors = ["Diftraku" => "diftraku[at]derpy.me"]; public string $description = "Ouroboros-like API for Shimmie"; public ?string $version = "0.2"; public ?string $documentation = diff --git a/ext/ouroboros_api/main.php b/ext/ouroboros_api/main.php index 07ec46c2b..29b78993b 100644 --- a/ext/ouroboros_api/main.php +++ b/ext/ouroboros_api/main.php @@ -72,13 +72,13 @@ public function __construct(Image $img) $this->id = intval($img->id); $this->parent_id = null; - if (Extension::is_enabled(RatingsInfo::KEY)!== false) { + if (Extension::is_enabled(RatingsInfo::KEY) !== false) { // 'u' is not a "valid" rating if ($img->rating == 's' || $img->rating == 'q' || $img->rating == 'e') { $this->rating = $img->rating; } } - if (Extension::is_enabled(NumericScoreInfo::KEY)!== false) { + if (Extension::is_enabled(NumericScoreInfo::KEY) !== false) { $this->score = $img->numeric_score; } @@ -333,7 +333,7 @@ protected function postCreate(OuroborosPost $post, ?string $md5 = '') $meta = []; $meta['tags'] = is_array($post->tags) ? $post->tags : Tag::explode($post->tags); $meta['source'] = $post->source; - if (Extension::is_enabled(RatingsInfo::KEY)!== false) { + if (Extension::is_enabled(RatingsInfo::KEY) !== false) { $meta['rating'] = $post->rating; } // Check where we should try for the file diff --git a/ext/pm/main.php b/ext/pm/main.php index 1755e839d..5600a2d94 100644 --- a/ext/pm/main.php +++ b/ext/pm/main.php @@ -184,10 +184,10 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="user") { + if ($event->parent === "user") { if ($user->can(Permissions::READ_PM)) { $count = $this->count_pms($user); - $h_count = $count > 0 ? SPAN(["class"=>'unread'], "($count)") : ""; + $h_count = $count > 0 ? SPAN(["class" => 'unread'], "($count)") : ""; $event->add_nav_link("pm", new Link('user#private-messages'), emptyHTML("Private Messages", $h_count)); } } @@ -198,7 +198,7 @@ public function onUserBlockBuilding(UserBlockBuildingEvent $event) global $user; if ($user->can(Permissions::READ_PM)) { $count = $this->count_pms($user); - $h_count = $count > 0 ? SPAN(["class"=>'unread'], "($count)") : ""; + $h_count = $count > 0 ? SPAN(["class" => 'unread'], "($count)") : ""; $event->add_link(emptyHTML("Private Messages", $h_count), make_link("user", null, "private-messages")); } } diff --git a/ext/pm/theme.php b/ext/pm/theme.php index 283acaced..c1cf4d064 100644 --- a/ext/pm/theme.php +++ b/ext/pm/theme.php @@ -58,7 +58,7 @@ public function display_pms(Page $page, $pms) $page->add_block(new Block("Private Messages", $html, "main", 40, "private-messages")); } - public function display_composer(Page $page, User $from, User $to, $subject="") + public function display_composer(Page $page, User $from, User $to, $subject = "") { global $user; $post_url = make_link("pm/send"); diff --git a/ext/pools/info.php b/ext/pools/info.php index a99ad94d8..a817cc67a 100644 --- a/ext/pools/info.php +++ b/ext/pools/info.php @@ -10,7 +10,7 @@ class PoolsInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Pools System"; - public array $authors = ["Sein Kraft"=>"mail@seinkraft.info", "jgen"=>"jgen.tech@gmail.com", "Daku"=>"admin@codeanimu.net"]; + public array $authors = ["Sein Kraft" => "mail@seinkraft.info", "jgen" => "jgen.tech@gmail.com", "Daku" => "admin@codeanimu.net"]; public string $license = self::LICENSE_GPLV2; public string $description = "Allow users to create groups of images and order them."; public ?string $documentation = diff --git a/ext/pools/main.php b/ext/pools/main.php index 9b107b891..226949564 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -98,18 +98,17 @@ public static function makePool(array $row): Pool { return new Pool($row); } - - public static function get_pool_id_by_title($poolTitle): ?int - { - global $database; + + public static function get_pool_id_by_title($poolTitle): ?int + { + global $database; $row = $database->get_row("SELECT * FROM pools WHERE title=:title", ["title" => $poolTitle]); if ($row != null) { - return $row['id']; - } - else { - return NULL; - } - } + return $row['id']; + } else { + return null; + } + } } function _image_to_id(Image $image): int @@ -204,7 +203,7 @@ public function onPageNavBuilding(PageNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="pool") { + if ($event->parent == "pool") { $event->add_nav_link("pool_list", new Link('pool/list'), "List"); $event->add_nav_link("pool_new", new Link('pool/new'), "Create"); $event->add_nav_link("pool_updated", new Link('pool/updated'), "Changes"); @@ -215,23 +214,21 @@ public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) public function onPageRequest(PageRequestEvent $event) { global $config, $database, $page, $user; - if ($event->page_matches("pool/list")) { //index - if (isset($_GET['search']) and $_GET['search'] != null) { - $page->set_mode(PageMode::REDIRECT); - $page->set_redirect(make_link('pool/list').'/'.$_GET['search'].'/'.strval($event->try_page_num(1))); - return; - } - if (count($event->args) >= 4) { // Assume first 2 args are search and page num - $search = $event->get_arg(0); // Search is based on name comparison instead of tag search - $page_num = $event->try_page_num(1); - } - else { - $search = ""; - $page_num = $event->try_page_num(0); - } - $this->list_pools($page, $page_num, $search); - } - elseif ($event->page_matches("pool")) { + if ($event->page_matches("pool/list")) { //index + if (isset($_GET['search']) and $_GET['search'] != null) { + $page->set_mode(PageMode::REDIRECT); + $page->set_redirect(make_link('pool/list').'/'.$_GET['search'].'/'.strval($event->try_page_num(1))); + return; + } + if (count($event->args) >= 4) { // Assume first 2 args are search and page num + $search = $event->get_arg(0); // Search is based on name comparison instead of tag search + $page_num = $event->try_page_num(1); + } else { + $search = ""; + $page_num = $event->try_page_num(0); + } + $this->list_pools($page, $page_num, $search); + } elseif ($event->page_matches("pool")) { $pool_id = 0; $pool = []; @@ -344,37 +341,35 @@ public function onPageRequest(PageRequestEvent $event) } } break; - case "reverse": - if ($this->have_permission($user, $pool)) { - $result = $database->execute( - "SELECT image_id FROM pool_images WHERE pool_id=:pid ORDER BY image_order DESC", - ["pid" => $pool_id] - ); - $image_order = 1; - try { - $database->begin_transaction(); - while ($row = $result->fetch()) { - $database->execute( - " + case "reverse": + if ($this->have_permission($user, $pool)) { + $result = $database->execute( + "SELECT image_id FROM pool_images WHERE pool_id=:pid ORDER BY image_order DESC", + ["pid" => $pool_id] + ); + $image_order = 1; + try { + $database->begin_transaction(); + while ($row = $result->fetch()) { + $database->execute( + " UPDATE pool_images SET image_order=:ord WHERE pool_id = :pid AND image_id = :iid", - ["ord" => $image_order, "pid" => $pool_id, "iid" => (int)$row['image_id']] - ); - $image_order = $image_order + 1; - } - $database->commit(); - } - catch (Exception $e) { - $database->rollback(); - } - $page->set_mode(PageMode::REDIRECT); - $page->set_redirect(make_link("pool/view/" . $pool_id)); - } - else { - $this->theme->display_error(403, "Permission Denied", "You do not have permission to access this page"); - } - break; + ["ord" => $image_order, "pid" => $pool_id, "iid" => (int)$row['image_id']] + ); + $image_order = $image_order + 1; + } + $database->commit(); + } catch (\Exception $e) { + $database->rollback(); + } + $page->set_mode(PageMode::REDIRECT); + $page->set_redirect(make_link("pool/view/" . $pool_id)); + } else { + $this->theme->display_error(403, "Permission Denied", "You do not have permission to access this page"); + } + break; case "import": if ($this->have_permission($user, $pool)) { $images = Image::find_images( @@ -501,7 +496,7 @@ public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $event->add_block(new Block("Pools", $this->theme->get_help_html())); } } @@ -535,7 +530,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) $poolID = str_replace("_", " ", $matches[1]); $event->add_querylet(new Querylet("images.id IN (SELECT DISTINCT image_id FROM pool_images WHERE pool_id = $poolID)")); } - + } public function onTagTermCheck(TagTermCheckEvent $event) @@ -647,11 +642,11 @@ private function list_pools(Page $page, int $pageNumber, $search) $order_by = "ORDER BY p.posts DESC"; } - $where_clause = "WHERE LOWER(title) like '%%'"; - if ($search != null) { - $where_clause = "WHERE LOWER(title) like '%".strtolower($search)."%'"; - } - + $where_clause = "WHERE LOWER(title) like '%%'"; + if ($search != null) { + $where_clause = "WHERE LOWER(title) like '%".strtolower($search)."%'"; + } + $pools = array_map([Pool::class, "makePool"], $database->get_all(" SELECT p.*, u.name as user_name FROM pools AS p diff --git a/ext/pools/theme.php b/ext/pools/theme.php index 43b168aff..a007846c8 100644 --- a/ext/pools/theme.php +++ b/ext/pools/theme.php @@ -47,7 +47,7 @@ public function get_adder_html(Image $image, array $pools): HTMLElement return SHM_SIMPLE_FORM( "pool/add_post", SHM_SELECT("pool_id", $pools), - INPUT(["type"=>"hidden", "name"=>"image_id", "value"=>$image->id]), + INPUT(["type" => "hidden", "name" => "image_id", "value" => $image->id]), SHM_SUBMIT("Add Post to Pool") ); } @@ -64,7 +64,7 @@ public function list_pools(Page $page, array $pools, string $search, int $pageNu $user_link = SHM_A("user/" . url_escape($pool->user_name), $pool->user_name); $pool_rows[] = TR( - TD(["class"=>"left"], $pool_link), + TD(["class" => "left"], $pool_link), TD($user_link), TD($pool->posts), TD($pool->public ? "Yes" : "No") @@ -72,23 +72,23 @@ public function list_pools(Page $page, array $pools, string $search, int $pageNu } $table = TABLE( - ["id"=>"poolsList", "class"=>"zebra"], + ["id" => "poolsList", "class" => "zebra"], THEAD(TR(TH("Name"), TH("Creator"), TH("Posts"), TH("Public"))), TBODY(...$pool_rows) ); $order_arr = ['created' => 'Recently created', 'updated' => 'Last updated', 'name' => 'Name', 'count' => 'Post Count']; $order_selected = $page->get_cookie('ui-order-pool'); - $order_sel = SHM_SELECT("order_pool", $order_arr, selected_options: [$order_selected], attrs: ["id"=>"order_pool"]); + $order_sel = SHM_SELECT("order_pool", $order_arr, selected_options: [$order_selected], attrs: ["id" => "order_pool"]); $this->display_top(null, "Pools"); $page->add_block(new Block("Order By", $order_sel, "left", 15)); $page->add_block(new Block("Pools", $table, position: 10)); - if ($search != "" and !str_starts_with($search, '/')) { - $search = '/'.$search; - } + if ($search != "" and !str_starts_with($search, '/')) { + $search = '/'.$search; + } $this->display_paginator($page, "pool/list".$search, null, $pageNumber, $totalPages); } @@ -98,10 +98,10 @@ public function list_pools(Page $page, array $pools, string $search, int $pageNu public function new_pool_composer(Page $page) { $form = SHM_SIMPLE_FORM("pool/create", TABLE( - TR(TD("Title:"), TD(INPUT(["type"=>"text", "name"=>"title"]))), - TR(TD("Public?:"), TD(INPUT(["type"=>"checkbox", "name"=>"public", "value"=>"Y", "checked"=>"checked"]))), - TR(TD("Description:"), TD(TEXTAREA(["name"=>"description"]))), - TR(TD(["colspan"=>"2"], SHM_SUBMIT("Create"))) + TR(TD("Title:"), TD(INPUT(["type" => "text", "name" => "title"]))), + TR(TD("Public?:"), TD(INPUT(["type" => "checkbox", "name" => "public", "value" => "Y", "checked" => "checked"]))), + TR(TD("Description:"), TD(TEXTAREA(["name" => "description"]))), + TR(TD(["colspan" => "2"], SHM_SUBMIT("Create"))) )); $this->display_top(null, "Create Pool"); @@ -122,8 +122,8 @@ private function display_top(?Pool $pool, string $heading, bool $check_all = fal BR(), SHM_A("pool/updated", "Pool Changes") ); - - $search = " + + $search = " @@ -131,7 +131,7 @@ private function display_top(?Pool $pool, string $heading, bool $check_all = fal $page->add_block(new NavBlock()); $page->add_block(new Block("Pool Navigation", $poolnav, "left", 10)); - $page->add_block(new Block("Search", $search, "left", 10)); + $page->add_block(new Block("Search", $search, "left", 10)); if (!is_null($pool)) { if ($pool->public || $user->can(Permissions::POOLS_ADMIN)) {// IF THE POOL IS PUBLIC OR IS ADMIN SHOW EDIT PANEL @@ -171,8 +171,8 @@ public function sidebar_options(Page $page, Pool $pool, bool $check_all) global $user; // This could become a SHM_INPUT function that also accepts 'type' and other attributes. - $_hidden=function (string $name, $value) { - return INPUT(["type"=>"hidden", "name"=>$name, "value"=>$value]); + $_hidden = function (string $name, $value) { + return INPUT(["type" => "hidden", "name" => $name, "value" => $value]); }; $_input_id = $_hidden("pool_id", $pool->id); @@ -180,38 +180,38 @@ public function sidebar_options(Page $page, Pool $pool, bool $check_all) $editor = emptyHTML( SHM_SIMPLE_FORM( "pool/import", - INPUT(["type"=>"text", "name"=>"pool_tag", "id"=>"edit_pool_tag", "placeholder"=>"Please enter a tag"]), + INPUT(["type" => "text", "name" => "pool_tag", "id" => "edit_pool_tag", "placeholder" => "Please enter a tag"]), $_input_id, - SHM_SUBMIT("Import", ["name"=>"edit", "id"=>"edit_pool_import_btn"]) + SHM_SUBMIT("Import", ["name" => "edit", "id" => "edit_pool_import_btn"]) ), SHM_SIMPLE_FORM( "pool/edit", $_hidden("edit_pool", "yes"), $_input_id, - SHM_SUBMIT("Edit Pool", ["name"=>"edit", "id"=>"edit_pool_btn"]), + SHM_SUBMIT("Edit Pool", ["name" => "edit", "id" => "edit_pool_btn"]), ), SHM_SIMPLE_FORM( "pool/order", $_hidden("order_view", "yes"), $_input_id, - SHM_SUBMIT("Order Pool", ["name"=>"edit", "id"=>"edit_pool_order_btn"]) + SHM_SUBMIT("Order Pool", ["name" => "edit", "id" => "edit_pool_order_btn"]) ), SHM_SIMPLE_FORM( "pool/reverse", $_hidden("reverse_view", "yes"), $_input_id, - SHM_SUBMIT("Reverse Order", ["name"=>"edit", "id"=>"reverse_pool_order_btn"]) + SHM_SUBMIT("Reverse Order", ["name" => "edit", "id" => "reverse_pool_order_btn"]) ), SHM_SIMPLE_FORM( "post/list/pool_id=" . $pool->id . "/1", - SHM_SUBMIT("Post/List View", ["name"=>"edit", "id"=>$pool->id]) + SHM_SUBMIT("Post/List View", ["name" => "edit", "id" => $pool->id]) ) ); if ($user->id == $pool->user_id || $user->can(Permissions::POOLS_ADMIN)) { $editor->appendChild( SCRIPT( - ["type"=>"text/javascript"], + ["type" => "text/javascript"], rawHTML("") ), - INPUT(["type"=>"button", "name"=>"CheckAll", "value"=>"Check All", "onclick"=>"setAll(true)"]), - INPUT(["type"=>"button", "name"=>"UnCheckAll", "value"=>"Uncheck All", "onclick"=>"setAll(false)"]) + INPUT(["type" => "button", "name" => "CheckAll", "value" => "Check All", "onclick" => "setAll(true)"]), + INPUT(["type" => "button", "name" => "UnCheckAll", "value" => "Uncheck All", "onclick" => "setAll(false)"]) ); } @@ -253,7 +253,7 @@ public function pool_result(Page $page, array $images, Pool $pool) $import = emptyHTML( SCRIPT( - ["type"=>"text/javascript"], + ["type" => "text/javascript"], rawHTML(" function confirm_action() { return confirm('Are you sure you want to add selected posts to this pool?'); @@ -264,14 +264,14 @@ function confirm_action() { $form = SHM_FORM("pool/add_posts", name: "checks"); foreach ($images as $image) { $form->appendChild( - SPAN(["class"=>"thumb"], $this->build_thumb_html($image), BR(), INPUT(["type"=>"checkbox", "name"=>"check[]", "value"=>$image->id])), + SPAN(["class" => "thumb"], $this->build_thumb_html($image), BR(), INPUT(["type" => "checkbox", "name" => "check[]", "value" => $image->id])), ); } $form->appendChild( BR(), - SHM_SUBMIT("Add Selected", ["name"=>"edit", "id"=>"edit_pool_add_btn", "onclick"=>"return confirm_action()"]), - INPUT(["type"=>"hidden", "name"=>"pool_id", "value"=>$pool->id]) + SHM_SUBMIT("Add Selected", ["name" => "edit", "id" => "edit_pool_add_btn", "onclick" => "return confirm_action()"]), + INPUT(["type" => "hidden", "name" => "pool_id", "value" => $pool->id]) ); $import->appendChild($form); @@ -289,18 +289,18 @@ public function edit_order(Page $page, Pool $pool, array $images) $this->display_top($pool, "Sorting Pool"); $form = SHM_FORM("pool/order", name: "checks"); - foreach ($images as $i=>$image) { + foreach ($images as $i => $image) { $form->appendChild(SPAN( - ["class"=>"thumb"], + ["class" => "thumb"], $this->build_thumb_html($image), - INPUT(["type"=>"number", "name"=>"imgs[$i][]", "value"=>$image->image_order, "style"=>"max-width: 50px;"]), - INPUT(["type"=>"hidden", "name"=>"imgs[$i][]", "value"=>$image->id]) + INPUT(["type" => "number", "name" => "imgs[$i][]", "value" => $image->image_order, "style" => "max-width: 50px;"]), + INPUT(["type" => "hidden", "name" => "imgs[$i][]", "value" => $image->id]) )); } $form->appendChild( - INPUT(["type"=>"hidden", "name"=>"pool_id", "value"=>$pool->id]), - SHM_SUBMIT("Order", ["name"=>"edit", "id"=>"edit_pool_order"]) + INPUT(["type" => "hidden", "name" => "pool_id", "value" => $pool->id]), + SHM_SUBMIT("Order", ["name" => "edit", "id" => "edit_pool_order"]) ); $page->add_block(new Block("Sorting Posts", $form, position: 30)); @@ -314,11 +314,11 @@ public function edit_order(Page $page, Pool $pool, array $images) */ public function edit_pool(Page $page, Pool $pool, array $images) { - $_input_id = INPUT(["type"=>"hidden", "name"=>"pool_id", "value"=>$pool->id]); + $_input_id = INPUT(["type" => "hidden", "name" => "pool_id", "value" => $pool->id]); $desc_form = SHM_SIMPLE_FORM( "pool/edit/description", - TEXTAREA(["name"=>"description"], $pool->description), + TEXTAREA(["name" => "description"], $pool->description), BR(), $_input_id, SHM_SUBMIT("Change Description") @@ -327,16 +327,16 @@ public function edit_pool(Page $page, Pool $pool, array $images) $images_form = SHM_FORM("pool/remove_posts", name: "checks"); foreach ($images as $image) { $images_form->appendChild(SPAN( - ["class"=>"thumb"], + ["class" => "thumb"], $this->build_thumb_html($image), - INPUT(["type"=>"checkbox", "name"=>"check[]", "value"=>$image->id]) + INPUT(["type" => "checkbox", "name" => "check[]", "value" => $image->id]) )); } $images_form->appendChild( BR(), $_input_id, - SHM_SUBMIT("Remove Selected", ["name"=>"edit", "id"=>"edit_pool_remove_sel"]) + SHM_SUBMIT("Remove Selected", ["name" => "edit", "id" => "edit_pool_remove_sel"]) ); $pool->description = ""; //This is a rough fix to avoid showing the description twice. @@ -353,7 +353,7 @@ public function show_history(array $histories, int $pageNumber, int $totalPages) global $page; $table = TABLE( - ["id"=>"poolsList", "class"=>"zebra"], + ["id" => "poolsList", "class" => "zebra"], THEAD(TR(TH("Pool"), TH("Post Count"), TH("Changes"), TH("Updater"), TH("Date"), TH("Action"))) ); @@ -380,7 +380,7 @@ public function show_history(array $histories, int $pageNumber, int $totalPages) } $body[] = TR( - TD(["class"=>"left"], $pool_link), + TD(["class" => "left"], $pool_link), TD($history["count"]), TD($image_links), TD($user_link), @@ -406,11 +406,11 @@ public function get_bulk_pool_input(array $search_terms): HTMLElement { return INPUT( [ - "type"=>"text", - "name"=>"bulk_pool_new", - "placeholder"=>"New Pool", - "required"=>"", - "value"=>implode(" ", $search_terms) + "type" => "text", + "name" => "bulk_pool_new", + "placeholder" => "New Pool", + "required" => "", + "value" => implode(" ", $search_terms) ] ); } diff --git a/ext/post_titles/info.php b/ext/post_titles/info.php index 1c1c87b06..a217ff87d 100644 --- a/ext/post_titles/info.php +++ b/ext/post_titles/info.php @@ -10,7 +10,7 @@ class PostTitlesInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Post Titles"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Add titles to media posts"; } diff --git a/ext/post_titles/main.php b/ext/post_titles/main.php index ff3ef241a..d4ff1698d 100644 --- a/ext/post_titles/main.php +++ b/ext/post_titles/main.php @@ -81,7 +81,7 @@ public function onBulkExport(BulkExportEvent $event) } public function onBulkImport(BulkImportEvent $event) { - if (array_key_exists("title", $event->fields) && $event->fields['title']!=null) { + if (array_key_exists("title", $event->fields) && $event->fields['title'] != null) { $this->set_title($event->image->id, $event->fields['title']); } } @@ -89,7 +89,7 @@ public function onBulkImport(BulkImportEvent $event) private function set_title(int $image_id, string $title) { global $database; - $database->execute("UPDATE images SET title=:title WHERE id=:id", ['title'=>$title, 'id'=>$image_id]); + $database->execute("UPDATE images SET title=:title WHERE id=:id", ['title' => $title, 'id' => $image_id]); log_info("post_titles", "Title for >>{$image_id} set to: ".$title); } @@ -97,7 +97,7 @@ public static function get_title(Image $image): string { global $config; - $title = $image->title??""; + $title = $image->title ?? ""; if (empty($title) && $config->get_bool(PostTitlesConfig::DEFAULT_TO_FILENAME)) { $info = pathinfo($image->filename); if (array_key_exists("extension", $info)) { diff --git a/ext/private_image/info.php b/ext/private_image/info.php index 2196f19e5..3c34e4463 100644 --- a/ext/private_image/info.php +++ b/ext/private_image/info.php @@ -10,7 +10,7 @@ class PrivateImageInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Private Post"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Allows users to mark images as private, which prevents other users from seeing them."; } diff --git a/ext/private_image/main.php b/ext/private_image/main.php index 7c9ada832..ae154dddd 100644 --- a/ext/private_image/main.php +++ b/ext/private_image/main.php @@ -53,10 +53,10 @@ public function onPageRequest(PageRequestEvent $event) throw new SCoreException("Can not make image private: No valid Post ID given."); } $image = Image::by_id($image_id); - if ($image==null) { + if ($image == null) { throw new SCoreException("Post not found."); } - if ($image->owner_id!=$user->can(Permissions::SET_OTHERS_PRIVATE_IMAGES)) { + if ($image->owner_id != $user->can(Permissions::SET_OTHERS_PRIVATE_IMAGES)) { throw new SCoreException("Cannot set another user's image to private."); } @@ -75,10 +75,10 @@ public function onPageRequest(PageRequestEvent $event) throw new SCoreException("Can not make image public: No valid Post ID given."); } $image = Image::by_id($image_id); - if ($image==null) { + if ($image == null) { throw new SCoreException("Post not found."); } - if ($image->owner_id!=$user->can(Permissions::SET_OTHERS_PRIVATE_IMAGES)) { + if ($image->owner_id != $user->can(Permissions::SET_OTHERS_PRIVATE_IMAGES)) { throw new SCoreException("Cannot set another user's image to public."); } @@ -117,7 +117,7 @@ public function onDisplayingImage(DisplayingImageEvent $event) { global $user, $page; - if ($event->image->private===true && $event->image->owner_id!=$user->id && !$user->can(Permissions::SET_OTHERS_PRIVATE_IMAGES)) { + if ($event->image->private === true && $event->image->owner_id != $user->id && !$user->can(Permissions::SET_OTHERS_PRIVATE_IMAGES)) { $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link()); } @@ -137,12 +137,12 @@ public function onSearchTermParse(SearchTermParseEvent $event) $event->add_querylet( new Querylet( "private != :true OR owner_id = :private_owner_id", - ["private_owner_id"=>$user->id, "true"=>true] + ["private_owner_id" => $user->id, "true" => true] ) ); } else { $event->add_querylet( - new Querylet("private != :true", ["true"=>true]) + new Querylet("private != :true", ["true" => true]) ); } } @@ -182,7 +182,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $block = new Block(); $block->header = "Private Posts"; $block->body = $this->theme->get_help_html(); @@ -207,7 +207,7 @@ public static function privatize_image($image_id) $database->execute( "UPDATE images SET private = :true WHERE id = :id AND private = :false", - ["id"=>$image_id, "true"=>true, "false"=>false] + ["id" => $image_id, "true" => true, "false" => false] ); } @@ -217,14 +217,14 @@ public static function publicize_image($image_id) $database->execute( "UPDATE images SET private = :false WHERE id = :id AND private = :true", - ["id"=>$image_id, "true"=>true, "false"=>false] + ["id" => $image_id, "true" => true, "false" => false] ); } public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { global $user; - if (($user->can(Permissions::SET_PRIVATE_IMAGE) && $user->id==$event->image->owner_id) || $user->can(Permissions::SET_OTHERS_PRIVATE_IMAGES)) { + if (($user->can(Permissions::SET_PRIVATE_IMAGE) && $user->id == $event->image->owner_id) || $user->can(Permissions::SET_OTHERS_PRIVATE_IMAGES)) { $event->add_part($this->theme->get_image_admin_html($event->image)); } } @@ -256,7 +256,7 @@ public function onBulkAction(BulkActionEvent $event) if ($user->can(Permissions::SET_PRIVATE_IMAGE)) { $total = 0; foreach ($event->items as $image) { - if ($image->owner_id==$user->id || + if ($image->owner_id == $user->id || $user->can(Permissions::SET_OTHERS_PRIVATE_IMAGES)) { self::privatize_image($image->id); $total++; @@ -268,7 +268,7 @@ public function onBulkAction(BulkActionEvent $event) case "bulk_publicize_image": $total = 0; foreach ($event->items as $image) { - if ($image->owner_id==$user->id || + if ($image->owner_id == $user->id || $user->can(Permissions::SET_OTHERS_PRIVATE_IMAGES)) { self::publicize_image($image->id); $total++; diff --git a/ext/private_image/theme.php b/ext/private_image/theme.php index a06a22397..65c12248f 100644 --- a/ext/private_image/theme.php +++ b/ext/private_image/theme.php @@ -10,16 +10,16 @@ class PrivateImageTheme extends Themelet { public function get_image_admin_html(Image $image): string { - if ($image->private===false) { + if ($image->private === false) { $html = SHM_SIMPLE_FORM( 'privatize_image/'.$image->id, - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image->id]), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image->id]), SHM_SUBMIT("Make Private") ); } else { $html = SHM_SIMPLE_FORM( 'publicize_image/'.$image->id, - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image->id]), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image->id]), SHM_SUBMIT("Make Public") ); } diff --git a/ext/qr_code/info.php b/ext/qr_code/info.php index c43b3fdee..dac6bf0d3 100644 --- a/ext/qr_code/info.php +++ b/ext/qr_code/info.php @@ -11,7 +11,7 @@ class QRImageInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "QR Codes"; public string $url = "http://seemslegit.com"; - public array $authors = ["Zach Hall"=>"zach@sosguy.net"]; + public array $authors = ["Zach Hall" => "zach@sosguy.net"]; public string $license = self::LICENSE_GPLV2; public string $description = "Shows a QR Code for downloading a post to cell phones"; public ?string $documentation = diff --git a/ext/random_image/main.php b/ext/random_image/main.php index 2733708c1..05c89294d 100644 --- a/ext/random_image/main.php +++ b/ext/random_image/main.php @@ -62,7 +62,7 @@ public function onPostListBuilding(PostListBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="posts") { + if ($event->parent == "posts") { $event->add_nav_link("posts_random", new Link('random_image/view'), "Random Post"); } } diff --git a/ext/random_image/theme.php b/ext/random_image/theme.php index 144e0717a..6150609ba 100644 --- a/ext/random_image/theme.php +++ b/ext/random_image/theme.php @@ -20,16 +20,16 @@ public function build_random_html(Image $image, ?string $query = null): string $tsize = get_thumbnail_size($image->width, $image->height); return (string)DIV( - ["style"=>"text-align: center;"], + ["style" => "text-align: center;"], A( - ["href"=>make_link("post/view/{$image->id}", $query)], + ["href" => make_link("post/view/{$image->id}", $query)], IMG([ - "id"=>"thumb_rand_{$image->id}", - "title"=>$image->get_tooltip(), - "alt"=>$image->get_tooltip(), - "class"=>'highlighted', - "style"=>"max-height: {$tsize[1]}px; max-width: 100%;", - "src"=>$image->get_thumb_link() + "id" => "thumb_rand_{$image->id}", + "title" => $image->get_tooltip(), + "alt" => $image->get_tooltip(), + "class" => 'highlighted', + "style" => "max-height: {$tsize[1]}px; max-width: 100%;", + "src" => $image->get_thumb_link() ]) ) ); diff --git a/ext/random_list/info.php b/ext/random_list/info.php index 38ec94df3..8a52e22bc 100644 --- a/ext/random_list/info.php +++ b/ext/random_list/info.php @@ -11,7 +11,7 @@ class RandomListInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Random List"; public string $url = "http://www.drudexsoftware.com"; - public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; + public array $authors = ["Drudex Software" => "support@drudexsoftware.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "Allows displaying a page with random posts"; public ?string $documentation = diff --git a/ext/random_list/main.php b/ext/random_list/main.php index 18b077d1c..a8c07ba31 100644 --- a/ext/random_list/main.php +++ b/ext/random_list/main.php @@ -72,7 +72,7 @@ public function onSetupBuilding(SetupBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="posts") { + if ($event->parent == "posts") { $event->add_nav_link("posts_random", new Link('random'), "Shuffle"); } } diff --git a/ext/rating/main.php b/ext/rating/main.php index ac70adb5d..b2db0f5f4 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -19,7 +19,7 @@ class ImageRating public function __construct(string $code, string $name, string $search_term, int $order) { - assert(strlen($code)==1, "Rating code must be exactly one character"); + assert(strlen($code) == 1, "Rating code must be exactly one character"); $this->name = $name; $this->code = $code; @@ -230,7 +230,7 @@ public function onParseLinkTemplate(ParseLinkTemplateEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $ratings = self::get_sorted_ratings(); $event->add_block(new Block("Ratings", $this->theme->get_help_html($ratings))); } @@ -253,7 +253,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) if (preg_match($this->search_regexp, strtolower($event->term), $matches)) { $ratings = $matches[1] ? $matches[1] : $matches[2][0]; - if (count($matches)>2&&in_array($matches[2], self::UNRATED_KEYWORDS)) { + if (count($matches) > 2 && in_array($matches[2], self::UNRATED_KEYWORDS)) { $ratings = "?"; } @@ -283,7 +283,7 @@ public function onTagTermParse(TagTermParseEvent $event) if (preg_match($this->search_regexp, strtolower($event->term), $matches)) { $ratings = $matches[1] ? $matches[1] : $matches[2][0]; - if (count($matches)>2&&in_array($matches[2], self::UNRATED_KEYWORDS)) { + if (count($matches) > 2 && in_array($matches[2], self::UNRATED_KEYWORDS)) { $ratings = "?"; } @@ -328,7 +328,7 @@ public function onAdminAction(AdminActionEvent $event) $new = $_POST["rating_new"]; if ($user->can(Permissions::BULK_EDIT_IMAGE_RATING)) { - $database->execute("UPDATE images SET rating = :new WHERE rating = :old", ["new"=>$new, "old"=>$old ]); + $database->execute("UPDATE images SET rating = :new WHERE rating = :old", ["new" => $new, "old" => $old ]); } break; @@ -410,7 +410,7 @@ public static function get_sorted_ratings(): array return $ratings; } - public static function get_ratings_dict(array $ratings=null): array + public static function get_ratings_dict(array $ratings = null): array { if (!isset($ratings)) { $ratings = self::get_sorted_ratings(); @@ -448,7 +448,7 @@ public static function privs_to_sql(array $privs): string foreach ($privs as $i) { $arr[] = "'" . $i . "'"; } - if (sizeof($arr)==0) { + if (sizeof($arr) == 0) { return "' '"; } return join(', ', $arr); @@ -538,7 +538,7 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) $database->set_timeout(null); // These updates can take a little bit - $database->execute("UPDATE images SET rating = :new WHERE rating = :old", ["new"=>'?', "old"=>'u' ]); + $database->execute("UPDATE images SET rating = :new WHERE rating = :old", ["new" => '?', "old" => 'u' ]); $this->set_version(RatingsConfig::VERSION, 4); } @@ -548,7 +548,7 @@ private function set_rating(int $image_id, string $rating, string $old_rating) { global $database; if ($old_rating != $rating) { - $database->execute("UPDATE images SET rating=:rating WHERE id=:id", ['rating'=>$rating, 'id'=>$image_id]); + $database->execute("UPDATE images SET rating=:rating WHERE id=:id", ['rating' => $rating, 'id' => $image_id]); log_info("rating", "Rating for >>{$image_id} set to: ".$this->rating_to_human($rating)); } } diff --git a/ext/rating/theme.php b/ext/rating/theme.php index 13408bcb1..654e9482b 100644 --- a/ext/rating/theme.php +++ b/ext/rating/theme.php @@ -21,7 +21,7 @@ public function get_rater_html(int $image_id, string $rating, bool $can_rate): H return SHM_POST_INFO( "Rating", $can_rate, - A(["href"=>search_link(["rating=$rating"])], Ratings::rating_to_human($rating)), + A(["href" => search_link(["rating=$rating"])], Ratings::rating_to_human($rating)), $this->get_selection_rater_html("rating", selected_options: [$rating]) ); } @@ -31,10 +31,10 @@ public function display_form(array $current_ratings) global $page; $table = TABLE( - ["class"=>"form"], + ["class" => "form"], TR(TH("Change"), TD($this->get_selection_rater_html("rating_old", $current_ratings))), TR(TH("To"), TD($this->get_selection_rater_html("rating_new"))), - TR(TD(["colspan"=>"2"], SHM_SUBMIT("Update"))) + TR(TD(["colspan" => "2"], SHM_SUBMIT("Update"))) ); $page->add_block(new Block("Update Ratings", SHM_SIMPLE_FORM("admin/update_ratings", $table))); diff --git a/ext/regen_thumb/main.php b/ext/regen_thumb/main.php index 1e40d6f0f..227d23cdb 100644 --- a/ext/regen_thumb/main.php +++ b/ext/regen_thumb/main.php @@ -75,8 +75,8 @@ public function onBulkAction(BulkActionEvent $event) if ($user->can(Permissions::DELETE_IMAGE)) { $force = true; if (isset($_POST["bulk_regen_thumb_missing_only"]) - &&$_POST["bulk_regen_thumb_missing_only"]=="true") { - $force=false; + && $_POST["bulk_regen_thumb_missing_only"] == "true") { + $force = false; } $total = 0; @@ -103,12 +103,12 @@ public function onAdminAction(AdminActionEvent $event) case "regen_thumbs": $event->redirect = true; $force = false; - if (isset($_POST["regen_thumb_force"])&&$_POST["regen_thumb_force"]=="true") { - $force=true; + if (isset($_POST["regen_thumb_force"]) && $_POST["regen_thumb_force"] == "true") { + $force = true; } $limit = 1000; - if (isset($_POST["regen_thumb_limit"])&&is_numeric($_POST["regen_thumb_limit"])) { - $limit=intval($_POST["regen_thumb_limit"]); + if (isset($_POST["regen_thumb_limit"]) && is_numeric($_POST["regen_thumb_limit"])) { + $limit = intval($_POST["regen_thumb_limit"]); } $mime = ""; @@ -129,7 +129,7 @@ public function onAdminAction(AdminActionEvent $event) if ($event->generated) { $i++; } - if ($i>=$limit) { + if ($i >= $limit) { break; } } @@ -138,7 +138,7 @@ public function onAdminAction(AdminActionEvent $event) case "delete_thumbs": $event->redirect = true; - if (isset($_POST["delete_thumb_mime"])&&$_POST["delete_thumb_mime"]!="") { + if (isset($_POST["delete_thumb_mime"]) && $_POST["delete_thumb_mime"] != "") { $images = $this->get_images($_POST["delete_thumb_mime"]); $i = 0; diff --git a/ext/regen_thumb/test.php b/ext/regen_thumb/test.php index 44f93fd19..0e84b8186 100644 --- a/ext/regen_thumb/test.php +++ b/ext/regen_thumb/test.php @@ -12,7 +12,7 @@ public function testRegenThumb() $image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot"); $this->get_page("post/view/$image_id"); - $this->post_page("regen_thumb/one", ['image_id'=>$image_id]); + $this->post_page("regen_thumb/one", ['image_id' => $image_id]); $this->assert_title("Thumbnail Regenerated"); # FIXME: test that the thumb's modified time has been updated diff --git a/ext/regen_thumb/theme.php b/ext/regen_thumb/theme.php index cf05e5c36..3b7205620 100644 --- a/ext/regen_thumb/theme.php +++ b/ext/regen_thumb/theme.php @@ -15,7 +15,7 @@ public function get_buttons_html(int $image_id): string { return (string)SHM_SIMPLE_FORM( "regen_thumb/one", - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), SHM_SUBMIT('Regenerate Thumbnail') ); } diff --git a/ext/relationships/info.php b/ext/relationships/info.php index f7a8e3444..387760246 100644 --- a/ext/relationships/info.php +++ b/ext/relationships/info.php @@ -10,7 +10,7 @@ class RelationshipsInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Post Relationships"; - public array $authors = ["Angus Johnston"=>"admin@codeanimu.net"]; + public array $authors = ["Angus Johnston" => "admin@codeanimu.net"]; public string $license = self::LICENSE_GPLV2; public string $description = "Allow posts to have relationships (parent/child)."; } diff --git a/ext/relationships/main.php b/ext/relationships/main.php index e6684cb8c..80f5183b5 100644 --- a/ext/relationships/main.php +++ b/ext/relationships/main.php @@ -85,17 +85,17 @@ public function onSearchTermParse(SearchTermParseEvent $event) $not = ($parentID == "any" ? "NOT" : ""); $event->add_querylet(new Querylet("images.parent_id IS $not NULL")); } else { - $event->add_querylet(new Querylet("images.parent_id = :pid", ["pid"=>$parentID])); + $event->add_querylet(new Querylet("images.parent_id = :pid", ["pid" => $parentID])); } } elseif (preg_match("/^child[=|:](any|none)$/", $event->term, $matches)) { $not = ($matches[1] == "any" ? "=" : "!="); - $event->add_querylet(new Querylet("images.has_children $not :true", ["true"=>true])); + $event->add_querylet(new Querylet("images.has_children $not :true", ["true" => true])); } } public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $block = new Block(); $block->header = "Relationships"; $block->body = $this->theme->get_help_html(); @@ -137,7 +137,7 @@ public function onImageDeletion(ImageDeletionEvent $event) global $database; if (bool_escape($event->image->has_children)) { - $database->execute("UPDATE images SET parent_id = NULL WHERE parent_id = :iid", ["iid"=>$event->image->id]); + $database->execute("UPDATE images SET parent_id = NULL WHERE parent_id = :iid", ["iid" => $event->image->id]); } if ($event->image->parent_id !== null) { @@ -149,7 +149,7 @@ public function onImageRelationshipSet(ImageRelationshipSetEvent $event) { global $database; - $old_parent = $database->get_one("SELECT parent_id FROM images WHERE id = :cid", ["cid"=>$event->child_id]); + $old_parent = $database->get_one("SELECT parent_id FROM images WHERE id = :cid", ["cid" => $event->child_id]); if (!is_null($old_parent)) { $old_parent = (int)$old_parent; } @@ -162,9 +162,9 @@ public function onImageRelationshipSet(ImageRelationshipSetEvent $event) } $database->execute("UPDATE images SET parent_id = :pid WHERE id = :cid", ["pid" => $event->parent_id, "cid" => $event->child_id]); - $database->execute("UPDATE images SET has_children = :true WHERE id = :pid", ["pid" => $event->parent_id, "true"=>true]); + $database->execute("UPDATE images SET has_children = :true WHERE id = :pid", ["pid" => $event->parent_id, "true" => true]); - if ($old_parent!=null) { + if ($old_parent != null) { $this->set_has_children($old_parent); } } @@ -172,10 +172,10 @@ public function onImageRelationshipSet(ImageRelationshipSetEvent $event) public static function get_children(Image $image, int $omit = null): array { global $database; - $results = $database->get_all_iterable("SELECT * FROM images WHERE parent_id = :pid ", ["pid"=>$image->id]); + $results = $database->get_all_iterable("SELECT * FROM images WHERE parent_id = :pid ", ["pid" => $image->id]); $output = []; foreach ($results as $result) { - if ($result["id"]==$omit) { + if ($result["id"] == $omit) { continue; } $output[] = new Image($result); @@ -186,10 +186,10 @@ public static function get_children(Image $image, int $omit = null): array private function remove_parent(int $imageID) { global $database; - $parentID = $database->get_one("SELECT parent_id FROM images WHERE id = :iid", ["iid"=>$imageID]); + $parentID = $database->get_one("SELECT parent_id FROM images WHERE id = :iid", ["iid" => $imageID]); if ($parentID) { - $database->execute("UPDATE images SET parent_id = NULL WHERE id = :iid", ["iid"=>$imageID]); + $database->execute("UPDATE images SET parent_id = NULL WHERE id = :iid", ["iid" => $imageID]); $this->set_has_children((int)$parentID); } } @@ -207,11 +207,11 @@ private function set_has_children(int $parent_id) $children = $database->get_one( "SELECT COUNT(*) FROM images WHERE parent_id=:pid", - ["pid"=>$parent_id] + ["pid" => $parent_id] ); $database->execute( "UPDATE images SET has_children = :has_children WHERE id = :pid", - ["has_children"=>$children>0, "pid"=>$parent_id] + ["has_children" => $children > 0, "pid" => $parent_id] ); } } diff --git a/ext/relationships/test.php b/ext/relationships/test.php index 88c54315e..6e24e0621 100644 --- a/ext/relationships/test.php +++ b/ext/relationships/test.php @@ -104,7 +104,7 @@ public function testRemoveParent($imgs) global $database; $database->execute( "UPDATE images SET parent_id=NULL, has_children=:false", - ["false"=>false] + ["false" => false] ); // FIXME: send_event(new ImageRelationshipSetEvent($image_2->id, null)); diff --git a/ext/relationships/theme.php b/ext/relationships/theme.php index c3cacf455..0a8af4a56 100644 --- a/ext/relationships/theme.php +++ b/ext/relationships/theme.php @@ -20,7 +20,7 @@ public function relationship_info(Image $image) } if (bool_escape($image->has_children)) { - $ids = $database->get_col("SELECT id FROM images WHERE parent_id = :iid", ["iid"=>$image->id]); + $ids = $database->get_col("SELECT id FROM images WHERE parent_id = :iid", ["iid" => $image->id]); $html = "This post has ".(count($ids) > 1 ? "child posts" : "a child post").""; $html .= " (post "; @@ -41,7 +41,7 @@ public function get_parent_editor_html(Image $image): HTMLElement "Parent", !$user->is_anonymous(), strval($image->parent_id) ?: "None", - INPUT(["type"=>"number", "name"=>"tag_edit__parent", "value"=>$image->parent_id]) + INPUT(["type" => "number", "name" => "tag_edit__parent", "value" => $image->parent_id]) ); } diff --git a/ext/report_image/info.php b/ext/report_image/info.php index 3a60a0f66..1cf3439d7 100644 --- a/ext/report_image/info.php +++ b/ext/report_image/info.php @@ -11,7 +11,7 @@ class ReportImageInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Report Posts"; public string $url = "http://atravelinggeek.com/"; - public array $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"]; + public array $authors = ["ATravelingGeek" => "atg@atravelinggeek.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "Report posts as dupes/illegal/etc"; public ?string $version = "0.3a"; diff --git a/ext/report_image/main.php b/ext/report_image/main.php index 01f83c3e4..2cc5b4be4 100644 --- a/ext/report_image/main.php +++ b/ext/report_image/main.php @@ -89,7 +89,7 @@ public function onAddReportedImage(AddReportedImageEvent $event) $database->execute( "INSERT INTO image_reports(image_id, reporter_id, reason) VALUES (:image_id, :reporter_id, :reason)", - ['image_id'=>$event->report->image_id, 'reporter_id'=>$event->report->user_id, 'reason'=>$event->report->reason] + ['image_id' => $event->report->image_id, 'reporter_id' => $event->report->user_id, 'reason' => $event->report->reason] ); $cache->delete("image-report-count"); } @@ -97,7 +97,7 @@ public function onAddReportedImage(AddReportedImageEvent $event) public function onRemoveReportedImage(RemoveReportedImageEvent $event) { global $cache, $database; - $database->execute("DELETE FROM image_reports WHERE id = :id", ["id"=>$event->id]); + $database->execute("DELETE FROM image_reports WHERE id = :id", ["id" => $event->id]); $cache->delete("image-report-count"); } @@ -122,7 +122,7 @@ public function onDisplayingImage(DisplayingImageEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::VIEW_IMAGE_REPORT)) { $count = $this->count_reported_images(); $h_count = $count > 0 ? " ($count)" : ""; @@ -145,7 +145,7 @@ public function onUserBlockBuilding(UserBlockBuildingEvent $event) public function onImageDeletion(ImageDeletionEvent $event) { global $cache, $database; - $database->execute("DELETE FROM image_reports WHERE image_id = :image_id", ["image_id"=>$event->image->id]); + $database->execute("DELETE FROM image_reports WHERE image_id = :image_id", ["image_id" => $event->image->id]); $cache->delete("image-report-count"); } @@ -170,7 +170,7 @@ public function onSetupBuilding(SetupBuildingEvent $event) public function delete_reports_by(int $user_id) { global $cache, $database; - $database->execute("DELETE FROM image_reports WHERE reporter_id=:reporter_id", ['reporter_id'=>$user_id]); + $database->execute("DELETE FROM image_reports WHERE reporter_id=:reporter_id", ['reporter_id' => $user_id]); $cache->delete("image-report-count"); } diff --git a/ext/report_image/theme.php b/ext/report_image/theme.php index 82dd33c24..55a16b999 100644 --- a/ext/report_image/theme.php +++ b/ext/report_image/theme.php @@ -96,7 +96,7 @@ public function get_nuller(User $duser) global $page; $html = (string)SHM_SIMPLE_FORM( "image_report/remove_reports_by", - INPUT(["type"=>'hidden', "name"=>'user_id', "value"=>$duser->id]), + INPUT(["type" => 'hidden', "name" => 'user_id', "value" => $duser->id]), SHM_SUBMIT('Delete all reports by this user') ); $page->add_block(new Block("Reports", $html, "main", 80)); diff --git a/ext/resize/info.php b/ext/resize/info.php index b7703588b..5b2bdfd97 100644 --- a/ext/resize/info.php +++ b/ext/resize/info.php @@ -16,7 +16,7 @@ class ResizeImageInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Resize Post"; - public array $authors = ["jgen"=>"jgen.tech@gmail.com"]; + public array $authors = ["jgen" => "jgen.tech@gmail.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "This extension allows admins to resize images."; public ?string $version = "0.1"; diff --git a/ext/resize/main.php b/ext/resize/main.php index 543c24372..373edba4f 100644 --- a/ext/resize/main.php +++ b/ext/resize/main.php @@ -186,7 +186,7 @@ public function onImageDownloading(ImageDownloadingEvent $event) [$new_width, $new_height] = get_scaled_by_aspect_ratio($event->image->width, $event->image->height, $max_width, $max_height); - if ($new_width!==$event->image->width || $new_height !==$event->image->height) { + if ($new_width !== $event->image->width || $new_height !== $event->image->height) { $tmp_filename = tempnam(sys_get_temp_dir(), 'shimmie_resize'); if (empty($tmp_filename)) { throw new ImageResizeException("Unable to save temporary image file."); @@ -201,7 +201,7 @@ public function onImageDownloading(ImageDownloadingEvent $event) $new_height )); - if ($event->file_modified===true&&$event->path!=$event->image->get_image_filename()) { + if ($event->file_modified === true && $event->path != $event->image->get_image_filename()) { // This means that we're dealing with a temp file that will need cleaned up unlink($event->path); } diff --git a/ext/rotate/info.php b/ext/rotate/info.php index 51c530d49..66ae62815 100644 --- a/ext/rotate/info.php +++ b/ext/rotate/info.php @@ -16,7 +16,7 @@ class RotateImageInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Rotate Image"; - public array $authors = ["jgen"=>"jgen.tech@gmail.com","Agasa"=>"hiroshiagasa@gmail.com"]; + public array $authors = ["jgen" => "jgen.tech@gmail.com","Agasa" => "hiroshiagasa@gmail.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "Allows admins to rotate images."; } diff --git a/ext/rotate/main.php b/ext/rotate/main.php index f8dcfa459..ff9dbe5d6 100644 --- a/ext/rotate/main.php +++ b/ext/rotate/main.php @@ -109,7 +109,7 @@ private function rotate_image(int $image_id, int $deg) } $image_filename = warehouse_path(Image::IMAGE_DIR, $hash); - if (file_exists($image_filename)===false) { + if (file_exists($image_filename) === false) { throw new ImageRotateException("$image_filename does not exist."); } @@ -136,12 +136,12 @@ private function rotate_image(int $image_id, int $deg) $background_color = imagecolorallocatealpha($image, 0, 0, 0, 127); break; } - if ($background_color===false) { + if ($background_color === false) { throw new ImageRotateException("Unable to allocate transparent color"); } $image_rotated = imagerotate($image, $deg, $background_color); - if ($image_rotated===false) { + if ($image_rotated === false) { throw new ImageRotateException("Image rotate failed"); } @@ -172,7 +172,7 @@ private function rotate_image(int $image_id, int $deg) throw new ImageRotateException("Unsupported image type."); } - if ($result===false) { + if ($result === false) { throw new ImageRotateException("Could not save image: ".$tmp_filename); } diff --git a/ext/rotate/theme.php b/ext/rotate/theme.php index a8a08a26b..a0d6f7e9f 100644 --- a/ext/rotate/theme.php +++ b/ext/rotate/theme.php @@ -15,9 +15,9 @@ public function get_rotate_html(int $image_id): string { return (string)SHM_SIMPLE_FORM( 'rotate/'.$image_id, - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]), - INPUT(["type"=>'number', "name"=>'rotate_deg', "id"=>"rotate_deg", "placeholder"=>"Rotation degrees"]), - INPUT(["type"=>'submit', "value"=>'Rotate', "id"=>"rotatebutton"]), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), + INPUT(["type" => 'number', "name" => 'rotate_deg', "id" => "rotate_deg", "placeholder" => "Rotation degrees"]), + INPUT(["type" => 'submit', "value" => 'Rotate', "id" => "rotatebutton"]), ); } diff --git a/ext/rss_comments/main.php b/ext/rss_comments/main.php index 5afadf6b1..64e7b9605 100644 --- a/ext/rss_comments/main.php +++ b/ext/rss_comments/main.php @@ -77,7 +77,7 @@ public function onPageRequest(PageRequestEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="comment") { + if ($event->parent == "comment") { $event->add_nav_link("comment_rss", new Link('rss/comments'), "Feed"); } } diff --git a/ext/rss_images/main.php b/ext/rss_images/main.php index 5cccc51ce..f1e015835 100644 --- a/ext/rss_images/main.php +++ b/ext/rss_images/main.php @@ -31,7 +31,7 @@ public function onPageRequest(PageRequestEvent $event) return; } try { - $images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms); + $images = Image::find_images(($page_number - 1) * $page_size, $page_size, $search_terms); $this->do_rss($images, $search_terms, $page_number); } catch (SearchTermParseException $stpe) { $this->theme->display_error(400, "Search parse error", $stpe->error); @@ -67,12 +67,12 @@ private function do_rss(array $images, array $search_terms, int $page_number) } if ($page_number > 1) { - $prev_url = make_link("rss/images/$search".($page_number-1)); + $prev_url = make_link("rss/images/$search".($page_number - 1)); $prev_link = ""; } else { $prev_link = ""; } - $next_url = make_link("rss/images/$search".($page_number+1)); + $next_url = make_link("rss/images/$search".($page_number + 1)); $next_link = ""; // no end... $version = VERSION; @@ -131,7 +131,7 @@ private function thumb(Image $image): string public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="posts") { + if ($event->parent == "posts") { $event->add_nav_link("posts_rss", new Link('rss/images'), "Feed"); } } diff --git a/ext/rule34/theme.php b/ext/rule34/theme.php index 0f607fe3a..9505b9d55 100644 --- a/ext/rule34/theme.php +++ b/ext/rule34/theme.php @@ -15,8 +15,8 @@ public function show_comic_changer(User $duser, bool $current_state): void global $page; $html = (string)SHM_SIMPLE_FORM( "rule34/comic_admin", - INPUT(["type"=>'hidden', "name"=>'user_id', "value"=>$duser->id]), - LABEL(INPUT(["type"=>'checkbox', "name"=>'is_admin', "checked"=>$current_state]), "Comic Admin"), + INPUT(["type" => 'hidden', "name" => 'user_id', "value" => $duser->id]), + LABEL(INPUT(["type" => 'checkbox', "name" => 'is_admin', "checked" => $current_state]), "Comic Admin"), BR(), SHM_SUBMIT("Set") ); diff --git a/ext/setup/main.php b/ext/setup/main.php index 8684c7a0e..1587060e3 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -172,7 +172,7 @@ private function format_option( } } - public function add_text_option(string $name, string $label=null, bool $table_row = false) + public function add_text_option(string $name, string $label = null, bool $table_row = false) { $val = html_escape($this->config->get_string($name)); @@ -182,7 +182,7 @@ public function add_text_option(string $name, string $label=null, bool $table_ro $this->format_option($name, $html, $label, $table_row); } - public function add_longtext_option(string $name, string $label=null, bool $table_row = false) + public function add_longtext_option(string $name, string $label = null, bool $table_row = false) { $val = html_escape($this->config->get_string($name)); @@ -193,12 +193,12 @@ public function add_longtext_option(string $name, string $label=null, bool $tabl $this->format_option($name, $html, $label, $table_row, true); } - public function add_bool_option(string $name, string $label=null, bool $table_row = false) + public function add_bool_option(string $name, string $label = null, bool $table_row = false) { $checked = $this->config->get_bool($name) ? " checked" : ""; $html = ""; - if (!$table_row&&!is_null($label)) { + if (!$table_row && !is_null($label)) { $html .= "{$label}"; } @@ -218,7 +218,7 @@ public function add_bool_option(string $name, string $label=null, bool $table_ro // $this->body .= ""; // } - public function add_int_option(string $name, string $label=null, bool $table_row = false) + public function add_int_option(string $name, string $label = null, bool $table_row = false) { $val = $this->config->get_int($name); @@ -228,7 +228,7 @@ public function add_int_option(string $name, string $label=null, bool $table_row $this->format_option($name, $html, $label, $table_row); } - public function add_shorthand_int_option(string $name, string $label=null, bool $table_row = false) + public function add_shorthand_int_option(string $name, string $label = null, bool $table_row = false) { $val = to_shorthand_int($this->config->get_int($name)); $html = "\n"; @@ -237,7 +237,7 @@ public function add_shorthand_int_option(string $name, string $label=null, bool $this->format_option($name, $html, $label, $table_row); } - public function add_choice_option(string $name, array $options, string $label=null, bool $table_row = false) + public function add_choice_option(string $name, array $options, string $label = null, bool $table_row = false) { if (is_int(array_values($options)[0])) { $current = $this->config->get_int($name); @@ -248,9 +248,9 @@ public function add_choice_option(string $name, array $options, string $label=nu $html = ""; foreach ($options as $optname => $optval) { if ($optval == $current) { - $selected=" selected"; + $selected = " selected"; } else { - $selected=""; + $selected = ""; } $html .= "$optname\n"; } @@ -260,16 +260,16 @@ public function add_choice_option(string $name, array $options, string $label=nu $this->format_option($name, $html, $label, $table_row); } - public function add_multichoice_option(string $name, array $options, string $label=null, bool $table_row = false) + public function add_multichoice_option(string $name, array $options, string $label = null, bool $table_row = false) { $current = $this->config->get_array($name); $html = ""; foreach ($options as $optname => $optval) { if (in_array($optval, $current)) { - $selected=" selected"; + $selected = " selected"; } else { - $selected=""; + $selected = ""; } $html .= "$optname\n"; } @@ -280,7 +280,7 @@ public function add_multichoice_option(string $name, array $options, string $lab $this->format_option($name, $html, $label, $table_row); } - public function add_color_option(string $name, string $label=null, bool $table_row = false) + public function add_color_option(string $name, string $label = null, bool $table_row = false) { $val = html_escape($this->config->get_string($name)); @@ -445,7 +445,7 @@ public function onCommand(CommandEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::CHANGE_SETTING)) { $event->add_nav_link("setup", new Link('setup'), "Board Config", null, 0); } diff --git a/ext/shimmie_api/main.php b/ext/shimmie_api/main.php index 7d5e12627..cf590df2e 100644 --- a/ext/shimmie_api/main.php +++ b/ext/shimmie_api/main.php @@ -70,7 +70,7 @@ public function onPageRequest(PageRequestEvent $event) $search_terms = $event->get_search_terms(); $page_number = $event->get_page_number(); $page_size = $event->get_page_size(); - $images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms); + $images = Image::find_images(($page_number - 1) * $page_size, $page_size, $search_terms); $safe_images = []; foreach ($images as $image) { $image->get_tag_array(); @@ -106,7 +106,7 @@ private function api_get_tags(?string $arg): array { global $database; if (!empty($arg)) { - $all = $database->get_all("SELECT tag FROM tags WHERE tag LIKE :tag", ['tag'=>$arg . "%"]); + $all = $database->get_all("SELECT tag FROM tags WHERE tag LIKE :tag", ['tag' => $arg . "%"]); } else { $all = $database->get_all("SELECT tag FROM tags"); } @@ -122,7 +122,7 @@ private function api_get_user(string $type, string $query): array global $database; $all = $database->get_row( "SELECT id, name, joindate, class FROM users WHERE $type=:query", - ['query'=>$query] + ['query' => $query] ); if (!empty($all)) { @@ -140,7 +140,7 @@ private function api_get_user(string $type, string $query): array if (isset($_GET['recent'])) { $recents = $database->get_all( "SELECT * FROM images WHERE owner_id=:owner_id ORDER BY id DESC LIMIT 0, 5", - ['owner_id'=>$all['id']] + ['owner_id' => $all['id']] ); $i = 0; diff --git a/ext/sitemap/info.php b/ext/sitemap/info.php index 58ec3e84f..cd18e749c 100644 --- a/ext/sitemap/info.php +++ b/ext/sitemap/info.php @@ -11,7 +11,7 @@ class XMLSitemapInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "XML Sitemap"; public string $url = "http://drudexsoftware.com"; - public array $authors = ["Sein Kraft"=>"mail@seinkraft.info","Drudex Software"=>"support@drudexsoftware.com"]; + public array $authors = ["Sein Kraft" => "mail@seinkraft.info","Drudex Software" => "support@drudexsoftware.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "Sitemap with caching & advanced priorities"; } diff --git a/ext/source_history/main.php b/ext/source_history/main.php index b83c29c31..aec6f1933 100644 --- a/ext/source_history/main.php +++ b/ext/source_history/main.php @@ -86,7 +86,7 @@ public function onSourceSet(SourceSetEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::BULK_EDIT_IMAGE_TAG)) { $event->add_nav_link("source_history", new Link('source_history/all/1'), "Source Changes", NavLink::is_active(["source_history"])); } @@ -224,7 +224,7 @@ public function get_source_history_from_revert(int $revert_id): ?array SELECT source_histories.*, users.name FROM source_histories JOIN users ON source_histories.user_id = users.id - WHERE source_histories.id = :id", ["id"=>$revert_id]); + WHERE source_histories.id = :id", ["id" => $revert_id]); return ($row ? $row : null); } @@ -238,7 +238,7 @@ public function get_source_history_from_id(int $image_id): array JOIN users ON source_histories.user_id = users.id WHERE image_id = :image_id ORDER BY source_histories.id DESC", - ["image_id"=>$image_id] + ["image_id" => $image_id] ); } @@ -251,7 +251,7 @@ public function get_global_source_history(int $page_id): array JOIN users ON source_histories.user_id = users.id ORDER BY source_histories.id DESC LIMIT 100 OFFSET :offset - ", ["offset" => ($page_id-1)*100]); + ", ["offset" => ($page_id - 1) * 100]); } /** @@ -373,13 +373,13 @@ private function add_source_history(Image $image, string $source) } // if the image has no history, make one with the old source - $entries = $database->get_one("SELECT COUNT(*) FROM source_histories WHERE image_id = :image_id", ['image_id'=>$image->id]); + $entries = $database->get_one("SELECT COUNT(*) FROM source_histories WHERE image_id = :image_id", ['image_id' => $image->id]); if ($entries == 0 && !empty($old_source)) { $database->execute( " INSERT INTO source_histories(image_id, source, user_id, user_ip, date_set) VALUES (:image_id, :source, :user_id, :user_ip, now())", - ["image_id"=>$image->id, "source"=>$old_source, "user_id"=>$config->get_int('anon_id'), "user_ip"=>'127.0.0.1'] + ["image_id" => $image->id, "source" => $old_source, "user_id" => $config->get_int('anon_id'), "user_ip" => '127.0.0.1'] ); $entries++; } @@ -389,7 +389,7 @@ private function add_source_history(Image $image, string $source) " INSERT INTO source_histories(image_id, source, user_id, user_ip, date_set) VALUES (:image_id, :source, :user_id, :user_ip, now())", - ["image_id"=>$image->id, "source"=>$new_source, "user_id"=>$user->id, "user_ip"=>get_real_ip()] + ["image_id" => $image->id, "source" => $new_source, "user_id" => $user->id, "user_ip" => get_real_ip()] ); $entries++; @@ -406,8 +406,8 @@ private function add_source_history(Image $image, string $source) https://dev.mysql.com/doc/refman/5.1/en/subquery-restrictions.html https://stackoverflow.com/questions/45494/mysql-error-1093-cant-specify-target-table-for-update-in-from-clause */ - $min_id = $database->get_one("SELECT MIN(id) FROM source_histories WHERE image_id = :image_id", ["image_id"=>$image->id]); - $database->execute("DELETE FROM source_histories WHERE id = :id", ["id"=>$min_id]); + $min_id = $database->get_one("SELECT MIN(id) FROM source_histories WHERE image_id = :image_id", ["image_id" => $image->id]); + $database->execute("DELETE FROM source_histories WHERE id = :id", ["id" => $min_id]); } } } diff --git a/ext/source_history/theme.php b/ext/source_history/theme.php index d583abfb6..7c6a106ba 100644 --- a/ext/source_history/theme.php +++ b/ext/source_history/theme.php @@ -33,9 +33,9 @@ public function display_global_page(Page $page, array $history, int $page_number $page->add_block(new Block("Source History", $history_html, "main", 10)); $h_prev = ($page_number <= 1) ? "Prev" : - 'Prev'; + 'Prev'; $h_index = "Index"; - $h_next = 'Next'; + $h_next = 'Next'; $nav = $h_prev.' | '.$h_index.' | '.$h_next; $page->add_block(new Block("Navigation", $nav, "left")); @@ -44,7 +44,7 @@ public function display_global_page(Page $page, array $history, int $page_number /** * Add a section to the admin page. */ - public function display_admin_block(string $validation_msg='') + public function display_admin_block(string $validation_msg = '') { global $page; @@ -113,14 +113,14 @@ protected function history_entry(array $fields, bool $selected): string $ip = $user->can(Permissions::VIEW_IP) ? rawHTML(" " . show_ip($fields['user_ip'], "Sourcing >>$image_id as '$current_source'")) : null; - $setter = A(["href"=>make_link("user/" . url_escape($name))], $name); + $setter = A(["href" => make_link("user/" . url_escape($name))], $name); return (string)LI( - INPUT(["type"=>"radio", "name"=>"revert", "id"=>"$current_id", "value"=>"$current_id", "checked"=>$selected]), - A(["href"=>make_link("post/view/$image_id")], $image_id), + INPUT(["type" => "radio", "name" => "revert", "id" => "$current_id", "value" => "$current_id", "checked" => $selected]), + A(["href" => make_link("post/view/$image_id")], $image_id), ": ", LABEL( - ["for"=>"$current_id"], + ["for" => "$current_id"], $current_source, " - ", $setter, diff --git a/ext/statsd/main.php b/ext/statsd/main.php index b853f7b50..4066d8637 100644 --- a/ext/statsd/main.php +++ b/ext/statsd/main.php @@ -74,7 +74,7 @@ public function get_priority(): int return 99; } - private function send(array $data, float $sampleRate=1) + private function send(array $data, float $sampleRate = 1) { if (!STATSD_HOST) { return; @@ -103,7 +103,7 @@ private function send(array $data, float $sampleRate=1) $host = $parts[0]; $port = (int)$parts[1]; $fp = fsockopen("udp://$host", $port, $errno, $errstr); - if (! $fp) { + if (!$fp) { return; } foreach ($sampledData as $stat => $value) { diff --git a/ext/system/info.php b/ext/system/info.php index 47eded77d..55383480c 100644 --- a/ext/system/info.php +++ b/ext/system/info.php @@ -10,7 +10,7 @@ class SystemInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "System"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Provides system screen"; public bool $core = true; diff --git a/ext/tag_categories/info.php b/ext/tag_categories/info.php index 221148b0d..e76398533 100644 --- a/ext/tag_categories/info.php +++ b/ext/tag_categories/info.php @@ -11,6 +11,6 @@ class TagCategoriesInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Tag Categories"; public string $url = "https://code.shishnet.org/shimmie2/"; - public array $authors = ["Daniel Oaks"=>"danneh@danneh.net"]; + public array $authors = ["Daniel Oaks" => "danneh@danneh.net"]; public string $description = "Let tags be split into 'categories', like Danbooru's tagging"; } diff --git a/ext/tag_categories/main.php b/ext/tag_categories/main.php index 0a31a7a82..118105ec0 100644 --- a/ext/tag_categories/main.php +++ b/ext/tag_categories/main.php @@ -45,22 +45,22 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) if ($number_of_db_rows == 0) { $database->execute( 'INSERT INTO image_tag_categories VALUES (:category, :single, :multiple, :color)', - ["category"=>"artist", "single"=>"Artist", "multiple"=>"Artists", "color"=>"#BB6666"] + ["category" => "artist", "single" => "Artist", "multiple" => "Artists", "color" => "#BB6666"] ); $database->execute( 'INSERT INTO image_tag_categories VALUES (:category, :single, :multiple, :color)', - ["category"=>"series", "single"=>"Series", "multiple"=>"Series", "color"=>"#AA00AA"] + ["category" => "series", "single" => "Series", "multiple" => "Series", "color" => "#AA00AA"] ); $database->execute( 'INSERT INTO image_tag_categories VALUES (:category, :single, :multiple, :color)', - ["category"=>"character", "single"=>"Character", "multiple"=>"Characters", "color"=>"#66BB66"] + ["category" => "character", "single" => "Character", "multiple" => "Characters", "color" => "#66BB66"] ); } } public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="tags") { + if ($event->parent == "tags") { $event->add_nav_link("tag_categories", new Link('tags/categories'), "Tag Categories", NavLink::is_active(["tag_categories"])); } } @@ -108,7 +108,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $block = new Block(); $block->header = "Tag Categories"; $block->body = $this->theme->get_help_html(); diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index 0fe2905ea..47b0f13cc 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -29,7 +29,7 @@ class SourceSetEvent extends Event public Image $image; public ?string $source; - public function __construct(Image $image, string $source=null) + public function __construct(Image $image, string $source = null) { parent::__construct(); $this->image = $image; @@ -194,7 +194,7 @@ public function onImageInfoSet(ImageInfoSetEvent $event) } } if ($user->can(Permissions::EDIT_IMAGE_LOCK)) { - $locked = isset($_POST['tag_edit__locked']) && $_POST['tag_edit__locked']=="on"; + $locked = isset($_POST['tag_edit__locked']) && $_POST['tag_edit__locked'] == "on"; send_event(new LockSetEvent($event->image, $locked)); } } @@ -246,7 +246,7 @@ public function onAdminBuilding(AdminBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="tags") { + if ($event->parent == "tags") { $event->add_nav_link("tags_help", new Link('ext_doc/tag_edit'), "Help"); } } diff --git a/ext/tag_edit/theme.php b/ext/tag_edit/theme.php index a27885001..66f4c8a24 100644 --- a/ext/tag_edit/theme.php +++ b/ext/tag_edit/theme.php @@ -63,7 +63,7 @@ public function get_tag_editor_html(Image $image): HTMLElement "type" => "text", "name" => "tag_edit__tags", "value" => $image->get_tag_list(), - "id"=>"tag_editor", + "id" => "tag_editor", "autocomplete" => "off" ]) ); @@ -117,7 +117,7 @@ protected function format_source(string $source = null): HTMLElement if (str_ends_with($h_source, "/")) { $h_source = substr($h_source, 0, -1); } - return A(["href"=>$source], $h_source); + return A(["href" => $source], $h_source); } return rawHTML("Unknown"); } diff --git a/ext/tag_editcloud/info.php b/ext/tag_editcloud/info.php index 315c1bc49..eeb866abc 100644 --- a/ext/tag_editcloud/info.php +++ b/ext/tag_editcloud/info.php @@ -10,6 +10,6 @@ class TagEditCloudInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Tag EditCloud"; - public array $authors = ["AtomicDryad", "Luana Latte"=>"luana.latte.cat@gmail.com"]; + public array $authors = ["AtomicDryad", "Luana Latte" => "luana.latte.cat@gmail.com"]; public string $description = "Add or remove tags to the editor via clicking."; } diff --git a/ext/tag_editcloud/main.php b/ext/tag_editcloud/main.php index 7d45a4a18..1158d8a4b 100644 --- a/ext/tag_editcloud/main.php +++ b/ext/tag_editcloud/main.php @@ -40,7 +40,7 @@ public function onInitExt(InitExtEvent $event) public function onSetupBuilding(SetupBuildingEvent $event) { - $sort_by = ['Alphabetical'=>'a','Popularity'=>'p','Relevance'=>'r','Categories'=>'c']; + $sort_by = ['Alphabetical' => 'a','Popularity' => 'p','Relevance' => 'r','Categories' => 'c']; $sb = $event->panel->create_new_block("Tag Edit Cloud"); $sb->add_bool_option("tageditcloud_disable", "Disable Tag Selection Cloud: "); @@ -99,7 +99,7 @@ private function build_tag_map(Image $image): ?HTMLElement GROUP BY t2.tag ORDER BY count DESC LIMIT :limit", - ["tag_min1" => $tags_min, "tag_min2" => $tags_min, "limit" => $max_count, "relevant_tags"=>$relevant_tags] + ["tag_min1" => $tags_min, "tag_min2" => $tags_min, "limit" => $max_count, "relevant_tags" => $relevant_tags] ); break; /** @noinspection PhpMissingBreakStatementInspection */ diff --git a/ext/tag_history/info.php b/ext/tag_history/info.php index 6cd8a6c12..ec87ddaf8 100644 --- a/ext/tag_history/info.php +++ b/ext/tag_history/info.php @@ -10,6 +10,6 @@ class TagHistoryInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Tag History"; - public array $authors = ["Bzchan"=>"bzchan@animemahou.com","jgen"=>"jgen.tech@gmail.com"]; + public array $authors = ["Bzchan" => "bzchan@animemahou.com","jgen" => "jgen.tech@gmail.com"]; public string $description = "Keep a record of tag changes, and allows you to revert changes."; } diff --git a/ext/tag_history/main.php b/ext/tag_history/main.php index 1384f3dbb..a748a5520 100644 --- a/ext/tag_history/main.php +++ b/ext/tag_history/main.php @@ -86,7 +86,7 @@ public function onTagSet(TagSetEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::BULK_EDIT_IMAGE_TAG)) { $event->add_nav_link("tag_history", new Link('tag_history/all/1'), "Tag Changes", NavLink::is_active(["tag_history"])); } @@ -163,7 +163,7 @@ private function process_revert_request(int $revert_id) $stored_tags = $result['tags']; $image = Image::by_id($stored_image_id); - if (! $image instanceof Image) { + if (!$image instanceof Image) { throw new ImageDoesNotExist("Error: cannot find any image with the ID = ". $stored_image_id); } @@ -222,7 +222,7 @@ public function get_tag_history_from_revert(int $revert_id): ?array SELECT tag_histories.*, users.name FROM tag_histories JOIN users ON tag_histories.user_id = users.id - WHERE tag_histories.id = :id", ["id"=>$revert_id]); + WHERE tag_histories.id = :id", ["id" => $revert_id]); return ($row ? $row : null); } @@ -236,7 +236,7 @@ public function get_tag_history_from_id(int $image_id): array JOIN users ON tag_histories.user_id = users.id WHERE image_id = :id ORDER BY tag_histories.id DESC", - ["id"=>$image_id] + ["id" => $image_id] ); } @@ -249,7 +249,7 @@ public function get_global_tag_history(int $page_id): array JOIN users ON tag_histories.user_id = users.id ORDER BY tag_histories.id DESC LIMIT 100 OFFSET :offset - ", ["offset" => ($page_id-1)*100]); + ", ["offset" => ($page_id - 1) * 100]); } /** @@ -328,7 +328,7 @@ public function process_revert_all_changes(?string $name, ?string $ip, ?string $ $stored_tags = $result['tags']; $image = Image::by_id($stored_image_id); - if (! $image instanceof Image) { + if (!$image instanceof Image) { continue; //throw new ImageDoesNotExist("Error: cannot find any image with the ID = ". $stored_image_id); } @@ -372,13 +372,13 @@ private function add_tag_history(Image $image, array $tags) } // if the image has no history, make one with the old tags - $entries = $database->get_one("SELECT COUNT(*) FROM tag_histories WHERE image_id = :id", ["id"=>$image->id]); + $entries = $database->get_one("SELECT COUNT(*) FROM tag_histories WHERE image_id = :id", ["id" => $image->id]); if ($entries == 0 && !empty($old_tags)) { $database->execute( " INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set) VALUES (:image_id, :tags, :user_id, :user_ip, now())", - ["image_id"=>$image->id, "tags"=>$old_tags, "user_id"=>$config->get_int('anon_id'), "user_ip"=>'127.0.0.1'] + ["image_id" => $image->id, "tags" => $old_tags, "user_id" => $config->get_int('anon_id'), "user_ip" => '127.0.0.1'] ); $entries++; } @@ -388,7 +388,7 @@ private function add_tag_history(Image $image, array $tags) " INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set) VALUES (:image_id, :tags, :user_id, :user_ip, now())", - ["image_id"=>$image->id, "tags"=>$new_tags, "user_id"=>$user->id, "user_ip"=>get_real_ip()] + ["image_id" => $image->id, "tags" => $new_tags, "user_id" => $user->id, "user_ip" => get_real_ip()] ); $entries++; @@ -405,8 +405,8 @@ private function add_tag_history(Image $image, array $tags) https://dev.mysql.com/doc/refman/5.1/en/subquery-restrictions.html https://stackoverflow.com/questions/45494/mysql-error-1093-cant-specify-target-table-for-update-in-from-clause */ - $min_id = $database->get_one("SELECT MIN(id) FROM tag_histories WHERE image_id = :image_id", ["image_id"=>$image->id]); - $database->execute("DELETE FROM tag_histories WHERE id = :id", ["id"=>$min_id]); + $min_id = $database->get_one("SELECT MIN(id) FROM tag_histories WHERE image_id = :image_id", ["image_id" => $image->id]); + $database->execute("DELETE FROM tag_histories WHERE id = :id", ["id" => $min_id]); } } } diff --git a/ext/tag_history/theme.php b/ext/tag_history/theme.php index 5beb37808..95ead7dae 100644 --- a/ext/tag_history/theme.php +++ b/ext/tag_history/theme.php @@ -34,9 +34,9 @@ public function display_global_page(Page $page, array $history, int $page_number $page->add_block(new Block("Tag History", $history_html, "main", 10)); $h_prev = ($page_number <= 1) ? "Prev" : - 'Prev'; + 'Prev'; $h_index = "Index"; - $h_next = 'Next'; + $h_next = 'Next'; $nav = $h_prev.' | '.$h_index.' | '.$h_next; $page->add_block(new Block("Navigation", $nav, "left", 0)); @@ -45,7 +45,7 @@ public function display_global_page(Page $page, array $history, int $page_number /** * Add a section to the admin page. */ - public function display_admin_block(string $validation_msg='') + public function display_admin_block(string $validation_msg = '') { global $page; @@ -114,21 +114,21 @@ protected function history_entry(array $fields, bool $selected): string $ip = $user->can(Permissions::VIEW_IP) ? rawHTML(" " . show_ip($fields['user_ip'], "Tagging >>$image_id as '$current_tags'")) : null; - $setter = A(["href"=>make_link("user/" . url_escape($name))], $name); + $setter = A(["href" => make_link("user/" . url_escape($name))], $name); $current_tags = Tag::explode($current_tags); $taglinks = SPAN(); foreach ($current_tags as $tag) { - $taglinks->appendChild(A(["href"=>search_link([$tag])], $tag)); + $taglinks->appendChild(A(["href" => search_link([$tag])], $tag)); $taglinks->appendChild(" "); } return (string)LI( - INPUT(["type"=>"radio", "name"=>"revert", "id"=>"$current_id", "value"=>"$current_id", "checked"=>$selected]), - A(["href"=>make_link("post/view/$image_id")], $image_id), + INPUT(["type" => "radio", "name" => "revert", "id" => "$current_id", "value" => "$current_id", "checked" => $selected]), + A(["href" => make_link("post/view/$image_id")], $image_id), ": ", LABEL( - ["for"=>"$current_id"], + ["for" => "$current_id"], $taglinks, " - ", $setter, diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index 14dc67d4f..3d13c7ae9 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -76,7 +76,7 @@ public function onPageNavBuilding(PageNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="tags") { + if ($event->parent == "tags") { $event->add_nav_link("tags_map", new Link('tags/map'), "Map"); $event->add_nav_link("tags_alphabetic", new Link('tags/alphabetic'), "Alphabetic"); $event->add_nav_link("tags_popularity", new Link('tags/popularity'), "Popularity"); @@ -214,11 +214,11 @@ private function build_az(): string FROM tags WHERE count >= :tags_min ORDER BY LOWER(substr(tag, 1, 1)) - ", ["tags_min"=>$tags_min]); + ", ["tags_min" => $tags_min]); $html = ""; foreach ($tag_data as $a) { - $html .= " $a"; + $html .= " $a"; } $html .= "\n"; @@ -231,7 +231,7 @@ private function build_navigation(): string $h_map = "Map"; $h_alphabetic = "Alphabetic"; $h_popularity = "Popularity"; - $h_all = "Show All"; + $h_all = "Show All"; return "$h_index $h_map$h_alphabetic$h_popularity $h_all"; } @@ -260,7 +260,7 @@ private function build_tag_map(): string WHERE count >= :tags_min AND LOWER(tag) LIKE LOWER(:starts_with) ORDER BY LOWER(tag) - ", ["tags_min"=>$tags_min, "tags_min2"=>$tags_min, "starts_with"=>$starts_with]); + ", ["tags_min" => $tags_min, "tags_min2" => $tags_min, "starts_with" => $starts_with]); $html = ""; if ($config->get_bool(TagListConfig::PAGES)) { @@ -275,7 +275,7 @@ private function build_tag_map(): string $h_tag = html_escape($row['tag']); $size = sprintf("%.2f", (float)$row['scaled']); $link = $this->theme->tag_link($row['tag']); - if ($size<0.5) { + if ($size < 0.5) { $size = 0.5; } $h_tag_no_underscores = str_replace("_", " ", $h_tag); @@ -314,7 +314,7 @@ private function build_tag_alphabetic(): string WHERE count >= :tags_min AND LOWER(tag) LIKE LOWER(:starts_with) ORDER BY LOWER(tag) - ", ["tags_min"=>$tags_min, "starts_with"=>$starts_with]); + ", ["tags_min" => $tags_min, "starts_with" => $starts_with]); $html = ""; if ($config->get_bool(TagListConfig::PAGES)) { @@ -349,8 +349,8 @@ private function build_tag_alphabetic(): string foreach ($tag_data as $tag => $count) { // In PHP, $array["10"] sets the array key as int(10), not string("10")... $tag = (string)$tag; - if ($lastLetter != mb_strtolower(substr($tag, 0, strlen($starts_with)+1))) { - $lastLetter = mb_strtolower(substr($tag, 0, strlen($starts_with)+1)); + if ($lastLetter != mb_strtolower(substr($tag, 0, strlen($starts_with) + 1))) { + $lastLetter = mb_strtolower(substr($tag, 0, strlen($starts_with) + 1)); $h_lastLetter = html_escape($lastLetter); $html .= "$h_lastLetter"; } @@ -395,7 +395,7 @@ private function build_tag_popularity(): string FROM tags WHERE count >= :tags_min ORDER BY count DESC, tag ASC - ", ["tags_min"=>$tags_min]); + ", ["tags_min" => $tags_min]); $html = "Results grouped by log10(n)"; $lastLog = ""; @@ -464,7 +464,7 @@ private function add_split_tags_block(Page $page, Image $image) AND image_tags.image_id = :image_id ORDER BY tags.count DESC "; - $args = ["image_id"=>$image->id]; + $args = ["image_id" => $image->id]; $tags = $database->get_all($query, $args); if (count($tags) > 0) { @@ -483,7 +483,7 @@ private function add_tags_block(Page $page, Image $image) AND image_tags.image_id = :image_id ORDER BY tags.count DESC "; - $args = ["image_id"=>$image->id]; + $args = ["image_id" => $image->id]; $tags = $database->get_all($query, $args); if (count($tags) > 0) { @@ -518,7 +518,7 @@ private function add_popular_block(Page $page) "; } - $args = ["popular_tag_list_length"=>$config->get_int(TagListConfig::POPULAR_TAG_LIST_LENGTH)]; + $args = ["popular_tag_list_length" => $config->get_int(TagListConfig::POPULAR_TAG_LIST_LENGTH)]; $tags = $database->get_all($query, $args); diff --git a/ext/tag_list/test.php b/ext/tag_list/test.php index f054a72eb..1f04f98a9 100644 --- a/ext/tag_list/test.php +++ b/ext/tag_list/test.php @@ -28,16 +28,16 @@ public function testTagList() public function testMinCount() { foreach ($this->pages as $page) { - $this->get_page("tags/$page", ["mincount"=>999999]); + $this->get_page("tags/$page", ["mincount" => 999999]); $this->assert_title("Tag List"); - $this->get_page("tags/$page", ["mincount"=>1]); + $this->get_page("tags/$page", ["mincount" => 1]); $this->assert_title("Tag List"); - $this->get_page("tags/$page", ["mincount"=>0]); + $this->get_page("tags/$page", ["mincount" => 0]); $this->assert_title("Tag List"); - $this->get_page("tags/$page", ["mincount"=>-1]); + $this->get_page("tags/$page", ["mincount" => -1]); $this->assert_title("Tag List"); } } diff --git a/ext/tag_tools/test.php b/ext/tag_tools/test.php index e99acbf41..8d7cc5057 100644 --- a/ext/tag_tools/test.php +++ b/ext/tag_tools/test.php @@ -43,7 +43,7 @@ public function testRecount() send_event(new UserLoginEvent(User::by_name(self::$admin_name))); $database->execute( "INSERT INTO tags(tag, count) VALUES(:tag, :count)", - ["tag"=>"tes$ts", "count"=>42] + ["tag" => "tes$ts", "count" => 42] ); // Fix @@ -54,7 +54,7 @@ public function testRecount() 0, $database->get_one( "SELECT count FROM tags WHERE tag = :tag", - ["tag"=>"tes$ts"] + ["tag" => "tes$ts"] ) ); } diff --git a/ext/tag_tools/theme.php b/ext/tag_tools/theme.php index 2f52c6b45..7cf2ea727 100644 --- a/ext/tag_tools/theme.php +++ b/ext/tag_tools/theme.php @@ -8,7 +8,7 @@ class TagToolsTheme extends Themelet { - protected function button(string $name, string $action, bool $protected=false): string + protected function button(string $name, string $action, bool $protected = false): string { $c_protected = $protected ? " protected" : ""; $html = make_form(make_link("admin/$action"), "POST", false, "admin$c_protected"); @@ -39,7 +39,7 @@ public function display_form() $html = (string)SHM_SIMPLE_FORM( "admin/set_tag_case", - INPUT(["type"=>'text', "name"=>'tag', "placeholder"=>'Enter tag with correct case', "autocomplete"=>'off']), + INPUT(["type" => 'text', "name" => 'tag', "placeholder" => 'Enter tag with correct case', "autocomplete" => 'off']), SHM_SUBMIT('Set Tag Case'), ); $page->add_block(new Block("Set Tag Case", $html)); diff --git a/ext/tagger_xml/info.php b/ext/tagger_xml/info.php index c7754babb..3de7720d0 100644 --- a/ext/tagger_xml/info.php +++ b/ext/tagger_xml/info.php @@ -10,7 +10,7 @@ class TaggerXMLInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Tagger AJAX backend"; - public array $authors = ["Artanis (Erik Youngren)"=>"artanis.00@gmail.com"]; + public array $authors = ["Artanis (Erik Youngren)" => "artanis.00@gmail.com"]; public ExtensionVisibility $visibility = ExtensionVisibility::HIDDEN; public string $description = "Advanced Tagging v2 AJAX backend"; } diff --git a/ext/tagger_xml/main.php b/ext/tagger_xml/main.php index e945e2eb2..6e577d553 100644 --- a/ext/tagger_xml/main.php +++ b/ext/tagger_xml/main.php @@ -19,7 +19,7 @@ public function onPageRequest(PageRequestEvent $event) //$match_tags = null; //$image_tags = null; - $tags=null; + $tags = null; if (isset($_GET['s'])) { // tagger/tags[/...]?s=$string // return matching tags in XML form $tags = $this->match_tag_list($_GET['s']); @@ -58,7 +58,7 @@ private function match_tag_list(string $s): string // $exclude = $event->get_arg(1)? "AND NOT IN ".$this->image_tags($event->get_arg(1)) : null; // Hidden Tags - $hidden = $config->get_string('ext-tagger_show-hidden', 'N')=='N' ? + $hidden = $config->get_string('ext-tagger_show-hidden', 'N') == 'N' ? "AND substring(tag,1,1) != '.'" : null; $q_where = "WHERE {$match} {$hidden} AND count > 0"; @@ -69,7 +69,7 @@ private function match_tag_list(string $s): string $q_from = "FROM (SELECT * FROM `tags` {$q_where} ". "ORDER BY count DESC LIMIT {$limit_rows} OFFSET 0) AS `c_tags`"; $q_where = null; - $count = ["max"=>$count]; + $count = ["max" => $count]; } else { $q_from = "FROM `tags`"; $count = []; @@ -93,17 +93,17 @@ private function image_tag_list(int $image_id): string $tags = $database->execute(" SELECT tags.* FROM image_tags JOIN tags ON image_tags.tag_id = tags.id - WHERE image_id=:image_id ORDER BY tag", ['image_id'=>$image_id]); + WHERE image_id=:image_id ORDER BY tag", ['image_id' => $image_id]); return $this->list_to_xml($tags, "image", (string)$image_id); } - private function list_to_xml(\FFSPHP\PDOStatement $tags, string $type, string $query, ?array $misc=[]): string + private function list_to_xml(\FFSPHP\PDOStatement $tags, string $type, string $query, ?array $misc = []): string { $props = [ - "id"=>$type, - "query"=>$query, + "id" => $type, + "query" => $query, // @phpstan-ignore-next-line - "rows"=>$tags->_numOfRows + "rows" => $tags->_numOfRows ]; if (!is_null($misc)) { foreach ($misc as $attr => $val) { @@ -113,7 +113,7 @@ private function list_to_xml(\FFSPHP\PDOStatement $tags, string $type, string $q $list = new \MicroHTML\HTMLElement("list", [$props]); foreach ($tags as $tag) { - $list->appendChild(new \MicroHTML\HTMLElement("tag", [["id"=>$tag["id"], "count"=>$tag["count"]], $tag["tag"]])); + $list->appendChild(new \MicroHTML\HTMLElement("tag", [["id" => $tag["id"], "count" => $tag["count"]], $tag["tag"]])); } return (string)($list); diff --git a/ext/tips/info.php b/ext/tips/info.php index d8dd65cd3..01fd91aa0 100644 --- a/ext/tips/info.php +++ b/ext/tips/info.php @@ -10,7 +10,7 @@ class TipsInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Random Tip"; - public array $authors = ["Sein Kraft"=>"mail@seinkraft.info"]; + public array $authors = ["Sein Kraft" => "mail@seinkraft.info"]; public string $license = "GPLv2"; public string $description = "Show a random line of text in the subheader space"; public ?string $documentation = "Formatting is done with HTML"; diff --git a/ext/tips/main.php b/ext/tips/main.php index 172184a64..14281ec05 100644 --- a/ext/tips/main.php +++ b/ext/tips/main.php @@ -50,7 +50,7 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) " INSERT INTO tips (enable, image, text) VALUES (:enable, :image, :text)", - ["enable"=>true, "image"=>"coins.png", "text"=>"Do you like this extension? Please support us for developing new ones. Donate through paypal."] + ["enable" => true, "image" => "coins.png", "text" => "Do you like this extension? Please support us for developing new ones. Donate through paypal."] ); $this->set_version("ext_tips_version", 2); @@ -101,7 +101,7 @@ public function onPageRequest(PageRequestEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::TIPS_ADMIN)) { $event->add_nav_link("tips", new Link('tips/list'), "Tips Editor"); } @@ -141,7 +141,7 @@ public function onCreateTip(CreateTipEvent $event) " INSERT INTO tips (enable, image, text) VALUES (:enable, :image, :text)", - ["enable"=>$event->enable, "image"=>$event->image, "text"=>$event->text] + ["enable" => $event->enable, "image" => $event->image, "text" => $event->text] ); } @@ -158,7 +158,7 @@ private function getTip() WHERE enable = :true ORDER BY RAND() LIMIT 1 - ", ["true"=>true]); + ", ["true" => true]); if ($tip) { $this->theme->showTip($url, $tip); @@ -181,16 +181,16 @@ private function setStatus(int $tipID) { global $database; - $tip = $database->get_row("SELECT * FROM tips WHERE id = :id ", ["id"=>$tipID]); + $tip = $database->get_row("SELECT * FROM tips WHERE id = :id ", ["id" => $tipID]); $enable = bool_escape($tip['enable']); - $database->execute("UPDATE tips SET enable = :enable WHERE id = :id", ["enable"=>$enable, "id"=>$tipID]); + $database->execute("UPDATE tips SET enable = :enable WHERE id = :id", ["enable" => $enable, "id" => $tipID]); } public function onDeleteTip(DeleteTipEvent $event) { global $database; - $database->execute("DELETE FROM tips WHERE id = :id", ["id"=>$event->tip_id]); + $database->execute("DELETE FROM tips WHERE id = :id", ["id" => $event->tip_id]); } } diff --git a/ext/transcode/info.php b/ext/transcode/info.php index f79529e27..7ec5c88f9 100644 --- a/ext/transcode/info.php +++ b/ext/transcode/info.php @@ -10,7 +10,7 @@ class TranscodeImageInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Transcode Image"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Allows admins to automatically and manually transcode images."; public ?string $documentation = diff --git a/ext/transcode/main.php b/ext/transcode/main.php index 29ee67850..304ede255 100644 --- a/ext/transcode/main.php +++ b/ext/transcode/main.php @@ -98,7 +98,7 @@ public static function get_enabled_mimes(): array public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { if ($this->get_version(TranscodeConfig::VERSION) < 1) { - $old_extensions =[]; + $old_extensions = []; foreach (array_values(self::INPUT_MIMES) as $mime) { $old_extensions = array_merge($old_extensions, FileExtension::get_all_for_mime($mime)); } @@ -152,7 +152,7 @@ public function onSetupBuilding(SetupBuildingEvent $event) $sb->add_bool_option(TranscodeConfig::GET_ENABLED, "Enable GET args", true); $sb->add_bool_option(TranscodeConfig::UPLOAD, "Transcode on upload", true); $sb->add_choice_option(TranscodeConfig::ENGINE, MediaEngine::IMAGE_ENGINES, "Engine", true); - foreach (self::INPUT_MIMES as $display=> $mime) { + foreach (self::INPUT_MIMES as $display => $mime) { if (MediaEngine::is_input_supported($engine, $mime)) { $outputs = $this->get_supported_output_mimes($engine, $mime); $sb->add_choice_option(self::get_mapping_name($mime), $outputs, "$display", true); @@ -180,7 +180,7 @@ public function onDataUpload(DataUploadEvent $event) } if ($config->get_bool(TranscodeConfig::UPLOAD) == true) { - if ($event->mime === MimeType::GIF&&MimeType::is_animated_gif($event->tmpname)) { + if ($event->mime === MimeType::GIF && MimeType::is_animated_gif($event->tmpname)) { return; } @@ -253,10 +253,10 @@ public function onImageDownloading(ImageDownloadingEvent $event) $source_mime = $event->image->get_mime(); - if ($source_mime!=$target_mime) { + if ($source_mime != $target_mime) { $tmp_filename = $this->transcode_image($event->path, $source_mime, $target_mime); - if ($event->file_modified===true&&$event->path!=$event->image->get_image_filename()) { + if ($event->file_modified === true && $event->path != $event->image->get_image_filename()) { // This means that we're dealing with a temp file that will need cleaned up unlink($event->path); } @@ -314,10 +314,10 @@ public function onBulkAction(BulkActionEvent $event) } } } - if ($size_difference>0) { + if ($size_difference > 0) { $page->flash("Transcoded $total items, reduced size by ".human_filesize($size_difference)); - } elseif ($size_difference<0) { - $page->flash("Transcoded $total items, increased size by ".human_filesize(-1*$size_difference)); + } elseif ($size_difference < 0) { + $page->flash("Transcoded $total items, increased size by ".human_filesize(-1 * $size_difference)); } else { $page->flash("Transcoded $total items, no size difference"); } @@ -338,13 +338,13 @@ private function get_supported_output_mimes($engine, ?string $omit_mime = null): $output = []; - foreach (self::OUTPUT_MIMES as $key=> $value) { - if ($value=="") { + foreach (self::OUTPUT_MIMES as $key => $value) { + if ($value == "") { $output[$key] = $value; continue; } if (MediaEngine::is_output_supported($engine, $value) - &&(empty($omit_mime)||$omit_mime!=$value)) { + && (empty($omit_mime) || $omit_mime != $value)) { $output[$key] = $value; } } @@ -385,7 +385,7 @@ private function transcode_image(string $source_name, string $source_mime, strin { global $config; - if ($source_mime==$target_mime) { + if ($source_mime == $target_mime) { throw new ImageTranscodeException("Source and target MIMEs are the same: ".$source_mime); } @@ -433,18 +433,18 @@ private function transcode_image_gd(string $source_name, string $source_mime, st $width = imagesx($image); $height = imagesy($image); $new_image = imagecreatetruecolor($width, $height); - if ($new_image===false) { + if ($new_image === false) { throw new ImageTranscodeException("Could not create image with dimensions $width x $height"); } try { $background_color = Media::hex_color_allocate($new_image, $config->get_string(TranscodeConfig::ALPHA_COLOR)); - if ($background_color===false) { + if ($background_color === false) { throw new ImageTranscodeException("Could not allocate background color"); } - if (imagefilledrectangle($new_image, 0, 0, $width, $height, $background_color)===false) { + if (imagefilledrectangle($new_image, 0, 0, $width, $height, $background_color) === false) { throw new ImageTranscodeException("Could not fill background color"); } - if (imagecopy($new_image, $image, 0, 0, 0, 0, $width, $height)===false) { + if (imagecopy($new_image, $image, 0, 0, 0, 0, $width, $height) === false) { throw new ImageTranscodeException("Could not copy source image to new image"); } $result = imagejpeg($new_image, $tmp_name, $q); @@ -456,7 +456,7 @@ private function transcode_image_gd(string $source_name, string $source_mime, st } finally { imagedestroy($image); } - if ($result===false) { + if ($result === false) { throw new ImageTranscodeException("Error while transcoding ".$source_name." to ".$target_mime); } return $tmp_name; @@ -507,7 +507,7 @@ private function transcode_image_convert(string $source_name, string $source_mim log_debug('transcode', "Transcoding with command `$cmd`, returns $ret"); - if ($ret!==0) { + if ($ret !== 0) { throw new ImageTranscodeException("Transcoding failed with command ".$cmd.", returning ".implode("\r\n", $output)); } diff --git a/ext/transcode/theme.php b/ext/transcode/theme.php index 55c1f61a0..171df779d 100644 --- a/ext/transcode/theme.php +++ b/ext/transcode/theme.php @@ -32,7 +32,7 @@ public function get_transcode_html(Image $image, array $options): string public function get_transcode_picker_html(array $options): string { $html = ""; - foreach ($options as $display=>$value) { + foreach ($options as $display => $value) { $html .= "$display"; } diff --git a/ext/transcode_video/info.php b/ext/transcode_video/info.php index 4dd7877c5..81f7f7fc7 100644 --- a/ext/transcode_video/info.php +++ b/ext/transcode_video/info.php @@ -10,8 +10,8 @@ class TranscodeVideoInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Transcode Video"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Allows admins to automatically and manually transcode videos."; - public ?string $documentation ="Requires ffmpeg"; + public ?string $documentation = "Requires ffmpeg"; } diff --git a/ext/transcode_video/main.php b/ext/transcode_video/main.php index 8235afea9..ca0c03044 100644 --- a/ext/transcode_video/main.php +++ b/ext/transcode_video/main.php @@ -48,9 +48,9 @@ public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { global $user; - if ($event->image->video===true && $user->can(Permissions::EDIT_FILES)) { + if ($event->image->video === true && $user->can(Permissions::EDIT_FILES)) { $options = self::get_output_options($event->image->get_mime(), $event->image->video_codec); - if (!empty($options)&&sizeof($options)>1) { + if (!empty($options) && sizeof($options) > 1) { $event->add_part($this->theme->get_transcode_html($event->image, $options)); } } @@ -65,37 +65,37 @@ public function onSetupBuilding(SetupBuildingEvent $event) $sb->end_table(); } -/* - public function onDataUpload(DataUploadEvent $event) - { - global $config; + /* + public function onDataUpload(DataUploadEvent $event) + { + global $config; - if ($config->get_bool(TranscodeVideoConfig::UPLOAD) == true) { - $ext = strtolower($event->type); + if ($config->get_bool(TranscodeVideoConfig::UPLOAD) == true) { + $ext = strtolower($event->type); - $ext = Media::normalize_format($ext); + $ext = Media::normalize_format($ext); - if ($event->type=="gif"&&Media::is_animated_gif($event->tmpname)) { - return; - } - - if (in_array($ext, array_values(self::INPUT_FORMATS))) { - $target_format = $config->get_string(TranscodeVideoConfig::UPLOAD_PREFIX.$ext); - if (empty($target_format)) { + if ($event->type=="gif"&&Media::is_animated_gif($event->tmpname)) { return; } - try { - $new_image = $this->transcode_image($event->tmpname, $ext, $target_format); - $event->set_tmpname($new_image, Media::determine_ext($target_format)); - } catch (Exception $e) { - log_error("transcode_video", "Error while performing upload transcode: ".$e->getMessage()); - // We don't want to interfere with the upload process, - // so if something goes wrong the untranscoded image jsut continues + + if (in_array($ext, array_values(self::INPUT_FORMATS))) { + $target_format = $config->get_string(TranscodeVideoConfig::UPLOAD_PREFIX.$ext); + if (empty($target_format)) { + return; + } + try { + $new_image = $this->transcode_image($event->tmpname, $ext, $target_format); + $event->set_tmpname($new_image, Media::determine_ext($target_format)); + } catch (Exception $e) { + log_error("transcode_video", "Error while performing upload transcode: ".$e->getMessage()); + // We don't want to interfere with the upload process, + // so if something goes wrong the untranscoded image jsut continues + } } } } - } -*/ + */ public function onPageRequest(PageRequestEvent $event) { @@ -162,7 +162,7 @@ public function onBulkAction(BulkActionEvent $event) // transcodes recorded already, otherwise the image entries will be stuck pointing to // missing image files $database->commit(); - if ($output_image!=$image) { + if ($output_image != $image) { $total++; } } catch (\Exception $e) { @@ -186,10 +186,10 @@ private static function get_output_options(?string $starting_container = null, ? foreach (VideoContainers::ALL as $container) { - if ($starting_container==$container) { + if ($starting_container == $container) { continue; } - if (!empty($starting_codec)&& + if (!empty($starting_codec) && !VideoContainers::is_video_codec_supported($container, $starting_codec)) { continue; } @@ -201,11 +201,11 @@ private static function get_output_options(?string $starting_container = null, ? private function transcode_and_replace_video(Image $image, string $target_mime): Image { - if ($image->get_mime()==$target_mime) { + if ($image->get_mime() == $target_mime) { return $image; } - if ($image->video==null||($image->video===true && empty($image->video_codec))) { + if ($image->video == null || ($image->video === true && empty($image->video_codec))) { // If image predates the media system, or the video codec support, run a media check send_event(new MediaCheckPropertiesEvent($image)); $image->save_to_db(); diff --git a/ext/transcode_video/theme.php b/ext/transcode_video/theme.php index 244730b23..29c8c1dee 100644 --- a/ext/transcode_video/theme.php +++ b/ext/transcode_video/theme.php @@ -32,7 +32,7 @@ public function get_transcode_html(Image $image, array $options): string public function get_transcode_picker_html(array $options): string { $html = ""; - foreach ($options as $display=>$value) { + foreach ($options as $display => $value) { $html .= "$display"; } diff --git a/ext/trash/info.php b/ext/trash/info.php index 13b643d63..d0d9a2bbe 100644 --- a/ext/trash/info.php +++ b/ext/trash/info.php @@ -10,7 +10,7 @@ class TrashInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Trash"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Provides \"Trash\" or \"Recycle Bin\"-type functionality, storing deleted images for later recovery"; } diff --git a/ext/trash/main.php b/ext/trash/main.php index 5fc70a50f..f71fff19b 100644 --- a/ext/trash/main.php +++ b/ext/trash/main.php @@ -49,7 +49,7 @@ private function check_permissions(Image $image): bool { global $user; - if ($image->trash===true && !$user->can(Permissions::VIEW_TRASH)) { + if ($image->trash === true && !$user->can(Permissions::VIEW_TRASH)) { return false; } return true; @@ -77,7 +77,7 @@ public function onDisplayingImage(DisplayingImageEvent $event) public function onImageDeletion(ImageDeletionEvent $event) { - if ($event->force!==true && $event->image->trash!==true) { + if ($event->force !== true && $event->image->trash !== true) { self::set_trash($event->image->id, true); $event->stop_processing = true; } @@ -86,7 +86,7 @@ public function onImageDeletion(ImageDeletionEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent=="posts") { + if ($event->parent == "posts") { if ($user->can(Permissions::VIEW_TRASH)) { $event->add_nav_link("posts_trash", new Link('/post/list/in%3Atrash/1'), "Trash", null, 60); } @@ -109,7 +109,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) $matches = []; if (is_null($event->term) && $this->no_trash_query($event->context)) { - $event->add_querylet(new Querylet("trash != :true", ["true"=>true])); + $event->add_querylet(new Querylet("trash != :true", ["true" => true])); } if (is_null($event->term)) { @@ -117,7 +117,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) } if (preg_match(self::SEARCH_REGEXP, strtolower($event->term), $matches)) { if ($user->can(Permissions::VIEW_TRASH)) { - $event->add_querylet(new Querylet("trash = :true", ["true"=>true])); + $event->add_querylet(new Querylet("trash = :true", ["true" => true])); } } } @@ -125,7 +125,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { global $user; - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { if ($user->can(Permissions::VIEW_TRASH)) { $block = new Block(); $block->header = "Trash"; @@ -151,13 +151,13 @@ public static function set_trash(int $image_id, bool $trash) $database->execute( "UPDATE images SET trash = :trash WHERE id = :id", - ["trash"=>$trash,"id"=>$image_id] + ["trash" => $trash,"id" => $image_id] ); } public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { global $user; - if ($event->image->trash===true && $user->can(Permissions::VIEW_TRASH)) { + if ($event->image->trash === true && $user->can(Permissions::VIEW_TRASH)) { $event->add_part($this->theme->get_image_admin_html($event->image->id)); } } @@ -166,7 +166,7 @@ public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event) { global $user; - if ($user->can(Permissions::VIEW_TRASH)&&in_array("in:trash", $event->search_terms)) { + if ($user->can(Permissions::VIEW_TRASH) && in_array("in:trash", $event->search_terms)) { $event->add_action("bulk_trash_restore", "(U)ndelete", "u"); } } diff --git a/ext/trash/theme.php b/ext/trash/theme.php index 9a5553a87..9c65c1385 100644 --- a/ext/trash/theme.php +++ b/ext/trash/theme.php @@ -12,8 +12,8 @@ public function get_image_admin_html(int $image_id): string { return (string)SHM_SIMPLE_FORM( 'trash_restore/'.$image_id, - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]), - INPUT(["type"=>'submit', "value"=>'Restore From Trash']), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), + INPUT(["type" => 'submit', "value" => 'Restore From Trash']), ); } diff --git a/ext/update/info.php b/ext/update/info.php index 7941141ca..a7e8ae8fa 100644 --- a/ext/update/info.php +++ b/ext/update/info.php @@ -11,7 +11,7 @@ class UpdateInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Update"; public string $url = "http://www.codeanimu.net"; - public array $authors = ["DakuTree"=>"dakutree@codeanimu.net"]; + public array $authors = ["DakuTree" => "dakutree@codeanimu.net"]; public string $license = self::LICENSE_GPLV2; public string $description = "Shimmie updater! (Requires admin panel extension & transload engine (cURL/fopen/Wget))"; } diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php index 648e95772..8fb3b6556 100644 --- a/ext/upgrade/main.php +++ b/ext/upgrade/main.php @@ -65,8 +65,8 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) if ($this->get_version("db_version") < 11) { log_info("upgrade", "Converting user flags to classes"); $database->execute("ALTER TABLE users ADD COLUMN class VARCHAR(32) NOT NULL default :user", ["user" => "user"]); - $database->execute("UPDATE users SET class = :name WHERE id=:id", ["name"=>"anonymous", "id"=>$config->get_int('anon_id')]); - $database->execute("UPDATE users SET class = :name WHERE admin=:admin", ["name"=>"admin", "admin"=>'Y']); + $database->execute("UPDATE users SET class = :name WHERE id=:id", ["name" => "anonymous", "id" => $config->get_int('anon_id')]); + $database->execute("UPDATE users SET class = :name WHERE admin=:admin", ["name" => "admin", "admin" => 'Y']); $this->set_version("db_version", 11); } @@ -195,13 +195,13 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) // them into one big transaction would not be a good idea. $database->commit(); } - $database->execute("UPDATE images SET lossless = :t, video = :t WHERE ext IN ('swf')", ["t"=>true]); - $database->execute("UPDATE images SET lossless = :f, video = :f, audio = :t WHERE ext IN ('mp3')", ["t"=>true, "f"=>false]); - $database->execute("UPDATE images SET lossless = :f, video = :f, audio = :f WHERE ext IN ('jpg','jpeg')", ["f"=>false]); - $database->execute("UPDATE images SET lossless = :t, video = :f, audio = :f WHERE ext IN ('ico','ani','cur','png','svg')", ["t"=>true, "f"=>false]); - $database->execute("UPDATE images SET lossless = :t, audio = :f WHERE ext IN ('gif')", ["t"=>true, "f"=>false]); - $database->execute("UPDATE images SET audio = :f WHERE ext IN ('webp')", ["f"=>false]); - $database->execute("UPDATE images SET lossless = :f, video = :t WHERE ext IN ('flv','mp4','m4v','ogv','webm')", ["t"=>true, "f"=>false]); + $database->execute("UPDATE images SET lossless = :t, video = :t WHERE ext IN ('swf')", ["t" => true]); + $database->execute("UPDATE images SET lossless = :f, video = :f, audio = :t WHERE ext IN ('mp3')", ["t" => true, "f" => false]); + $database->execute("UPDATE images SET lossless = :f, video = :f, audio = :f WHERE ext IN ('jpg','jpeg')", ["f" => false]); + $database->execute("UPDATE images SET lossless = :t, video = :f, audio = :f WHERE ext IN ('ico','ani','cur','png','svg')", ["t" => true, "f" => false]); + $database->execute("UPDATE images SET lossless = :t, audio = :f WHERE ext IN ('gif')", ["t" => true, "f" => false]); + $database->execute("UPDATE images SET audio = :f WHERE ext IN ('webp')", ["f" => false]); + $database->execute("UPDATE images SET lossless = :f, video = :t WHERE ext IN ('flv','mp4','m4v','ogv','webm')", ["t" => true, "f" => false]); $this->set_version("db_version", 21); } } diff --git a/ext/upload/main.php b/ext/upload/main.php index ffb9192c9..f22d55c41 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -39,7 +39,7 @@ public function __construct( $metadata['filename'] = substr($metadata['filename'], 0, 255); } - public function set_tmpname(string $tmpname, ?string $mime=null) + public function set_tmpname(string $tmpname, ?string $mime = null) { assert(is_readable($tmpname)); $this->tmpname = $tmpname; @@ -151,7 +151,7 @@ public function onPageNavBuilding(PageNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="upload") { + if ($event->parent == "upload") { if (class_exists("Shimmie2\Wiki")) { $event->add_nav_link("upload_guidelines", new Link('wiki/upload_guidelines'), "Guidelines"); } diff --git a/ext/upload/test.php b/ext/upload/test.php index a45bb445d..9e12f99e0 100644 --- a/ext/upload/test.php +++ b/ext/upload/test.php @@ -43,7 +43,7 @@ public function testRawUpload() 'size' => [0], ] ]; - $page = $this->post_page("upload", ["tags0"=>"foo bar"]); + $page = $this->post_page("upload", ["tags0" => "foo bar"]); $this->assert_response(302); $this->assertStringStartsWith("/test/post/list/poster%3Dtest/1", $page->redirect); @@ -67,7 +67,7 @@ public function testRawReplace() ] ]; - $page = $this->post_page("upload/replace", ["image_id"=>$image_id]); + $page = $this->post_page("upload/replace", ["image_id" => $image_id]); $this->assert_response(302); $this->assertEquals("/test/post/view/$image_id", $page->redirect); @@ -104,7 +104,7 @@ public function testRejectUnknownFiletype() public function testRejectHuge() { // FIXME: huge.dat is rejected for other reasons; manual testing shows that this works - file_put_contents("data/huge.jpg", file_get_contents("tests/pbx_screenshot.jpg") . str_repeat("U", 1024*1024*3)); + file_put_contents("data/huge.jpg", file_get_contents("tests/pbx_screenshot.jpg") . str_repeat("U", 1024 * 1024 * 3)); try { $this->post_image("data/huge.jpg", "test"); $this->fail("Uploading huge.jpg didn't fail..."); diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 2d3c770f2..77ba47c0b 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -50,22 +50,22 @@ public function display_page(Page $page): void $form = SHM_FORM("upload", "POST", true, "file_upload"); $form->appendChild( TABLE( - ["id"=>"large_upload_form", "class"=>"vert"], + ["id" => "large_upload_form", "class" => "vert"], TR( - TD(["width"=>"20"], rawHTML("Common Tags")), - TD(["colspan"=>"5"], INPUT(["name"=>"tags", "type"=>"text", "placeholder"=>"tagme", "class"=>"autocomplete_tags", "autocomplete"=>"off"])) + TD(["width" => "20"], rawHTML("Common Tags")), + TD(["colspan" => "5"], INPUT(["name" => "tags", "type" => "text", "placeholder" => "tagme", "class" => "autocomplete_tags", "autocomplete" => "off"])) ), TR( - TD(["width"=>"20"], rawHTML("Common Source")), - TD(["colspan"=>"5"], INPUT(["name"=>"source", "type"=>"text"])) + TD(["width" => "20"], rawHTML("Common Source")), + TD(["colspan" => "5"], INPUT(["name" => "source", "type" => "text"])) ), $upload_list, TR( - TD(["colspan"=>$tl_enabled ? 2 : 4,"id"=>"upload_size_tracker"], ""), - TD(["colspan"=>2], ""), + TD(["colspan" => $tl_enabled ? 2 : 4,"id" => "upload_size_tracker"], ""), + TD(["colspan" => 2], ""), ), TR( - TD(["colspan"=>"6"], INPUT(["id"=>"uploadbutton", "type"=>"submit", "value"=>"Post"])) + TD(["colspan" => "6"], INPUT(["id" => "uploadbutton", "type" => "submit", "value" => "Post"])) ), ) ); @@ -148,18 +148,18 @@ protected function h_upload_list_1(): HTMLElement $upload_list->appendChild( TR( - TD(["colspan"=>$tl_enabled ? 2 : 4], "Files"), - $tl_enabled ? TD(["colspan"=>"2"], "URLs") : emptyHTML(), - TD(["colspan"=>"2"], "Post-Specific Tags"), + TD(["colspan" => $tl_enabled ? 2 : 4], "Files"), + $tl_enabled ? TD(["colspan" => "2"], "URLs") : emptyHTML(), + TD(["colspan" => "2"], "Post-Specific Tags"), ) ); - for ($i=0; $i<$upload_count; $i++) { + for ($i = 0; $i < $upload_count; $i++) { $upload_list->appendChild( TR( - TD(["colspan"=>$tl_enabled ? 2 : 4], DIV(["name"=>"canceldata{$i}[]","style"=>"display:inline;margin-right:5px;font-size:15px;visibility:hidden;","onclick"=>"$(\"input[name='data{$i}[]']\")[0].value='';updateTracker();"], "✖"), INPUT(["type"=>"file", "name"=>"data{$i}[]", "accept"=>$accept, "multiple"=>true])), - $tl_enabled ? TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"url{$i}"])) : emptyHTML(), - TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"tags{$i}", "class"=>"autocomplete_tags", "autocomplete"=>"off"])), + TD(["colspan" => $tl_enabled ? 2 : 4], DIV(["name" => "canceldata{$i}[]","style" => "display:inline;margin-right:5px;font-size:15px;visibility:hidden;","onclick" => "$(\"input[name='data{$i}[]']\")[0].value='';updateTracker();"], "✖"), INPUT(["type" => "file", "name" => "data{$i}[]", "accept" => $accept, "multiple" => true])), + $tl_enabled ? TD(["colspan" => "2"], INPUT(["type" => "text", "name" => "url{$i}"])) : emptyHTML(), + TD(["colspan" => "2"], INPUT(["type" => "text", "name" => "tags{$i}", "class" => "autocomplete_tags", "autocomplete" => "off"])), ) ); } @@ -177,7 +177,7 @@ protected function h_bookmarklets(): HTMLElement $max_kb = to_shorthand_int($max_size); $delimiter = $config->get_bool('nice_urls') ? '?' : '&'; - $js='javascript:( + $js = 'javascript:( function() { if(typeof window=="undefined" || !window.location || window.location.href=="about:blank") { window.location = "'. $main_page .'"; @@ -198,7 +198,7 @@ function() { } )();'; $html1 = P( - A(["href"=>$js], "Upload to $title"), + A(["href" => $js], "Upload to $title"), rawHTML(' (Drag & drop onto your bookmarks toolbar, then click when looking at a post)') ); @@ -216,7 +216,7 @@ function() { void(document.body.appendChild(document.createElement("script")).src="'.make_http(get_base_href())."/ext/upload/bookmarklet.js".'") '; $html2 = P( - A(["href"=>$js], $title), + A(["href" => $js], $title), rawHTML("(Click when looking at a post page. Works on sites running Shimmie / Danbooru / Gelbooru. (This also grabs the tags / rating / source!))"), ); @@ -235,14 +235,14 @@ public function display_replace_page(Page $page, int $image_id) $upload_list = emptyHTML( TR( TD("File"), - TD(INPUT(["name"=>"data[]", "type"=>"file", "accept"=>$accept])) + TD(INPUT(["name" => "data[]", "type" => "file", "accept" => $accept])) ) ); if ($tl_enabled) { $upload_list->appendChild( TR( TD("or URL"), - TD(INPUT(["name"=>"url", "type"=>"text"])) + TD(INPUT(["name" => "url", "type" => "text"])) ) ); } @@ -255,12 +255,12 @@ public function display_replace_page(Page $page, int $image_id) $form = SHM_FORM("upload/replace/".$image_id, "POST", true); $form->appendChild(emptyHTML( - INPUT(["type"=>"hidden", "name"=>"image_id", "value"=>$image_id]), + INPUT(["type" => "hidden", "name" => "image_id", "value" => $image_id]), TABLE( - ["id"=>"large_upload_form", "class"=>"vert"], + ["id" => "large_upload_form", "class" => "vert"], $upload_list, - TR(TD("Source"), TD(["colspan"=>3], INPUT(["name"=>"source", "type"=>"text"]))), - TR(TD(["colspan"=>4], INPUT(["id"=>"uploadbutton", "type"=>"submit", "value"=>"Post"]))), + TR(TD("Source"), TD(["colspan" => 3], INPUT(["name" => "source", "type" => "text"]))), + TR(TD(["colspan" => 4], INPUT(["id" => "uploadbutton", "type" => "submit", "value" => "Post"]))), ) )); @@ -328,18 +328,18 @@ protected function build_upload_block(): HTMLElement $form = SHM_FORM("upload", "POST", true); $form->appendChild( emptyHTML( - INPUT(["id"=>"data[]", "name"=>"data[]", "size"=>"16", "type"=>"file", "accept"=>$accept, "multiple"=>true]), - INPUT(["name"=>"tags", "type"=>"text", "placeholder"=>"tagme", "class"=>"autocomplete_tags", "required"=>true, "autocomplete"=>"off"]), - INPUT(["type"=>"submit", "value"=>"Post"]), + INPUT(["id" => "data[]", "name" => "data[]", "size" => "16", "type" => "file", "accept" => $accept, "multiple" => true]), + INPUT(["name" => "tags", "type" => "text", "placeholder" => "tagme", "class" => "autocomplete_tags", "required" => true, "autocomplete" => "off"]), + INPUT(["type" => "submit", "value" => "Post"]), ) ); return DIV( - ["class"=>'mini_upload'], + ["class" => 'mini_upload'], $form, SMALL("(Max file size is $max_kb)"), SMALL(BR(), "(Max total size is $max_total_kb)"), - NOSCRIPT(BR(), A(["href"=>make_link("upload")], "Larger Form")) + NOSCRIPT(BR(), A(["href" => make_link("upload")], "Larger Form")) ); } diff --git a/ext/user/events.php b/ext/user/events.php index aacf7fa1c..d4a75de83 100644 --- a/ext/user/events.php +++ b/ext/user/events.php @@ -10,7 +10,7 @@ class UserBlockBuildingEvent extends Event { public array $parts = []; - public function add_link(string|HTMLElement $name, string $link, int $position=50): void + public function add_link(string|HTMLElement $name, string $link, int $position = 50): void { while (isset($this->parts[$position])) { $position++; @@ -43,7 +43,7 @@ public function __construct(public User $display_user) parent::__construct(); } - public function add_stats(string $html, int $position=50) + public function add_stats(string $html, int $position = 50) { while (isset($this->stats[$position])) { $position++; diff --git a/ext/user/main.php b/ext/user/main.php index a3a923242..ce2c97334 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -24,7 +24,7 @@ class UserNameColumn extends TextColumn { public function display(array $row): HTMLElement { - return A(["href"=>make_link("user/{$row[$this->name]}")], $row[$this->name]); + return A(["href" => make_link("user/{$row[$this->name]}")], $row[$this->name]); } } @@ -38,7 +38,7 @@ public function __construct() public function display(array $row): HTMLElement { - return A(["href"=>search_link(["user={$row['name']}"])], "Posts"); + return A(["href" => search_link(["user={$row['name']}"])], "Posts"); } } @@ -368,17 +368,17 @@ public function onSetupBuilding(SetupBuildingEvent $event) $sb->add_choice_option( "avatar_gravatar_type", [ - 'Default'=>'default', - 'Wavatar'=>'wavatar', - 'Monster ID'=>'monsterid', - 'Identicon'=>'identicon' + 'Default' => 'default', + 'Wavatar' => 'wavatar', + 'Monster ID' => 'monsterid', + 'Identicon' => 'identicon' ], "Type", true ); $sb->add_choice_option( "avatar_gravatar_rating", - ['G'=>'g', 'PG'=>'pg', 'R'=>'r', 'X'=>'x'], + ['G' => 'g', 'PG' => 'pg', 'R' => 'r', 'X' => 'x'], "Rating", true ); @@ -389,13 +389,13 @@ public function onSetupBuilding(SetupBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::EDIT_USER_PASSWORD)) { $event->add_nav_link("user_admin", new Link('user_admin/list'), "User List", NavLink::is_active(["user_admin"])); } } - if ($event->parent==="user" && !$user->is_anonymous()) { + if ($event->parent === "user" && !$user->is_anonymous()) { $event->add_nav_link("logout", new Link('user_admin/logout'), "Log Out", false, 90); } } @@ -465,7 +465,7 @@ public function onUserCreation(UserCreationEvent $event) public static function has_user_query(array $context): bool { foreach ($context as $term) { - if (preg_match(self::USER_SEARCH_REGEX, $term)|| + if (preg_match(self::USER_SEARCH_REGEX, $term) || preg_match(self::USER_ID_SEARCH_REGEX, $term)) { return true; } @@ -501,7 +501,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $block = new Block(); $block->header = "Users"; $block->body = (string)$this->theme->get_help_html(); @@ -616,7 +616,7 @@ private function create_user(UserCreationEvent $event): User $database->execute( "INSERT INTO users (name, pass, joindate, email, class) VALUES (:username, :hash, now(), :email, :class)", - ["username"=>$event->username, "hash"=>'', "email"=>$email, "class"=>$class] + ["username" => $event->username, "hash" => '', "email" => $email, "class" => $class] ); $uid = $database->get_last_insert_id('users_id_seq'); $new_user = User::by_name($event->username); @@ -643,13 +643,13 @@ private function set_login_cookie(string $name): void $page->add_cookie( "user", $name, - time()+60*60*24*365, + time() + 60 * 60 * 24 * 365, '/' ); $page->add_cookie( "session", $this->get_session_id($name), - time()+60*60*24*$config->get_int('login_memory'), + time() + 60 * 60 * 24 * $config->get_int('login_memory'), '/' ); } @@ -754,7 +754,7 @@ private function count_upload_ips(User $duser): array FROM images WHERE owner_id=:id GROUP BY owner_ip - ORDER BY max(posted) DESC", ["id"=>$duser->id]); + ORDER BY max(posted) DESC", ["id" => $duser->id]); } private function count_comment_ips(User $duser): array @@ -767,7 +767,7 @@ private function count_comment_ips(User $duser): array FROM comments WHERE owner_id=:id GROUP BY owner_ip - ORDER BY max(posted) DESC", ["id"=>$duser->id]); + ORDER BY max(posted) DESC", ["id" => $duser->id]); } private function count_log_ips(User $duser): array @@ -783,10 +783,10 @@ private function count_log_ips(User $duser): array FROM score_log WHERE username=:username GROUP BY address - ORDER BY MAX(date_sent) DESC", ["username"=>$duser->name]); + ORDER BY MAX(date_sent) DESC", ["username" => $duser->name]); } - private function delete_user(Page $page, bool $with_images=false, bool $with_comments=false): void + private function delete_user(Page $page, bool $with_images = false, bool $with_comments = false): void { global $user, $config, $database; diff --git a/ext/user/theme.php b/ext/user/theme.php index 33d8a5fb5..786dafbd2 100644 --- a/ext/user/theme.php +++ b/ext/user/theme.php @@ -54,7 +54,7 @@ public function display_user_block(Page $page, User $user, $parts) $html = emptyHTML('Logged in as ', $user->name); foreach ($parts as $part) { $html->appendChild(BR()); - $html->appendChild(A(["href"=>$part["link"]], $part["name"])); + $html->appendChild(A(["href" => $part["link"]], $part["name"])); } $b = new Block("User Links", $html, "left", 90); $b->is_content = false; @@ -74,30 +74,30 @@ public function display_signup_page(Page $page) $form = SHM_SIMPLE_FORM( "user_admin/create", TABLE( - ["class"=>"form"], + ["class" => "form"], TBODY( TR( TH("Name"), - TD(INPUT(["type"=>'text', "name"=>'name', "required"=>true])) + TD(INPUT(["type" => 'text', "name" => 'name', "required" => true])) ), TR( TH("Password"), - TD(INPUT(["type"=>'password', "name"=>'pass1', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass1', "required" => true])) ), TR( TH(rawHTML("Repeat Password")), - TD(INPUT(["type"=>'password', "name"=>'pass2', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass2', "required" => true])) ), TR( TH(rawHTML("Email (Optional)")), - TD(INPUT(["type"=>'email', "name"=>'email'])) + TD(INPUT(["type" => 'email', "name" => 'email'])) ), TR( - TD(["colspan"=>"2"], rawHTML(captcha_get_html())) + TD(["colspan" => "2"], rawHTML(captcha_get_html())) ), ), TFOOT( - TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Create Account"]))) + TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => "Create Account"]))) ) ) ); @@ -120,27 +120,27 @@ public function display_user_creator() $form = SHM_SIMPLE_FORM( "user_admin/create_other", TABLE( - ["class"=>"form"], + ["class" => "form"], TBODY( TR( TH("Name"), - TD(INPUT(["type"=>'text', "name"=>'name', "required"=>true])) + TD(INPUT(["type" => 'text', "name" => 'name', "required" => true])) ), TR( TH("Password"), - TD(INPUT(["type"=>'password', "name"=>'pass1', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass1', "required" => true])) ), TR( TH(rawHTML("Repeat Password")), - TD(INPUT(["type"=>'password', "name"=>'pass2', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass2', "required" => true])) ), TR( TH(rawHTML("Email (Optional)")), - TD(INPUT(["type"=>'email', "name"=>'email'])) + TD(INPUT(["type" => 'email', "name" => 'email'])) ), ), TFOOT( - TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Create Account"]))) + TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => "Create Account"]))) ) ) ); @@ -164,19 +164,19 @@ public function display_login_block(Page $page) $form = SHM_SIMPLE_FORM( "user_admin/login", TABLE( - ["style"=>"width: 100%", "class"=>"form"], + ["style" => "width: 100%", "class" => "form"], TBODY( TR( - TH(LABEL(["for"=>"user"], "Name")), - TD(INPUT(["id"=>"user", "type"=>"text", "name"=>"user", "autocomplete"=>"username"])) + TH(LABEL(["for" => "user"], "Name")), + TD(INPUT(["id" => "user", "type" => "text", "name" => "user", "autocomplete" => "username"])) ), TR( - TH(LABEL(["for"=>"pass"], "Password")), - TD(INPUT(["id"=>"pass", "type"=>"password", "name"=>"pass", "autocomplete"=>"current-password"])) + TH(LABEL(["for" => "pass"], "Password")), + TD(INPUT(["id" => "pass", "type" => "password", "name" => "pass", "autocomplete" => "current-password"])) ) ), TFOOT( - TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Log In"]))) + TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => "Log In"]))) ) ) ); @@ -184,7 +184,7 @@ public function display_login_block(Page $page) $html = emptyHTML(); $html->appendChild($form); if ($config->get_bool("login_signup_enabled") && $user->can(Permissions::CREATE_USER)) { - $html->appendChild(SMALL(A(["href"=>make_link("user_admin/create")], "Create Account"))); + $html->appendChild(SMALL(A(["href" => make_link("user_admin/create")], "Create Account"))); } $page->add_block(new Block("Login", $html, "left", 90)); @@ -209,14 +209,14 @@ private function _ip_list(string $name, array $ips): HTMLElement public function display_ip_list(Page $page, array $uploads, array $comments, array $events) { $html = TABLE( - ["id"=>"ip-history"], + ["id" => "ip-history"], TR( $this->_ip_list("Uploaded from", $uploads), $this->_ip_list("Commented from", $comments), $this->_ip_list("Logged Events", $events) ), TR( - TD(["colspan"=>"3"], "(Most recent at top)") + TD(["colspan" => "3"], "(Most recent at top)") ) ); @@ -250,7 +250,7 @@ public function build_operations(User $duser, UserOperationsBuildingEvent $event "Change Name", TBODY(TR( TH("New name"), - TD(INPUT(["type"=>'text', "name"=>'name', "value"=>$duser->name])) + TD(INPUT(["type" => 'text', "name" => 'name', "value" => $duser->name])) )), "Set" )); @@ -263,11 +263,11 @@ public function build_operations(User $duser, UserOperationsBuildingEvent $event TBODY( TR( TH("Password"), - TD(INPUT(["type"=>'password', "name"=>'pass1', "autocomplete"=>'new-password'])) + TD(INPUT(["type" => 'password', "name" => 'pass1', "autocomplete" => 'new-password'])) ), TR( TH("Repeat Password"), - TD(INPUT(["type"=>'password', "name"=>'pass2', "autocomplete"=>'new-password'])) + TD(INPUT(["type" => 'password', "name" => 'pass2', "autocomplete" => 'new-password'])) ), ), "Set" @@ -279,17 +279,17 @@ public function build_operations(User $duser, UserOperationsBuildingEvent $event "Change Email", TBODY(TR( TH("Address"), - TD(INPUT(["type"=>'text', "name"=>'address', "value"=>$duser->email, "autocomplete"=>'email', "inputmode"=>'email'])) + TD(INPUT(["type" => 'text', "name" => 'address', "value" => $duser->email, "autocomplete" => 'email', "inputmode" => 'email'])) )), "Set" )); if ($user->can(Permissions::EDIT_USER_CLASS)) { global $_shm_user_classes; - $select = SELECT(["name"=>"class"]); + $select = SELECT(["name" => "class"]); foreach ($_shm_user_classes as $name => $values) { $select->appendChild( - OPTION(["value"=>$name, "selected"=>$name == $duser->class->name], ucwords($name)) + OPTION(["value" => $name, "selected" => $name == $duser->class->name], ucwords($name)) ); } $html->appendChild(SHM_USER_FORM( @@ -307,12 +307,12 @@ public function build_operations(User $duser, UserOperationsBuildingEvent $event "user_admin/delete_user", "Delete User", TBODY( - TR(TD(LABEL(INPUT(["type"=>'checkbox', "name"=>'with_images']), "Delete images"))), - TR(TD(LABEL(INPUT(["type"=>'checkbox', "name"=>'with_comments']), "Delete comments"))), + TR(TD(LABEL(INPUT(["type" => 'checkbox', "name" => 'with_images']), "Delete images"))), + TR(TD(LABEL(INPUT(["type" => 'checkbox', "name" => 'with_comments']), "Delete comments"))), ), TFOOT( - TR(TD(INPUT(["type"=>'button', "class"=>'shm-unlocker', "data-unlock-sel"=>'.deluser', "value"=>'Unlock']))), - TR(TD(INPUT(["type"=>'submit', "class"=>'deluser', "value"=>'Delete User', "disabled"=>'true']))), + TR(TD(INPUT(["type" => 'button', "class" => 'shm-unlocker', "data-unlock-sel" => '.deluser', "value" => 'Unlock']))), + TR(TD(INPUT(["type" => 'submit', "class" => 'deluser', "value" => 'Delete User', "disabled" => 'true']))), ) )); } @@ -353,7 +353,7 @@ public function get_help_html(): HTMLElement */ public function display_user_classes(Page $page, array $classes, array $permissions): void { - $table = TABLE(["class"=>"zebra"]); + $table = TABLE(["class" => "zebra"]); $row = TR(); $row->appendChild(TH("Permission")); @@ -374,9 +374,9 @@ public function display_user_classes(Page $page, array $classes, array $permissi foreach ($classes as $class) { $opacity = array_key_exists($perm->getValue(), $class->abilities) ? 1 : 0.2; if ($class->can($perm->getValue())) { - $cell = TD(["style"=>"color: green; opacity: $opacity;"], "✔"); + $cell = TD(["style" => "color: green; opacity: $opacity;"], "✔"); } else { - $cell = TD(["style"=>"color: red; opacity: $opacity;"], "✘"); + $cell = TD(["style" => "color: red; opacity: $opacity;"], "✘"); } $row->appendChild($cell); } @@ -384,7 +384,7 @@ public function display_user_classes(Page $page, array $classes, array $permissi $doc = $perm->getDocComment(); if ($doc) { $doc = preg_replace('/\/\*\*|\n\s*\*\s*|\*\//', '', $doc); - $row->appendChild(TD(["style"=>"text-align: left;"], $doc)); + $row->appendChild(TD(["style" => "text-align: left;"], $doc)); } else { $row->appendChild(TD("")); } diff --git a/ext/user_config/info.php b/ext/user_config/info.php index a6495dbd9..d546352a4 100644 --- a/ext/user_config/info.php +++ b/ext/user_config/info.php @@ -10,7 +10,7 @@ class UserConfigInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "User-specific settings"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Provides system-wide support for user-specific settings"; public ExtensionVisibility $visibility = ExtensionVisibility::HIDDEN; diff --git a/ext/user_config/main.php b/ext/user_config/main.php index cf53dbb0a..2a729732f 100644 --- a/ext/user_config/main.php +++ b/ext/user_config/main.php @@ -93,7 +93,7 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event): void public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="user" && !$user->is_anonymous()) { + if ($event->parent === "user" && !$user->is_anonymous()) { $event->add_nav_link("user_config", new Link('user_config'), "User Options", false, 40); } } @@ -154,7 +154,7 @@ public function onPageRequest(PageRequestEvent $event) ]); $duser = User::by_id($input['id']); - if ($user->id!=$duser->id && !$user->can(Permissions::CHANGE_OTHER_USER_SETTING)) { + if ($user->id != $duser->id && !$user->can(Permissions::CHANGE_OTHER_USER_SETTING)) { $this->theme->display_permission_denied(); return; } diff --git a/ext/view/events/image_admin_block_building_event.php b/ext/view/events/image_admin_block_building_event.php index 47cb6a5c1..6a1d458d2 100644 --- a/ext/view/events/image_admin_block_building_event.php +++ b/ext/view/events/image_admin_block_building_event.php @@ -20,7 +20,7 @@ public function __construct(Image $image, User $user, string $context) $this->context = $context; } - public function add_part(string $html, int $position=50) + public function add_part(string $html, int $position = 50) { while (isset($this->parts[$position])) { $position++; diff --git a/ext/view/events/image_info_box_building_event.php b/ext/view/events/image_info_box_building_event.php index 206cbf25f..db9399e6b 100644 --- a/ext/view/events/image_info_box_building_event.php +++ b/ext/view/events/image_info_box_building_event.php @@ -19,7 +19,7 @@ public function __construct(Image $image, User $user) $this->user = $user; } - public function add_part(HTMLElement $html, int $position=50) + public function add_part(HTMLElement $html, int $position = 50) { while (isset($this->parts[$position])) { $position++; diff --git a/ext/view/test.php b/ext/view/test.php index 8faeab77b..320270522 100644 --- a/ext/view/test.php +++ b/ext/view/test.php @@ -47,10 +47,10 @@ public function testPrevNext() $this->assertEquals("/test/post/view/$image_id_2", $page->redirect); // When searching, we skip the middle - $page = $this->get_page("post/prev/$image_id_1", ["search"=>"test"]); + $page = $this->get_page("post/prev/$image_id_1", ["search" => "test"]); $this->assertEquals("/test/post/view/$image_id_3?#search=test", $page->redirect); - $page = $this->get_page("post/next/$image_id_3", ["search"=>"test"]); + $page = $this->get_page("post/next/$image_id_3", ["search" => "test"]); $this->assertEquals("/test/post/view/$image_id_1?#search=test", $page->redirect); // Middle image: has next and prev diff --git a/ext/wiki/info.php b/ext/wiki/info.php index 8c2583a1b..9c28808ae 100644 --- a/ext/wiki/info.php +++ b/ext/wiki/info.php @@ -11,7 +11,7 @@ class WikiInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Simple Wiki"; public string $url = self::SHIMMIE_URL; - public array $authors = [self::SHISH_NAME=>self::SHISH_EMAIL, "Luana Latte"=>"luana.latte.cat@gmail.com"]; + public array $authors = [self::SHISH_NAME => self::SHISH_EMAIL, "Luana Latte" => "luana.latte.cat@gmail.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "A simple wiki, for those who don't want the hugeness of mediawiki"; public ?string $documentation = "Standard formatting APIs are used (This will be BBCode by default)"; diff --git a/ext/wiki/main.php b/ext/wiki/main.php index c115512ab..179eacfc9 100644 --- a/ext/wiki/main.php +++ b/ext/wiki/main.php @@ -67,7 +67,7 @@ class WikiPage #[Field] public string $body; - public function __construct(array $row=null) + public function __construct(array $row = null) { //assert(!empty($row)); global $database; @@ -80,7 +80,7 @@ public function __construct(array $row=null) $this->title = $row['title']; $this->revision = (int)$row['revision']; $this->locked = bool_escape($row['locked']); - $this->exists = $database->exists("SELECT id FROM wiki_pages WHERE title = :title", ["title"=>$this->title]); + $this->exists = $database->exists("SELECT id FROM wiki_pages WHERE title = :title", ["title" => $this->title]); $this->body = $row['body']; } } @@ -248,7 +248,7 @@ public function onPageNavBuilding(PageNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="wiki") { + if ($event->parent == "wiki") { $event->add_nav_link("wiki_rules", new Link('wiki/rules'), "Rules"); $event->add_nav_link("wiki_help", new Link('ext_doc/wiki'), "Help"); } @@ -259,24 +259,24 @@ public function onWikiUpdate(WikiUpdateEvent $event) global $database, $config; $wpage = $event->wikipage; - $exists = $database->exists("SELECT id FROM wiki_pages WHERE title = :title", ["title"=>$wpage->title]); + $exists = $database->exists("SELECT id FROM wiki_pages WHERE title = :title", ["title" => $wpage->title]); try { - if ($config->get_bool(WikiConfig::ENABLE_REVISIONS) || ! $exists) { + if ($config->get_bool(WikiConfig::ENABLE_REVISIONS) || !$exists) { $database->execute( " INSERT INTO wiki_pages(owner_id, owner_ip, date, title, revision, locked, body) VALUES (:owner_id, :owner_ip, now(), :title, :revision, :locked, :body)", - ["owner_id"=>$event->user->id, "owner_ip"=>get_real_ip(), - "title"=>$wpage->title, "revision"=>$wpage->revision, "locked"=>$wpage->locked, "body"=>$wpage->body] + ["owner_id" => $event->user->id, "owner_ip" => get_real_ip(), + "title" => $wpage->title, "revision" => $wpage->revision, "locked" => $wpage->locked, "body" => $wpage->body] ); } else { $database->execute( " UPDATE wiki_pages SET owner_id=:owner_id, owner_ip=:owner_ip, date=now(), locked=:locked, body=:body WHERE title = :title ORDER BY revision DESC LIMIT 1", - ["owner_id"=>$event->user->id, "owner_ip"=>get_real_ip(), - "title"=>$wpage->title, "locked"=>$wpage->locked, "body"=>$wpage->body] + ["owner_id" => $event->user->id, "owner_ip" => get_real_ip(), + "title" => $wpage->title, "locked" => $wpage->locked, "body" => $wpage->body] ); } } catch (\Exception $e) { @@ -289,7 +289,7 @@ public function onWikiDeleteRevision(WikiDeleteRevisionEvent $event) global $database; $database->execute( "DELETE FROM wiki_pages WHERE title=:title AND revision=:rev", - ["title"=>$event->title, "rev"=>$event->revision] + ["title" => $event->title, "rev" => $event->revision] ); } @@ -336,12 +336,12 @@ public static function get_history(string $title): array WHERE LOWER(title) LIKE LOWER(:title) ORDER BY revision DESC ", - ["title"=>$title] + ["title" => $title] ); } #[Query(name: "wiki")] - public static function get_page(string $title, ?int $revision=null): WikiPage + public static function get_page(string $title, ?int $revision = null): WikiPage { global $database; // first try and get the actual page @@ -353,7 +353,7 @@ public static function get_page(string $title, ?int $revision=null): WikiPage AND (:revision = -1 OR revision = :revision) ORDER BY revision DESC ", - ["title"=>$title, "revision"=>$revision ?? -1] + ["title" => $title, "revision" => $revision ?? -1] ); // fall back to wiki:default @@ -363,7 +363,7 @@ public static function get_page(string $title, ?int $revision=null): WikiPage FROM wiki_pages WHERE title LIKE :title ORDER BY revision DESC - ", ["title"=>"wiki:default"]); + ", ["title" => "wiki:default"]); // fall further back to manual if (empty($row)) { @@ -397,7 +397,7 @@ public static function format_tag_wiki_page(WikiPage $page): string SELECT * FROM tags WHERE tag = :title - ", ["title"=>$page->title]); + ", ["title" => $page->title]); if (!empty($row)) { $template = $config->get_string(WikiConfig::TAG_PAGE_TEMPLATE); @@ -414,7 +414,7 @@ public static function format_tag_wiki_page(WikiPage $page): string FROM aliases WHERE newtag = :title ORDER BY oldtag ASC - ", ["title"=>$row["tag"]]); + ", ["title" => $row["tag"]]); if (!empty($aliases)) { $template = str_replace("{aliases}", implode(", ", $aliases), $template); @@ -431,7 +431,7 @@ public static function format_tag_wiki_page(WikiPage $page): string SELECT additional_tags FROM auto_tag WHERE tag = :title - ", ["title"=>$row["tag"]]); + ", ["title" => $row["tag"]]); if (!empty($auto_tags)) { $auto_tags = Tag::explode($auto_tags); @@ -444,7 +444,7 @@ public static function format_tag_wiki_page(WikiPage $page): string SELECT * FROM tags WHERE tag = :title - ", ["title"=>$a_tag]); + ", ["title" => $a_tag]); $tag_html = $tag_list_t->return_tag($a_row, $tag_category_dict ?? []); $f_auto_tags[] = $tag_html[1]; @@ -521,7 +521,7 @@ private function arr_diff(array $f1, array $f2, int $show_equal = 0): string /** * add to output-string, if "show_equal" is enabled */ - $out .= ($show_equal==1) + $out .= ($show_equal == 1) ? $this->formatline(($c1), ($c2), "=", $f1[ $c1 ]) : "" ; /** @@ -535,8 +535,8 @@ private function arr_diff(array $f1, array $f2, int $show_equal = 0): string /** * move the current-pointer in the left and right side */ - $c1 ++; - $c2 ++; + $c1++; + $c2++; } /** @@ -576,7 +576,7 @@ private function arr_diff(array $f1, array $f2, int $show_equal = 0): string * be used, else it will be discarded later */ #hit - if (trim($f1[$c1+$s1]) == trim($f2[$c2])) { + if (trim($f1[$c1 + $s1]) == trim($f2[$c2])) { $found = 1 ; # set flag to stop further search $s2 = 0 ; # reset right side search-pointer $c2-- ; # move back the current right, so next loop hits @@ -593,7 +593,7 @@ private function arr_diff(array $f1, array $f2, int $show_equal = 0): string /** * add current search-line to diffence-buffer */ - $b1 .= $this->formatline(($c1 + $s1), ($c2), "-", $f1[ $c1+$s1 ]); + $b1 .= $this->formatline(($c1 + $s1), ($c2), "-", $f1[ $c1 + $s1 ]); /** * mark this line as 'searched' to prevent doubles. @@ -609,7 +609,7 @@ private function arr_diff(array $f1, array $f2, int $show_equal = 0): string * * comparing current line with the searching line on the right */ - if (trim($f1[$c1]) == trim($f2[$c2+$s2])) { + if (trim($f1[$c1]) == trim($f2[$c2 + $s2])) { $found = 1 ; # flag to stop search $s1 = 0 ; # reset pointer for search $c1-- ; # move current line back, so we hit next loop @@ -622,7 +622,7 @@ private function arr_diff(array $f1, array $f2, int $show_equal = 0): string /** * add current searchline to buffer */ - $b2 .= $this->formatline(($c1), ($c2 + $s2), "+", $f2[ $c2+$s2 ]); + $b2 .= $this->formatline(($c1), ($c2 + $s2), "+", $f2[ $c2 + $s2 ]); /** * mark current line to prevent double-hits diff --git a/ext/wiki/test.php b/ext/wiki/test.php index 8f5551cc2..52da9b008 100644 --- a/ext/wiki/test.php +++ b/ext/wiki/test.php @@ -35,7 +35,7 @@ public function testAccess() $this->assert_text("This is a default page"); if ($allowed || $user == "admin") { - $this->post_page("wiki_admin/edit", ["title"=>"test"]); + $this->post_page("wiki_admin/edit", ["title" => "test"]); $this->assert_text("Editor"); } /* diff --git a/ext/wiki/theme.php b/ext/wiki/theme.php index 66b315a66..2d4dfd024 100644 --- a/ext/wiki/theme.php +++ b/ext/wiki/theme.php @@ -12,7 +12,7 @@ class WikiTheme extends Themelet * $wiki_page The wiki page, has ->title and ->body * $nav_page A wiki page object with navigation, has ->body */ - public function display_page(Page $page, WikiPage $wiki_page, ?WikiPage $nav_page=null) + public function display_page(Page $page, WikiPage $wiki_page, ?WikiPage $nav_page = null) { global $user; diff --git a/index.php b/index.php index 61b176caf..7aebad1c4 100644 --- a/index.php +++ b/index.php @@ -67,9 +67,9 @@ $_tracer->begin( $_SERVER["REQUEST_URI"] ?? "No Request", [ - "user"=>$_COOKIE["shm_user"] ?? "No User", - "ip"=>get_real_ip() ?? "No IP", - "user_agent"=>$_SERVER['HTTP_USER_AGENT'] ?? "No UA", + "user" => $_COOKIE["shm_user"] ?? "No User", + "ip" => get_real_ip() ?? "No IP", + "user_agent" => $_SERVER['HTTP_USER_AGENT'] ?? "No UA", ] ); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 8203ee969..2cd651ef3 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -111,7 +111,7 @@ private static function check_args(?array $args): array if (!$args) { return []; } - foreach ($args as $k=>$v) { + foreach ($args as $k => $v) { if (is_array($v)) { $args[$k] = $v; } else { @@ -121,7 +121,7 @@ private static function check_args(?array $args): array return $args; } - protected static function request($page_name, $get_args=null, $post_args=null): Page + protected static function request($page_name, $get_args = null, $post_args = null): Page { // use a fresh page global $page; @@ -142,12 +142,12 @@ protected static function request($page_name, $get_args=null, $post_args=null): return $page; } - protected static function get_page($page_name, $args=null): Page + protected static function get_page($page_name, $args = null): Page { return self::request($page_name, $args, null); } - protected static function post_page($page_name, $args=null): Page + protected static function post_page($page_name, $args = null): Page { return self::request($page_name, null, $args); } @@ -177,7 +177,7 @@ protected function assert_response(int $code): void $this->assertEquals($code, $page->code); } - protected function page_to_text(string $section=null): string + protected function page_to_text(string $section = null): string { global $page; if ($page->mode == PageMode::PAGE) { @@ -196,12 +196,12 @@ protected function page_to_text(string $section=null): string } } - protected function assert_text(string $text, string $section=null): void + protected function assert_text(string $text, string $section = null): void { $this->assertStringContainsString($text, $this->page_to_text($section)); } - protected function assert_no_text(string $text, string $section=null): void + protected function assert_no_text(string $text, string $section = null): void { $this->assertStringNotContainsString($text, $this->page_to_text($section)); } diff --git a/themes/danbooru/comment.theme.php b/themes/danbooru/comment.theme.php index 525fb2617..935a560c1 100644 --- a/themes/danbooru/comment.theme.php +++ b/themes/danbooru/comment.theme.php @@ -90,7 +90,7 @@ public function display_recent_comments(array $comments) // no recent comments in this theme } - protected function comment_to_html(Comment $comment, bool $trim=false): string + protected function comment_to_html(Comment $comment, bool $trim = false): string { global $user; diff --git a/themes/danbooru/themelet.class.php b/themes/danbooru/themelet.class.php index 96675fa2c..4b7a1a2ae 100644 --- a/themes/danbooru/themelet.class.php +++ b/themes/danbooru/themelet.class.php @@ -40,15 +40,15 @@ private function build_paginator(int $current_page, int $total_pages, string $ba $prev = $current_page - 1; $at_start = ($current_page <= 3 || $total_pages <= 3); - $at_end = ($current_page >= $total_pages -2); + $at_end = ($current_page >= $total_pages - 2); $first_html = $at_start ? "" : $this->gen_page_link($base_url, $query, 1, "1"); $prev_html = $at_start ? "" : $this->gen_page_link($base_url, $query, $prev, "<<"); $next_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $next, ">>"); $last_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $total_pages, "$total_pages"); - $start = $current_page-2 > 1 ? $current_page-2 : 1; - $end = $current_page+2 <= $total_pages ? $current_page+2 : $total_pages; + $start = $current_page - 2 > 1 ? $current_page - 2 : 1; + $end = $current_page + 2 <= $total_pages ? $current_page + 2 : $total_pages; $pages = []; foreach (range($start, $end) as $i) { @@ -68,6 +68,6 @@ private function build_paginator(int $current_page, int $total_pages, string $ba $ndots = ""; } - return DIV(["id"=>'paginator'], joinHTML(" ", [$prev_html, $first_html, $pdots, $pages_html, $ndots, $last_html, $next_html])); + return DIV(["id" => 'paginator'], joinHTML(" ", [$prev_html, $first_html, $pdots, $pages_html, $ndots, $last_html, $next_html])); } } diff --git a/themes/danbooru/view.theme.php b/themes/danbooru/view.theme.php index 7314829e5..28facb934 100644 --- a/themes/danbooru/view.theme.php +++ b/themes/danbooru/view.theme.php @@ -37,7 +37,7 @@ private function build_stats(Image $image): string Filesize: $h_filesize Type: $h_type"; - if ($image->length!=null) { + if ($image->length != null) { $h_length = format_milliseconds($image->length); $html .= "Length: $h_length"; } diff --git a/themes/danbooru2/comment.theme.php b/themes/danbooru2/comment.theme.php index dd43860eb..4ca014e9e 100644 --- a/themes/danbooru2/comment.theme.php +++ b/themes/danbooru2/comment.theme.php @@ -91,7 +91,7 @@ public function display_recent_comments(array $comments) } - protected function comment_to_html(Comment $comment, bool $trim=false): string + protected function comment_to_html(Comment $comment, bool $trim = false): string { global $user; diff --git a/themes/danbooru2/themelet.class.php b/themes/danbooru2/themelet.class.php index 0f1922755..7e619442b 100644 --- a/themes/danbooru2/themelet.class.php +++ b/themes/danbooru2/themelet.class.php @@ -21,7 +21,7 @@ public function display_paginator(Page $page, string $base, ?string $query, int private function gen_page_link(string $base_url, ?string $query, int $page, string $name): HTMLElement { - return A(["href"=>make_link("$base_url/$page", $query)], $name); + return A(["href" => make_link("$base_url/$page", $query)], $name); } private function gen_page_link_block(string $base_url, ?string $query, int $page, int $current_page, string $name): HTMLElement @@ -40,15 +40,15 @@ private function build_paginator(int $current_page, int $total_pages, string $ba $prev = $current_page - 1; $at_start = ($current_page <= 3 || $total_pages <= 3); - $at_end = ($current_page >= $total_pages -2); + $at_end = ($current_page >= $total_pages - 2); $first_html = $at_start ? "" : $this->gen_page_link($base_url, $query, 1, "1"); $prev_html = $at_start ? "" : $this->gen_page_link($base_url, $query, $prev, "<<"); $next_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $next, ">>"); $last_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $total_pages, "$total_pages"); - $start = $current_page-2 > 1 ? $current_page-2 : 1; - $end = $current_page+2 <= $total_pages ? $current_page+2 : $total_pages; + $start = $current_page - 2 > 1 ? $current_page - 2 : 1; + $end = $current_page + 2 <= $total_pages ? $current_page + 2 : $total_pages; $pages = []; foreach (range($start, $end) as $i) { @@ -62,12 +62,12 @@ private function build_paginator(int $current_page, int $total_pages, string $ba $pdots = ""; } - if ($total_pages > $end+1) { + if ($total_pages > $end + 1) { $ndots = "..."; } else { $ndots = ""; } - return DIV(["id"=>"paginator"], joinHTML(" ", [$prev_html, $first_html, $pdots, $pages_html, $ndots, $last_html, $next_html])); + return DIV(["id" => "paginator"], joinHTML(" ", [$prev_html, $first_html, $pdots, $pages_html, $ndots, $last_html, $next_html])); } } diff --git a/themes/danbooru2/view.theme.php b/themes/danbooru2/view.theme.php index 130eb81d0..99e3c8607 100644 --- a/themes/danbooru2/view.theme.php +++ b/themes/danbooru2/view.theme.php @@ -37,7 +37,7 @@ private function build_information(Image $image): string Type: $h_type "; - if ($image->length!=null) { + if ($image->length != null) { $h_length = format_milliseconds($image->length); $html .= "Length: $h_length"; } diff --git a/themes/futaba/comment.theme.php b/themes/futaba/comment.theme.php index ae30fed18..ec39b18e7 100644 --- a/themes/futaba/comment.theme.php +++ b/themes/futaba/comment.theme.php @@ -64,7 +64,7 @@ public function build_upload_box(): string } - protected function comment_to_html(Comment $comment, bool $trim=false): string + protected function comment_to_html(Comment $comment, bool $trim = false): string { $inner_id = $this->inner_id; // because custom themes can't add params, because PHP global $user; diff --git a/themes/futaba/themelet.class.php b/themes/futaba/themelet.class.php index cb2c937d1..e059b3c2b 100644 --- a/themes/futaba/themelet.class.php +++ b/themes/futaba/themelet.class.php @@ -55,8 +55,8 @@ public function futaba_build_paginator(int $current_page, int $total_pages, stri $next_html = $at_end ? "Next" : $this->futaba_gen_page_link($base_url, $query, $next, "Next"); //$last_html = $at_end ? "Last" : $this->futaba_gen_page_link($base_url, $query, $total_pages, "Last"); - $start = $current_page-5 > 1 ? $current_page-5 : 1; - $end = $start+10 < $total_pages ? $start+10 : $total_pages; + $start = $current_page - 5 > 1 ? $current_page - 5 : 1; + $end = $start + 10 < $total_pages ? $start + 10 : $total_pages; $pages = []; foreach (range($start, $end) as $i) { diff --git a/themes/lite/comment.theme.php b/themes/lite/comment.theme.php index ce60276c9..20717a981 100644 --- a/themes/lite/comment.theme.php +++ b/themes/lite/comment.theme.php @@ -6,7 +6,7 @@ class CustomCommentListTheme extends CommentListTheme { - protected function comment_to_html(Comment $comment, bool $trim=false): string + protected function comment_to_html(Comment $comment, bool $trim = false): string { return $this->rr(parent::comment_to_html($comment, $trim)); } diff --git a/themes/lite/page.class.php b/themes/lite/page.class.php index 212c89646..d6d606344 100644 --- a/themes/lite/page.class.php +++ b/themes/lite/page.class.php @@ -112,7 +112,7 @@ public function render() EOD; } /* end of function display_page() */ - public function block_to_html(Block $block, bool $hidable=false): string + public function block_to_html(Block $block, bool $hidable = false): string { $h = $block->header; $b = $block->body; diff --git a/themes/lite/themelet.class.php b/themes/lite/themelet.class.php index 336cefff2..39c61b720 100644 --- a/themes/lite/themelet.class.php +++ b/themes/lite/themelet.class.php @@ -34,7 +34,7 @@ public function display_paginator(Page $page, string $base, ?string $query, int $page->add_block(new Block("Paginator", $body, "main", 90)); } - public function litetheme_gen_page_link(string $base_url, ?string $query, int $page, string $name, ?string $link_class=null): HTMLElement + public function litetheme_gen_page_link(string $base_url, ?string $query, int $page, string $name, ?string $link_class = null): HTMLElement { return A(["href" => make_link("$base_url/$page", $query), "class" => $link_class], $name); } @@ -57,8 +57,8 @@ public function litetheme_build_paginator(int $current_page, int $total_pages, s $at_start = ($current_page <= 1 || $total_pages <= 1); $at_end = ($current_page >= $total_pages); - $first_html = $at_start ? SPAN(["class"=>"tab"], "First") : $this->litetheme_gen_page_link($base_url, $query, 1, "First"); - $prev_html = $at_start ? SPAN(["class"=>"tab"], "Prev") : $this->litetheme_gen_page_link($base_url, $query, $prev, "Prev"); + $first_html = $at_start ? SPAN(["class" => "tab"], "First") : $this->litetheme_gen_page_link($base_url, $query, 1, "First"); + $prev_html = $at_start ? SPAN(["class" => "tab"], "Prev") : $this->litetheme_gen_page_link($base_url, $query, $prev, "Prev"); $random_html = ""; if ($show_random) { @@ -66,11 +66,11 @@ public function litetheme_build_paginator(int $current_page, int $total_pages, s $random_html = $this->litetheme_gen_page_link($base_url, $query, $rand, "Random"); } - $next_html = $at_end ? SPAN(["class"=>"tab"], "Next") : $this->litetheme_gen_page_link($base_url, $query, $next, "Next"); - $last_html = $at_end ? SPAN(["class"=>"tab"], "Last") : $this->litetheme_gen_page_link($base_url, $query, $total_pages, "Last"); + $next_html = $at_end ? SPAN(["class" => "tab"], "Next") : $this->litetheme_gen_page_link($base_url, $query, $next, "Next"); + $last_html = $at_end ? SPAN(["class" => "tab"], "Last") : $this->litetheme_gen_page_link($base_url, $query, $total_pages, "Last"); - $start = $current_page-5 > 1 ? $current_page-5 : 1; - $end = $start+10 < $total_pages ? $start+10 : $total_pages; + $start = $current_page - 5 > 1 ? $current_page - 5 : 1; + $end = $start + 10 < $total_pages ? $start + 10 : $total_pages; $pages = []; foreach (range($start, $end) as $i) { @@ -78,7 +78,7 @@ public function litetheme_build_paginator(int $current_page, int $total_pages, s } return DIV( - ["class"=>"paginator sfoot"], + ["class" => "paginator sfoot"], $first_html, $prev_html, $random_html, diff --git a/themes/lite/view.theme.php b/themes/lite/view.theme.php index 76f95336b..02d55c963 100644 --- a/themes/lite/view.theme.php +++ b/themes/lite/view.theme.php @@ -38,10 +38,10 @@ private function build_stats(Image $image): string Filesize: $h_filesize Type: ".$h_type." "; - if ($image->video_codec!=null) { + if ($image->video_codec != null) { $html .= "Video Codec: $image->video_codec"; } - if ($image->length!=null) { + if ($image->length != null) { $h_length = format_milliseconds($image->length); $html .= "Length: $h_length"; } diff --git a/themes/rule34v2/themelet.class.php b/themes/rule34v2/themelet.class.php index e9902ad84..e26ff2294 100644 --- a/themes/rule34v2/themelet.class.php +++ b/themes/rule34v2/themelet.class.php @@ -35,14 +35,14 @@ public function build_thumb_html(Image $image): HTMLElement } $html = DIV( - ['class'=>'shm-thumb thumb', 'data-ext'=>$ext, 'data-tags'=>$tags, 'data-post-id'=>$id], + ['class' => 'shm-thumb thumb', 'data-ext' => $ext, 'data-tags' => $tags, 'data-post-id' => $id], A( - ['class'=>'shm-thumb-link', 'href'=>$view_link], - IMG(['id'=>"thumb_$id", 'title'=>$tip, 'alt'=>$tip, 'height'=>$tsize[1], 'width'=>$tsize[0], 'src'=>$thumb_link, 'loading'=>'lazy']) + ['class' => 'shm-thumb-link', 'href' => $view_link], + IMG(['id' => "thumb_$id", 'title' => $tip, 'alt' => $tip, 'height' => $tsize[1], 'width' => $tsize[0], 'src' => $thumb_link, 'loading' => 'lazy']) ), BR(), - A(['href'=>$image_link], 'File Only'), - SPAN(['class'=>'need-del'], ' - ', A(['href'=>'#', 'onclick'=>"image_hash_ban($id); return false;"], 'Ban')) + A(['href' => $image_link], 'File Only'), + SPAN(['class' => 'need-del'], ' - ', A(['href' => '#', 'onclick' => "image_hash_ban($id); return false;"], 'Ban')) ); // cache for ages; will be cleared in ext/index:onImageInfoSet diff --git a/themes/rule34v2/upload.theme.php b/themes/rule34v2/upload.theme.php index 405364e8e..bf4ccb708 100644 --- a/themes/rule34v2/upload.theme.php +++ b/themes/rule34v2/upload.theme.php @@ -44,18 +44,18 @@ public function display_page(Page $page): void $form = SHM_FORM("upload", "POST", true, "file_upload"); $form->appendChild( TABLE( - ["id"=>"large_upload_form", "class"=>"vert"], + ["id" => "large_upload_form", "class" => "vert"], TR( - TD(["width"=>"20"], rawHTML("Common Tags")), - TD(["colspan"=>"5"], INPUT(["name"=>"tags", "type"=>"text", "placeholder"=>"tagme", "autocomplete"=>"off"])) + TD(["width" => "20"], rawHTML("Common Tags")), + TD(["colspan" => "5"], INPUT(["name" => "tags", "type" => "text", "placeholder" => "tagme", "autocomplete" => "off"])) ), TR( - TD(["width"=>"20"], rawHTML("Common Source")), - TD(["colspan"=>"5"], INPUT(["name"=>"source", "type"=>"text"])) + TD(["width" => "20"], rawHTML("Common Source")), + TD(["colspan" => "5"], INPUT(["name" => "source", "type" => "text"])) ), $upload_list, TR( - TD(["colspan"=>"6"], INPUT(["id"=>"uploadbutton", "type"=>"submit", "value"=>"Post"])) + TD(["colspan" => "6"], INPUT(["id" => "uploadbutton", "type" => "submit", "value" => "Post"])) ), ) ); @@ -79,7 +79,7 @@ public function display_page(Page $page): void protected function build_upload_block(): HTMLElement { - return A(["href"=>make_link("upload"), "style"=>'font-size: 2em; display: block;'], "Upload"); + return A(["href" => make_link("upload"), "style" => 'font-size: 2em; display: block;'], "Upload"); } protected function h_upload_list_1(): HTMLElement @@ -92,18 +92,18 @@ protected function h_upload_list_1(): HTMLElement $upload_list->appendChild( TR( - TD(["colspan"=>$tl_enabled ? 2 : 4], "Files"), - $tl_enabled ? TD(["colspan"=>"2"], "URLs") : emptyHTML(), - TD(["colspan"=>"2"], "Post-Specific Tags"), + TD(["colspan" => $tl_enabled ? 2 : 4], "Files"), + $tl_enabled ? TD(["colspan" => "2"], "URLs") : emptyHTML(), + TD(["colspan" => "2"], "Post-Specific Tags"), ) ); - for ($i=0; $i<$upload_count; $i++) { + for ($i = 0; $i < $upload_count; $i++) { $upload_list->appendChild( TR( - TD(["colspan"=>$tl_enabled ? 2 : 4], INPUT(["type"=>"file", "name"=>"data{$i}[]", "accept"=>$accept, "multiple"=>true])), - $tl_enabled ? TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"url{$i}"])) : emptyHTML(), - TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"tags{$i}", "autocomplete"=>"off"])), + TD(["colspan" => $tl_enabled ? 2 : 4], INPUT(["type" => "file", "name" => "data{$i}[]", "accept" => $accept, "multiple" => true])), + $tl_enabled ? TD(["colspan" => "2"], INPUT(["type" => "text", "name" => "url{$i}"])) : emptyHTML(), + TD(["colspan" => "2"], INPUT(["type" => "text", "name" => "tags{$i}", "autocomplete" => "off"])), ) ); } diff --git a/themes/rule34v2/user.theme.php b/themes/rule34v2/user.theme.php index 56e2219fd..f621e1579 100644 --- a/themes/rule34v2/user.theme.php +++ b/themes/rule34v2/user.theme.php @@ -73,30 +73,30 @@ public function display_signup_page(Page $page) $form = SHM_SIMPLE_FORM( "user_admin/create", TABLE( - ["class"=>"form"], + ["class" => "form"], TBODY( TR( TH("Name"), - TD(INPUT(["type"=>'text', "name"=>'name', "required"=>true])) + TD(INPUT(["type" => 'text', "name" => 'name', "required" => true])) ), TR( TH("Password"), - TD(INPUT(["type"=>'password', "name"=>'pass1', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass1', "required" => true])) ), TR( TH(rawHTML("Repeat Password")), - TD(INPUT(["type"=>'password', "name"=>'pass2', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass2', "required" => true])) ), TR( TH(rawHTML("Email")), - TD(INPUT(["type"=>'email', "name"=>'email', "required"=>true])) + TD(INPUT(["type" => 'email', "name" => 'email', "required" => true])) ), TR( - TD(["colspan"=>"2"], rawHTML(captcha_get_html())) + TD(["colspan" => "2"], rawHTML(captcha_get_html())) ), ), TFOOT( - TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Create Account"]))) + TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => "Create Account"]))) ) ) ); @@ -119,30 +119,30 @@ public function display_user_creator() $form = SHM_SIMPLE_FORM( "user_admin/create_other", TABLE( - ["class"=>"form"], + ["class" => "form"], TBODY( TR( TH("Name"), - TD(INPUT(["type"=>'text', "name"=>'name', "required"=>true])) + TD(INPUT(["type" => 'text', "name" => 'name', "required" => true])) ), TR( TH("Password"), - TD(INPUT(["type"=>'password', "name"=>'pass1', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass1', "required" => true])) ), TR( TH(rawHTML("Repeat Password")), - TD(INPUT(["type"=>'password', "name"=>'pass2', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass2', "required" => true])) ), TR( TH(rawHTML("Email")), - TD(INPUT(["type"=>'email', "name"=>'email'])) + TD(INPUT(["type" => 'email', "name" => 'email'])) ), TR( - TD(["colspan"=>2], rawHTML("(Email is optional for admin-created accounts)")), + TD(["colspan" => 2], rawHTML("(Email is optional for admin-created accounts)")), ), ), TFOOT( - TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Create Account"]))) + TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => "Create Account"]))) ) ) );
" . $middle . "
" . $this->theme->build_thumb_html($duplicate); throw new ImageReplaceException($error); @@ -306,7 +306,7 @@ public function onSetupBuilding(SetupBuildingEvent $event) $sb->add_int_option(ImageConfig::THUMB_QUALITY, "Quality", true); $sb->add_int_option(ImageConfig::THUMB_SCALING, "High-DPI Scale %", true); - if ($config->get_string(ImageConfig::THUMB_MIME)===MimeType::JPEG) { + if ($config->get_string(ImageConfig::THUMB_MIME) === MimeType::JPEG) { $sb->add_color_option(ImageConfig::THUMB_ALPHA_COLOR, "Alpha Conversion Color", true); } diff --git a/ext/image/theme.php b/ext/image/theme.php index 3a016fc72..9d8fd9d47 100644 --- a/ext/image/theme.php +++ b/ext/image/theme.php @@ -16,8 +16,8 @@ public function get_deleter_html(int $image_id): string { return (string)"".SHM_SIMPLE_FORM( "image/delete", - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]), - INPUT(["type"=>'submit', "value"=>'Delete', "onclick"=>'return confirm("Delete the image?");', "id"=>"image_delete_button"]), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), + INPUT(["type" => 'submit', "value" => 'Delete', "onclick" => 'return confirm("Delete the image?");', "id" => "image_delete_button"]), ).""; } @@ -28,8 +28,8 @@ public function get_replace_html(int $image_id): string { return (string)SHM_SIMPLE_FORM( "image/replace", - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]), - INPUT(["type"=>'submit', "value"=>'Replace']), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), + INPUT(["type" => 'submit', "value" => 'Replace']), ); } } diff --git a/ext/image_hash_ban/info.php b/ext/image_hash_ban/info.php index 339fa5ce2..1feefb557 100644 --- a/ext/image_hash_ban/info.php +++ b/ext/image_hash_ban/info.php @@ -11,7 +11,7 @@ class ImageBanInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Post Hash Ban"; public string $url = "http://atravelinggeek.com/"; - public array $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"]; + public array $authors = ["ATravelingGeek" => "atg@atravelinggeek.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "Ban images based on their hash"; public ?string $version = "0.1, October 21, 2007"; diff --git a/ext/image_hash_ban/main.php b/ext/image_hash_ban/main.php index c50604cf1..810b3a8e2 100644 --- a/ext/image_hash_ban/main.php +++ b/ext/image_hash_ban/main.php @@ -79,7 +79,7 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) public function onDataUpload(DataUploadEvent $event) { global $database; - $row = $database->get_row("SELECT * FROM image_bans WHERE hash = :hash", ["hash"=>$event->hash]); + $row = $database->get_row("SELECT * FROM image_bans WHERE hash = :hash", ["hash" => $event->hash]); if ($row) { log_info("image_hash_ban", "Attempted to upload a blocked image ({$event->hash} - {$row['reason']})"); throw new UploadException("Post ".html_escape($row["hash"])." has been banned, reason: ".format_text($row["reason"])); @@ -94,7 +94,7 @@ public function onPageRequest(PageRequestEvent $event) if ($user->can(Permissions::BAN_IMAGE)) { if ($event->get_arg(0) == "add") { $user->ensure_authed(); - $input = validate_input(["c_hash"=>"optional,string", "c_reason"=>"string", "c_image_id"=>"optional,int"]); + $input = validate_input(["c_hash" => "optional,string", "c_reason" => "string", "c_image_id" => "optional,int"]); $image = isset($input['c_image_id']) ? Image::by_id($input['c_image_id']) : null; $hash = isset($input["c_hash"]) ? $input["c_hash"] : $image->hash; $reason = isset($input['c_reason']) ? $input['c_reason'] : "DNP"; @@ -113,7 +113,7 @@ public function onPageRequest(PageRequestEvent $event) } } elseif ($event->get_arg(0) == "remove") { $user->ensure_authed(); - $input = validate_input(["d_hash"=>"string"]); + $input = validate_input(["d_hash" => "string"]); send_event(new RemoveImageHashBanEvent($input['d_hash'])); $page->flash("Post ban removed"); $page->set_mode(PageMode::REDIRECT); @@ -131,7 +131,7 @@ public function onPageRequest(PageRequestEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::BAN_IMAGE)) { $event->add_nav_link("image_bans", new Link('image_hash_ban/list/1'), "Post Bans", NavLink::is_active(["image_hash_ban"])); } @@ -151,7 +151,7 @@ public function onAddImageHashBan(AddImageHashBanEvent $event) global $database; $database->execute( "INSERT INTO image_bans (hash, reason, date) VALUES (:hash, :reason, now())", - ["hash"=>$event->hash, "reason"=>$event->reason] + ["hash" => $event->hash, "reason" => $event->reason] ); log_info("image_hash_ban", "Banned hash {$event->hash} because '{$event->reason}'"); } @@ -159,7 +159,7 @@ public function onAddImageHashBan(AddImageHashBanEvent $event) public function onRemoveImageHashBan(RemoveImageHashBanEvent $event) { global $database; - $database->execute("DELETE FROM image_bans WHERE hash = :hash", ["hash"=>$event->hash]); + $database->execute("DELETE FROM image_bans WHERE hash = :hash", ["hash" => $event->hash]); } public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) diff --git a/ext/image_hash_ban/theme.php b/ext/image_hash_ban/theme.php index 723d197a1..7d347d38a 100644 --- a/ext/image_hash_ban/theme.php +++ b/ext/image_hash_ban/theme.php @@ -26,10 +26,10 @@ public function get_buttons_html(Image $image): string { return (string)SHM_SIMPLE_FORM( "image_hash_ban/add", - INPUT(["type"=>'hidden', "name"=>'c_hash', "value"=>$image->hash]), - INPUT(["type"=>'hidden', "name"=>'c_image_id', "value"=>$image->id]), - INPUT(["type"=>'text', "name"=>'c_reason']), - INPUT(["type"=>'submit', "value"=>'Ban Hash and Delete Post']), + INPUT(["type" => 'hidden', "name" => 'c_hash', "value" => $image->hash]), + INPUT(["type" => 'hidden', "name" => 'c_image_id', "value" => $image->id]), + INPUT(["type" => 'text', "name" => 'c_reason']), + INPUT(["type" => 'submit', "value" => 'Ban Hash and Delete Post']), ); } } diff --git a/ext/image_view_counter/info.php b/ext/image_view_counter/info.php index 7a4a42f4f..48558ac3d 100644 --- a/ext/image_view_counter/info.php +++ b/ext/image_view_counter/info.php @@ -11,7 +11,7 @@ class ImageViewCounterInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Post View Counter"; public string $url = "http://www.drudexsoftware.com/"; - public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; + public array $authors = ["Drudex Software" => "support@drudexsoftware.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "Tracks & displays how many times a post is viewed"; public ?string $documentation = diff --git a/ext/image_view_counter/main.php b/ext/image_view_counter/main.php index 667d74490..269bd0950 100644 --- a/ext/image_view_counter/main.php +++ b/ext/image_view_counter/main.php @@ -113,7 +113,7 @@ public function onPageRequest(PageRequestEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="posts") { + if ($event->parent == "posts") { $event->add_nav_link("sort_by_visits", new Link('popular_images'), "Popular Posts"); } } diff --git a/ext/index/events.php b/ext/index/events.php index 235cfc4e5..f89f1eb75 100644 --- a/ext/index/events.php +++ b/ext/index/events.php @@ -21,7 +21,7 @@ class SearchTermParseEvent extends Event public array $tag_conditions = []; public ?string $order = null; - public function __construct(int $id, string $term=null, array $context=[]) + public function __construct(int $id, string $term = null, array $context = []) { parent::__construct(); @@ -75,7 +75,7 @@ public function __construct(array $search) $this->search_terms = $search; } - public function add_control(string $html, int $position=50) + public function add_control(string $html, int $position = 50) { while (isset($this->parts[$position])) { $position++; diff --git a/ext/index/main.php b/ext/index/main.php index 3f6582737..d8c57900a 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -79,14 +79,14 @@ public function onPageRequest(PageRequestEvent $event) // extra caching for the first few post/list pages $images = $cache->get("post-list:$page_number"); if (is_null($images)) { - $images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms); + $images = Image::find_images(($page_number - 1) * $page_size, $page_size, $search_terms); $cache->set("post-list:$page_number", $images, 60); } } } if (!$images) { - $images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms); + $images = Image::find_images(($page_number - 1) * $page_size, $page_size, $search_terms); } } catch (PermissionDeniedException $pde) { $this->theme->display_error(403, "Permission denied", $pde->error); @@ -135,14 +135,14 @@ public function onPageNavBuilding(PageNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="posts") { + if ($event->parent == "posts") { $event->add_nav_link("posts_all", new Link('post/list'), "All"); } } public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $event->add_block(new Block("General", $this->theme->get_help_html()), 0); } } @@ -186,13 +186,13 @@ public function onSearchTermParse(SearchTermParseEvent $event) ); } elseif (preg_match("/^ratio([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+):(\d+)$/i", $event->term, $matches)) { $cmp = preg_replace('/^:/', '=', $matches[1]); - $args = ["width{$event->id}"=>int_escape($matches[2]), "height{$event->id}"=>int_escape($matches[3])]; + $args = ["width{$event->id}" => int_escape($matches[2]), "height{$event->id}" => int_escape($matches[3])]; $event->add_querylet(new Querylet("width / :width{$event->id} $cmp height / :height{$event->id}", $args)); } elseif (preg_match("/^(filesize|id)([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+[kmg]?b?)$/i", $event->term, $matches)) { $col = $matches[1]; $cmp = ltrim($matches[2], ":") ?: "="; $val = parse_shorthand_int($matches[3]); - $event->add_querylet(new Querylet("images.$col $cmp :val{$event->id}", ["val{$event->id}"=>$val])); + $event->add_querylet(new Querylet("images.$col $cmp :val{$event->id}", ["val{$event->id}" => $val])); } elseif (preg_match("/^(hash|md5)[=|:]([0-9a-fA-F]*)$/i", $event->term, $matches)) { $hash = strtolower($matches[2]); $event->add_querylet(new Querylet('images.hash = :hash', ["hash" => $hash])); @@ -201,7 +201,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) $event->add_querylet(new Querylet('images.phash = :phash', ["phash" => $phash])); } elseif (preg_match("/^(filename|name)[=|:](.+)$/i", $event->term, $matches)) { $filename = strtolower($matches[2]); - $event->add_querylet(new Querylet("lower(images.filename) LIKE :filename{$event->id}", ["filename{$event->id}"=>"%$filename%"])); + $event->add_querylet(new Querylet("lower(images.filename) LIKE :filename{$event->id}", ["filename{$event->id}" => "%$filename%"])); } elseif (preg_match("/^(source)[=|:](.*)$/i", $event->term, $matches)) { $source = strtolower($matches[2]); @@ -209,27 +209,27 @@ public function onSearchTermParse(SearchTermParseEvent $event) $not = ($source == "any" ? "NOT" : ""); $event->add_querylet(new Querylet("images.source IS $not NULL")); } else { - $event->add_querylet(new Querylet('images.source LIKE :src', ["src"=>"%$source%"])); + $event->add_querylet(new Querylet('images.source LIKE :src', ["src" => "%$source%"])); } } elseif (preg_match("/^posted([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])([0-9-]*)$/i", $event->term, $matches)) { // TODO Make this able to search = without needing a time component. $cmp = ltrim($matches[1], ":") ?: "="; $val = $matches[2]; - $event->add_querylet(new Querylet("images.posted $cmp :posted{$event->id}", ["posted{$event->id}"=>$val])); + $event->add_querylet(new Querylet("images.posted $cmp :posted{$event->id}", ["posted{$event->id}" => $val])); } elseif (preg_match("/^size([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)x(\d+)$/i", $event->term, $matches)) { $cmp = ltrim($matches[1], ":") ?: "="; - $args = ["width{$event->id}"=>int_escape($matches[2]), "height{$event->id}"=>int_escape($matches[3])]; + $args = ["width{$event->id}" => int_escape($matches[2]), "height{$event->id}" => int_escape($matches[3])]; $event->add_querylet(new Querylet("width $cmp :width{$event->id} AND height $cmp :height{$event->id}", $args)); } elseif (preg_match("/^width([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)$/i", $event->term, $matches)) { $cmp = ltrim($matches[1], ":") ?: "="; - $event->add_querylet(new Querylet("width $cmp :width{$event->id}", ["width{$event->id}"=>int_escape($matches[2])])); + $event->add_querylet(new Querylet("width $cmp :width{$event->id}", ["width{$event->id}" => int_escape($matches[2])])); } elseif (preg_match("/^height([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+)$/i", $event->term, $matches)) { $cmp = ltrim($matches[1], ":") ?: "="; - $event->add_querylet(new Querylet("height $cmp :height{$event->id}", ["height{$event->id}"=>int_escape($matches[2])])); + $event->add_querylet(new Querylet("height $cmp :height{$event->id}", ["height{$event->id}" => int_escape($matches[2])])); } elseif (preg_match("/^length([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(.+)$/i", $event->term, $matches)) { $value = parse_to_milliseconds($matches[2]); $cmp = ltrim($matches[1], ":") ?: "="; - $event->add_querylet(new Querylet("length $cmp :length{$event->id}", ["length{$event->id}"=>$value])); + $event->add_querylet(new Querylet("length $cmp :length{$event->id}", ["length{$event->id}" => $value])); } elseif (preg_match("/^order[=|:](id|width|height|length|filesize|filename)[_]?(desc|asc)?$/i", $event->term, $matches)) { $ord = strtolower($matches[1]); $default_order_for_column = preg_match("/^(id|filename)$/", $matches[1]) ? "ASC" : "DESC"; diff --git a/ext/ipban/main.php b/ext/ipban/main.php index ce97c6afb..6174d02f7 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -29,10 +29,10 @@ public function __construct(\FFSPHP\PDO $db) $this->set_columns([ new InetColumn("ip", "IP"), new EnumColumn("mode", "Mode", [ - "Block"=>"block", - "Firewall"=>"firewall", - "Ghost"=>"ghost", - "Anon Ghost"=>"anon-ghost" + "Block" => "block", + "Firewall" => "firewall", + "Ghost" => "ghost", + "Anon Ghost" => "anon-ghost" ]), new TextColumn("reason", "Reason"), new StringColumn("banner", "Banner"), @@ -135,7 +135,7 @@ public function onUserLogin(UserLoginEvent $event) // If an active ban is found, act on it if (!is_null($active_ban_id)) { - $row = $database->get_row("SELECT * FROM bans WHERE id=:id", ["id"=>$active_ban_id]); + $row = $database->get_row("SELECT * FROM bans WHERE id=:id", ["id" => $active_ban_id]); if (empty($row)) { return; } @@ -159,14 +159,14 @@ public function onUserLogin(UserLoginEvent $event) $b = new Block(null, $msg, "main", 0); $b->is_content = false; $page->add_block($b); - $page->add_cookie("nocache", "Ghost Banned", time()+60*60*2, "/"); + $page->add_cookie("nocache", "Ghost Banned", time() + 60 * 60 * 2, "/"); $event->user->class = $_shm_user_classes["ghost"]; } elseif ($row["mode"] == "anon-ghost") { if ($event->user->is_anonymous()) { $b = new Block(null, $msg, "main", 0); $b->is_content = false; $page->add_block($b); - $page->add_cookie("nocache", "Ghost Banned", time()+60*60*2, "/"); + $page->add_cookie("nocache", "Ghost Banned", time() + 60 * 60 * 2, "/"); $event->user->class = $_shm_user_classes["ghost"]; } } else { @@ -184,14 +184,14 @@ public function onPageRequest(PageRequestEvent $event) if ($user->can(Permissions::BAN_IP)) { if ($event->get_arg(0) == "create") { $user->ensure_authed(); - $input = validate_input(["c_ip"=>"string", "c_mode"=>"string", "c_reason"=>"string", "c_expires"=>"optional,date"]); + $input = validate_input(["c_ip" => "string", "c_mode" => "string", "c_reason" => "string", "c_expires" => "optional,date"]); send_event(new AddIPBanEvent($input['c_ip'], $input['c_mode'], $input['c_reason'], $input['c_expires'])); $page->flash("Ban for {$input['c_ip']} added"); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link("ip_ban/list")); } elseif ($event->get_arg(0) == "delete") { $user->ensure_authed(); - $input = validate_input(["d_id"=>"int"]); + $input = validate_input(["d_id" => "int"]); send_event(new RemoveIPBanEvent($input['d_id'])); $page->flash("Ban removed"); $page->set_mode(PageMode::REDIRECT); @@ -227,7 +227,7 @@ public function onSetupBuilding(SetupBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::BAN_IP)) { $event->add_nav_link("ip_bans", new Link('ip_ban/list'), "IP Bans", NavLink::is_active(["ip_ban"])); } @@ -246,7 +246,7 @@ public function onAddIPBan(AddIPBanEvent $event) { global $cache, $user, $database; $sql = "INSERT INTO bans (ip, mode, reason, expires, banner_id) VALUES (:ip, :mode, :reason, :expires, :admin_id)"; - $database->execute($sql, ["ip"=>$event->ip, "mode"=>$event->mode, "reason"=>$event->reason, "expires"=>$event->expires, "admin_id"=>$user->id]); + $database->execute($sql, ["ip" => $event->ip, "mode" => $event->mode, "reason" => $event->reason, "expires" => $event->expires, "admin_id" => $user->id]); $cache->delete("ip_bans"); $cache->delete("network_bans"); log_info("ipban", "Banned ({$event->mode}) {$event->ip} because '{$event->reason}' until {$event->expires}"); @@ -255,9 +255,9 @@ public function onAddIPBan(AddIPBanEvent $event) public function onRemoveIPBan(RemoveIPBanEvent $event) { global $cache, $database; - $ban = $database->get_row("SELECT * FROM bans WHERE id = :id", ["id"=>$event->id]); + $ban = $database->get_row("SELECT * FROM bans WHERE id = :id", ["id" => $event->id]); if ($ban) { - $database->execute("DELETE FROM bans WHERE id = :id", ["id"=>$event->id]); + $database->execute("DELETE FROM bans WHERE id = :id", ["id" => $event->id]); $cache->delete("ip_bans"); $cache->delete("network_bans"); log_info("ipban", "Removed {$ban['ip']}'s ban"); diff --git a/ext/ipban/test.php b/ext/ipban/test.php index 4dbb9f1ee..6beb6edec 100644 --- a/ext/ipban/test.php +++ b/ext/ipban/test.php @@ -56,7 +56,7 @@ public function test_all() { // just test it doesn't crash for now $this->log_in_as_admin(); - $page = $this->get_page('ip_ban/list', ['r_all'=>'on']); + $page = $this->get_page('ip_ban/list', ['r_all' => 'on']); $this->assertEquals(200, $page->code); } } diff --git a/ext/link_image/info.php b/ext/link_image/info.php index c0cedfe52..c735b5243 100644 --- a/ext/link_image/info.php +++ b/ext/link_image/info.php @@ -10,7 +10,7 @@ class LinkImageInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Link to Post"; - public array $authors = ["Artanis"=>"artanis.00@gmail.com"]; + public array $authors = ["Artanis" => "artanis.00@gmail.com"]; public string $description = "Show various forms of link to each image, for copy & paste"; public string $license = self::LICENSE_GPLV2; public ?string $documentation = "There is one option in Board Config: Text Link Format. diff --git a/ext/link_image/theme.php b/ext/link_image/theme.php index fe4a7b68a..dfe9e4c77 100644 --- a/ext/link_image/theme.php +++ b/ext/link_image/theme.php @@ -62,7 +62,7 @@ public function links_block(Page $page, $data) protected function url(string $url, string $content, string $type): string { if (empty($content)) { - $content=$url; + $content = $url; } switch ($type) { @@ -93,7 +93,7 @@ protected function img(string $src, string $type): string return $text; } - protected function link_code(string $label, string $content, $id=null): string + protected function link_code(string $label, string $content, $id = null): string { return "
$h_lastLetter"; } @@ -395,7 +395,7 @@ private function build_tag_popularity(): string FROM tags WHERE count >= :tags_min ORDER BY count DESC, tag ASC - ", ["tags_min"=>$tags_min]); + ", ["tags_min" => $tags_min]); $html = "Results grouped by log10(n)"; $lastLog = ""; @@ -464,7 +464,7 @@ private function add_split_tags_block(Page $page, Image $image) AND image_tags.image_id = :image_id ORDER BY tags.count DESC "; - $args = ["image_id"=>$image->id]; + $args = ["image_id" => $image->id]; $tags = $database->get_all($query, $args); if (count($tags) > 0) { @@ -483,7 +483,7 @@ private function add_tags_block(Page $page, Image $image) AND image_tags.image_id = :image_id ORDER BY tags.count DESC "; - $args = ["image_id"=>$image->id]; + $args = ["image_id" => $image->id]; $tags = $database->get_all($query, $args); if (count($tags) > 0) { @@ -518,7 +518,7 @@ private function add_popular_block(Page $page) "; } - $args = ["popular_tag_list_length"=>$config->get_int(TagListConfig::POPULAR_TAG_LIST_LENGTH)]; + $args = ["popular_tag_list_length" => $config->get_int(TagListConfig::POPULAR_TAG_LIST_LENGTH)]; $tags = $database->get_all($query, $args); diff --git a/ext/tag_list/test.php b/ext/tag_list/test.php index f054a72eb..1f04f98a9 100644 --- a/ext/tag_list/test.php +++ b/ext/tag_list/test.php @@ -28,16 +28,16 @@ public function testTagList() public function testMinCount() { foreach ($this->pages as $page) { - $this->get_page("tags/$page", ["mincount"=>999999]); + $this->get_page("tags/$page", ["mincount" => 999999]); $this->assert_title("Tag List"); - $this->get_page("tags/$page", ["mincount"=>1]); + $this->get_page("tags/$page", ["mincount" => 1]); $this->assert_title("Tag List"); - $this->get_page("tags/$page", ["mincount"=>0]); + $this->get_page("tags/$page", ["mincount" => 0]); $this->assert_title("Tag List"); - $this->get_page("tags/$page", ["mincount"=>-1]); + $this->get_page("tags/$page", ["mincount" => -1]); $this->assert_title("Tag List"); } } diff --git a/ext/tag_tools/test.php b/ext/tag_tools/test.php index e99acbf41..8d7cc5057 100644 --- a/ext/tag_tools/test.php +++ b/ext/tag_tools/test.php @@ -43,7 +43,7 @@ public function testRecount() send_event(new UserLoginEvent(User::by_name(self::$admin_name))); $database->execute( "INSERT INTO tags(tag, count) VALUES(:tag, :count)", - ["tag"=>"tes$ts", "count"=>42] + ["tag" => "tes$ts", "count" => 42] ); // Fix @@ -54,7 +54,7 @@ public function testRecount() 0, $database->get_one( "SELECT count FROM tags WHERE tag = :tag", - ["tag"=>"tes$ts"] + ["tag" => "tes$ts"] ) ); } diff --git a/ext/tag_tools/theme.php b/ext/tag_tools/theme.php index 2f52c6b45..7cf2ea727 100644 --- a/ext/tag_tools/theme.php +++ b/ext/tag_tools/theme.php @@ -8,7 +8,7 @@ class TagToolsTheme extends Themelet { - protected function button(string $name, string $action, bool $protected=false): string + protected function button(string $name, string $action, bool $protected = false): string { $c_protected = $protected ? " protected" : ""; $html = make_form(make_link("admin/$action"), "POST", false, "admin$c_protected"); @@ -39,7 +39,7 @@ public function display_form() $html = (string)SHM_SIMPLE_FORM( "admin/set_tag_case", - INPUT(["type"=>'text', "name"=>'tag', "placeholder"=>'Enter tag with correct case', "autocomplete"=>'off']), + INPUT(["type" => 'text', "name" => 'tag', "placeholder" => 'Enter tag with correct case', "autocomplete" => 'off']), SHM_SUBMIT('Set Tag Case'), ); $page->add_block(new Block("Set Tag Case", $html)); diff --git a/ext/tagger_xml/info.php b/ext/tagger_xml/info.php index c7754babb..3de7720d0 100644 --- a/ext/tagger_xml/info.php +++ b/ext/tagger_xml/info.php @@ -10,7 +10,7 @@ class TaggerXMLInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Tagger AJAX backend"; - public array $authors = ["Artanis (Erik Youngren)"=>"artanis.00@gmail.com"]; + public array $authors = ["Artanis (Erik Youngren)" => "artanis.00@gmail.com"]; public ExtensionVisibility $visibility = ExtensionVisibility::HIDDEN; public string $description = "Advanced Tagging v2 AJAX backend"; } diff --git a/ext/tagger_xml/main.php b/ext/tagger_xml/main.php index e945e2eb2..6e577d553 100644 --- a/ext/tagger_xml/main.php +++ b/ext/tagger_xml/main.php @@ -19,7 +19,7 @@ public function onPageRequest(PageRequestEvent $event) //$match_tags = null; //$image_tags = null; - $tags=null; + $tags = null; if (isset($_GET['s'])) { // tagger/tags[/...]?s=$string // return matching tags in XML form $tags = $this->match_tag_list($_GET['s']); @@ -58,7 +58,7 @@ private function match_tag_list(string $s): string // $exclude = $event->get_arg(1)? "AND NOT IN ".$this->image_tags($event->get_arg(1)) : null; // Hidden Tags - $hidden = $config->get_string('ext-tagger_show-hidden', 'N')=='N' ? + $hidden = $config->get_string('ext-tagger_show-hidden', 'N') == 'N' ? "AND substring(tag,1,1) != '.'" : null; $q_where = "WHERE {$match} {$hidden} AND count > 0"; @@ -69,7 +69,7 @@ private function match_tag_list(string $s): string $q_from = "FROM (SELECT * FROM `tags` {$q_where} ". "ORDER BY count DESC LIMIT {$limit_rows} OFFSET 0) AS `c_tags`"; $q_where = null; - $count = ["max"=>$count]; + $count = ["max" => $count]; } else { $q_from = "FROM `tags`"; $count = []; @@ -93,17 +93,17 @@ private function image_tag_list(int $image_id): string $tags = $database->execute(" SELECT tags.* FROM image_tags JOIN tags ON image_tags.tag_id = tags.id - WHERE image_id=:image_id ORDER BY tag", ['image_id'=>$image_id]); + WHERE image_id=:image_id ORDER BY tag", ['image_id' => $image_id]); return $this->list_to_xml($tags, "image", (string)$image_id); } - private function list_to_xml(\FFSPHP\PDOStatement $tags, string $type, string $query, ?array $misc=[]): string + private function list_to_xml(\FFSPHP\PDOStatement $tags, string $type, string $query, ?array $misc = []): string { $props = [ - "id"=>$type, - "query"=>$query, + "id" => $type, + "query" => $query, // @phpstan-ignore-next-line - "rows"=>$tags->_numOfRows + "rows" => $tags->_numOfRows ]; if (!is_null($misc)) { foreach ($misc as $attr => $val) { @@ -113,7 +113,7 @@ private function list_to_xml(\FFSPHP\PDOStatement $tags, string $type, string $q $list = new \MicroHTML\HTMLElement("list", [$props]); foreach ($tags as $tag) { - $list->appendChild(new \MicroHTML\HTMLElement("tag", [["id"=>$tag["id"], "count"=>$tag["count"]], $tag["tag"]])); + $list->appendChild(new \MicroHTML\HTMLElement("tag", [["id" => $tag["id"], "count" => $tag["count"]], $tag["tag"]])); } return (string)($list); diff --git a/ext/tips/info.php b/ext/tips/info.php index d8dd65cd3..01fd91aa0 100644 --- a/ext/tips/info.php +++ b/ext/tips/info.php @@ -10,7 +10,7 @@ class TipsInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Random Tip"; - public array $authors = ["Sein Kraft"=>"mail@seinkraft.info"]; + public array $authors = ["Sein Kraft" => "mail@seinkraft.info"]; public string $license = "GPLv2"; public string $description = "Show a random line of text in the subheader space"; public ?string $documentation = "Formatting is done with HTML"; diff --git a/ext/tips/main.php b/ext/tips/main.php index 172184a64..14281ec05 100644 --- a/ext/tips/main.php +++ b/ext/tips/main.php @@ -50,7 +50,7 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) " INSERT INTO tips (enable, image, text) VALUES (:enable, :image, :text)", - ["enable"=>true, "image"=>"coins.png", "text"=>"Do you like this extension? Please support us for developing new ones. Donate through paypal."] + ["enable" => true, "image" => "coins.png", "text" => "Do you like this extension? Please support us for developing new ones. Donate through paypal."] ); $this->set_version("ext_tips_version", 2); @@ -101,7 +101,7 @@ public function onPageRequest(PageRequestEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::TIPS_ADMIN)) { $event->add_nav_link("tips", new Link('tips/list'), "Tips Editor"); } @@ -141,7 +141,7 @@ public function onCreateTip(CreateTipEvent $event) " INSERT INTO tips (enable, image, text) VALUES (:enable, :image, :text)", - ["enable"=>$event->enable, "image"=>$event->image, "text"=>$event->text] + ["enable" => $event->enable, "image" => $event->image, "text" => $event->text] ); } @@ -158,7 +158,7 @@ private function getTip() WHERE enable = :true ORDER BY RAND() LIMIT 1 - ", ["true"=>true]); + ", ["true" => true]); if ($tip) { $this->theme->showTip($url, $tip); @@ -181,16 +181,16 @@ private function setStatus(int $tipID) { global $database; - $tip = $database->get_row("SELECT * FROM tips WHERE id = :id ", ["id"=>$tipID]); + $tip = $database->get_row("SELECT * FROM tips WHERE id = :id ", ["id" => $tipID]); $enable = bool_escape($tip['enable']); - $database->execute("UPDATE tips SET enable = :enable WHERE id = :id", ["enable"=>$enable, "id"=>$tipID]); + $database->execute("UPDATE tips SET enable = :enable WHERE id = :id", ["enable" => $enable, "id" => $tipID]); } public function onDeleteTip(DeleteTipEvent $event) { global $database; - $database->execute("DELETE FROM tips WHERE id = :id", ["id"=>$event->tip_id]); + $database->execute("DELETE FROM tips WHERE id = :id", ["id" => $event->tip_id]); } } diff --git a/ext/transcode/info.php b/ext/transcode/info.php index f79529e27..7ec5c88f9 100644 --- a/ext/transcode/info.php +++ b/ext/transcode/info.php @@ -10,7 +10,7 @@ class TranscodeImageInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Transcode Image"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Allows admins to automatically and manually transcode images."; public ?string $documentation = diff --git a/ext/transcode/main.php b/ext/transcode/main.php index 29ee67850..304ede255 100644 --- a/ext/transcode/main.php +++ b/ext/transcode/main.php @@ -98,7 +98,7 @@ public static function get_enabled_mimes(): array public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { if ($this->get_version(TranscodeConfig::VERSION) < 1) { - $old_extensions =[]; + $old_extensions = []; foreach (array_values(self::INPUT_MIMES) as $mime) { $old_extensions = array_merge($old_extensions, FileExtension::get_all_for_mime($mime)); } @@ -152,7 +152,7 @@ public function onSetupBuilding(SetupBuildingEvent $event) $sb->add_bool_option(TranscodeConfig::GET_ENABLED, "Enable GET args", true); $sb->add_bool_option(TranscodeConfig::UPLOAD, "Transcode on upload", true); $sb->add_choice_option(TranscodeConfig::ENGINE, MediaEngine::IMAGE_ENGINES, "Engine", true); - foreach (self::INPUT_MIMES as $display=> $mime) { + foreach (self::INPUT_MIMES as $display => $mime) { if (MediaEngine::is_input_supported($engine, $mime)) { $outputs = $this->get_supported_output_mimes($engine, $mime); $sb->add_choice_option(self::get_mapping_name($mime), $outputs, "$display", true); @@ -180,7 +180,7 @@ public function onDataUpload(DataUploadEvent $event) } if ($config->get_bool(TranscodeConfig::UPLOAD) == true) { - if ($event->mime === MimeType::GIF&&MimeType::is_animated_gif($event->tmpname)) { + if ($event->mime === MimeType::GIF && MimeType::is_animated_gif($event->tmpname)) { return; } @@ -253,10 +253,10 @@ public function onImageDownloading(ImageDownloadingEvent $event) $source_mime = $event->image->get_mime(); - if ($source_mime!=$target_mime) { + if ($source_mime != $target_mime) { $tmp_filename = $this->transcode_image($event->path, $source_mime, $target_mime); - if ($event->file_modified===true&&$event->path!=$event->image->get_image_filename()) { + if ($event->file_modified === true && $event->path != $event->image->get_image_filename()) { // This means that we're dealing with a temp file that will need cleaned up unlink($event->path); } @@ -314,10 +314,10 @@ public function onBulkAction(BulkActionEvent $event) } } } - if ($size_difference>0) { + if ($size_difference > 0) { $page->flash("Transcoded $total items, reduced size by ".human_filesize($size_difference)); - } elseif ($size_difference<0) { - $page->flash("Transcoded $total items, increased size by ".human_filesize(-1*$size_difference)); + } elseif ($size_difference < 0) { + $page->flash("Transcoded $total items, increased size by ".human_filesize(-1 * $size_difference)); } else { $page->flash("Transcoded $total items, no size difference"); } @@ -338,13 +338,13 @@ private function get_supported_output_mimes($engine, ?string $omit_mime = null): $output = []; - foreach (self::OUTPUT_MIMES as $key=> $value) { - if ($value=="") { + foreach (self::OUTPUT_MIMES as $key => $value) { + if ($value == "") { $output[$key] = $value; continue; } if (MediaEngine::is_output_supported($engine, $value) - &&(empty($omit_mime)||$omit_mime!=$value)) { + && (empty($omit_mime) || $omit_mime != $value)) { $output[$key] = $value; } } @@ -385,7 +385,7 @@ private function transcode_image(string $source_name, string $source_mime, strin { global $config; - if ($source_mime==$target_mime) { + if ($source_mime == $target_mime) { throw new ImageTranscodeException("Source and target MIMEs are the same: ".$source_mime); } @@ -433,18 +433,18 @@ private function transcode_image_gd(string $source_name, string $source_mime, st $width = imagesx($image); $height = imagesy($image); $new_image = imagecreatetruecolor($width, $height); - if ($new_image===false) { + if ($new_image === false) { throw new ImageTranscodeException("Could not create image with dimensions $width x $height"); } try { $background_color = Media::hex_color_allocate($new_image, $config->get_string(TranscodeConfig::ALPHA_COLOR)); - if ($background_color===false) { + if ($background_color === false) { throw new ImageTranscodeException("Could not allocate background color"); } - if (imagefilledrectangle($new_image, 0, 0, $width, $height, $background_color)===false) { + if (imagefilledrectangle($new_image, 0, 0, $width, $height, $background_color) === false) { throw new ImageTranscodeException("Could not fill background color"); } - if (imagecopy($new_image, $image, 0, 0, 0, 0, $width, $height)===false) { + if (imagecopy($new_image, $image, 0, 0, 0, 0, $width, $height) === false) { throw new ImageTranscodeException("Could not copy source image to new image"); } $result = imagejpeg($new_image, $tmp_name, $q); @@ -456,7 +456,7 @@ private function transcode_image_gd(string $source_name, string $source_mime, st } finally { imagedestroy($image); } - if ($result===false) { + if ($result === false) { throw new ImageTranscodeException("Error while transcoding ".$source_name." to ".$target_mime); } return $tmp_name; @@ -507,7 +507,7 @@ private function transcode_image_convert(string $source_name, string $source_mim log_debug('transcode', "Transcoding with command `$cmd`, returns $ret"); - if ($ret!==0) { + if ($ret !== 0) { throw new ImageTranscodeException("Transcoding failed with command ".$cmd.", returning ".implode("\r\n", $output)); } diff --git a/ext/transcode/theme.php b/ext/transcode/theme.php index 55c1f61a0..171df779d 100644 --- a/ext/transcode/theme.php +++ b/ext/transcode/theme.php @@ -32,7 +32,7 @@ public function get_transcode_html(Image $image, array $options): string public function get_transcode_picker_html(array $options): string { $html = ""; - foreach ($options as $display=>$value) { + foreach ($options as $display => $value) { $html .= "$display"; } diff --git a/ext/transcode_video/info.php b/ext/transcode_video/info.php index 4dd7877c5..81f7f7fc7 100644 --- a/ext/transcode_video/info.php +++ b/ext/transcode_video/info.php @@ -10,8 +10,8 @@ class TranscodeVideoInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Transcode Video"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Allows admins to automatically and manually transcode videos."; - public ?string $documentation ="Requires ffmpeg"; + public ?string $documentation = "Requires ffmpeg"; } diff --git a/ext/transcode_video/main.php b/ext/transcode_video/main.php index 8235afea9..ca0c03044 100644 --- a/ext/transcode_video/main.php +++ b/ext/transcode_video/main.php @@ -48,9 +48,9 @@ public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { global $user; - if ($event->image->video===true && $user->can(Permissions::EDIT_FILES)) { + if ($event->image->video === true && $user->can(Permissions::EDIT_FILES)) { $options = self::get_output_options($event->image->get_mime(), $event->image->video_codec); - if (!empty($options)&&sizeof($options)>1) { + if (!empty($options) && sizeof($options) > 1) { $event->add_part($this->theme->get_transcode_html($event->image, $options)); } } @@ -65,37 +65,37 @@ public function onSetupBuilding(SetupBuildingEvent $event) $sb->end_table(); } -/* - public function onDataUpload(DataUploadEvent $event) - { - global $config; + /* + public function onDataUpload(DataUploadEvent $event) + { + global $config; - if ($config->get_bool(TranscodeVideoConfig::UPLOAD) == true) { - $ext = strtolower($event->type); + if ($config->get_bool(TranscodeVideoConfig::UPLOAD) == true) { + $ext = strtolower($event->type); - $ext = Media::normalize_format($ext); + $ext = Media::normalize_format($ext); - if ($event->type=="gif"&&Media::is_animated_gif($event->tmpname)) { - return; - } - - if (in_array($ext, array_values(self::INPUT_FORMATS))) { - $target_format = $config->get_string(TranscodeVideoConfig::UPLOAD_PREFIX.$ext); - if (empty($target_format)) { + if ($event->type=="gif"&&Media::is_animated_gif($event->tmpname)) { return; } - try { - $new_image = $this->transcode_image($event->tmpname, $ext, $target_format); - $event->set_tmpname($new_image, Media::determine_ext($target_format)); - } catch (Exception $e) { - log_error("transcode_video", "Error while performing upload transcode: ".$e->getMessage()); - // We don't want to interfere with the upload process, - // so if something goes wrong the untranscoded image jsut continues + + if (in_array($ext, array_values(self::INPUT_FORMATS))) { + $target_format = $config->get_string(TranscodeVideoConfig::UPLOAD_PREFIX.$ext); + if (empty($target_format)) { + return; + } + try { + $new_image = $this->transcode_image($event->tmpname, $ext, $target_format); + $event->set_tmpname($new_image, Media::determine_ext($target_format)); + } catch (Exception $e) { + log_error("transcode_video", "Error while performing upload transcode: ".$e->getMessage()); + // We don't want to interfere with the upload process, + // so if something goes wrong the untranscoded image jsut continues + } } } } - } -*/ + */ public function onPageRequest(PageRequestEvent $event) { @@ -162,7 +162,7 @@ public function onBulkAction(BulkActionEvent $event) // transcodes recorded already, otherwise the image entries will be stuck pointing to // missing image files $database->commit(); - if ($output_image!=$image) { + if ($output_image != $image) { $total++; } } catch (\Exception $e) { @@ -186,10 +186,10 @@ private static function get_output_options(?string $starting_container = null, ? foreach (VideoContainers::ALL as $container) { - if ($starting_container==$container) { + if ($starting_container == $container) { continue; } - if (!empty($starting_codec)&& + if (!empty($starting_codec) && !VideoContainers::is_video_codec_supported($container, $starting_codec)) { continue; } @@ -201,11 +201,11 @@ private static function get_output_options(?string $starting_container = null, ? private function transcode_and_replace_video(Image $image, string $target_mime): Image { - if ($image->get_mime()==$target_mime) { + if ($image->get_mime() == $target_mime) { return $image; } - if ($image->video==null||($image->video===true && empty($image->video_codec))) { + if ($image->video == null || ($image->video === true && empty($image->video_codec))) { // If image predates the media system, or the video codec support, run a media check send_event(new MediaCheckPropertiesEvent($image)); $image->save_to_db(); diff --git a/ext/transcode_video/theme.php b/ext/transcode_video/theme.php index 244730b23..29c8c1dee 100644 --- a/ext/transcode_video/theme.php +++ b/ext/transcode_video/theme.php @@ -32,7 +32,7 @@ public function get_transcode_html(Image $image, array $options): string public function get_transcode_picker_html(array $options): string { $html = ""; - foreach ($options as $display=>$value) { + foreach ($options as $display => $value) { $html .= "$display"; } diff --git a/ext/trash/info.php b/ext/trash/info.php index 13b643d63..d0d9a2bbe 100644 --- a/ext/trash/info.php +++ b/ext/trash/info.php @@ -10,7 +10,7 @@ class TrashInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Trash"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Provides \"Trash\" or \"Recycle Bin\"-type functionality, storing deleted images for later recovery"; } diff --git a/ext/trash/main.php b/ext/trash/main.php index 5fc70a50f..f71fff19b 100644 --- a/ext/trash/main.php +++ b/ext/trash/main.php @@ -49,7 +49,7 @@ private function check_permissions(Image $image): bool { global $user; - if ($image->trash===true && !$user->can(Permissions::VIEW_TRASH)) { + if ($image->trash === true && !$user->can(Permissions::VIEW_TRASH)) { return false; } return true; @@ -77,7 +77,7 @@ public function onDisplayingImage(DisplayingImageEvent $event) public function onImageDeletion(ImageDeletionEvent $event) { - if ($event->force!==true && $event->image->trash!==true) { + if ($event->force !== true && $event->image->trash !== true) { self::set_trash($event->image->id, true); $event->stop_processing = true; } @@ -86,7 +86,7 @@ public function onImageDeletion(ImageDeletionEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent=="posts") { + if ($event->parent == "posts") { if ($user->can(Permissions::VIEW_TRASH)) { $event->add_nav_link("posts_trash", new Link('/post/list/in%3Atrash/1'), "Trash", null, 60); } @@ -109,7 +109,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) $matches = []; if (is_null($event->term) && $this->no_trash_query($event->context)) { - $event->add_querylet(new Querylet("trash != :true", ["true"=>true])); + $event->add_querylet(new Querylet("trash != :true", ["true" => true])); } if (is_null($event->term)) { @@ -117,7 +117,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) } if (preg_match(self::SEARCH_REGEXP, strtolower($event->term), $matches)) { if ($user->can(Permissions::VIEW_TRASH)) { - $event->add_querylet(new Querylet("trash = :true", ["true"=>true])); + $event->add_querylet(new Querylet("trash = :true", ["true" => true])); } } } @@ -125,7 +125,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { global $user; - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { if ($user->can(Permissions::VIEW_TRASH)) { $block = new Block(); $block->header = "Trash"; @@ -151,13 +151,13 @@ public static function set_trash(int $image_id, bool $trash) $database->execute( "UPDATE images SET trash = :trash WHERE id = :id", - ["trash"=>$trash,"id"=>$image_id] + ["trash" => $trash,"id" => $image_id] ); } public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { global $user; - if ($event->image->trash===true && $user->can(Permissions::VIEW_TRASH)) { + if ($event->image->trash === true && $user->can(Permissions::VIEW_TRASH)) { $event->add_part($this->theme->get_image_admin_html($event->image->id)); } } @@ -166,7 +166,7 @@ public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event) { global $user; - if ($user->can(Permissions::VIEW_TRASH)&&in_array("in:trash", $event->search_terms)) { + if ($user->can(Permissions::VIEW_TRASH) && in_array("in:trash", $event->search_terms)) { $event->add_action("bulk_trash_restore", "(U)ndelete", "u"); } } diff --git a/ext/trash/theme.php b/ext/trash/theme.php index 9a5553a87..9c65c1385 100644 --- a/ext/trash/theme.php +++ b/ext/trash/theme.php @@ -12,8 +12,8 @@ public function get_image_admin_html(int $image_id): string { return (string)SHM_SIMPLE_FORM( 'trash_restore/'.$image_id, - INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]), - INPUT(["type"=>'submit', "value"=>'Restore From Trash']), + INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]), + INPUT(["type" => 'submit', "value" => 'Restore From Trash']), ); } diff --git a/ext/update/info.php b/ext/update/info.php index 7941141ca..a7e8ae8fa 100644 --- a/ext/update/info.php +++ b/ext/update/info.php @@ -11,7 +11,7 @@ class UpdateInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Update"; public string $url = "http://www.codeanimu.net"; - public array $authors = ["DakuTree"=>"dakutree@codeanimu.net"]; + public array $authors = ["DakuTree" => "dakutree@codeanimu.net"]; public string $license = self::LICENSE_GPLV2; public string $description = "Shimmie updater! (Requires admin panel extension & transload engine (cURL/fopen/Wget))"; } diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php index 648e95772..8fb3b6556 100644 --- a/ext/upgrade/main.php +++ b/ext/upgrade/main.php @@ -65,8 +65,8 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) if ($this->get_version("db_version") < 11) { log_info("upgrade", "Converting user flags to classes"); $database->execute("ALTER TABLE users ADD COLUMN class VARCHAR(32) NOT NULL default :user", ["user" => "user"]); - $database->execute("UPDATE users SET class = :name WHERE id=:id", ["name"=>"anonymous", "id"=>$config->get_int('anon_id')]); - $database->execute("UPDATE users SET class = :name WHERE admin=:admin", ["name"=>"admin", "admin"=>'Y']); + $database->execute("UPDATE users SET class = :name WHERE id=:id", ["name" => "anonymous", "id" => $config->get_int('anon_id')]); + $database->execute("UPDATE users SET class = :name WHERE admin=:admin", ["name" => "admin", "admin" => 'Y']); $this->set_version("db_version", 11); } @@ -195,13 +195,13 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) // them into one big transaction would not be a good idea. $database->commit(); } - $database->execute("UPDATE images SET lossless = :t, video = :t WHERE ext IN ('swf')", ["t"=>true]); - $database->execute("UPDATE images SET lossless = :f, video = :f, audio = :t WHERE ext IN ('mp3')", ["t"=>true, "f"=>false]); - $database->execute("UPDATE images SET lossless = :f, video = :f, audio = :f WHERE ext IN ('jpg','jpeg')", ["f"=>false]); - $database->execute("UPDATE images SET lossless = :t, video = :f, audio = :f WHERE ext IN ('ico','ani','cur','png','svg')", ["t"=>true, "f"=>false]); - $database->execute("UPDATE images SET lossless = :t, audio = :f WHERE ext IN ('gif')", ["t"=>true, "f"=>false]); - $database->execute("UPDATE images SET audio = :f WHERE ext IN ('webp')", ["f"=>false]); - $database->execute("UPDATE images SET lossless = :f, video = :t WHERE ext IN ('flv','mp4','m4v','ogv','webm')", ["t"=>true, "f"=>false]); + $database->execute("UPDATE images SET lossless = :t, video = :t WHERE ext IN ('swf')", ["t" => true]); + $database->execute("UPDATE images SET lossless = :f, video = :f, audio = :t WHERE ext IN ('mp3')", ["t" => true, "f" => false]); + $database->execute("UPDATE images SET lossless = :f, video = :f, audio = :f WHERE ext IN ('jpg','jpeg')", ["f" => false]); + $database->execute("UPDATE images SET lossless = :t, video = :f, audio = :f WHERE ext IN ('ico','ani','cur','png','svg')", ["t" => true, "f" => false]); + $database->execute("UPDATE images SET lossless = :t, audio = :f WHERE ext IN ('gif')", ["t" => true, "f" => false]); + $database->execute("UPDATE images SET audio = :f WHERE ext IN ('webp')", ["f" => false]); + $database->execute("UPDATE images SET lossless = :f, video = :t WHERE ext IN ('flv','mp4','m4v','ogv','webm')", ["t" => true, "f" => false]); $this->set_version("db_version", 21); } } diff --git a/ext/upload/main.php b/ext/upload/main.php index ffb9192c9..f22d55c41 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -39,7 +39,7 @@ public function __construct( $metadata['filename'] = substr($metadata['filename'], 0, 255); } - public function set_tmpname(string $tmpname, ?string $mime=null) + public function set_tmpname(string $tmpname, ?string $mime = null) { assert(is_readable($tmpname)); $this->tmpname = $tmpname; @@ -151,7 +151,7 @@ public function onPageNavBuilding(PageNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="upload") { + if ($event->parent == "upload") { if (class_exists("Shimmie2\Wiki")) { $event->add_nav_link("upload_guidelines", new Link('wiki/upload_guidelines'), "Guidelines"); } diff --git a/ext/upload/test.php b/ext/upload/test.php index a45bb445d..9e12f99e0 100644 --- a/ext/upload/test.php +++ b/ext/upload/test.php @@ -43,7 +43,7 @@ public function testRawUpload() 'size' => [0], ] ]; - $page = $this->post_page("upload", ["tags0"=>"foo bar"]); + $page = $this->post_page("upload", ["tags0" => "foo bar"]); $this->assert_response(302); $this->assertStringStartsWith("/test/post/list/poster%3Dtest/1", $page->redirect); @@ -67,7 +67,7 @@ public function testRawReplace() ] ]; - $page = $this->post_page("upload/replace", ["image_id"=>$image_id]); + $page = $this->post_page("upload/replace", ["image_id" => $image_id]); $this->assert_response(302); $this->assertEquals("/test/post/view/$image_id", $page->redirect); @@ -104,7 +104,7 @@ public function testRejectUnknownFiletype() public function testRejectHuge() { // FIXME: huge.dat is rejected for other reasons; manual testing shows that this works - file_put_contents("data/huge.jpg", file_get_contents("tests/pbx_screenshot.jpg") . str_repeat("U", 1024*1024*3)); + file_put_contents("data/huge.jpg", file_get_contents("tests/pbx_screenshot.jpg") . str_repeat("U", 1024 * 1024 * 3)); try { $this->post_image("data/huge.jpg", "test"); $this->fail("Uploading huge.jpg didn't fail..."); diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 2d3c770f2..77ba47c0b 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -50,22 +50,22 @@ public function display_page(Page $page): void $form = SHM_FORM("upload", "POST", true, "file_upload"); $form->appendChild( TABLE( - ["id"=>"large_upload_form", "class"=>"vert"], + ["id" => "large_upload_form", "class" => "vert"], TR( - TD(["width"=>"20"], rawHTML("Common Tags")), - TD(["colspan"=>"5"], INPUT(["name"=>"tags", "type"=>"text", "placeholder"=>"tagme", "class"=>"autocomplete_tags", "autocomplete"=>"off"])) + TD(["width" => "20"], rawHTML("Common Tags")), + TD(["colspan" => "5"], INPUT(["name" => "tags", "type" => "text", "placeholder" => "tagme", "class" => "autocomplete_tags", "autocomplete" => "off"])) ), TR( - TD(["width"=>"20"], rawHTML("Common Source")), - TD(["colspan"=>"5"], INPUT(["name"=>"source", "type"=>"text"])) + TD(["width" => "20"], rawHTML("Common Source")), + TD(["colspan" => "5"], INPUT(["name" => "source", "type" => "text"])) ), $upload_list, TR( - TD(["colspan"=>$tl_enabled ? 2 : 4,"id"=>"upload_size_tracker"], ""), - TD(["colspan"=>2], ""), + TD(["colspan" => $tl_enabled ? 2 : 4,"id" => "upload_size_tracker"], ""), + TD(["colspan" => 2], ""), ), TR( - TD(["colspan"=>"6"], INPUT(["id"=>"uploadbutton", "type"=>"submit", "value"=>"Post"])) + TD(["colspan" => "6"], INPUT(["id" => "uploadbutton", "type" => "submit", "value" => "Post"])) ), ) ); @@ -148,18 +148,18 @@ protected function h_upload_list_1(): HTMLElement $upload_list->appendChild( TR( - TD(["colspan"=>$tl_enabled ? 2 : 4], "Files"), - $tl_enabled ? TD(["colspan"=>"2"], "URLs") : emptyHTML(), - TD(["colspan"=>"2"], "Post-Specific Tags"), + TD(["colspan" => $tl_enabled ? 2 : 4], "Files"), + $tl_enabled ? TD(["colspan" => "2"], "URLs") : emptyHTML(), + TD(["colspan" => "2"], "Post-Specific Tags"), ) ); - for ($i=0; $i<$upload_count; $i++) { + for ($i = 0; $i < $upload_count; $i++) { $upload_list->appendChild( TR( - TD(["colspan"=>$tl_enabled ? 2 : 4], DIV(["name"=>"canceldata{$i}[]","style"=>"display:inline;margin-right:5px;font-size:15px;visibility:hidden;","onclick"=>"$(\"input[name='data{$i}[]']\")[0].value='';updateTracker();"], "✖"), INPUT(["type"=>"file", "name"=>"data{$i}[]", "accept"=>$accept, "multiple"=>true])), - $tl_enabled ? TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"url{$i}"])) : emptyHTML(), - TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"tags{$i}", "class"=>"autocomplete_tags", "autocomplete"=>"off"])), + TD(["colspan" => $tl_enabled ? 2 : 4], DIV(["name" => "canceldata{$i}[]","style" => "display:inline;margin-right:5px;font-size:15px;visibility:hidden;","onclick" => "$(\"input[name='data{$i}[]']\")[0].value='';updateTracker();"], "✖"), INPUT(["type" => "file", "name" => "data{$i}[]", "accept" => $accept, "multiple" => true])), + $tl_enabled ? TD(["colspan" => "2"], INPUT(["type" => "text", "name" => "url{$i}"])) : emptyHTML(), + TD(["colspan" => "2"], INPUT(["type" => "text", "name" => "tags{$i}", "class" => "autocomplete_tags", "autocomplete" => "off"])), ) ); } @@ -177,7 +177,7 @@ protected function h_bookmarklets(): HTMLElement $max_kb = to_shorthand_int($max_size); $delimiter = $config->get_bool('nice_urls') ? '?' : '&'; - $js='javascript:( + $js = 'javascript:( function() { if(typeof window=="undefined" || !window.location || window.location.href=="about:blank") { window.location = "'. $main_page .'"; @@ -198,7 +198,7 @@ function() { } )();'; $html1 = P( - A(["href"=>$js], "Upload to $title"), + A(["href" => $js], "Upload to $title"), rawHTML(' (Drag & drop onto your bookmarks toolbar, then click when looking at a post)') ); @@ -216,7 +216,7 @@ function() { void(document.body.appendChild(document.createElement("script")).src="'.make_http(get_base_href())."/ext/upload/bookmarklet.js".'") '; $html2 = P( - A(["href"=>$js], $title), + A(["href" => $js], $title), rawHTML("(Click when looking at a post page. Works on sites running Shimmie / Danbooru / Gelbooru. (This also grabs the tags / rating / source!))"), ); @@ -235,14 +235,14 @@ public function display_replace_page(Page $page, int $image_id) $upload_list = emptyHTML( TR( TD("File"), - TD(INPUT(["name"=>"data[]", "type"=>"file", "accept"=>$accept])) + TD(INPUT(["name" => "data[]", "type" => "file", "accept" => $accept])) ) ); if ($tl_enabled) { $upload_list->appendChild( TR( TD("or URL"), - TD(INPUT(["name"=>"url", "type"=>"text"])) + TD(INPUT(["name" => "url", "type" => "text"])) ) ); } @@ -255,12 +255,12 @@ public function display_replace_page(Page $page, int $image_id) $form = SHM_FORM("upload/replace/".$image_id, "POST", true); $form->appendChild(emptyHTML( - INPUT(["type"=>"hidden", "name"=>"image_id", "value"=>$image_id]), + INPUT(["type" => "hidden", "name" => "image_id", "value" => $image_id]), TABLE( - ["id"=>"large_upload_form", "class"=>"vert"], + ["id" => "large_upload_form", "class" => "vert"], $upload_list, - TR(TD("Source"), TD(["colspan"=>3], INPUT(["name"=>"source", "type"=>"text"]))), - TR(TD(["colspan"=>4], INPUT(["id"=>"uploadbutton", "type"=>"submit", "value"=>"Post"]))), + TR(TD("Source"), TD(["colspan" => 3], INPUT(["name" => "source", "type" => "text"]))), + TR(TD(["colspan" => 4], INPUT(["id" => "uploadbutton", "type" => "submit", "value" => "Post"]))), ) )); @@ -328,18 +328,18 @@ protected function build_upload_block(): HTMLElement $form = SHM_FORM("upload", "POST", true); $form->appendChild( emptyHTML( - INPUT(["id"=>"data[]", "name"=>"data[]", "size"=>"16", "type"=>"file", "accept"=>$accept, "multiple"=>true]), - INPUT(["name"=>"tags", "type"=>"text", "placeholder"=>"tagme", "class"=>"autocomplete_tags", "required"=>true, "autocomplete"=>"off"]), - INPUT(["type"=>"submit", "value"=>"Post"]), + INPUT(["id" => "data[]", "name" => "data[]", "size" => "16", "type" => "file", "accept" => $accept, "multiple" => true]), + INPUT(["name" => "tags", "type" => "text", "placeholder" => "tagme", "class" => "autocomplete_tags", "required" => true, "autocomplete" => "off"]), + INPUT(["type" => "submit", "value" => "Post"]), ) ); return DIV( - ["class"=>'mini_upload'], + ["class" => 'mini_upload'], $form, SMALL("(Max file size is $max_kb)"), SMALL(BR(), "(Max total size is $max_total_kb)"), - NOSCRIPT(BR(), A(["href"=>make_link("upload")], "Larger Form")) + NOSCRIPT(BR(), A(["href" => make_link("upload")], "Larger Form")) ); } diff --git a/ext/user/events.php b/ext/user/events.php index aacf7fa1c..d4a75de83 100644 --- a/ext/user/events.php +++ b/ext/user/events.php @@ -10,7 +10,7 @@ class UserBlockBuildingEvent extends Event { public array $parts = []; - public function add_link(string|HTMLElement $name, string $link, int $position=50): void + public function add_link(string|HTMLElement $name, string $link, int $position = 50): void { while (isset($this->parts[$position])) { $position++; @@ -43,7 +43,7 @@ public function __construct(public User $display_user) parent::__construct(); } - public function add_stats(string $html, int $position=50) + public function add_stats(string $html, int $position = 50) { while (isset($this->stats[$position])) { $position++; diff --git a/ext/user/main.php b/ext/user/main.php index a3a923242..ce2c97334 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -24,7 +24,7 @@ class UserNameColumn extends TextColumn { public function display(array $row): HTMLElement { - return A(["href"=>make_link("user/{$row[$this->name]}")], $row[$this->name]); + return A(["href" => make_link("user/{$row[$this->name]}")], $row[$this->name]); } } @@ -38,7 +38,7 @@ public function __construct() public function display(array $row): HTMLElement { - return A(["href"=>search_link(["user={$row['name']}"])], "Posts"); + return A(["href" => search_link(["user={$row['name']}"])], "Posts"); } } @@ -368,17 +368,17 @@ public function onSetupBuilding(SetupBuildingEvent $event) $sb->add_choice_option( "avatar_gravatar_type", [ - 'Default'=>'default', - 'Wavatar'=>'wavatar', - 'Monster ID'=>'monsterid', - 'Identicon'=>'identicon' + 'Default' => 'default', + 'Wavatar' => 'wavatar', + 'Monster ID' => 'monsterid', + 'Identicon' => 'identicon' ], "Type", true ); $sb->add_choice_option( "avatar_gravatar_rating", - ['G'=>'g', 'PG'=>'pg', 'R'=>'r', 'X'=>'x'], + ['G' => 'g', 'PG' => 'pg', 'R' => 'r', 'X' => 'x'], "Rating", true ); @@ -389,13 +389,13 @@ public function onSetupBuilding(SetupBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="system") { + if ($event->parent === "system") { if ($user->can(Permissions::EDIT_USER_PASSWORD)) { $event->add_nav_link("user_admin", new Link('user_admin/list'), "User List", NavLink::is_active(["user_admin"])); } } - if ($event->parent==="user" && !$user->is_anonymous()) { + if ($event->parent === "user" && !$user->is_anonymous()) { $event->add_nav_link("logout", new Link('user_admin/logout'), "Log Out", false, 90); } } @@ -465,7 +465,7 @@ public function onUserCreation(UserCreationEvent $event) public static function has_user_query(array $context): bool { foreach ($context as $term) { - if (preg_match(self::USER_SEARCH_REGEX, $term)|| + if (preg_match(self::USER_SEARCH_REGEX, $term) || preg_match(self::USER_ID_SEARCH_REGEX, $term)) { return true; } @@ -501,7 +501,7 @@ public function onSearchTermParse(SearchTermParseEvent $event) public function onHelpPageBuilding(HelpPageBuildingEvent $event) { - if ($event->key===HelpPages::SEARCH) { + if ($event->key === HelpPages::SEARCH) { $block = new Block(); $block->header = "Users"; $block->body = (string)$this->theme->get_help_html(); @@ -616,7 +616,7 @@ private function create_user(UserCreationEvent $event): User $database->execute( "INSERT INTO users (name, pass, joindate, email, class) VALUES (:username, :hash, now(), :email, :class)", - ["username"=>$event->username, "hash"=>'', "email"=>$email, "class"=>$class] + ["username" => $event->username, "hash" => '', "email" => $email, "class" => $class] ); $uid = $database->get_last_insert_id('users_id_seq'); $new_user = User::by_name($event->username); @@ -643,13 +643,13 @@ private function set_login_cookie(string $name): void $page->add_cookie( "user", $name, - time()+60*60*24*365, + time() + 60 * 60 * 24 * 365, '/' ); $page->add_cookie( "session", $this->get_session_id($name), - time()+60*60*24*$config->get_int('login_memory'), + time() + 60 * 60 * 24 * $config->get_int('login_memory'), '/' ); } @@ -754,7 +754,7 @@ private function count_upload_ips(User $duser): array FROM images WHERE owner_id=:id GROUP BY owner_ip - ORDER BY max(posted) DESC", ["id"=>$duser->id]); + ORDER BY max(posted) DESC", ["id" => $duser->id]); } private function count_comment_ips(User $duser): array @@ -767,7 +767,7 @@ private function count_comment_ips(User $duser): array FROM comments WHERE owner_id=:id GROUP BY owner_ip - ORDER BY max(posted) DESC", ["id"=>$duser->id]); + ORDER BY max(posted) DESC", ["id" => $duser->id]); } private function count_log_ips(User $duser): array @@ -783,10 +783,10 @@ private function count_log_ips(User $duser): array FROM score_log WHERE username=:username GROUP BY address - ORDER BY MAX(date_sent) DESC", ["username"=>$duser->name]); + ORDER BY MAX(date_sent) DESC", ["username" => $duser->name]); } - private function delete_user(Page $page, bool $with_images=false, bool $with_comments=false): void + private function delete_user(Page $page, bool $with_images = false, bool $with_comments = false): void { global $user, $config, $database; diff --git a/ext/user/theme.php b/ext/user/theme.php index 33d8a5fb5..786dafbd2 100644 --- a/ext/user/theme.php +++ b/ext/user/theme.php @@ -54,7 +54,7 @@ public function display_user_block(Page $page, User $user, $parts) $html = emptyHTML('Logged in as ', $user->name); foreach ($parts as $part) { $html->appendChild(BR()); - $html->appendChild(A(["href"=>$part["link"]], $part["name"])); + $html->appendChild(A(["href" => $part["link"]], $part["name"])); } $b = new Block("User Links", $html, "left", 90); $b->is_content = false; @@ -74,30 +74,30 @@ public function display_signup_page(Page $page) $form = SHM_SIMPLE_FORM( "user_admin/create", TABLE( - ["class"=>"form"], + ["class" => "form"], TBODY( TR( TH("Name"), - TD(INPUT(["type"=>'text', "name"=>'name', "required"=>true])) + TD(INPUT(["type" => 'text', "name" => 'name', "required" => true])) ), TR( TH("Password"), - TD(INPUT(["type"=>'password', "name"=>'pass1', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass1', "required" => true])) ), TR( TH(rawHTML("Repeat Password")), - TD(INPUT(["type"=>'password', "name"=>'pass2', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass2', "required" => true])) ), TR( TH(rawHTML("Email (Optional)")), - TD(INPUT(["type"=>'email', "name"=>'email'])) + TD(INPUT(["type" => 'email', "name" => 'email'])) ), TR( - TD(["colspan"=>"2"], rawHTML(captcha_get_html())) + TD(["colspan" => "2"], rawHTML(captcha_get_html())) ), ), TFOOT( - TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Create Account"]))) + TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => "Create Account"]))) ) ) ); @@ -120,27 +120,27 @@ public function display_user_creator() $form = SHM_SIMPLE_FORM( "user_admin/create_other", TABLE( - ["class"=>"form"], + ["class" => "form"], TBODY( TR( TH("Name"), - TD(INPUT(["type"=>'text', "name"=>'name', "required"=>true])) + TD(INPUT(["type" => 'text', "name" => 'name', "required" => true])) ), TR( TH("Password"), - TD(INPUT(["type"=>'password', "name"=>'pass1', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass1', "required" => true])) ), TR( TH(rawHTML("Repeat Password")), - TD(INPUT(["type"=>'password', "name"=>'pass2', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass2', "required" => true])) ), TR( TH(rawHTML("Email (Optional)")), - TD(INPUT(["type"=>'email', "name"=>'email'])) + TD(INPUT(["type" => 'email', "name" => 'email'])) ), ), TFOOT( - TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Create Account"]))) + TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => "Create Account"]))) ) ) ); @@ -164,19 +164,19 @@ public function display_login_block(Page $page) $form = SHM_SIMPLE_FORM( "user_admin/login", TABLE( - ["style"=>"width: 100%", "class"=>"form"], + ["style" => "width: 100%", "class" => "form"], TBODY( TR( - TH(LABEL(["for"=>"user"], "Name")), - TD(INPUT(["id"=>"user", "type"=>"text", "name"=>"user", "autocomplete"=>"username"])) + TH(LABEL(["for" => "user"], "Name")), + TD(INPUT(["id" => "user", "type" => "text", "name" => "user", "autocomplete" => "username"])) ), TR( - TH(LABEL(["for"=>"pass"], "Password")), - TD(INPUT(["id"=>"pass", "type"=>"password", "name"=>"pass", "autocomplete"=>"current-password"])) + TH(LABEL(["for" => "pass"], "Password")), + TD(INPUT(["id" => "pass", "type" => "password", "name" => "pass", "autocomplete" => "current-password"])) ) ), TFOOT( - TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Log In"]))) + TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => "Log In"]))) ) ) ); @@ -184,7 +184,7 @@ public function display_login_block(Page $page) $html = emptyHTML(); $html->appendChild($form); if ($config->get_bool("login_signup_enabled") && $user->can(Permissions::CREATE_USER)) { - $html->appendChild(SMALL(A(["href"=>make_link("user_admin/create")], "Create Account"))); + $html->appendChild(SMALL(A(["href" => make_link("user_admin/create")], "Create Account"))); } $page->add_block(new Block("Login", $html, "left", 90)); @@ -209,14 +209,14 @@ private function _ip_list(string $name, array $ips): HTMLElement public function display_ip_list(Page $page, array $uploads, array $comments, array $events) { $html = TABLE( - ["id"=>"ip-history"], + ["id" => "ip-history"], TR( $this->_ip_list("Uploaded from", $uploads), $this->_ip_list("Commented from", $comments), $this->_ip_list("Logged Events", $events) ), TR( - TD(["colspan"=>"3"], "(Most recent at top)") + TD(["colspan" => "3"], "(Most recent at top)") ) ); @@ -250,7 +250,7 @@ public function build_operations(User $duser, UserOperationsBuildingEvent $event "Change Name", TBODY(TR( TH("New name"), - TD(INPUT(["type"=>'text', "name"=>'name', "value"=>$duser->name])) + TD(INPUT(["type" => 'text', "name" => 'name', "value" => $duser->name])) )), "Set" )); @@ -263,11 +263,11 @@ public function build_operations(User $duser, UserOperationsBuildingEvent $event TBODY( TR( TH("Password"), - TD(INPUT(["type"=>'password', "name"=>'pass1', "autocomplete"=>'new-password'])) + TD(INPUT(["type" => 'password', "name" => 'pass1', "autocomplete" => 'new-password'])) ), TR( TH("Repeat Password"), - TD(INPUT(["type"=>'password', "name"=>'pass2', "autocomplete"=>'new-password'])) + TD(INPUT(["type" => 'password', "name" => 'pass2', "autocomplete" => 'new-password'])) ), ), "Set" @@ -279,17 +279,17 @@ public function build_operations(User $duser, UserOperationsBuildingEvent $event "Change Email", TBODY(TR( TH("Address"), - TD(INPUT(["type"=>'text', "name"=>'address', "value"=>$duser->email, "autocomplete"=>'email', "inputmode"=>'email'])) + TD(INPUT(["type" => 'text', "name" => 'address', "value" => $duser->email, "autocomplete" => 'email', "inputmode" => 'email'])) )), "Set" )); if ($user->can(Permissions::EDIT_USER_CLASS)) { global $_shm_user_classes; - $select = SELECT(["name"=>"class"]); + $select = SELECT(["name" => "class"]); foreach ($_shm_user_classes as $name => $values) { $select->appendChild( - OPTION(["value"=>$name, "selected"=>$name == $duser->class->name], ucwords($name)) + OPTION(["value" => $name, "selected" => $name == $duser->class->name], ucwords($name)) ); } $html->appendChild(SHM_USER_FORM( @@ -307,12 +307,12 @@ public function build_operations(User $duser, UserOperationsBuildingEvent $event "user_admin/delete_user", "Delete User", TBODY( - TR(TD(LABEL(INPUT(["type"=>'checkbox', "name"=>'with_images']), "Delete images"))), - TR(TD(LABEL(INPUT(["type"=>'checkbox', "name"=>'with_comments']), "Delete comments"))), + TR(TD(LABEL(INPUT(["type" => 'checkbox', "name" => 'with_images']), "Delete images"))), + TR(TD(LABEL(INPUT(["type" => 'checkbox', "name" => 'with_comments']), "Delete comments"))), ), TFOOT( - TR(TD(INPUT(["type"=>'button', "class"=>'shm-unlocker', "data-unlock-sel"=>'.deluser', "value"=>'Unlock']))), - TR(TD(INPUT(["type"=>'submit', "class"=>'deluser', "value"=>'Delete User', "disabled"=>'true']))), + TR(TD(INPUT(["type" => 'button', "class" => 'shm-unlocker', "data-unlock-sel" => '.deluser', "value" => 'Unlock']))), + TR(TD(INPUT(["type" => 'submit', "class" => 'deluser', "value" => 'Delete User', "disabled" => 'true']))), ) )); } @@ -353,7 +353,7 @@ public function get_help_html(): HTMLElement */ public function display_user_classes(Page $page, array $classes, array $permissions): void { - $table = TABLE(["class"=>"zebra"]); + $table = TABLE(["class" => "zebra"]); $row = TR(); $row->appendChild(TH("Permission")); @@ -374,9 +374,9 @@ public function display_user_classes(Page $page, array $classes, array $permissi foreach ($classes as $class) { $opacity = array_key_exists($perm->getValue(), $class->abilities) ? 1 : 0.2; if ($class->can($perm->getValue())) { - $cell = TD(["style"=>"color: green; opacity: $opacity;"], "✔"); + $cell = TD(["style" => "color: green; opacity: $opacity;"], "✔"); } else { - $cell = TD(["style"=>"color: red; opacity: $opacity;"], "✘"); + $cell = TD(["style" => "color: red; opacity: $opacity;"], "✘"); } $row->appendChild($cell); } @@ -384,7 +384,7 @@ public function display_user_classes(Page $page, array $classes, array $permissi $doc = $perm->getDocComment(); if ($doc) { $doc = preg_replace('/\/\*\*|\n\s*\*\s*|\*\//', '', $doc); - $row->appendChild(TD(["style"=>"text-align: left;"], $doc)); + $row->appendChild(TD(["style" => "text-align: left;"], $doc)); } else { $row->appendChild(TD("")); } diff --git a/ext/user_config/info.php b/ext/user_config/info.php index a6495dbd9..d546352a4 100644 --- a/ext/user_config/info.php +++ b/ext/user_config/info.php @@ -10,7 +10,7 @@ class UserConfigInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "User-specific settings"; - public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public array $authors = ["Matthew Barbour" => "matthew@darkholme.net"]; public string $license = self::LICENSE_WTFPL; public string $description = "Provides system-wide support for user-specific settings"; public ExtensionVisibility $visibility = ExtensionVisibility::HIDDEN; diff --git a/ext/user_config/main.php b/ext/user_config/main.php index cf53dbb0a..2a729732f 100644 --- a/ext/user_config/main.php +++ b/ext/user_config/main.php @@ -93,7 +93,7 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event): void public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { global $user; - if ($event->parent==="user" && !$user->is_anonymous()) { + if ($event->parent === "user" && !$user->is_anonymous()) { $event->add_nav_link("user_config", new Link('user_config'), "User Options", false, 40); } } @@ -154,7 +154,7 @@ public function onPageRequest(PageRequestEvent $event) ]); $duser = User::by_id($input['id']); - if ($user->id!=$duser->id && !$user->can(Permissions::CHANGE_OTHER_USER_SETTING)) { + if ($user->id != $duser->id && !$user->can(Permissions::CHANGE_OTHER_USER_SETTING)) { $this->theme->display_permission_denied(); return; } diff --git a/ext/view/events/image_admin_block_building_event.php b/ext/view/events/image_admin_block_building_event.php index 47cb6a5c1..6a1d458d2 100644 --- a/ext/view/events/image_admin_block_building_event.php +++ b/ext/view/events/image_admin_block_building_event.php @@ -20,7 +20,7 @@ public function __construct(Image $image, User $user, string $context) $this->context = $context; } - public function add_part(string $html, int $position=50) + public function add_part(string $html, int $position = 50) { while (isset($this->parts[$position])) { $position++; diff --git a/ext/view/events/image_info_box_building_event.php b/ext/view/events/image_info_box_building_event.php index 206cbf25f..db9399e6b 100644 --- a/ext/view/events/image_info_box_building_event.php +++ b/ext/view/events/image_info_box_building_event.php @@ -19,7 +19,7 @@ public function __construct(Image $image, User $user) $this->user = $user; } - public function add_part(HTMLElement $html, int $position=50) + public function add_part(HTMLElement $html, int $position = 50) { while (isset($this->parts[$position])) { $position++; diff --git a/ext/view/test.php b/ext/view/test.php index 8faeab77b..320270522 100644 --- a/ext/view/test.php +++ b/ext/view/test.php @@ -47,10 +47,10 @@ public function testPrevNext() $this->assertEquals("/test/post/view/$image_id_2", $page->redirect); // When searching, we skip the middle - $page = $this->get_page("post/prev/$image_id_1", ["search"=>"test"]); + $page = $this->get_page("post/prev/$image_id_1", ["search" => "test"]); $this->assertEquals("/test/post/view/$image_id_3?#search=test", $page->redirect); - $page = $this->get_page("post/next/$image_id_3", ["search"=>"test"]); + $page = $this->get_page("post/next/$image_id_3", ["search" => "test"]); $this->assertEquals("/test/post/view/$image_id_1?#search=test", $page->redirect); // Middle image: has next and prev diff --git a/ext/wiki/info.php b/ext/wiki/info.php index 8c2583a1b..9c28808ae 100644 --- a/ext/wiki/info.php +++ b/ext/wiki/info.php @@ -11,7 +11,7 @@ class WikiInfo extends ExtensionInfo public string $key = self::KEY; public string $name = "Simple Wiki"; public string $url = self::SHIMMIE_URL; - public array $authors = [self::SHISH_NAME=>self::SHISH_EMAIL, "Luana Latte"=>"luana.latte.cat@gmail.com"]; + public array $authors = [self::SHISH_NAME => self::SHISH_EMAIL, "Luana Latte" => "luana.latte.cat@gmail.com"]; public string $license = self::LICENSE_GPLV2; public string $description = "A simple wiki, for those who don't want the hugeness of mediawiki"; public ?string $documentation = "Standard formatting APIs are used (This will be BBCode by default)"; diff --git a/ext/wiki/main.php b/ext/wiki/main.php index c115512ab..179eacfc9 100644 --- a/ext/wiki/main.php +++ b/ext/wiki/main.php @@ -67,7 +67,7 @@ class WikiPage #[Field] public string $body; - public function __construct(array $row=null) + public function __construct(array $row = null) { //assert(!empty($row)); global $database; @@ -80,7 +80,7 @@ public function __construct(array $row=null) $this->title = $row['title']; $this->revision = (int)$row['revision']; $this->locked = bool_escape($row['locked']); - $this->exists = $database->exists("SELECT id FROM wiki_pages WHERE title = :title", ["title"=>$this->title]); + $this->exists = $database->exists("SELECT id FROM wiki_pages WHERE title = :title", ["title" => $this->title]); $this->body = $row['body']; } } @@ -248,7 +248,7 @@ public function onPageNavBuilding(PageNavBuildingEvent $event) public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) { - if ($event->parent=="wiki") { + if ($event->parent == "wiki") { $event->add_nav_link("wiki_rules", new Link('wiki/rules'), "Rules"); $event->add_nav_link("wiki_help", new Link('ext_doc/wiki'), "Help"); } @@ -259,24 +259,24 @@ public function onWikiUpdate(WikiUpdateEvent $event) global $database, $config; $wpage = $event->wikipage; - $exists = $database->exists("SELECT id FROM wiki_pages WHERE title = :title", ["title"=>$wpage->title]); + $exists = $database->exists("SELECT id FROM wiki_pages WHERE title = :title", ["title" => $wpage->title]); try { - if ($config->get_bool(WikiConfig::ENABLE_REVISIONS) || ! $exists) { + if ($config->get_bool(WikiConfig::ENABLE_REVISIONS) || !$exists) { $database->execute( " INSERT INTO wiki_pages(owner_id, owner_ip, date, title, revision, locked, body) VALUES (:owner_id, :owner_ip, now(), :title, :revision, :locked, :body)", - ["owner_id"=>$event->user->id, "owner_ip"=>get_real_ip(), - "title"=>$wpage->title, "revision"=>$wpage->revision, "locked"=>$wpage->locked, "body"=>$wpage->body] + ["owner_id" => $event->user->id, "owner_ip" => get_real_ip(), + "title" => $wpage->title, "revision" => $wpage->revision, "locked" => $wpage->locked, "body" => $wpage->body] ); } else { $database->execute( " UPDATE wiki_pages SET owner_id=:owner_id, owner_ip=:owner_ip, date=now(), locked=:locked, body=:body WHERE title = :title ORDER BY revision DESC LIMIT 1", - ["owner_id"=>$event->user->id, "owner_ip"=>get_real_ip(), - "title"=>$wpage->title, "locked"=>$wpage->locked, "body"=>$wpage->body] + ["owner_id" => $event->user->id, "owner_ip" => get_real_ip(), + "title" => $wpage->title, "locked" => $wpage->locked, "body" => $wpage->body] ); } } catch (\Exception $e) { @@ -289,7 +289,7 @@ public function onWikiDeleteRevision(WikiDeleteRevisionEvent $event) global $database; $database->execute( "DELETE FROM wiki_pages WHERE title=:title AND revision=:rev", - ["title"=>$event->title, "rev"=>$event->revision] + ["title" => $event->title, "rev" => $event->revision] ); } @@ -336,12 +336,12 @@ public static function get_history(string $title): array WHERE LOWER(title) LIKE LOWER(:title) ORDER BY revision DESC ", - ["title"=>$title] + ["title" => $title] ); } #[Query(name: "wiki")] - public static function get_page(string $title, ?int $revision=null): WikiPage + public static function get_page(string $title, ?int $revision = null): WikiPage { global $database; // first try and get the actual page @@ -353,7 +353,7 @@ public static function get_page(string $title, ?int $revision=null): WikiPage AND (:revision = -1 OR revision = :revision) ORDER BY revision DESC ", - ["title"=>$title, "revision"=>$revision ?? -1] + ["title" => $title, "revision" => $revision ?? -1] ); // fall back to wiki:default @@ -363,7 +363,7 @@ public static function get_page(string $title, ?int $revision=null): WikiPage FROM wiki_pages WHERE title LIKE :title ORDER BY revision DESC - ", ["title"=>"wiki:default"]); + ", ["title" => "wiki:default"]); // fall further back to manual if (empty($row)) { @@ -397,7 +397,7 @@ public static function format_tag_wiki_page(WikiPage $page): string SELECT * FROM tags WHERE tag = :title - ", ["title"=>$page->title]); + ", ["title" => $page->title]); if (!empty($row)) { $template = $config->get_string(WikiConfig::TAG_PAGE_TEMPLATE); @@ -414,7 +414,7 @@ public static function format_tag_wiki_page(WikiPage $page): string FROM aliases WHERE newtag = :title ORDER BY oldtag ASC - ", ["title"=>$row["tag"]]); + ", ["title" => $row["tag"]]); if (!empty($aliases)) { $template = str_replace("{aliases}", implode(", ", $aliases), $template); @@ -431,7 +431,7 @@ public static function format_tag_wiki_page(WikiPage $page): string SELECT additional_tags FROM auto_tag WHERE tag = :title - ", ["title"=>$row["tag"]]); + ", ["title" => $row["tag"]]); if (!empty($auto_tags)) { $auto_tags = Tag::explode($auto_tags); @@ -444,7 +444,7 @@ public static function format_tag_wiki_page(WikiPage $page): string SELECT * FROM tags WHERE tag = :title - ", ["title"=>$a_tag]); + ", ["title" => $a_tag]); $tag_html = $tag_list_t->return_tag($a_row, $tag_category_dict ?? []); $f_auto_tags[] = $tag_html[1]; @@ -521,7 +521,7 @@ private function arr_diff(array $f1, array $f2, int $show_equal = 0): string /** * add to output-string, if "show_equal" is enabled */ - $out .= ($show_equal==1) + $out .= ($show_equal == 1) ? $this->formatline(($c1), ($c2), "=", $f1[ $c1 ]) : "" ; /** @@ -535,8 +535,8 @@ private function arr_diff(array $f1, array $f2, int $show_equal = 0): string /** * move the current-pointer in the left and right side */ - $c1 ++; - $c2 ++; + $c1++; + $c2++; } /** @@ -576,7 +576,7 @@ private function arr_diff(array $f1, array $f2, int $show_equal = 0): string * be used, else it will be discarded later */ #hit - if (trim($f1[$c1+$s1]) == trim($f2[$c2])) { + if (trim($f1[$c1 + $s1]) == trim($f2[$c2])) { $found = 1 ; # set flag to stop further search $s2 = 0 ; # reset right side search-pointer $c2-- ; # move back the current right, so next loop hits @@ -593,7 +593,7 @@ private function arr_diff(array $f1, array $f2, int $show_equal = 0): string /** * add current search-line to diffence-buffer */ - $b1 .= $this->formatline(($c1 + $s1), ($c2), "-", $f1[ $c1+$s1 ]); + $b1 .= $this->formatline(($c1 + $s1), ($c2), "-", $f1[ $c1 + $s1 ]); /** * mark this line as 'searched' to prevent doubles. @@ -609,7 +609,7 @@ private function arr_diff(array $f1, array $f2, int $show_equal = 0): string * * comparing current line with the searching line on the right */ - if (trim($f1[$c1]) == trim($f2[$c2+$s2])) { + if (trim($f1[$c1]) == trim($f2[$c2 + $s2])) { $found = 1 ; # flag to stop search $s1 = 0 ; # reset pointer for search $c1-- ; # move current line back, so we hit next loop @@ -622,7 +622,7 @@ private function arr_diff(array $f1, array $f2, int $show_equal = 0): string /** * add current searchline to buffer */ - $b2 .= $this->formatline(($c1), ($c2 + $s2), "+", $f2[ $c2+$s2 ]); + $b2 .= $this->formatline(($c1), ($c2 + $s2), "+", $f2[ $c2 + $s2 ]); /** * mark current line to prevent double-hits diff --git a/ext/wiki/test.php b/ext/wiki/test.php index 8f5551cc2..52da9b008 100644 --- a/ext/wiki/test.php +++ b/ext/wiki/test.php @@ -35,7 +35,7 @@ public function testAccess() $this->assert_text("This is a default page"); if ($allowed || $user == "admin") { - $this->post_page("wiki_admin/edit", ["title"=>"test"]); + $this->post_page("wiki_admin/edit", ["title" => "test"]); $this->assert_text("Editor"); } /* diff --git a/ext/wiki/theme.php b/ext/wiki/theme.php index 66b315a66..2d4dfd024 100644 --- a/ext/wiki/theme.php +++ b/ext/wiki/theme.php @@ -12,7 +12,7 @@ class WikiTheme extends Themelet * $wiki_page The wiki page, has ->title and ->body * $nav_page A wiki page object with navigation, has ->body */ - public function display_page(Page $page, WikiPage $wiki_page, ?WikiPage $nav_page=null) + public function display_page(Page $page, WikiPage $wiki_page, ?WikiPage $nav_page = null) { global $user; diff --git a/index.php b/index.php index 61b176caf..7aebad1c4 100644 --- a/index.php +++ b/index.php @@ -67,9 +67,9 @@ $_tracer->begin( $_SERVER["REQUEST_URI"] ?? "No Request", [ - "user"=>$_COOKIE["shm_user"] ?? "No User", - "ip"=>get_real_ip() ?? "No IP", - "user_agent"=>$_SERVER['HTTP_USER_AGENT'] ?? "No UA", + "user" => $_COOKIE["shm_user"] ?? "No User", + "ip" => get_real_ip() ?? "No IP", + "user_agent" => $_SERVER['HTTP_USER_AGENT'] ?? "No UA", ] ); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 8203ee969..2cd651ef3 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -111,7 +111,7 @@ private static function check_args(?array $args): array if (!$args) { return []; } - foreach ($args as $k=>$v) { + foreach ($args as $k => $v) { if (is_array($v)) { $args[$k] = $v; } else { @@ -121,7 +121,7 @@ private static function check_args(?array $args): array return $args; } - protected static function request($page_name, $get_args=null, $post_args=null): Page + protected static function request($page_name, $get_args = null, $post_args = null): Page { // use a fresh page global $page; @@ -142,12 +142,12 @@ protected static function request($page_name, $get_args=null, $post_args=null): return $page; } - protected static function get_page($page_name, $args=null): Page + protected static function get_page($page_name, $args = null): Page { return self::request($page_name, $args, null); } - protected static function post_page($page_name, $args=null): Page + protected static function post_page($page_name, $args = null): Page { return self::request($page_name, null, $args); } @@ -177,7 +177,7 @@ protected function assert_response(int $code): void $this->assertEquals($code, $page->code); } - protected function page_to_text(string $section=null): string + protected function page_to_text(string $section = null): string { global $page; if ($page->mode == PageMode::PAGE) { @@ -196,12 +196,12 @@ protected function page_to_text(string $section=null): string } } - protected function assert_text(string $text, string $section=null): void + protected function assert_text(string $text, string $section = null): void { $this->assertStringContainsString($text, $this->page_to_text($section)); } - protected function assert_no_text(string $text, string $section=null): void + protected function assert_no_text(string $text, string $section = null): void { $this->assertStringNotContainsString($text, $this->page_to_text($section)); } diff --git a/themes/danbooru/comment.theme.php b/themes/danbooru/comment.theme.php index 525fb2617..935a560c1 100644 --- a/themes/danbooru/comment.theme.php +++ b/themes/danbooru/comment.theme.php @@ -90,7 +90,7 @@ public function display_recent_comments(array $comments) // no recent comments in this theme } - protected function comment_to_html(Comment $comment, bool $trim=false): string + protected function comment_to_html(Comment $comment, bool $trim = false): string { global $user; diff --git a/themes/danbooru/themelet.class.php b/themes/danbooru/themelet.class.php index 96675fa2c..4b7a1a2ae 100644 --- a/themes/danbooru/themelet.class.php +++ b/themes/danbooru/themelet.class.php @@ -40,15 +40,15 @@ private function build_paginator(int $current_page, int $total_pages, string $ba $prev = $current_page - 1; $at_start = ($current_page <= 3 || $total_pages <= 3); - $at_end = ($current_page >= $total_pages -2); + $at_end = ($current_page >= $total_pages - 2); $first_html = $at_start ? "" : $this->gen_page_link($base_url, $query, 1, "1"); $prev_html = $at_start ? "" : $this->gen_page_link($base_url, $query, $prev, "<<"); $next_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $next, ">>"); $last_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $total_pages, "$total_pages"); - $start = $current_page-2 > 1 ? $current_page-2 : 1; - $end = $current_page+2 <= $total_pages ? $current_page+2 : $total_pages; + $start = $current_page - 2 > 1 ? $current_page - 2 : 1; + $end = $current_page + 2 <= $total_pages ? $current_page + 2 : $total_pages; $pages = []; foreach (range($start, $end) as $i) { @@ -68,6 +68,6 @@ private function build_paginator(int $current_page, int $total_pages, string $ba $ndots = ""; } - return DIV(["id"=>'paginator'], joinHTML(" ", [$prev_html, $first_html, $pdots, $pages_html, $ndots, $last_html, $next_html])); + return DIV(["id" => 'paginator'], joinHTML(" ", [$prev_html, $first_html, $pdots, $pages_html, $ndots, $last_html, $next_html])); } } diff --git a/themes/danbooru/view.theme.php b/themes/danbooru/view.theme.php index 7314829e5..28facb934 100644 --- a/themes/danbooru/view.theme.php +++ b/themes/danbooru/view.theme.php @@ -37,7 +37,7 @@ private function build_stats(Image $image): string Filesize: $h_filesize Type: $h_type"; - if ($image->length!=null) { + if ($image->length != null) { $h_length = format_milliseconds($image->length); $html .= "Length: $h_length"; } diff --git a/themes/danbooru2/comment.theme.php b/themes/danbooru2/comment.theme.php index dd43860eb..4ca014e9e 100644 --- a/themes/danbooru2/comment.theme.php +++ b/themes/danbooru2/comment.theme.php @@ -91,7 +91,7 @@ public function display_recent_comments(array $comments) } - protected function comment_to_html(Comment $comment, bool $trim=false): string + protected function comment_to_html(Comment $comment, bool $trim = false): string { global $user; diff --git a/themes/danbooru2/themelet.class.php b/themes/danbooru2/themelet.class.php index 0f1922755..7e619442b 100644 --- a/themes/danbooru2/themelet.class.php +++ b/themes/danbooru2/themelet.class.php @@ -21,7 +21,7 @@ public function display_paginator(Page $page, string $base, ?string $query, int private function gen_page_link(string $base_url, ?string $query, int $page, string $name): HTMLElement { - return A(["href"=>make_link("$base_url/$page", $query)], $name); + return A(["href" => make_link("$base_url/$page", $query)], $name); } private function gen_page_link_block(string $base_url, ?string $query, int $page, int $current_page, string $name): HTMLElement @@ -40,15 +40,15 @@ private function build_paginator(int $current_page, int $total_pages, string $ba $prev = $current_page - 1; $at_start = ($current_page <= 3 || $total_pages <= 3); - $at_end = ($current_page >= $total_pages -2); + $at_end = ($current_page >= $total_pages - 2); $first_html = $at_start ? "" : $this->gen_page_link($base_url, $query, 1, "1"); $prev_html = $at_start ? "" : $this->gen_page_link($base_url, $query, $prev, "<<"); $next_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $next, ">>"); $last_html = $at_end ? "" : $this->gen_page_link($base_url, $query, $total_pages, "$total_pages"); - $start = $current_page-2 > 1 ? $current_page-2 : 1; - $end = $current_page+2 <= $total_pages ? $current_page+2 : $total_pages; + $start = $current_page - 2 > 1 ? $current_page - 2 : 1; + $end = $current_page + 2 <= $total_pages ? $current_page + 2 : $total_pages; $pages = []; foreach (range($start, $end) as $i) { @@ -62,12 +62,12 @@ private function build_paginator(int $current_page, int $total_pages, string $ba $pdots = ""; } - if ($total_pages > $end+1) { + if ($total_pages > $end + 1) { $ndots = "..."; } else { $ndots = ""; } - return DIV(["id"=>"paginator"], joinHTML(" ", [$prev_html, $first_html, $pdots, $pages_html, $ndots, $last_html, $next_html])); + return DIV(["id" => "paginator"], joinHTML(" ", [$prev_html, $first_html, $pdots, $pages_html, $ndots, $last_html, $next_html])); } } diff --git a/themes/danbooru2/view.theme.php b/themes/danbooru2/view.theme.php index 130eb81d0..99e3c8607 100644 --- a/themes/danbooru2/view.theme.php +++ b/themes/danbooru2/view.theme.php @@ -37,7 +37,7 @@ private function build_information(Image $image): string Type: $h_type "; - if ($image->length!=null) { + if ($image->length != null) { $h_length = format_milliseconds($image->length); $html .= "Length: $h_length"; } diff --git a/themes/futaba/comment.theme.php b/themes/futaba/comment.theme.php index ae30fed18..ec39b18e7 100644 --- a/themes/futaba/comment.theme.php +++ b/themes/futaba/comment.theme.php @@ -64,7 +64,7 @@ public function build_upload_box(): string } - protected function comment_to_html(Comment $comment, bool $trim=false): string + protected function comment_to_html(Comment $comment, bool $trim = false): string { $inner_id = $this->inner_id; // because custom themes can't add params, because PHP global $user; diff --git a/themes/futaba/themelet.class.php b/themes/futaba/themelet.class.php index cb2c937d1..e059b3c2b 100644 --- a/themes/futaba/themelet.class.php +++ b/themes/futaba/themelet.class.php @@ -55,8 +55,8 @@ public function futaba_build_paginator(int $current_page, int $total_pages, stri $next_html = $at_end ? "Next" : $this->futaba_gen_page_link($base_url, $query, $next, "Next"); //$last_html = $at_end ? "Last" : $this->futaba_gen_page_link($base_url, $query, $total_pages, "Last"); - $start = $current_page-5 > 1 ? $current_page-5 : 1; - $end = $start+10 < $total_pages ? $start+10 : $total_pages; + $start = $current_page - 5 > 1 ? $current_page - 5 : 1; + $end = $start + 10 < $total_pages ? $start + 10 : $total_pages; $pages = []; foreach (range($start, $end) as $i) { diff --git a/themes/lite/comment.theme.php b/themes/lite/comment.theme.php index ce60276c9..20717a981 100644 --- a/themes/lite/comment.theme.php +++ b/themes/lite/comment.theme.php @@ -6,7 +6,7 @@ class CustomCommentListTheme extends CommentListTheme { - protected function comment_to_html(Comment $comment, bool $trim=false): string + protected function comment_to_html(Comment $comment, bool $trim = false): string { return $this->rr(parent::comment_to_html($comment, $trim)); } diff --git a/themes/lite/page.class.php b/themes/lite/page.class.php index 212c89646..d6d606344 100644 --- a/themes/lite/page.class.php +++ b/themes/lite/page.class.php @@ -112,7 +112,7 @@ public function render() EOD; } /* end of function display_page() */ - public function block_to_html(Block $block, bool $hidable=false): string + public function block_to_html(Block $block, bool $hidable = false): string { $h = $block->header; $b = $block->body; diff --git a/themes/lite/themelet.class.php b/themes/lite/themelet.class.php index 336cefff2..39c61b720 100644 --- a/themes/lite/themelet.class.php +++ b/themes/lite/themelet.class.php @@ -34,7 +34,7 @@ public function display_paginator(Page $page, string $base, ?string $query, int $page->add_block(new Block("Paginator", $body, "main", 90)); } - public function litetheme_gen_page_link(string $base_url, ?string $query, int $page, string $name, ?string $link_class=null): HTMLElement + public function litetheme_gen_page_link(string $base_url, ?string $query, int $page, string $name, ?string $link_class = null): HTMLElement { return A(["href" => make_link("$base_url/$page", $query), "class" => $link_class], $name); } @@ -57,8 +57,8 @@ public function litetheme_build_paginator(int $current_page, int $total_pages, s $at_start = ($current_page <= 1 || $total_pages <= 1); $at_end = ($current_page >= $total_pages); - $first_html = $at_start ? SPAN(["class"=>"tab"], "First") : $this->litetheme_gen_page_link($base_url, $query, 1, "First"); - $prev_html = $at_start ? SPAN(["class"=>"tab"], "Prev") : $this->litetheme_gen_page_link($base_url, $query, $prev, "Prev"); + $first_html = $at_start ? SPAN(["class" => "tab"], "First") : $this->litetheme_gen_page_link($base_url, $query, 1, "First"); + $prev_html = $at_start ? SPAN(["class" => "tab"], "Prev") : $this->litetheme_gen_page_link($base_url, $query, $prev, "Prev"); $random_html = ""; if ($show_random) { @@ -66,11 +66,11 @@ public function litetheme_build_paginator(int $current_page, int $total_pages, s $random_html = $this->litetheme_gen_page_link($base_url, $query, $rand, "Random"); } - $next_html = $at_end ? SPAN(["class"=>"tab"], "Next") : $this->litetheme_gen_page_link($base_url, $query, $next, "Next"); - $last_html = $at_end ? SPAN(["class"=>"tab"], "Last") : $this->litetheme_gen_page_link($base_url, $query, $total_pages, "Last"); + $next_html = $at_end ? SPAN(["class" => "tab"], "Next") : $this->litetheme_gen_page_link($base_url, $query, $next, "Next"); + $last_html = $at_end ? SPAN(["class" => "tab"], "Last") : $this->litetheme_gen_page_link($base_url, $query, $total_pages, "Last"); - $start = $current_page-5 > 1 ? $current_page-5 : 1; - $end = $start+10 < $total_pages ? $start+10 : $total_pages; + $start = $current_page - 5 > 1 ? $current_page - 5 : 1; + $end = $start + 10 < $total_pages ? $start + 10 : $total_pages; $pages = []; foreach (range($start, $end) as $i) { @@ -78,7 +78,7 @@ public function litetheme_build_paginator(int $current_page, int $total_pages, s } return DIV( - ["class"=>"paginator sfoot"], + ["class" => "paginator sfoot"], $first_html, $prev_html, $random_html, diff --git a/themes/lite/view.theme.php b/themes/lite/view.theme.php index 76f95336b..02d55c963 100644 --- a/themes/lite/view.theme.php +++ b/themes/lite/view.theme.php @@ -38,10 +38,10 @@ private function build_stats(Image $image): string Filesize: $h_filesize Type: ".$h_type." "; - if ($image->video_codec!=null) { + if ($image->video_codec != null) { $html .= "Video Codec: $image->video_codec"; } - if ($image->length!=null) { + if ($image->length != null) { $h_length = format_milliseconds($image->length); $html .= "Length: $h_length"; } diff --git a/themes/rule34v2/themelet.class.php b/themes/rule34v2/themelet.class.php index e9902ad84..e26ff2294 100644 --- a/themes/rule34v2/themelet.class.php +++ b/themes/rule34v2/themelet.class.php @@ -35,14 +35,14 @@ public function build_thumb_html(Image $image): HTMLElement } $html = DIV( - ['class'=>'shm-thumb thumb', 'data-ext'=>$ext, 'data-tags'=>$tags, 'data-post-id'=>$id], + ['class' => 'shm-thumb thumb', 'data-ext' => $ext, 'data-tags' => $tags, 'data-post-id' => $id], A( - ['class'=>'shm-thumb-link', 'href'=>$view_link], - IMG(['id'=>"thumb_$id", 'title'=>$tip, 'alt'=>$tip, 'height'=>$tsize[1], 'width'=>$tsize[0], 'src'=>$thumb_link, 'loading'=>'lazy']) + ['class' => 'shm-thumb-link', 'href' => $view_link], + IMG(['id' => "thumb_$id", 'title' => $tip, 'alt' => $tip, 'height' => $tsize[1], 'width' => $tsize[0], 'src' => $thumb_link, 'loading' => 'lazy']) ), BR(), - A(['href'=>$image_link], 'File Only'), - SPAN(['class'=>'need-del'], ' - ', A(['href'=>'#', 'onclick'=>"image_hash_ban($id); return false;"], 'Ban')) + A(['href' => $image_link], 'File Only'), + SPAN(['class' => 'need-del'], ' - ', A(['href' => '#', 'onclick' => "image_hash_ban($id); return false;"], 'Ban')) ); // cache for ages; will be cleared in ext/index:onImageInfoSet diff --git a/themes/rule34v2/upload.theme.php b/themes/rule34v2/upload.theme.php index 405364e8e..bf4ccb708 100644 --- a/themes/rule34v2/upload.theme.php +++ b/themes/rule34v2/upload.theme.php @@ -44,18 +44,18 @@ public function display_page(Page $page): void $form = SHM_FORM("upload", "POST", true, "file_upload"); $form->appendChild( TABLE( - ["id"=>"large_upload_form", "class"=>"vert"], + ["id" => "large_upload_form", "class" => "vert"], TR( - TD(["width"=>"20"], rawHTML("Common Tags")), - TD(["colspan"=>"5"], INPUT(["name"=>"tags", "type"=>"text", "placeholder"=>"tagme", "autocomplete"=>"off"])) + TD(["width" => "20"], rawHTML("Common Tags")), + TD(["colspan" => "5"], INPUT(["name" => "tags", "type" => "text", "placeholder" => "tagme", "autocomplete" => "off"])) ), TR( - TD(["width"=>"20"], rawHTML("Common Source")), - TD(["colspan"=>"5"], INPUT(["name"=>"source", "type"=>"text"])) + TD(["width" => "20"], rawHTML("Common Source")), + TD(["colspan" => "5"], INPUT(["name" => "source", "type" => "text"])) ), $upload_list, TR( - TD(["colspan"=>"6"], INPUT(["id"=>"uploadbutton", "type"=>"submit", "value"=>"Post"])) + TD(["colspan" => "6"], INPUT(["id" => "uploadbutton", "type" => "submit", "value" => "Post"])) ), ) ); @@ -79,7 +79,7 @@ public function display_page(Page $page): void protected function build_upload_block(): HTMLElement { - return A(["href"=>make_link("upload"), "style"=>'font-size: 2em; display: block;'], "Upload"); + return A(["href" => make_link("upload"), "style" => 'font-size: 2em; display: block;'], "Upload"); } protected function h_upload_list_1(): HTMLElement @@ -92,18 +92,18 @@ protected function h_upload_list_1(): HTMLElement $upload_list->appendChild( TR( - TD(["colspan"=>$tl_enabled ? 2 : 4], "Files"), - $tl_enabled ? TD(["colspan"=>"2"], "URLs") : emptyHTML(), - TD(["colspan"=>"2"], "Post-Specific Tags"), + TD(["colspan" => $tl_enabled ? 2 : 4], "Files"), + $tl_enabled ? TD(["colspan" => "2"], "URLs") : emptyHTML(), + TD(["colspan" => "2"], "Post-Specific Tags"), ) ); - for ($i=0; $i<$upload_count; $i++) { + for ($i = 0; $i < $upload_count; $i++) { $upload_list->appendChild( TR( - TD(["colspan"=>$tl_enabled ? 2 : 4], INPUT(["type"=>"file", "name"=>"data{$i}[]", "accept"=>$accept, "multiple"=>true])), - $tl_enabled ? TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"url{$i}"])) : emptyHTML(), - TD(["colspan"=>"2"], INPUT(["type"=>"text", "name"=>"tags{$i}", "autocomplete"=>"off"])), + TD(["colspan" => $tl_enabled ? 2 : 4], INPUT(["type" => "file", "name" => "data{$i}[]", "accept" => $accept, "multiple" => true])), + $tl_enabled ? TD(["colspan" => "2"], INPUT(["type" => "text", "name" => "url{$i}"])) : emptyHTML(), + TD(["colspan" => "2"], INPUT(["type" => "text", "name" => "tags{$i}", "autocomplete" => "off"])), ) ); } diff --git a/themes/rule34v2/user.theme.php b/themes/rule34v2/user.theme.php index 56e2219fd..f621e1579 100644 --- a/themes/rule34v2/user.theme.php +++ b/themes/rule34v2/user.theme.php @@ -73,30 +73,30 @@ public function display_signup_page(Page $page) $form = SHM_SIMPLE_FORM( "user_admin/create", TABLE( - ["class"=>"form"], + ["class" => "form"], TBODY( TR( TH("Name"), - TD(INPUT(["type"=>'text', "name"=>'name', "required"=>true])) + TD(INPUT(["type" => 'text', "name" => 'name', "required" => true])) ), TR( TH("Password"), - TD(INPUT(["type"=>'password', "name"=>'pass1', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass1', "required" => true])) ), TR( TH(rawHTML("Repeat Password")), - TD(INPUT(["type"=>'password', "name"=>'pass2', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass2', "required" => true])) ), TR( TH(rawHTML("Email")), - TD(INPUT(["type"=>'email', "name"=>'email', "required"=>true])) + TD(INPUT(["type" => 'email', "name" => 'email', "required" => true])) ), TR( - TD(["colspan"=>"2"], rawHTML(captcha_get_html())) + TD(["colspan" => "2"], rawHTML(captcha_get_html())) ), ), TFOOT( - TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Create Account"]))) + TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => "Create Account"]))) ) ) ); @@ -119,30 +119,30 @@ public function display_user_creator() $form = SHM_SIMPLE_FORM( "user_admin/create_other", TABLE( - ["class"=>"form"], + ["class" => "form"], TBODY( TR( TH("Name"), - TD(INPUT(["type"=>'text', "name"=>'name', "required"=>true])) + TD(INPUT(["type" => 'text', "name" => 'name', "required" => true])) ), TR( TH("Password"), - TD(INPUT(["type"=>'password', "name"=>'pass1', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass1', "required" => true])) ), TR( TH(rawHTML("Repeat Password")), - TD(INPUT(["type"=>'password', "name"=>'pass2', "required"=>true])) + TD(INPUT(["type" => 'password', "name" => 'pass2', "required" => true])) ), TR( TH(rawHTML("Email")), - TD(INPUT(["type"=>'email', "name"=>'email'])) + TD(INPUT(["type" => 'email', "name" => 'email'])) ), TR( - TD(["colspan"=>2], rawHTML("(Email is optional for admin-created accounts)")), + TD(["colspan" => 2], rawHTML("(Email is optional for admin-created accounts)")), ), ), TFOOT( - TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Create Account"]))) + TR(TD(["colspan" => "2"], INPUT(["type" => "submit", "value" => "Create Account"]))) ) ) );