From 2e9b8111fb09fd64d06e28128c0fbafa2a448c03 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 21 Dec 2022 15:36:08 +0100 Subject: [PATCH] Changes: - converted double-quotes to single - added some more spaces for better readability - removed some redudant empty lines - fixed indenting (4 spaces to tab) --- catavatar/catavatar.php | 2 +- discourse/discourse.php | 4 ++-- fromapp/fromapp.php | 4 ++-- irc/irc.php | 11 ++++++----- libertree/libertree.php | 19 +++++++++---------- ljpost/ljpost.php | 6 +++--- opmlexport/opmlexport.php | 4 ++-- planets/planets.php | 16 +++------------- public_server/public_server.php | 16 ++++++++-------- randplace/randplace.php | 2 +- saml/README.md | 0 saml/saml.php | 22 ++++++++-------------- showmore/showmore.php | 2 +- statusnet/statusnet.php | 4 ++-- 14 files changed, 48 insertions(+), 64 deletions(-) mode change 100755 => 100644 saml/README.md mode change 100755 => 100644 saml/saml.php diff --git a/catavatar/catavatar.php b/catavatar/catavatar.php index 2116ac44..5da7a196 100644 --- a/catavatar/catavatar.php +++ b/catavatar/catavatar.php @@ -18,7 +18,7 @@ use Friendica\Model\Photo; use Friendica\Model\Profile; use Friendica\Network\HTTPException\NotFoundException; -define("CATAVATAR_SIZE", 256); +define('CATAVATAR_SIZE', 256); /** * Installs the addon hook diff --git a/discourse/discourse.php b/discourse/discourse.php index 3d27c5b0..6f1cc041 100644 --- a/discourse/discourse.php +++ b/discourse/discourse.php @@ -61,8 +61,8 @@ function discourse_settings(array &$data) function discourse_settings_post() { if (!DI::userSession()->getLocalUserId() || empty($_POST['discourse-submit'])) { - return; - } + return; + } DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'discourse', 'enabled', intval($_POST['enabled'])); } diff --git a/fromapp/fromapp.php b/fromapp/fromapp.php index 0d5a5b16..8c011704 100644 --- a/fromapp/fromapp.php +++ b/fromapp/fromapp.php @@ -53,7 +53,7 @@ function fromapp_settings(array &$data) ]; } -function fromapp_post_hook(&$item) +function fromapp_post_hook(array &$item) { if (!DI::userSession()->getLocalUserId()) { return; @@ -76,6 +76,6 @@ function fromapp_post_hook(&$item) $apps = explode(',', $app); $item['app'] = trim($apps[mt_rand(0, count($apps)-1)]); - + return; } diff --git a/irc/irc.php b/irc/irc.php index d4435851..f58163e8 100644 --- a/irc/irc.php +++ b/irc/irc.php @@ -99,13 +99,14 @@ function irc_content() } DI::page()['aside'] .= ''; - /* setting the channel(s) to auto connect */ + /* setting the channel(s) to auto connect */ if (DI::userSession()->getLocalUserId()) { - $autochans = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'irc', 'autochans'); - if (!$autochans) - $autochans = DI::config()->get('irc','autochans'); + $autochans = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'irc', 'autochans'); + if (!$autochans) { + $autochans = DI::config()->get('irc','autochans'); + } } else { - $autochans = DI::config()->get('irc','autochans'); + $autochans = DI::config()->get('irc','autochans'); } if ($autochans) { diff --git a/libertree/libertree.php b/libertree/libertree.php index c0f896c0..ef8760aa 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -56,10 +56,10 @@ function libertree_settings(array &$data) $t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/libertree/'); $html = Renderer::replaceMacros($t, [ - '$enabled' => ['libertree', DI::l10n()->t('Enable Libertree Post Addon'), $enabled], - '$ltree_url' => ['libertree_url', DI::l10n()->t('Libertree site URL'), $ltree_url], + '$enabled' => ['libertree', DI::l10n()->t('Enable Libertree Post Addon'), $enabled], + '$ltree_url' => ['libertree_url', DI::l10n()->t('Libertree site URL'), $ltree_url], '$ltree_api_token' => ['libertree_api_token', DI::l10n()->t('Libertree API token'), $ltree_api_token], - '$bydefault' => ['ij_bydefault', DI::l10n()->t('Post to Libertree by default'), $def_enabled], + '$bydefault' => ['ij_bydefault', DI::l10n()->t('Post to Libertree by default'), $def_enabled], ]); $data = [ @@ -74,11 +74,10 @@ function libertree_settings(array &$data) function libertree_settings_post(array &$b) { if (!empty($_POST['libertree-submit'])) { - DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','post',intval($_POST['libertree'])); - DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','post_by_default',intval($_POST['libertree_bydefault'])); - DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','libertree_api_token',trim($_POST['libertree_api_token'])); - DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','libertree_url',trim($_POST['libertree_url'])); - + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'post' , intval($_POST['libertree'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'post_by_default' , intval($_POST['libertree_bydefault'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_api_token', trim($_POST['libertree_api_token'])); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_url' , trim($_POST['libertree_url'])); } } @@ -115,11 +114,11 @@ function libertree_post_local(array &$b) return; } - $ltree_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'libertree','post')); + $ltree_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post')); $ltree_enable = (($ltree_post && !empty($_REQUEST['libertree_enable'])) ? intval($_REQUEST['libertree_enable']) : 0); - if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'libertree','post_by_default'))) { + if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post_by_default'))) { $ltree_enable = 1; } diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index f6f2b79a..fee48e2e 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -67,10 +67,10 @@ function ljpost_settings(array &$data) $data = [ 'connector' => 'ljpost', - 'title' => DI::l10n()->t('LiveJournal Export'), - 'image' => 'addon/ljpost/livejournal.png', + 'title' => DI::l10n()->t('LiveJournal Export'), + 'image' => 'addon/ljpost/livejournal.png', 'enabled' => $enabled, - 'html' => $html, + 'html' => $html, ]; } diff --git a/opmlexport/opmlexport.php b/opmlexport/opmlexport.php index fdfacc3e..92d6b7b0 100644 --- a/opmlexport/opmlexport.php +++ b/opmlexport/opmlexport.php @@ -29,8 +29,8 @@ function opmlexport_install() function opmlexport() { $condition = [ - 'uid' => DI::userSession()->getLocalUserId(), - 'self' => false, + 'uid' => DI::userSession()->getLocalUserId(), + 'self' => false, 'deleted' => false, 'archive' => false, 'blocked' => false, diff --git a/planets/planets.php b/planets/planets.php index 8a206fb5..2937c036 100644 --- a/planets/planets.php +++ b/planets/planets.php @@ -81,38 +81,28 @@ function planets_post_hook(&$item) return; } - - - /** - * * Callback from the settings post function. * $post contains the $_POST array. * We will make sure we've got a valid user account * and if so set our configuration setting for this person. - * */ - -function planets_settings_post($post) +function planets_settings_post(array $post) { if (!DI::userSession()->getLocalUserId()) { return; } - if ($_POST['planets-submit']) { - DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'planets', 'enable' ,intval($_POST['planets'])); + if ($post['planets-submit']) { + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'planets', 'enable' ,intval($post['planets'])); } } /** - * * Called from the Addon Setting form. * Add our own settings info to the page. * */ - - - function planets_settings(array &$data) { if(!DI::userSession()->getLocalUserId()) { diff --git a/public_server/public_server.php b/public_server/public_server.php index 7591c7d0..545f4f80 100644 --- a/public_server/public_server.php +++ b/public_server/public_server.php @@ -140,14 +140,14 @@ function public_server_addon_admin(string &$o) $token = BaseModule::getFormSecurityToken('publicserver'); $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/public_server'); $o = Renderer::replaceMacros($t, [ - '$submit' => DI::l10n()->t('Save Settings'), + '$submit' => DI::l10n()->t('Save Settings'), '$form_security_token' => $token, - '$infotext' => DI::l10n()->t('Set any of these options to 0 to deactivate it.'), - '$expiredays' => ["expiredays", "Expire Days", intval(DI::config()->get('public_server', 'expiredays')), "When an account is created on the site, it is given a hard "], - '$expireposts' => ["expireposts", "Expire Posts", intval(DI::config()->get('public_server', 'expireposts')), "Set the default days for posts to expire here"], - '$nologin' => ["nologin", "No Login", intval(DI::config()->get('public_server', 'nologin')), "Remove users who have never logged in after nologin days "], - '$flagusers' => ["flagusers", "Flag users", intval(DI::config()->get('public_server', 'flagusers')), "Remove users who last logged in over flagusers days ago"], - '$flagposts' => ["flagposts", "Flag posts", intval(DI::config()->get('public_server', 'flagposts')), "For users who last logged in over flagposts days ago set post expiry days to flagpostsexpire "], - '$flagpostsexpire' => ["flagpostsexpire", "Flag posts expire", intval(DI::config()->get('public_server', 'flagpostsexpire'))], + '$infotext' => DI::l10n()->t('Set any of these options to 0 to deactivate it.'), + '$expiredays' => ['expiredays', 'Expire Days', intval(DI::config()->get('public_server', 'expiredays')), 'When an account is created on the site, it is given a hard '], + '$expireposts' => ['expireposts', 'Expire Posts', intval(DI::config()->get('public_server', 'expireposts')), 'Set the default days for posts to expire here'], + '$nologin' => ['nologin', 'No Login', intval(DI::config()->get('public_server', 'nologin')), 'Remove users who have never logged in after nologin days '], + '$flagusers' => ['flagusers', 'Flag users', intval(DI::config()->get('public_server', 'flagusers')), 'Remove users who last logged in over flagusers days ago'], + '$flagposts' => ['flagposts', 'Flag posts', intval(DI::config()->get('public_server', 'flagposts')), 'For users who last logged in over flagposts days ago set post expiry days to flagpostsexpire '], + '$flagpostsexpire' => ['flagpostsexpire', 'Flag posts expire', intval(DI::config()->get('public_server', 'flagpostsexpire'))], ]); } diff --git a/randplace/randplace.php b/randplace/randplace.php index 34f48c6c..37182ab0 100644 --- a/randplace/randplace.php +++ b/randplace/randplace.php @@ -142,7 +142,7 @@ function randplace_settings(array &$data) return; } - $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(),'randplace','enable'); + $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'randplace', 'enable'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/randplace/'); $html = Renderer::replaceMacros($t, [ diff --git a/saml/README.md b/saml/README.md old mode 100755 new mode 100644 diff --git a/saml/saml.php b/saml/saml.php old mode 100755 new mode 100644 index 56dd0f5d..a0710992 --- a/saml/saml.php +++ b/saml/saml.php @@ -10,6 +10,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; +use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\User; @@ -91,7 +92,7 @@ if (target.length) { target.append("

$fragment

"); } EOL; } -function saml_is_configured() +function saml_is_configured(): bool { return DI::config()->get('saml', 'idp_id') && @@ -113,11 +114,8 @@ function saml_sso_initiate(string &$body) $auth = new \OneLogin\Saml2\Auth(saml_settings()); $ssoBuiltUrl = $auth->login(null, [], false, false, true); - DI::session()->set('AuthNRequestID', $auth->getLastRequestID()); - header('Pragma: no-cache'); - header('Cache-Control: no-cache, must-revalidate'); - header('Location: ' . $ssoBuiltUrl); - exit(); + $_SESSION['AuthNRequestID'] = $auth->getLastRequestID(); + System::externalRedirect($ssoBuiltUrl, 302, true); } function saml_sso_reply() @@ -177,13 +175,9 @@ function saml_slo_initiate() } $auth = new \OneLogin\Saml2\Auth(saml_settings()); - $sloBuiltUrl = $auth->logout(); - DI::session()->set('LogoutRequestID', $auth->getLastRequestID()); - header('Pragma: no-cache'); - header('Cache-Control: no-cache, must-revalidate'); - header('Location: ' . $sloBuiltUrl); - exit(); + $_SESSION['LogoutRequestID'] = $auth->getLastRequestID(); + System::externalRedirect($sloBuiltUrl, 302, true); } function saml_slo_reply() @@ -207,7 +201,7 @@ function saml_slo_reply() } } -function saml_input($key, $label, $description) +function saml_input($key, $label, $description): array { return [ '$' . $key => [ @@ -333,7 +327,7 @@ function saml_create_user($username, $email, $name) } } -function saml_settings() +function saml_settings(): array { return [ diff --git a/showmore/showmore.php b/showmore/showmore.php index 8e85925a..e31e0480 100644 --- a/showmore/showmore.php +++ b/showmore/showmore.php @@ -108,7 +108,7 @@ function showmore_prepare_body(&$hook_data) if (get_body_length($hook_data['html']) > $chars) { $found = true; - $shortened = trim(showmore_cutitem($hook_data['html'], $chars)) . "..."; + $shortened = trim(showmore_cutitem($hook_data['html'], $chars)) . '...'; } else { $found = false; } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index f0372852..cf4aef2b 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -91,8 +91,8 @@ function statusnet_settings_post($post) } if (!empty($_POST['statusnet-disconnect'])) { - /* * * - * if the GNU Social-disconnect button is clicked, clear the GNU Social configuration + /* + * If the GNU Social-disconnect button is clicked, clear the GNU Social configuration */ DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'statusnet', 'consumerkey'); DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'statusnet', 'consumersecret'); -- 2.39.5