diff --git a/blockbot/blockbot.php b/blockbot/blockbot.php index 3c5e33195..0ff372c50 100644 --- a/blockbot/blockbot.php +++ b/blockbot/blockbot.php @@ -15,6 +15,7 @@ use Friendica\DI; use Jaybizzle\CrawlerDetect\CrawlerDetect; use Friendica\Core\Logger; use Friendica\Core\Renderer; +use Friendica\Network\HTTPException\ForbiddenException; require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; @@ -92,7 +93,7 @@ function blockbot_init_1(App $a) { foreach ($agents as $agent) { if (stristr($_SERVER['HTTP_USER_AGENT'], $agent)) { - System::httpExit(403, 'Bots are not allowed'); + throw new ForbiddenException('Bots are not allowed'); } } @@ -130,5 +131,5 @@ function blockbot_init_1(App $a) { } logger::info('Blocked bot', $logdata); - System::httpExit(403, 'Bots are not allowed'); + throw new ForbiddenException('Bots are not allowed'); } diff --git a/cookienotice/cookienotice.php b/cookienotice/cookienotice.php index 4ca862800..bec981844 100644 --- a/cookienotice/cookienotice.php +++ b/cookienotice/cookienotice.php @@ -35,7 +35,7 @@ function cookienotice_install() */ function cookienotice_addon_admin(App $a, &$s) { - if (!is_site_admin()) { + if (!$a->isSiteAdmin()) { return; } @@ -63,7 +63,7 @@ function cookienotice_addon_admin(App $a, &$s) */ function cookienotice_addon_admin_post(App $a) { - if (!is_site_admin()) { + if (!$a->isSiteAdmin()) { return; } diff --git a/curweather/curweather.php b/curweather/curweather.php index 0fd60eac2..118c4a9a5 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -204,7 +204,7 @@ function curweather_addon_settings(App $a, &$s) // for accessing the API of openweathermap function curweather_addon_admin_post(App $a) { - if (!is_site_admin()) { + if (!$a->isSiteAdmin()) { return; } @@ -216,7 +216,7 @@ function curweather_addon_admin_post(App $a) function curweather_addon_admin(App $a, &$o) { - if (!is_site_admin()) { + if (!$a->isSiteAdmin()) { return; } diff --git a/diaspora/Diaspora_Connection.php b/diaspora/Diaspora_Connection.php index a33bf6089..d8390d707 100644 --- a/diaspora/Diaspora_Connection.php +++ b/diaspora/Diaspora_Connection.php @@ -1,4 +1,7 @@ setPassword($password); } - $this->cookiejar = tempnam(get_temppath(), 'cookies'); + $this->cookiejar = tempnam(System::getTempPath(), 'cookies'); return $this; } diff --git a/diaspora/diasphp.php b/diaspora/diasphp.php index f48933a62..4225353e6 100644 --- a/diaspora/diasphp.php +++ b/diaspora/diasphp.php @@ -1,4 +1,7 @@ token_regex = '/content="(.*?)" name="csrf-token/'; $this->pod = $pod; - $this->cookiejar = tempnam(get_temppath(), 'cookies'); + $this->cookiejar = tempnam(System::getTempPath(), 'cookies'); } function __destruct() { diff --git a/irc/irc.php b/irc/irc.php index 4cb99c3f6..b441cebf3 100644 --- a/irc/irc.php +++ b/irc/irc.php @@ -118,7 +118,7 @@ return $o; } function irc_addon_admin_post (&$a) { - if(! is_site_admin()) + if(!$a->isSiteAdmin()) return; if($_POST['irc-submit']) { diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 9739913d2..7e3f87f8c 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.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\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; @@ -204,7 +205,7 @@ function mailstream_do_images(&$item, &$attachments) if (!$components) { continue; } - $cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-'); + $cookiejar = tempnam(System::getTempPath(), 'cookiejar-mailstream-'); $curlResult = DI::httpClient()->fetchFull($url, 0, '', $cookiejar); $attachments[$url] = [ 'data' => $curlResult->getBody(), diff --git a/mailstream/phpmailer/class.phpmailer.php b/mailstream/phpmailer/class.phpmailer.php index 46ff4360c..ab7fe0305 100644 --- a/mailstream/phpmailer/class.phpmailer.php +++ b/mailstream/phpmailer/class.phpmailer.php @@ -17,6 +17,8 @@ * FITNESS FOR A PARTICULAR PURPOSE. */ +use Friendica\Core\System; + /** * PHPMailer - PHP email creation and transport class. * @package PHPMailer @@ -2350,11 +2352,11 @@ class PHPMailer throw new phpmailerException($this->lang('extension_missing') . 'openssl'); } // @TODO would be nice to use php://temp streams here, but need to wrap for PHP < 5.1 - $file = tempnam(get_temppath(), 'mail'); + $file = tempnam(System::getTempPath(), 'mail'); if (false === file_put_contents($file, $body)) { throw new phpmailerException($this->lang('signing') . ' Could not write temp file'); } - $signed = tempnam(get_temppath(), 'signed'); + $signed = tempnam(System::getTempPath(), 'signed'); //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197 if (empty($this->sign_extracerts_file)) { $sign = @openssl_pkcs7_sign( diff --git a/notifyall/notifyall.php b/notifyall/notifyall.php index e5e94c7ec..8eff50931 100644 --- a/notifyall/notifyall.php +++ b/notifyall/notifyall.php @@ -25,7 +25,7 @@ function notifyall_addon_admin(App $a, &$o) function notifyall_post(App $a) { - if(!is_site_admin()) { + if (!$a->isSiteAdmin()) { return; } @@ -62,7 +62,7 @@ function notifyall_post(App $a) function notifyall_content(&$a) { - if (! is_site_admin()) { + if (!$a->isSiteAdmin()) { return ''; } diff --git a/pageheader/pageheader.php b/pageheader/pageheader.php index f0d75400e..ce3b26844 100644 --- a/pageheader/pageheader.php +++ b/pageheader/pageheader.php @@ -19,7 +19,7 @@ function pageheader_install() { function pageheader_addon_admin(App &$a, &$s) { - if(! is_site_admin()) { + if (!$a->isSiteAdmin()) { return; } @@ -43,7 +43,7 @@ function pageheader_addon_admin(App &$a, &$s) function pageheader_addon_admin_post(App $a) { - if(!is_site_admin()) { + if (!$a->isSiteAdmin()) { return; } diff --git a/rendertime/rendertime.php b/rendertime/rendertime.php index 1d8e97019..135bcc76f 100644 --- a/rendertime/rendertime.php +++ b/rendertime/rendertime.php @@ -31,7 +31,7 @@ function rendertime_page_end(Friendica\App $a, &$o) $ignored_modules = ["fbrowser"]; $ignored = in_array(DI::module()->getName(), $ignored_modules); - if (is_site_admin() && (($_GET['mode'] ?? '') != 'minimal') && !DI::mode()->isMobile() && !DI::mode()->isMobile() && !$ignored) { + if ($a->isSiteAdmin() && (($_GET['mode'] ?? '') != 'minimal') && !DI::mode()->isMobile() && !DI::mode()->isMobile() && !$ignored) { $o = $o . '