]> git.mxchange.org Git - friendica-addons.git/commitdiff
Support for cleared boot.php
authorMichael <heluecht@pirati.ca>
Thu, 4 Nov 2021 20:32:16 +0000 (20:32 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 4 Nov 2021 20:32:16 +0000 (20:32 +0000)
15 files changed:
blockbot/blockbot.php
cookienotice/cookienotice.php
curweather/curweather.php
diaspora/Diaspora_Connection.php
diaspora/diasphp.php
irc/irc.php
mailstream/mailstream.php
mailstream/phpmailer/class.phpmailer.php
notifyall/notifyall.php
pageheader/pageheader.php
rendertime/rendertime.php
statusnet/library/codebirdsn.php
statusnet/statusnet.php
twitter/twitter.php
windowsphonepush/windowsphonepush.php

index 3c5e33195bb9430d0bf2469631d46b3c35ffe6f3..0ff372c502862a3b8f1a4093f5f99cf9acaf2f40 100644 (file)
@@ -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');
 }
index 4ca862800b2e78064d2a4dac274561b90703f5e6..bec98184436a016cc006faaae1dc1473c3ec585b 100644 (file)
@@ -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;
        }
 
index 0fd60eac26f10936898c8930306496426f5a82eb..118c4a9a550beb10b7b57f5cfb69556f164b2a41 100644 (file)
@@ -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;
        }
 
index a33bf608950f1ef8a4f9b6d546dc1d8d8103d595..d8390d707b965a8bb29c59179e6229a4ad0ec97f 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\Core\System;
+
 /**
  * Super-skeletal class to interact with Diaspora.
  *
@@ -29,7 +32,7 @@ class Diaspora_Connection {
                        $this->setPassword($password);
                }
 
-               $this->cookiejar = tempnam(get_temppath(), 'cookies');
+               $this->cookiejar = tempnam(System::getTempPath(), 'cookies');
                return $this;
        }
 
index f48933a62115e32b85b636732bcdba06a2279c36..4225353e64742c6ac69cbdc5e8314c1bc5ddb71c 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\Core\System;
+
 /**
  * Ein fies zusammengehackter PHP-Diaspory-Client, der direkt von diesem abgeschaut ist:
  * https://github.com/Javafant/diaspy/blob/master/client.py
@@ -11,7 +14,7 @@ class Diasphp {
                $this->token_regex = '/content="(.*?)" name="csrf-token/';
 
                $this->pod = $pod;
-               $this->cookiejar = tempnam(get_temppath(), 'cookies');
+               $this->cookiejar = tempnam(System::getTempPath(), 'cookies');
        }
 
        function __destruct() {
index 4cb99c3f67ee4ff8d44595dbaacd34e1fb04bf9f..b441cebf3078722502a4f317e6cb25885407d073 100644 (file)
@@ -118,7 +118,7 @@ return $o;
 }
 
 function irc_addon_admin_post (&$a) {
-       if(! is_site_admin())
+       if(!$a->isSiteAdmin())
                return;
 
        if($_POST['irc-submit']) {
index 9739913d2f1825263158e8b1199e502c2e720fa4..7e3f87f8c3a3c3f5ff46283745d0c96a1ff30c3c 100644 (file)
@@ -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(),
index 46ff4360c259b75e2935b37ef9866c6ddd78e639..ab7fe030588c6406728c1476240a07a1da554c3f 100644 (file)
@@ -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(
index e5e94c7ec7e68786d9efe00926d52d0021bc48bd..8eff509313db966ae641d79e1906df5c11114c93 100644 (file)
@@ -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 '';
        }
 
index f0d75400e80e1645795800ffec8e5aa3bc7e44ed..ce3b26844e4d6e084948ca6a3b408b51e5b0021d 100644 (file)
@@ -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;
        }
 
index 1d8e9701935d8cb6324395d5c98b4d85fa73d077..135bcc76f2283e28715ae46c5abab5294664402a 100644 (file)
@@ -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 . '<div class="renderinfo">' . DI::l10n()->t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s",
                                round($profiler->get('database') - $profiler->get('database_write'), 3),
index cba5f9360f2cf794f53dc539ba5de2f83aa29d85..e5e281b9a38a03d473e10cf201f8fa4f91a4ebf6 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace CodebirdSN;
 
+use Friendica\Core\System;
+
 /**
  * A Twitter library in PHP.
  *
@@ -820,7 +822,7 @@ class CodebirdSN
                 }
 
                // To-Do
-               $tempfile = tempnam(get_temppath(), "mimecheck");
+               $tempfile = tempnam(System::getTempPath(), "mimecheck");
                file_put_contents($tempfile, $data);
                $mime = image_type_to_mime_type(exif_imagetype($tempfile));
                unlink($tempfile);
index e474264ec37d4870dffa835b1dca0cbd59039eea..75e4415151188f7a9c0b74d3b09e3b73d8d420db 100644 (file)
@@ -47,6 +47,7 @@ use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -599,7 +600,7 @@ function statusnet_post_hook(App $a, &$b)
 
                if ($image != "") {
                        $img_str = DI::httpClient()->fetch($image);
-                       $tempfile = tempnam(get_temppath(), "cache");
+                       $tempfile = tempnam(System::getTempPath(), "cache");
                        file_put_contents($tempfile, $img_str);
                        $postdata = ["status" => $msg, "media[]" => $tempfile];
                } else {
@@ -1417,7 +1418,7 @@ function statusnet_convertmsg(App $a, $body)
                        } else {
                                $img_str = DI::httpClient()->fetch($expanded_url, 4);
 
-                               $tempfile = tempnam(get_temppath(), "cache");
+                               $tempfile = tempnam(System::getTempPath(), "cache");
                                file_put_contents($tempfile, $img_str);
                                $mime = mime_content_type($tempfile);
                                unlink($tempfile);
index ef64e1a2d15c517d8f5db75e908cf0151c247267..6f53b2e4f7e426ee35df28d0fcf42890672b8611 100644 (file)
@@ -85,6 +85,7 @@ use Friendica\Model\Tag;
 use Friendica\Model\User;
 use Friendica\Protocol\Activity;
 use Friendica\Core\Config\Util\ConfigFileLoader;
+use Friendica\Core\System;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Images;
 use Friendica\Util\Strings;
@@ -734,7 +735,7 @@ function twitter_post_hook(App $a, array &$b)
 
                                        $img_str = DI::httpClient()->fetch($image['url']);
 
-                                       $tempfile = tempnam(get_temppath(), 'cache');
+                                       $tempfile = tempnam(System::getTempPath(), 'cache');
                                        file_put_contents($tempfile, $img_str);
 
                                        Logger::info('Uploading', ['id' => $b['id'], 'image' => $image['url']]);
index 6ee4e0f025ee9198377b4fb00eeadfcc11ede5d2..4201db661b6f88dd7f23e1e157addf3c8694c30b 100644 (file)
@@ -36,6 +36,7 @@ use Friendica\DI;
 use Friendica\Model\Item;
 use Friendica\Model\Post;
 use Friendica\Model\User;
+use Friendica\Network\HTTPException\UnauthorizedException;
 
 function windowsphonepush_install()
 {
@@ -436,8 +437,7 @@ function windowsphonepush_login(App $a)
        if (!isset($_SERVER['PHP_AUTH_USER'])) {
                Logger::info('API_login: ' . print_r($_SERVER, true));
                header('WWW-Authenticate: Basic realm="Friendica"');
-               header('HTTP/1.0 401 Unauthorized');
-               die('This api requires login');
+               throw new UnauthorizedException('This api requires login');
        }
 
        $user_id = User::authenticate($_SERVER['PHP_AUTH_USER'], trim($_SERVER['PHP_AUTH_PW']));
@@ -447,8 +447,7 @@ function windowsphonepush_login(App $a)
        } else {
                Logger::info('API_login failure: ' . print_r($_SERVER, true));
                header('WWW-Authenticate: Basic realm="Friendica"');
-               header('HTTP/1.0 401 Unauthorized');
-               die('This api requires login');
+               throw new UnauthorizedException('This api requires login');
        }
 
        DI::auth()->setForUser($a, $record);