]> git.mxchange.org Git - friendica.git/commitdiff
The boot.php had been cleared of most functions
authorMichael <heluecht@pirati.ca>
Thu, 4 Nov 2021 20:29:59 +0000 (20:29 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 4 Nov 2021 20:29:59 +0000 (20:29 +0000)
37 files changed:
boot.php
include/api.php
mod/photos.php
mod/ping.php
mod/settings.php
mod/uimport.php
mod/wall_upload.php
src/App.php
src/App/Page.php
src/Content/Conversation.php
src/Content/Nav.php
src/Content/Widget.php
src/Core/Lock/Type/SemaphoreLock.php
src/Core/Renderer.php
src/Core/System.php
src/Core/Worker.php
src/Model/Item.php
src/Model/Photo.php
src/Model/User.php
src/Module/ActivityPub/Inbox.php
src/Module/Admin/Site.php
src/Module/BaseAdmin.php
src/Module/Invite.php
src/Module/Special/HTTPException.php
src/Module/WellKnown/XSocialRelay.php
src/Network/HTTPClient/Factory/HttpClient.php
src/Object/Image.php
src/Protocol/DFRN.php
src/Protocol/Relay.php
src/Render/FriendicaSmartyEngine.php
src/Worker/OnePoll.php
src/Worker/SpoolPost.php
static/defaults.config.php
static/settings.config.php
tests/datasets/config/.htconfig.php
tests/src/Core/Lock/SemaphoreLockTest.php
view/theme/frio/config.php

index a4d0fe5c735e3c2be51e36115490ff93dc229f62..d291220ce8be19c4cc40c9a221d486acd992fbc9 100644 (file)
--- a/boot.php
+++ b/boot.php
  * easily as email does today.
  */
 
-use Friendica\Core\Protocol;
-use Friendica\Core\System;
-use Friendica\Database\DBA;
-use Friendica\DI;
 use Friendica\Model\Contact;
-use Friendica\Model\Notification;
-use Friendica\Util\BasePath;
-use Friendica\Util\DateTimeFormat;
 
 define('FRIENDICA_PLATFORM',     'Friendica');
 define('FRIENDICA_CODENAME',     'Siberian Iris');
@@ -51,51 +44,6 @@ define('NEW_TABLE_STRUCTURE_VERSION', 1288);
  */
 define('EOL',                    "<br />\r\n");
 
-/**
- * Image storage quality.
- *
- * Lower numbers save space at cost of image detail.
- * For ease of upgrade, please do not change here. Set system.jpegquality = n in config/local.config.php,
- * where n is between 1 and 100, and with very poor results below about 50
- */
-define('JPEG_QUALITY',            100);
-
-/**
- * system.png_quality = n where is between 0 (uncompressed) to 9
- */
-define('PNG_QUALITY',             8);
-
-/**
- * An alternate way of limiting picture upload sizes. Specify the maximum pixel
- * length that pictures are allowed to be (for non-square pictures, it will apply
- * to the longest side). Pictures longer than this length will be resized to be
- * this length (on the longest side, the other side will be scaled appropriately).
- * Modify this value using
- *
- * 'system' => [
- *      'max_image_length' => 'n',
- *      ...
- * ],
- *
- * in config/local.config.php
- *
- * If you don't want to set a maximum length, set to -1. The default value is
- * defined by 'MAX_IMAGE_LENGTH' below.
- */
-define('MAX_IMAGE_LENGTH',        -1);
-
-/**
- * Not yet used
- */
-define('DEFAULT_DB_ENGINE',  'InnoDB');
-
-/** @deprecated since version 2019.03, please use \Friendica\Module\Register::CLOSED instead */
-define('REGISTER_CLOSED',        \Friendica\Module\Register::CLOSED);
-/** @deprecated since version 2019.03, please use \Friendica\Module\Register::APPROVE instead */
-define('REGISTER_APPROVE',       \Friendica\Module\Register::APPROVE);
-/** @deprecated since version 2019.03, please use \Friendica\Module\Register::OPEN instead */
-define('REGISTER_OPEN',          \Friendica\Module\Register::OPEN);
-
 /**
  * @name CP
  *
@@ -111,72 +59,6 @@ define('CP_USERS_AND_GLOBAL',       2);
  * @}
  */
 
-/**
- * These numbers are used in stored permissions
- * and existing allocations MUST NEVER BE CHANGED
- * OR RE-ASSIGNED! You may only add to them.
- */
-$netgroup_ids = [
-       Protocol::DFRN     => (-1),
-       Protocol::ZOT      => (-2),
-       Protocol::OSTATUS  => (-3),
-       Protocol::FEED     => (-4),
-       Protocol::DIASPORA => (-5),
-       Protocol::MAIL     => (-6),
-       Protocol::FACEBOOK => (-8),
-       Protocol::LINKEDIN => (-9),
-       Protocol::XMPP     => (-10),
-       Protocol::MYSPACE  => (-11),
-       Protocol::GPLUS    => (-12),
-       Protocol::PUMPIO   => (-13),
-       Protocol::TWITTER  => (-14),
-       Protocol::DIASPORA2 => (-15),
-       Protocol::STATUSNET => (-16),
-       Protocol::NEWS      => (-18),
-       Protocol::ICALENDAR => (-19),
-       Protocol::PNUT      => (-20),
-
-       Protocol::PHANTOM  => (-127),
-];
-
-/**
- * Maximum number of "people who like (or don't like) this"  that we will list by name
- */
-define('MAX_LIKERS',    75);
-
-/**
- * @name Notification
- *
- * Email notification options
- * @{
- */
-/** @deprecated since 2020.03, use Notification\Type::INTRO instead */
-define('NOTIFY_INTRO',        Notification\Type::INTRO);
-/** @deprecated since 2020.03, use Notification\Type::CONFIRM instead */
-define('NOTIFY_CONFIRM',      Notification\Type::CONFIRM);
-/** @deprecated since 2020.03, use Notification\Type::WALL instead */
-define('NOTIFY_WALL',         Notification\Type::WALL);
-/** @deprecated since 2020.03, use Notification\Type::COMMENT instead */
-define('NOTIFY_COMMENT',      Notification\Type::COMMENT);
-/** @deprecated since 2020.03, use Notification\Type::MAIL instead */
-define('NOTIFY_MAIL',        Notification\Type::MAIL);
-/** @deprecated since 2020.03, use Notification\Type::SUGGEST instead */
-define('NOTIFY_SUGGEST',     Notification\Type::SUGGEST);
-/** @deprecated since 2020.03, use Notification\Type::PROFILE instead */
-define('NOTIFY_PROFILE',     Notification\Type::PROFILE);
-/** @deprecated since 2020.03, use Notification\Type::TAG_SELF instead */
-define('NOTIFY_TAGSELF',     Notification\Type::TAG_SELF);
-/** @deprecated since 2020.03, use Notification\Type::TAG_SHARE instead */
-define('NOTIFY_TAGSHARE',    Notification\Type::TAG_SHARE);
-/** @deprecated since 2020.03, use Notification\Type::POKE instead */
-define('NOTIFY_POKE',        Notification\Type::POKE);
-/** @deprecated since 2020.03, use Notification\Type::SHARE instead */
-define('NOTIFY_SHARE',       Notification\Type::SHARE);
-
-/** @deprecated since 2020.12, use Notification\Type::SYSTEM instead */
-define('NOTIFY_SYSTEM',      Notification\Type::SYSTEM);
-/* @}*/
-
 /**
  * @name Gravity
  *
@@ -204,18 +86,6 @@ define('PRIORITY_NEGLIGIBLE', 50);
 define('PRIORITIES', [PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE]);
 /* @}*/
 
-/**
- * @name Social Relay settings
- *
- * See here: https://github.com/jaywink/social-relay
- * and here: https://wiki.diasporafoundation.org/Relay_servers_for_public_posts
- * @{
- */
-define('SR_SCOPE_NONE', '');
-define('SR_SCOPE_ALL',  'all');
-define('SR_SCOPE_TAGS', 'tags');
-/* @}*/
-
 // Normally this constant is defined - but not if "pcntl" isn't installed
 if (!defined("SIGTERM")) {
        define("SIGTERM", 15);
@@ -229,6 +99,14 @@ if (!defined('CURLE_OPERATION_TIMEDOUT')) {
        define('CURLE_OPERATION_TIMEDOUT', CURLE_OPERATION_TIMEOUTED);
 }
 
+if (!function_exists('exif_imagetype')) {
+       function exif_imagetype($file)
+       {
+               $size = getimagesize($file);
+               return $size[2];
+       }
+}
+
 /**
  * Returns the user id of locally logged in user or false.
  *
@@ -323,200 +201,3 @@ function info($s)
 
        $_SESSION['sysmsg_info'][] = $s;
 }
-
-function feed_birthday($uid, $tz)
-{
-       /**
-        * Determine the next birthday, but only if the birthday is published
-        * in the default profile. We _could_ also look for a private profile that the
-        * recipient can see, but somebody could get mad at us if they start getting
-        * public birthday greetings when they haven't made this info public.
-        *
-        * Assuming we are able to publish this info, we are then going to convert
-        * the start time from the owner's timezone to UTC.
-        *
-        * This will potentially solve the problem found with some social networks
-        * where birthdays are converted to the viewer's timezone and salutations from
-        * elsewhere in the world show up on the wrong day. We will convert it to the
-        * viewer's timezone also, but first we are going to convert it from the birthday
-        * person's timezone to GMT - so the viewer may find the birthday starting at
-        * 6:00PM the day before, but that will correspond to midnight to the birthday person.
-        */
-       $birthday = '';
-
-       if (!strlen($tz)) {
-               $tz = 'UTC';
-       }
-
-       $profile = DBA::selectFirst('profile', ['dob'], ['uid' => $uid]);
-       if (DBA::isResult($profile)) {
-               $tmp_dob = substr($profile['dob'], 5);
-               if (intval($tmp_dob)) {
-                       $y = DateTimeFormat::timezoneNow($tz, 'Y');
-                       $bd = $y . '-' . $tmp_dob . ' 00:00';
-                       $t_dob = strtotime($bd);
-                       $now = strtotime(DateTimeFormat::timezoneNow($tz));
-                       if ($t_dob < $now) {
-                               $bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
-                       }
-                       $birthday = DateTimeFormat::convert($bd, 'UTC', $tz, DateTimeFormat::ATOM);
-               }
-       }
-
-       return $birthday;
-}
-
-/**
- * Check if current user has admin role.
- *
- * @return bool true if user is an admin
- */
-function is_site_admin()
-{
-       $a = DI::app();
-
-       $admin_email = DI::config()->get('config', 'admin_email');
-
-       $adminlist = explode(',', str_replace(' ', '', $admin_email));
-
-       return local_user() && $admin_email && DBA::exists('user', ['uid' => $a->getLoggedInUserId(), 'email' => $adminlist]);
-}
-
-/**
- * Returns the complete URL of the current page, e.g.: http(s)://something.com/network
- *
- * Taken from http://webcheatsheet.com/php/get_current_page_url.php
- */
-function curPageURL()
-{
-       $pageURL = 'http';
-       if (!empty($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on")) {
-               $pageURL .= "s";
-       }
-
-       $pageURL .= "://";
-
-       if ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") {
-               $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
-       } else {
-               $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
-       }
-       return $pageURL;
-}
-
-function get_temppath()
-{
-       $temppath = DI::config()->get("system", "temppath");
-
-       if (($temppath != "") && System::isDirectoryUsable($temppath)) {
-               // We have a temp path and it is usable
-               return BasePath::getRealPath($temppath);
-       }
-
-       // We don't have a working preconfigured temp path, so we take the system path.
-       $temppath = sys_get_temp_dir();
-
-       // Check if it is usable
-       if (($temppath != "") && System::isDirectoryUsable($temppath)) {
-               // Always store the real path, not the path through symlinks
-               $temppath = BasePath::getRealPath($temppath);
-
-               // To avoid any interferences with other systems we create our own directory
-               $new_temppath = $temppath . "/" . DI::baseUrl()->getHostname();
-               if (!is_dir($new_temppath)) {
-                       /// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method?
-                       mkdir($new_temppath);
-               }
-
-               if (System::isDirectoryUsable($new_temppath)) {
-                       // The new path is usable, we are happy
-                       DI::config()->set("system", "temppath", $new_temppath);
-                       return $new_temppath;
-               } else {
-                       // We can't create a subdirectory, strange.
-                       // But the directory seems to work, so we use it but don't store it.
-                       return $temppath;
-               }
-       }
-
-       // Reaching this point means that the operating system is configured badly.
-       return '';
-}
-
-/**
- * Returns the path where spool files are stored
- *
- * @return string Spool path
- */
-function get_spoolpath()
-{
-       $spoolpath = DI::config()->get('system', 'spoolpath');
-       if (($spoolpath != "") && System::isDirectoryUsable($spoolpath)) {
-               // We have a spool path and it is usable
-               return $spoolpath;
-       }
-
-       // We don't have a working preconfigured spool path, so we take the temp path.
-       $temppath = get_temppath();
-
-       if ($temppath != "") {
-               // To avoid any interferences with other systems we create our own directory
-               $spoolpath = $temppath . "/spool";
-               if (!is_dir($spoolpath)) {
-                       mkdir($spoolpath);
-               }
-
-               if (System::isDirectoryUsable($spoolpath)) {
-                       // The new path is usable, we are happy
-                       DI::config()->set("system", "spoolpath", $spoolpath);
-                       return $spoolpath;
-               } else {
-                       // We can't create a subdirectory, strange.
-                       // But the directory seems to work, so we use it but don't store it.
-                       return $temppath;
-               }
-       }
-
-       // Reaching this point means that the operating system is configured badly.
-       return "";
-}
-
-if (!function_exists('exif_imagetype')) {
-       function exif_imagetype($file)
-       {
-               $size = getimagesize($file);
-               return $size[2];
-       }
-}
-
-function validate_include(&$file)
-{
-       $orig_file = $file;
-
-       $file = realpath($file);
-
-       if (strpos($file, getcwd()) !== 0) {
-               return false;
-       }
-
-       $file = str_replace(getcwd() . "/", "", $file, $count);
-       if ($count != 1) {
-               return false;
-       }
-
-       if ($orig_file !== $file) {
-               return false;
-       }
-
-       $valid = false;
-       if (strpos($file, "include/") === 0) {
-               $valid = true;
-       }
-
-       if (strpos($file, "addon/") === 0) {
-               $valid = true;
-       }
-
-       // Simply return flag
-       return $valid;
-}
index 6a00268b04604adb0a31b4c53a99454163f59f27..2495f5d192be9faf16feeb178b303f109eb02e19 100644 (file)
@@ -4604,9 +4604,6 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
 
        // check max length of images on server
        $max_length = DI::config()->get('system', 'max_image_length');
-       if (!$max_length) {
-               $max_length = MAX_IMAGE_LENGTH;
-       }
        if ($max_length > 0) {
                $Image->scaleDown($max_length);
                logger::info("File upload: Scaling picture to new size " . $max_length);
index 2efd3a5a7af55aa4459eec73955ba37b47bc81bd..5ca9aa600ae93b311ca8bd168cc7106036ab9e04 100644 (file)
@@ -703,9 +703,6 @@ function photos_post(App $a)
        @unlink($src);
 
        $max_length = DI::config()->get('system', 'max_image_length');
-       if (!$max_length) {
-               $max_length = MAX_IMAGE_LENGTH;
-       }
        if ($max_length > 0) {
                $image->scaleDown($max_length);
        }
index c12594902ae6acee3270d407ea15ad6aef32f735..fce4cbcf01b5b2a37a8ef7a9d66d08323b612205 100644 (file)
@@ -196,7 +196,7 @@ function ping_init(App $a)
                $myurl = DI::baseUrl() . '/profile/' . $a->getLoggedInUserNickname();
                $mail_count = DBA::count('mail', ["`uid` = ? AND NOT `seen` AND `from-url` != ?", local_user(), $myurl]);
 
-               if (intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::APPROVE && is_site_admin()) {
+               if (intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::APPROVE && $a->isSiteAdmin()) {
                        $regs = Friendica\Model\Register::getPending();
 
                        if (DBA::isResult($regs)) {
index e84917c35c67c9d9361e72ac214b4676fc563812..d3fbd81db83d44efde74569e2453e748ec740eef 100644 (file)
@@ -492,7 +492,7 @@ function settings_content(App $a)
                $settings_connectors = '';
                Hook::callAll('connector_settings', $settings_connectors);
 
-               if (is_site_admin()) {
+               if ($a->isSiteAdmin()) {
                        $diasp_enabled = DI::l10n()->t('Built-in support for %s connectivity is %s', DI::l10n()->t('Diaspora (Socialhome, Hubzilla)'), ((DI::config()->get('system', 'diaspora_enabled')) ? DI::l10n()->t('enabled') : DI::l10n()->t('disabled')));
                        $ostat_enabled = DI::l10n()->t('Built-in support for %s connectivity is %s', DI::l10n()->t('OStatus (GNU Social)'), ((DI::config()->get('system', 'ostatus_disabled')) ? DI::l10n()->t('disabled') : DI::l10n()->t('enabled')));
                } else {
index 62bece5e3a2cc0291986339a7358d05e567a2079..a00bf250873c7165048495c364d8a5470f4475b3 100644 (file)
@@ -29,7 +29,7 @@ use Friendica\DI;
 
 function uimport_post(App $a)
 {
-       if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !is_site_admin()) {
+       if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !$a->isSiteAdmin()) {
                notice(DI::l10n()->t('Permission denied.'));
                return;
        }
@@ -42,7 +42,7 @@ function uimport_post(App $a)
 
 function uimport_content(App $a)
 {
-       if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !is_site_admin()) {
+       if ((DI::config()->get('config', 'register_policy') != \Friendica\Module\Register::OPEN) && !$a->isSiteAdmin()) {
                notice(DI::l10n()->t('User imports on closed servers can only be done by an administrator.'));
                return;
        }
index 38819c9a581768893e913ab2c2d8ad30265e8293..fd88ab2bc262a76af36359b6852caadf26f34d62 100644 (file)
@@ -177,9 +177,6 @@ function wall_upload_post(App $a, $desktopmode = true)
        @unlink($src);
 
        $max_length = DI::config()->get('system', 'max_image_length');
-       if (!$max_length) {
-               $max_length = MAX_IMAGE_LENGTH;
-       }
        if ($max_length > 0) {
                $Image->scaleDown($max_length);
                $filesize = strlen($Image->asString());
index 44a5eb40dfcd95430a988ff535f81700cb4c44c7..dd848838873b7439de50e17c84a4493b51386d40 100644 (file)
@@ -154,6 +154,20 @@ class App
                return local_user() && $this->user_id && ($this->user_id == local_user());
        }
 
+       /**
+        * Check if current user has admin role.
+        *
+        * @return bool true if user is an admin
+        */
+       public function isSiteAdmin()
+       {
+               $admin_email = $this->config->get('config', 'admin_email');
+
+               $adminlist = explode(',', str_replace(' ', '', $admin_email));
+
+               return local_user() && $admin_email && $this->database->exists('user', ['uid' => $this->getLoggedInUserId(), 'email' => $adminlist]);
+       }
+
        /**
         * Fetch the user id
         * @return int 
index 578f9ab3e3a4209f7772650ccc541ce4efd222e0..fcb2d18533d40634162798f3a1d241cd73673e3f 100644 (file)
@@ -257,6 +257,28 @@ class Page implements ArrayAccess
                ]) . $this->page['htmlhead'];
        }
 
+       /**
+        * Returns the complete URL of the current page, e.g.: http(s)://something.com/network
+        *
+        * Taken from http://webcheatsheet.com/php/get_current_page_url.php
+        */
+       private function curPageURL()
+       {
+               $pageURL = 'http';
+               if (!empty($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on")) {
+                       $pageURL .= "s";
+               }
+       
+               $pageURL .= "://";
+       
+               if ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") {
+                       $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
+               } else {
+                       $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
+               }
+               return $pageURL;
+       }
+      
        /**
         * Initializes Page->page['footer'].
         *
@@ -290,9 +312,9 @@ class Page implements ArrayAccess
                 */
                if ($mode->isMobile() || $mode->isTablet()) {
                        if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
-                               $link = 'toggle_mobile?address=' . urlencode(curPageURL());
+                               $link = 'toggle_mobile?address=' . urlencode($this->curPageURL());
                        } else {
-                               $link = 'toggle_mobile?off=1&address=' . urlencode(curPageURL());
+                               $link = 'toggle_mobile?off=1&address=' . urlencode($this->curPageURL());
                        }
                        $this->page['footer'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate("toggle_mobile_footer.tpl"), [
                                '$toggle_link' => $link,
index 7bd7ea69fbb436d909832ea5946c232933dd4b97..d8cbbf7cbb6dec2129ea5cdaab2c4bbbe5ad2a97 100644 (file)
@@ -223,12 +223,12 @@ class Conversation
                                        break;
                        }
                } elseif ($total > 1) {
-                       if ($total < MAX_LIKERS) {
+                       if ($total < $this->config->get('system', 'max_likers')) {
                                $likers = implode(', ', array_slice($links, 0, -1));
                                $likers .= ' ' . $this->l10n->t('and') . ' ' . $links[count($links) - 1];
                        } else {
-                               $likers = implode(', ', array_slice($links, 0, MAX_LIKERS - 1));
-                               $likers .= ' ' . $this->l10n->t('and %d other people', $total - MAX_LIKERS);
+                               $likers = implode(', ', array_slice($links, 0, $this->config->get('system', 'max_likers') - 1));
+                               $likers .= ' ' . $this->l10n->t('and %d other people', $total - $this->config->get('system', 'max_likers'));
                        }
 
                        $spanatts = "class=\"fakelink\" onclick=\"openClose('{$verb}list-$id');\"";
index 90822c7e6fed3fb2bb7c7e6364b41e650046973a..506e71623c550ecd404ea529d501f6f91c405731 100644 (file)
@@ -295,7 +295,7 @@ class Nav
                }
 
                // Show the link to the admin configuration page if user is admin
-               if (is_site_admin()) {
+               if ($a->isSiteAdmin()) {
                        $nav['admin'] = ['admin/', DI::l10n()->t('Admin'), '', DI::l10n()->t('Site setup and configuration')];
                }
 
index 4a3e9186741d57ac6a1c6b6d27ed97445dec8d98..8ec57dce40f8316906ff9698c389b9bc4b9d572e 100644 (file)
@@ -63,7 +63,7 @@ class Widget
 
                if (DI::config()->get('system', 'invitation_only')) {
                        $x = intval(DI::pConfig()->get(local_user(), 'system', 'invites_remaining'));
-                       if ($x || is_site_admin()) {
+                       if ($x || DI::app()->isSiteAdmin()) {
                                DI::page()['aside'] .= '<div class="side-link widget" id="side-invite-remain">'
                                        . DI::l10n()->tt('%d invitation available', '%d invitations available', $x)
                                        . '</div>';
index f68b5546cd2e94c4935081b4e79935000e86a7da..198e8dcc418043bea18dc0e6b2e3c868f86fbcd7 100644 (file)
@@ -24,7 +24,7 @@ namespace Friendica\Core\Lock\Type;
 use Friendica\Core\Cache\Enum\Duration;
 use Friendica\Core\Lock\Enum\Type;
 use Friendica\Core\Lock\Exception\InvalidLockDriverException;
-use function get_temppath;
+use Friendica\Core\System;
 
 class SemaphoreLock extends AbstractLock
 {
@@ -44,7 +44,7 @@ class SemaphoreLock extends AbstractLock
        {
                $success = true;
 
-               $temp = get_temppath();
+               $temp = System::getTempPath();
 
                $file = $temp . '/' . $key . '.sem';
 
index 4eb4084728f462b6cbbd7175a75e3ad720c1b297..608c707434ca539c295b68425c943c99c757da88 100644 (file)
@@ -84,7 +84,7 @@ class Renderer
                        $output = $t->replaceMacros($template, $vars);
                } catch (Exception $e) {
                        DI::logger()->critical($e->getMessage(), ['template' => $template, 'vars' => $vars]);
-                       $message = is_site_admin() ?
+                       $message = DI::app()->isSiteAdmin() ?
                                $e->getMessage() :
                                DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
                        throw new ServiceUnavailableException($message);
@@ -113,7 +113,7 @@ class Renderer
                        $template = $t->getTemplateFile($file, $subDir);
                } catch (Exception $e) {
                        DI::logger()->critical($e->getMessage(), ['file' => $file, 'subDir' => $subDir]);
-                       $message = is_site_admin() ?
+                       $message = DI::app()->isSiteAdmin() ?
                                $e->getMessage() :
                                DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
                        throw new ServiceUnavailableException($message);
@@ -140,7 +140,7 @@ class Renderer
                } else {
                        $admin_message = DI::l10n()->t('template engine cannot be registered without a name.');
                        DI::logger()->critical($admin_message, ['class' => $class]);
-                       $message = is_site_admin() ?
+                       $message = DI::app()->isSiteAdmin() ?
                                $admin_message :
                                DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
                        throw new ServiceUnavailableException($message);
@@ -174,7 +174,7 @@ class Renderer
 
                $admin_message = DI::l10n()->t('template engine is not registered!');
                DI::logger()->critical($admin_message, ['template_engine' => $template_engine]);
-               $message = is_site_admin() ?
+               $message = DI::app()->isSiteAdmin() ?
                        $admin_message :
                        DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
                throw new ServiceUnavailableException($message);
index f680b6530dfcfe008edd7f000fb8abc78b5ea7f2..2a7510ec7607d1d2f8765b253ebcab08daa744e7 100644 (file)
 
 namespace Friendica\Core;
 
+use Exception;
 use Friendica\DI;
 use Friendica\Network\HTTPException\FoundException;
 use Friendica\Network\HTTPException\MovedPermanentlyException;
 use Friendica\Network\HTTPException\TemporaryRedirectException;
+use Friendica\Util\BasePath;
 use Friendica\Util\XML;
 
 /**
@@ -323,6 +325,88 @@ class System
                exit();
        }
 
+       /**
+        * Fetch the temp path of the system
+        *
+        * @return string Path for temp files
+        */
+       public static function getTempPath()
+       {
+               $temppath = DI::config()->get("system", "temppath");
+
+               if (($temppath != "") && System::isDirectoryUsable($temppath)) {
+                       // We have a temp path and it is usable
+                       return BasePath::getRealPath($temppath);
+               }
+
+               // We don't have a working preconfigured temp path, so we take the system path.
+               $temppath = sys_get_temp_dir();
+
+               // Check if it is usable
+               if (($temppath != "") && System::isDirectoryUsable($temppath)) {
+                       // Always store the real path, not the path through symlinks
+                       $temppath = BasePath::getRealPath($temppath);
+
+                       // To avoid any interferences with other systems we create our own directory
+                       $new_temppath = $temppath . "/" . DI::baseUrl()->getHostname();
+                       if (!is_dir($new_temppath)) {
+                               /// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method?
+                               mkdir($new_temppath);
+                       }
+
+                       if (System::isDirectoryUsable($new_temppath)) {
+                               // The new path is usable, we are happy
+                               DI::config()->set("system", "temppath", $new_temppath);
+                               return $new_temppath;
+                       } else {
+                               // We can't create a subdirectory, strange.
+                               // But the directory seems to work, so we use it but don't store it.
+                               return $temppath;
+                       }
+               }
+
+               // Reaching this point means that the operating system is configured badly.
+               return '';
+       }
+
+       /**
+        * Returns the path where spool files are stored
+        *
+        * @return string Spool path
+        */
+       public static function getSpoolPath()
+       {
+               $spoolpath = DI::config()->get('system', 'spoolpath');
+               if (($spoolpath != "") && System::isDirectoryUsable($spoolpath)) {
+                       // We have a spool path and it is usable
+                       return $spoolpath;
+               }
+
+               // We don't have a working preconfigured spool path, so we take the temp path.
+               $temppath = self::getTempPath();
+
+               if ($temppath != "") {
+                       // To avoid any interferences with other systems we create our own directory
+                       $spoolpath = $temppath . "/spool";
+                       if (!is_dir($spoolpath)) {
+                               mkdir($spoolpath);
+                       }
+
+                       if (System::isDirectoryUsable($spoolpath)) {
+                               // The new path is usable, we are happy
+                               DI::config()->set("system", "spoolpath", $spoolpath);
+                               return $spoolpath;
+                       } else {
+                               // We can't create a subdirectory, strange.
+                               // But the directory seems to work, so we use it but don't store it.
+                               return $temppath;
+                       }
+               }
+
+               // Reaching this point means that the operating system is configured badly.
+               return "";
+       }
+
        /// @todo Move the following functions from boot.php
        /*
        function local_user()
@@ -331,7 +415,5 @@ class System
        function notice($s)
        function info($s)
        function is_site_admin()
-       function get_temppath()
-       function get_spoolpath()
        */
 }
index 0431c79521507e646bc4b0b990e2fe892ccd4d8e..3d1648ea45936bfee7b81cb80ac1923c57012b56 100644 (file)
@@ -277,6 +277,44 @@ class Worker
                return DBA::exists('workerqueue', $condition);
        }
 
+       /**
+        * Checks if the given file is valid to be included
+        *
+        * @param mixed $file 
+        * @return bool 
+        */
+       private static function validateInclude(&$file)
+       {
+               $orig_file = $file;
+       
+               $file = realpath($file);
+       
+               if (strpos($file, getcwd()) !== 0) {
+                       return false;
+               }
+       
+               $file = str_replace(getcwd() . "/", "", $file, $count);
+               if ($count != 1) {
+                       return false;
+               }
+       
+               if ($orig_file !== $file) {
+                       return false;
+               }
+       
+               $valid = false;
+               if (strpos($file, "include/") === 0) {
+                       $valid = true;
+               }
+       
+               if (strpos($file, "addon/") === 0) {
+                       $valid = true;
+               }
+       
+               // Simply return flag
+               return $valid;
+       }
+       
        /**
         * Execute a worker entry
         *
@@ -360,7 +398,7 @@ class Worker
                        $include = "include/".$include.".php";
                }
 
-               if (!validate_include($include)) {
+               if (!self::validateInclude($include)) {
                        Logger::warning("Include file is not valid", ['file' => $argv[0]]);
                        $stamp = (float)microtime(true);
                        DBA::delete('workerqueue', ['id' => $queue["id"]]);
index 297506176aa500010d892c5fa6f0d35c2ecf8994..094fa3b029c902553a9d174f27bfd087f25a46c6 100644 (file)
@@ -448,7 +448,7 @@ class Item
                // We use "microtime" to keep the arrival order and "mt_rand" to avoid duplicates
                $file = 'item-' . round(microtime(true) * 10000) . '-' . mt_rand() . '.msg';
 
-               $spoolpath = get_spoolpath();
+               $spoolpath = System::getSpoolPath();
                if ($spoolpath != "") {
                        $spool = $spoolpath . '/' . $file;
 
index 13beb05b3caabdc831adc394dee7aa6cd502054a..d27bac47aceaaf385e82c5f7274da6f5476a2f56 100644 (file)
@@ -951,9 +951,6 @@ class Photo
                @unlink($src);
 
                $max_length = DI::config()->get('system', 'max_image_length');
-               if (!$max_length) {
-                       $max_length = MAX_IMAGE_LENGTH;
-               }
                if ($max_length > 0) {
                        $Image->scaleDown($max_length);
                        $filesize = strlen($Image->asString());
index 65e64cb5cdeba815be57dba13a9485cf6e528f52..92f50dd25cdc89e920e67c80dd0f664cf25b4e9e 100644 (file)
@@ -706,7 +706,7 @@ class User
        {
                $cache = new CacheItemPool();
                $cache->changeConfig([
-                       'cacheDirectory' => get_temppath() . '/password-exposed-cache/',
+                       'cacheDirectory' => System::getTempPath() . '/password-exposed-cache/',
                ]);
 
                try {
index 36940cb2deb35b5a5edb21e40d74ed63559cae2a..2ef12a83d811da054220cbe7fd662b047a252835 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module\ActivityPub;
 
 use Friendica\BaseModule;
 use Friendica\Core\Logger;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Protocol\ActivityPub;
@@ -48,7 +49,7 @@ class Inbox extends BaseModule
                        } else {
                                $filename = 'failed-activitypub';
                        }
-                       $tempfile = tempnam(get_temppath(), $filename);
+                       $tempfile = tempnam(System::getTempPath(), $filename);
                        file_put_contents($tempfile, json_encode(['parameters' => $parameters, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
                        Logger::notice('Incoming message stored', ['file' => $tempfile]);
                }
index 71deb67ef3952093bdb116d8174ad955b2957879..2cc4ac23a31d809ecfa03def885a8d133466af35 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Module\Admin;
 use Friendica\App;
 use Friendica\Core\Renderer;
 use Friendica\Core\Search;
+use Friendica\Core\System;
 use Friendica\Core\Theme;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
@@ -138,8 +139,8 @@ class Site extends BaseAdmin
                $theme            = (!empty($_POST['theme'])            ? Strings::escapeTags(trim($_POST['theme']))         : '');
                $theme_mobile     = (!empty($_POST['theme_mobile'])     ? Strings::escapeTags(trim($_POST['theme_mobile']))  : '');
                $maximagesize     = (!empty($_POST['maximagesize'])     ? intval(trim($_POST['maximagesize']))               : 0);
-               $maximagelength   = (!empty($_POST['maximagelength'])   ? intval(trim($_POST['maximagelength']))             : MAX_IMAGE_LENGTH);
-               $jpegimagequality = (!empty($_POST['jpegimagequality']) ? intval(trim($_POST['jpegimagequality']))           : JPEG_QUALITY);
+               $maximagelength   = (!empty($_POST['maximagelength'])   ? intval(trim($_POST['maximagelength']))             : -1);
+               $jpegimagequality = (!empty($_POST['jpegimagequality']) ? intval(trim($_POST['jpegimagequality']))           : 100);
 
                $register_policy        = (!empty($_POST['register_policy'])         ? intval(trim($_POST['register_policy']))             : 0);
                $daily_registrations    = (!empty($_POST['max_daily_registrations']) ? intval(trim($_POST['max_daily_registrations']))     : 0);
@@ -463,7 +464,7 @@ class Site extends BaseAdmin
                $additional_info = DI::config()->get('config', 'info');
 
                // Automatically create temporary paths
-               get_temppath();
+               System::getTempPath();
 
                /* Register policy */
                $register_choices = [
@@ -609,7 +610,7 @@ class Site extends BaseAdmin
                        '$worker_fastlane'        => ['worker_fastlane', DI::l10n()->t('Enable fastlane'), DI::config()->get('system', 'worker_fastlane'), DI::l10n()->t('When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.')],
 
                        '$relay_directly'         => ['relay_directly', DI::l10n()->t('Direct relay transfer'), DI::config()->get('system', 'relay_directly'), DI::l10n()->t('Enables the direct transfer to other servers without using the relay servers')],
-                       '$relay_scope'            => ['relay_scope', DI::l10n()->t('Relay scope'), DI::config()->get('system', 'relay_scope'), DI::l10n()->t('Can be "all" or "tags". "all" means that every public post should be received. "tags" means that only posts with selected tags should be received.'), [SR_SCOPE_NONE => DI::l10n()->t('Disabled'), SR_SCOPE_ALL => DI::l10n()->t('all'), SR_SCOPE_TAGS => DI::l10n()->t('tags')]],
+                       '$relay_scope'            => ['relay_scope', DI::l10n()->t('Relay scope'), DI::config()->get('system', 'relay_scope'), DI::l10n()->t('Can be "all" or "tags". "all" means that every public post should be received. "tags" means that only posts with selected tags should be received.'), [Relay::SCOPE_NONE => DI::l10n()->t('Disabled'), Relay::SCOPE_ALL => DI::l10n()->t('all'), Relay::SCOPE_TAGS => DI::l10n()->t('tags')]],
                        '$relay_server_tags'      => ['relay_server_tags', DI::l10n()->t('Server tags'), DI::config()->get('system', 'relay_server_tags'), DI::l10n()->t('Comma separated list of tags for the "tags" subscription.')],
                        '$relay_deny_tags'        => ['relay_deny_tags', DI::l10n()->t('Deny Server tags'), DI::config()->get('system', 'relay_deny_tags'), DI::l10n()->t('Comma separated list of tags that are rejected.')],
                        '$relay_user_tags'        => ['relay_user_tags', DI::l10n()->t('Allow user tags'), DI::config()->get('system', 'relay_user_tags'), DI::l10n()->t('If enabled, the tags from the saved searches will used for the "tags" subscription in addition to the "relay_server_tags".')],
index 5d5841f994662aea0b1b15c68d0f9219f6615eea..69c2879de6bd4fa9c0817e4aad4e747b8947aabc 100644 (file)
@@ -59,7 +59,7 @@ abstract class BaseAdmin extends BaseModule
                        }
                }
 
-               if (!is_site_admin()) {
+               if (!DI::app()->isSiteAdmin()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('You don\'t have access to administration pages.'));
                }
 
index 82b8c604a900939319dd5a718a8ee8c493b4ae0c..566e54b129db3da2ba97c543f00a49abbfb9c23f 100644 (file)
@@ -67,7 +67,7 @@ class Invite extends BaseModule
                if ($config->get('system', 'invitation_only')) {
                        $invitation_only = true;
                        $invites_remaining = DI::pConfig()->get(local_user(), 'system', 'invites_remaining');
-                       if ((!$invites_remaining) && (!is_site_admin())) {
+                       if ((!$invites_remaining) && (!$app->isSiteAdmin())) {
                                throw new HTTPException\ForbiddenException();
                        }
                }
@@ -82,11 +82,11 @@ class Invite extends BaseModule
                                continue;
                        }
 
-                       if ($invitation_only && ($invites_remaining || is_site_admin())) {
+                       if ($invitation_only && ($invites_remaining || $app->isSiteAdmin())) {
                                $code = Model\Register::createForInvitation();
                                $nmessage = str_replace('$invite_code', $code, $message);
 
-                               if (!is_site_admin()) {
+                               if (!$app->isSiteAdmin()) {
                                        $invites_remaining--;
                                        if ($invites_remaining >= 0) {
                                                DI::pConfig()->set(local_user(), 'system', 'invites_remaining', $invites_remaining);
@@ -138,7 +138,7 @@ class Invite extends BaseModule
                if ($config->get('system', 'invitation_only')) {
                        $inviteOnly = true;
                        $x = DI::pConfig()->get(local_user(), 'system', 'invites_remaining');
-                       if ((!$x) && (!is_site_admin())) {
+                       if ((!$x) && (!$app->isSiteAdmin())) {
                                throw new HTTPException\ForbiddenException(DI::l10n()->t('You have no more invitations available'));
                        }
                }
index 8fe4c8ce5752054c5d462340bb2b66a35b07223f..3b771c3ac7d5bc7b8c2ef426e1e3873e73b94469 100644 (file)
@@ -51,7 +51,7 @@ class HTTPException
                        '$stack_trace' => DI::l10n()->t('Stack trace:'),
                ];
 
-               if (is_site_admin()) {
+               if (DI::app()->isSiteAdmin()) {
                        $vars['$thrown'] = DI::l10n()->t('Exception thrown in %s:%d', $e->getFile(), $e->getLine());
                        $vars['$trace'] = $e->getTraceAsString();
                }
index 15b8e276ad7b2b888206a2bc0065d1162fe4d743..96968680dc7f3126f3a81da9a786187869337978 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Module\WellKnown;
 use Friendica\BaseModule;
 use Friendica\DI;
 use Friendica\Model\Search;
+use Friendica\Protocol\Relay;
 
 /**
  * Node subscription preferences for social realy systems
@@ -40,7 +41,7 @@ class XSocialRelay extends BaseModule
                $systemTags = [];
                $userTags = [];
 
-               if ($scope == SR_SCOPE_TAGS) {
+               if ($scope == Relay::SCOPE_TAGS) {
                        $server_tags = $config->get('system', 'relay_server_tags');
                        $tagitems = explode(',', $server_tags);
 
@@ -57,7 +58,7 @@ class XSocialRelay extends BaseModule
                $tagList = array_unique(array_merge($systemTags, $userTags));
 
                $relay = [
-                       'subscribe' => ($scope != SR_SCOPE_NONE),
+                       'subscribe' => ($scope != Relay::SCOPE_NONE),
                        'scope'     => $scope,
                        'tags'      => $tagList,
                        'protocols' => [
index c7ee68a926340c3d9244b90b98d11e2a3c32a229..18fc73ab88b25640f2458af21a651220f0066313 100644 (file)
@@ -5,6 +5,7 @@ namespace Friendica\Network\HTTPClient\Factory;
 use Friendica\App;
 use Friendica\BaseFactory;
 use Friendica\Core\Config\Capability\IManageConfigValues;
+use Friendica\Core\System;
 use Friendica\Network\HTTPClient\Client;
 use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
 use Friendica\Util\Profiler;
@@ -106,7 +107,7 @@ class HttpClient extends BaseFactory
                $resolver->setMaxResponseDataSize(1000000);
                // Designate a temporary file that will store cookies during the session.
                // Some websites test the browser for cookie support, so this enhances results.
-               $resolver->setCookieJar(get_temppath() .'/resolver-cookie-' . Strings::getRandomName(10));
+               $resolver->setCookieJar(System::getTempPath() .'/resolver-cookie-' . Strings::getRandomName(10));
 
                return new Client\HttpClient($logger, $this->profiler, $guzzle, $resolver);
        }
index dd9590369611712df969d751b3dad0f5a5b55bf7..4551db248c8513a05fa2aef4908b499e823add08 100644 (file)
@@ -134,9 +134,6 @@ class Image
                        switch ($this->getType()) {
                                case "image/png":
                                        $quality = DI::config()->get('system', 'png_quality');
-                                       if ((! $quality) || ($quality > 9)) {
-                                               $quality = PNG_QUALITY;
-                                       }
                                        /*
                                         * From http://www.imagemagick.org/script/command-line-options.php#quality:
                                         *
@@ -150,9 +147,6 @@ class Image
                                        break;
                                case "image/jpeg":
                                        $quality = DI::config()->get('system', 'jpeg_quality');
-                                       if ((! $quality) || ($quality > 100)) {
-                                               $quality = JPEG_QUALITY;
-                                       }
                                        $this->image->setCompressionQuality($quality);
                        }
 
@@ -680,16 +674,10 @@ class Image
                switch ($this->getType()) {
                        case "image/png":
                                $quality = DI::config()->get('system', 'png_quality');
-                               if ((!$quality) || ($quality > 9)) {
-                                       $quality = PNG_QUALITY;
-                               }
                                imagepng($this->image, null, $quality);
                                break;
                        case "image/jpeg":
                                $quality = DI::config()->get('system', 'jpeg_quality');
-                               if ((!$quality) || ($quality > 100)) {
-                                       $quality = JPEG_QUALITY;
-                               }
                                imagejpeg($this->image, null, $quality);
                }
                $string = ob_get_contents();
index ac51e104a922f1ae575b0736de57d3564f77d82a..79a90d403c561c4454401f5bff385d019931a093 100644 (file)
@@ -413,6 +413,48 @@ class DFRN
                return $root;
        }
 
+       /**
+        * Determine the next birthday, but only if the birthday is published
+        * in the default profile. We _could_ also look for a private profile that the
+        * recipient can see, but somebody could get mad at us if they start getting
+        * public birthday greetings when they haven't made this info public.
+        *
+        * Assuming we are able to publish this info, we are then going to convert
+        * the start time from the owner's timezone to UTC.
+        *
+        * This will potentially solve the problem found with some social networks
+        * where birthdays are converted to the viewer's timezone and salutations from
+        * elsewhere in the world show up on the wrong day. We will convert it to the
+        * viewer's timezone also, but first we are going to convert it from the birthday
+        * person's timezone to GMT - so the viewer may find the birthday starting at
+        * 6:00PM the day before, but that will correspond to midnight to the birthday person.
+        */
+       private static function determineNextBirthday($uid, $tz)
+       {
+               $birthday = '';
+
+               if (!strlen($tz)) {
+                       $tz = 'UTC';
+               }
+
+               $profile = DBA::selectFirst('profile', ['dob'], ['uid' => $uid]);
+               if (DBA::isResult($profile)) {
+                       $tmp_dob = substr($profile['dob'], 5);
+                       if (intval($tmp_dob)) {
+                               $y = DateTimeFormat::timezoneNow($tz, 'Y');
+                               $bd = $y . '-' . $tmp_dob . ' 00:00';
+                               $t_dob = strtotime($bd);
+                               $now = strtotime(DateTimeFormat::timezoneNow($tz));
+                               if ($t_dob < $now) {
+                                       $bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
+                               }
+                               $birthday = DateTimeFormat::convert($bd, 'UTC', $tz, DateTimeFormat::ATOM);
+                       }
+               }
+
+               return $birthday;
+       }
+
        /**
         * Adds the author element in the header for the DFRN protocol
         *
@@ -467,7 +509,7 @@ class DFRN
                        return $author;
                }
 
-               $birthday = feed_birthday($owner['uid'], $owner['timezone']);
+               $birthday = self::determineNextBirthday($owner['uid'], $owner['timezone']);
 
                if ($birthday) {
                        XML::addElement($doc, $author, "dfrn:birthday", $birthday);
index da9a2e3923484d62130a4eb60031a62d59814e37..d98fda46d7620289bae4fe4eb1218b6b829689e3 100644 (file)
@@ -37,9 +37,15 @@ use Friendica\Util\Strings;
 
 /**
  * Base class for relay handling
+ * @see https://github.com/jaywink/social-relay
+ * @see https://wiki.diasporafoundation.org/Relay_servers_for_public_posts
  */
 class Relay
 {
+       const SCOPE_NONE = '';
+       const SCOPE_ALL = 'all';
+       const SCOPE_TAGS = 'tags';
+
        /**
         * Check if a post is wanted
         *
@@ -55,7 +61,7 @@ class Relay
 
                $scope = $config->get('system', 'relay_scope');
 
-               if ($scope == SR_SCOPE_NONE) {
+               if ($scope == self::SCOPE_NONE) {
                        Logger::info('Server does not accept relay posts - rejected', ['network' => $network, 'url' => $url]);
                        return false;
                }
@@ -74,7 +80,7 @@ class Relay
                $userTags = [];
                $denyTags = [];
 
-               if ($scope == SR_SCOPE_TAGS) {
+               if ($scope == self::SCOPE_TAGS) {
                        $server_tags = $config->get('system', 'relay_server_tags');
                        $tagitems = explode(',', mb_strtolower($server_tags));
                        foreach ($tagitems as $tag) {
@@ -119,7 +125,7 @@ class Relay
                        }
                }
 
-               if ($scope == SR_SCOPE_ALL) {
+               if ($scope == self::SCOPE_ALL) {
                        Logger::info('Server accept all posts - accepted', ['network' => $network, 'url' => $url]);
                        return true;
                }
index c336273c728a41cd42baa7326a1fe03b657f246e..e482b70e645a91fc53026c4f5e2d48b305da01ef 100644 (file)
@@ -51,7 +51,7 @@ final class FriendicaSmartyEngine extends TemplateEngine
                if (!is_writable(DI::basePath() . '/view/smarty3')) {
                        $admin_message = DI::l10n()->t('The folder view/smarty3/ must be writable by webserver.');
                        DI::logger()->critical($admin_message);
-                       $message = is_site_admin() ?
+                       $message = DI::app()->isSiteAdmin() ?
                                $admin_message :
                                DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
                        throw new ServiceUnavailableException($message);
index 1b5fdaa343849c115ba6568b0d13d839a5acd43f..a5567841e1609ea880122077368a0144e8e0548e 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Worker;
 
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -152,7 +153,7 @@ class OnePoll
                        return false;
                }
 
-               $cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
+               $cookiejar = tempnam(System::getTempPath(), 'cookiejar-onepoll-');
                $curlResult = DI::httpClient()->get($contact['poll'], [HttpClientOptions::COOKIEJAR => $cookiejar]);
                unlink($cookiejar);
 
index e32cee1f2f513dbf2996172b3c7e73a4537bc716..9501dc64a40a8cb89c8a0ecc93108677a954bf9d 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Worker;
 
 use Friendica\Core\Logger;
+use Friendica\Core\System;
 use Friendica\Model\Item;
 
 /**
@@ -29,7 +30,7 @@ use Friendica\Model\Item;
  */
 class SpoolPost {
        public static function execute() {
-               $path = get_spoolpath();
+               $path = System::getSpoolPath();
 
                if (($path != '') && is_writable($path)){
                        if ($dh = opendir($path)) {
index 0d25a1751a47db971d4fde0256757d12ac510ff1..0cfc2f65826f4fa6489f0a4a549cd9ac176a26ea 100644 (file)
@@ -295,6 +295,12 @@ return [
                // on detected mobile devices
                'itemspage_network_mobile' => 20,
 
+               // jpeg_quality (Integer)
+               // 
+               // Lower numbers save space at cost of image detail
+               // where n is between 1 and 100, and with very poor results below about 50
+               'jpeg_quality' => 100,
+
                // like_no_comment (Boolean)
                // Don't update the "commented" value of an item when it is liked.
                'like_no_comment' => false,
@@ -359,6 +365,10 @@ return [
                // If you don't want to set a maximum length, set to -1.
                'max_image_length' => -1,
 
+               // max_likers (Integer)
+               // Maximum number of "people who like (or don't like) this"  that we will list by name
+               'max_likers' => 75,
+
                // max_processes_backend (Integer)
                // Maximum number of concurrent database processes for background tasks.
                'max_processes_backend' => 5,
index 5530163dc89b8bd13f7a8ec62c83e4c08ecc6040..e3a7a10a2c41e2fe42f882a44e208553c5bba741 100644 (file)
@@ -176,9 +176,9 @@ return [
                // Directly transmit content to relay subscribers without using a relay server
                'relay_directly' => false,
 
-               // relay_scope (SR_SCOPE_NONE, SR_SCOPE_TAGS or SR_SCOPE_ALL)
+               // relay_scope (Relay::SCOPE_NONE, Relay::SCOPE_TAGS or Relay::SCOPE_ALL)
                // Defines the scope of accepted posts from the relay servers
-               'relay_scope' => SR_SCOPE_NONE,
+               'relay_scope' => '',
 
                // relay_server_tags (String)
                // Comma separated list of tags for the "tags" subscription.
index 7ab35bb28e65a29018d574627a52d66f7799bedf..696ca5a03c0cbff98c326af15a08f59cde781666 100644 (file)
@@ -31,7 +31,7 @@ $a->config['sitename'] = "Friendica My Network";
 // and/or approve/deny the request.
 // In order to perform system administration via the admin panel, admin_email
 // must precisely match the email address of the person logged in.
-$a->config['register_policy'] = REGISTER_OPEN;
+$a->config['register_policy'] = Friendica\Module\Register::OPEN;
 $a->config['register_text'] = 'A register text';
 $a->config['admin_email'] = 'admin@test.it';
 $a->config['admin_nickname'] = 'Friendly admin';
index 17e83a37d3cf752bd403f8cfa8df4f8eff35c48c..02cd447090cad7126a1d302cc216f29d44b513fa 100644 (file)
@@ -26,6 +26,7 @@ use Friendica\App;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\Config\Type\JitConfig;
 use Friendica\Core\Lock\Type\SemaphoreLock;
+use Friendica\Core\System;
 use Friendica\DI;
 use Mockery;
 use Mockery\MockInterface;
@@ -73,7 +74,7 @@ class SemaphoreLockTest extends LockTest
         */
        public function testMissingFileNotOverriding()
        {
-               $file = get_temppath() . '/test.sem';
+               $file = System::getTempPath() . '/test.sem';
                touch($file);
 
                self::assertTrue(file_exists($file));
@@ -91,7 +92,7 @@ class SemaphoreLockTest extends LockTest
         */
        public function testMissingFileOverriding()
        {
-               $file = get_temppath() . '/test.sem';
+               $file = System::getTempPath() . '/test.sem';
                touch($file);
 
                self::assertTrue(file_exists($file));
@@ -104,7 +105,7 @@ class SemaphoreLockTest extends LockTest
         */
        public function testOverrideSemFile()
        {
-               $file = get_temppath() . '/test.sem';
+               $file = System::getTempPath() . '/test.sem';
                touch($file);
 
                self::assertTrue(file_exists($file));
index 38334e1d187573b2a2f1f1d305bede0e43bdd1af..ee4f036607c89f3ba8ac161008cf24e8f6c36938 100644 (file)
@@ -57,7 +57,7 @@ function theme_post(App $a)
 
 function theme_admin_post(App $a)
 {
-       if (!is_site_admin()) {
+       if (!$a->isSiteAdmin()) {
                return;
        }