The boot.php had been cleared of most functions
This commit is contained in:
+14
@@ -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
|
||||
|
||||
+24
-2
@@ -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,
|
||||
|
||||
@@ -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');\"";
|
||||
|
||||
+1
-1
@@ -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')];
|
||||
}
|
||||
|
||||
|
||||
@@ -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>';
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
+84
-2
@@ -21,10 +21,12 @@
|
||||
|
||||
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()
|
||||
*/
|
||||
}
|
||||
|
||||
+39
-1
@@ -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"]]);
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
+1
-1
@@ -706,7 +706,7 @@ class User
|
||||
{
|
||||
$cache = new CacheItemPool();
|
||||
$cache->changeConfig([
|
||||
'cacheDirectory' => get_temppath() . '/password-exposed-cache/',
|
||||
'cacheDirectory' => System::getTempPath() . '/password-exposed-cache/',
|
||||
]);
|
||||
|
||||
try {
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
@@ -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".')],
|
||||
|
||||
@@ -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.'));
|
||||
}
|
||||
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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' => [
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
+43
-1
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user