From 138865bbde25bb6193930c98e30c33913d19e367 Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Tue, 11 Jan 2022 12:36:17 +0100 Subject: Install code QA helpers, enforce PSR2 Installs phpcs, phpmd, parallel-lint, phpstan. --- admin/index.php | 8 +- admin/login.php | 2 +- admin/logout.php | 2 +- admin/purgecache.php | 4 +- admin/subscriptions.php | 12 +- admin/template.php | 7 +- app/app.php | 3 +- app/classes/Cache.php | 360 ++++++----- app/classes/Opml.php | 42 +- app/classes/OpmlManager.php | 6 +- app/classes/Planet.php | 25 +- app/classes/PlanetConfig.php | 4 +- app/classes/Simplel10n.php | 30 +- app/helpers.php | 7 +- app/l10n/extract.php | 78 +-- atom.php | 11 +- composer.json | 6 +- composer.lock | 1207 ++++++++++++++++++++++++++++++++++-- cron.php | 2 +- custom/views/archive/index.tpl.php | 24 +- custom/views/default/index.tpl.php | 6 +- custom/views/install.tpl.php | 3 +- index.php | 4 +- install.php | 18 +- phpcs.xml | 11 + postload.php | 8 +- tests/GuzzleHarness.php | 3 +- tests/InstallTest.php | 5 +- tests/PlanetErrorTest.php | 2 +- tests/PlanetTest.php | 16 +- 30 files changed, 1528 insertions(+), 388 deletions(-) create mode 100644 phpcs.xml diff --git a/admin/index.php b/admin/index.php index 0118923..3a9e259 100755 --- a/admin/index.php +++ b/admin/index.php @@ -6,7 +6,7 @@ require_once __DIR__ . '/inc/auth.inc.php'; //Load configuration $config_file = __DIR__ . '/../custom/config.yml'; -if (is_file($config_file)){ +if (is_file($config_file)) { $conf = Spyc::YAMLLoad($config_file); $PlanetConfig = new PlanetConfig($conf); } else { @@ -107,9 +107,9 @@ ob_start(); + foreach ($everyone as $opml_person) { + $i++; + ?> diff --git a/admin/login.php b/admin/login.php index a95e59f..618cfb9 100755 --- a/admin/login.php +++ b/admin/login.php @@ -4,7 +4,7 @@ require_once __DIR__ . '/../app/app.php'; if (isset($_POST['password'])) { session_regenerate_id(); - setcookie('auth',md5($_POST['password'])); + setcookie('auth', md5($_POST['password'])); header('Location: index.php'); } diff --git a/admin/logout.php b/admin/logout.php index adb843f..88c60b3 100644 --- a/admin/logout.php +++ b/admin/logout.php @@ -2,7 +2,7 @@ require_once __DIR__ . '/../app/app.php'; -setcookie('auth','', time()-3600); +setcookie('auth', '', time() - 3600); session_destroy(); session_regenerate_id(); diff --git a/admin/purgecache.php b/admin/purgecache.php index 23a5712..7b01c97 100644 --- a/admin/purgecache.php +++ b/admin/purgecache.php @@ -3,13 +3,13 @@ require_once __DIR__.'/../app/app.php'; require_once __DIR__.'/inc/auth.inc.php'; -if (isset($_POST['purge'])){ +if (isset($_POST['purge'])) { $dir = __DIR__.'/../cache/'; $dh = opendir($dir); while ($filename = readdir($dh)) { - if ($filename == '.' OR $filename == '..') { + if ($filename == '.' or $filename == '..') { continue; } diff --git a/admin/subscriptions.php b/admin/subscriptions.php index 0940168..313e5bd 100755 --- a/admin/subscriptions.php +++ b/admin/subscriptions.php @@ -3,7 +3,8 @@ require_once __DIR__ . '/../app/app.php'; require_once __DIR__ . '/inc/auth.inc.php'; -function removeSlashes(&$item, $key){ +function removeSlashes(&$item, $key) +{ $item = stripslashes($item); } @@ -12,7 +13,6 @@ if (!$csrf->verify($_POST['_csrf'], 'feedmanage')) { } if (isset($_POST['opml']) || isset($_POST['add'])) { - // Load old OPML $oldOpml = OpmlManager::load(__DIR__.'/../custom/people.opml'); if ($PlanetConfig->getName() === '') { @@ -26,11 +26,11 @@ if (isset($_POST['opml']) || isset($_POST['add'])) { array_walk_recursive($_POST['opml'], 'removeSlashes'); } // Delete/Save feeds - if (isset($_POST['delete']) || isset($_POST['save'])){ - foreach ($_POST['opml'] as $person){ + if (isset($_POST['delete']) || isset($_POST['save'])) { + foreach ($_POST['opml'] as $person) { if (isset($_POST['delete'])) { //delete mode, check if to be deleted - if (!isset($person['delete'])){ + if (!isset($person['delete'])) { $newOpml->entries[] = $person; } } else { @@ -40,7 +40,7 @@ if (isset($_POST['opml']) || isset($_POST['add'])) { } // Add feed - if (isset($_POST['add'])){ + if (isset($_POST['add'])) { if ('http://' != $_POST['url']) { //autodiscover feed $feed = new SimplePie(); diff --git a/admin/template.php b/admin/template.php index 7818bef..964c639 100755 --- a/admin/template.php +++ b/admin/template.php @@ -1,4 +1,6 @@ - + @@ -26,8 +28,7 @@

- - +