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';
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');
}
}
}
logger::info('Blocked bot', $logdata);
- System::httpExit(403, 'Bots are not allowed');
+ throw new ForbiddenException('Bots are not allowed');
}
*/
function cookienotice_addon_admin(App $a, &$s)
{
- if (!is_site_admin()) {
+ if (!$a->isSiteAdmin()) {
return;
}
*/
function cookienotice_addon_admin_post(App $a)
{
- if (!is_site_admin()) {
+ if (!$a->isSiteAdmin()) {
return;
}
// for accessing the API of openweathermap
function curweather_addon_admin_post(App $a)
{
- if (!is_site_admin()) {
+ if (!$a->isSiteAdmin()) {
return;
}
function curweather_addon_admin(App $a, &$o)
{
- if (!is_site_admin()) {
+ if (!$a->isSiteAdmin()) {
return;
}
<?php
+
+use Friendica\Core\System;
+
/**
* Super-skeletal class to interact with Diaspora.
*
$this->setPassword($password);
}
- $this->cookiejar = tempnam(get_temppath(), 'cookies');
+ $this->cookiejar = tempnam(System::getTempPath(), 'cookies');
return $this;
}
<?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
$this->token_regex = '/content="(.*?)" name="csrf-token/';
$this->pod = $pod;
- $this->cookiejar = tempnam(get_temppath(), 'cookies');
+ $this->cookiejar = tempnam(System::getTempPath(), 'cookies');
}
function __destruct() {
}
function irc_addon_admin_post (&$a) {
- if(! is_site_admin())
+ if(!$a->isSiteAdmin())
return;
if($_POST['irc-submit']) {
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;
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(),
* FITNESS FOR A PARTICULAR PURPOSE.
*/
+use Friendica\Core\System;
+
/**
* PHPMailer - PHP email creation and transport class.
* @package 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(
function notifyall_post(App $a)
{
- if(!is_site_admin()) {
+ if (!$a->isSiteAdmin()) {
return;
}
function notifyall_content(&$a)
{
- if (! is_site_admin()) {
+ if (!$a->isSiteAdmin()) {
return '';
}
function pageheader_addon_admin(App &$a, &$s)
{
- if(! is_site_admin()) {
+ if (!$a->isSiteAdmin()) {
return;
}
function pageheader_addon_admin_post(App $a)
{
- if(!is_site_admin()) {
+ if (!$a->isSiteAdmin()) {
return;
}
$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),
namespace CodebirdSN;
+use Friendica\Core\System;
+
/**
* A Twitter library in PHP.
*
}
// 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);
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;
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 {
} 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);
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;
$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']]);
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\User;
+use Friendica\Network\HTTPException\UnauthorizedException;
function windowsphonepush_install()
{
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']));
} 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);