Merge pull request #1201 from annando/boot

Support for cleared boot.php
This commit is contained in:
Hypolite Petovan 2021-11-04 19:17:56 -04:00 committed by GitHub
commit 6a7f36ba89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 38 additions and 25 deletions

View 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');
}

View 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;
}

View 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;
}

View 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;
}

View 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() {

View 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']) {

View 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(),

View 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(

View 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 '';
}

View 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;
}

View 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),

View 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);

View 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);

View 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']]);

View 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);