define('CURLE_OPERATION_TIMEDOUT', CURLE_OPERATION_TIMEOUTED);
}
-/**
- * @brief Retrieve the App structure
- *
- * Useful in functions which require it but don't get it passed to them
- *
- * @deprecated since version 2018.09
- * @see DI::app()
- * @return App
- */
-function get_app()
-{
- return DI::app();
-}
-
/**
* @brief Used to end the current process, after saving session state.
* @deprecated
return;
}
- $a = \get_app();
+ $a = DI::app();
if (empty($_SESSION['sysmsg'])) {
$_SESSION['sysmsg'] = [];
}
*/
function info($s)
{
- $a = \get_app();
+ $a = DI::app();
if (local_user() && PConfig::get(local_user(), 'system', 'ignore_info')) {
return;
*/
function is_site_admin()
{
- $a = \get_app();
+ $a = DI::app();
$admin_email = Config::get('config', 'admin_email');
*/
function api_account_verify_credentials($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_statuses_mediap($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
Logger::log('api_statuses_update: no user');
*/
function api_statuses_update($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
Logger::log('api_statuses_update: no user');
*/
function api_media_upload()
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
Logger::log('no user');
*/
function api_media_metadata_create($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
Logger::info('no user');
*/
function api_users_search($type)
{
- $a = \get_app();
+ $a = DI::app();
$userlist = [];
if (!empty($_REQUEST['user_id'])) {
foreach (explode(',', $_REQUEST['user_id']) as $id) {
if (!empty($id)) {
- $users[] = api_get_user(get_app(), $id);
+ $users[] = api_get_user(DI::app(), $id);
}
}
}
*/
function api_search($type)
{
- $a = \get_app();
+ $a = DI::app();
$user_info = api_get_user($a);
if (api_user() === false || $user_info === false) {
*/
function api_statuses_home_timeline($type)
{
- $a = \get_app();
+ $a = DI::app();
$user_info = api_get_user($a);
if (api_user() === false || $user_info === false) {
*/
function api_statuses_public_timeline($type)
{
- $a = \get_app();
+ $a = DI::app();
$user_info = api_get_user($a);
if (api_user() === false || $user_info === false) {
*/
function api_statuses_networkpublic_timeline($type)
{
- $a = \get_app();
+ $a = DI::app();
$user_info = api_get_user($a);
if (api_user() === false || $user_info === false) {
*/
function api_statuses_show($type)
{
- $a = \get_app();
+ $a = DI::app();
$user_info = api_get_user($a);
if (api_user() === false || $user_info === false) {
*/
function api_conversation_show($type)
{
- $a = \get_app();
+ $a = DI::app();
$user_info = api_get_user($a);
if (api_user() === false || $user_info === false) {
{
global $called_api;
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_statuses_destroy($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_statuses_mentions($type)
{
- $a = \get_app();
+ $a = DI::app();
$user_info = api_get_user($a);
if (api_user() === false || $user_info === false) {
*/
function api_statuses_user_timeline($type)
{
- $a = \get_app();
+ $a = DI::app();
$user_info = api_get_user($a);
if (api_user() === false || $user_info === false) {
*/
function api_favorites_create_destroy($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
{
global $called_api;
- $a = \get_app();
+ $a = DI::app();
$user_info = api_get_user($a);
if (api_user() === false || $user_info === false) {
*/
function api_format_items_activities($item, $type = "json")
{
- $a = \get_app();
+ $a = DI::app();
$activities = [
'like' => [],
*/
function api_lists_ownerships($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_lists_statuses($type)
{
- $a = \get_app();
+ $a = DI::app();
$user_info = api_get_user($a);
if (api_user() === false || $user_info === false) {
*/
function api_statuses_f($qtype)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
throw new ForbiddenException();
}
- $a = \get_app();
+ $a = DI::app();
api_get_user($a);
*/
function api_direct_messages_new($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_direct_messages_destroy($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_direct_messages_box($type, $box, $verbose)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
}
Contact::updateSelfFromUserID(api_user(), true);
// Update global directory in background
- $url = DI::baseUrl() . '/profile/' . \get_app()->user['nickname'];
+ $url = DI::baseUrl() . '/profile/' . DI::app()->user['nickname'];
if ($url && strlen(Config::get('system', 'directory'))) {
Worker::add(PRIORITY_LOW, "Directory", $url);
}
function api_account_update_profile($type)
{
$local_user = api_user();
- $api_user = api_get_user(get_app());
+ $api_user = api_get_user(DI::app());
if (!empty($_POST['name'])) {
DBA::update('profile', ['name' => $_POST['name']], ['uid' => $local_user]);
*/
function prepare_photo_data($type, $scale, $photo_id)
{
- $a = \get_app();
+ $a = DI::app();
$user_info = api_get_user($a);
if ($user_info === false) {
*/
function api_friendica_group_show($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_friendica_group_delete($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_lists_destroy($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_friendica_group_create($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_lists_create($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_friendica_group_update($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_lists_update($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_friendica_activity($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_friendica_notification($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_friendica_notification_seen($type)
{
- $a = \get_app();
+ $a = DI::app();
$user_info = api_get_user($a);
if (api_user() === false || $user_info === false) {
*/
function api_friendica_direct_messages_setseen($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
}
*/
function api_friendica_direct_messages_search($type, $box = "")
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function api_friendica_profile_show($type)
{
- $a = \get_app();
+ $a = DI::app();
if (api_user() === false) {
throw new ForbiddenException();
*/
function notification($params)
{
- $a = \get_app();
+ $a = DI::app();
// Temporary logging for finding the origin
if (!isset($params['uid'])) {
function _map_files1($rr)
{
- $a = \get_app();
+ $a = DI::app();
$types = Images::supportedTypes();
$ext = $types[$rr['type']];
$filename_e = $rr['filename'];
function item_post_return($baseurl, $api_source, $return_path)
{
// figure out how to return, depending on from whence we came
- $a = \get_app();
+ $a = DI::app();
if ($api_source) {
return;
function render_messages(array $msg, $t)
{
- $a = \get_app();
+ $a = DI::app();
$tpl = Renderer::getMarkupTemplate($t);
$rslt = '';
{
$theme = Strings::sanitizeFilePathItem($theme);
- $a = \get_app();
+ $a = DI::app();
$base_theme = $a->theme_info['extends'] ?? '';
if (file_exists("view/theme/$theme/config.php")) {
*/
public static function getFormSecurityToken($typename = '')
{
- $a = \get_app();
+ $a = DI::app();
$timestamp = time();
$sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $timestamp . $typename);
$max_livetime = 10800; // 3 hours
- $a = \get_app();
+ $a = DI::app();
$x = explode('.', $hash);
if (time() > (intval($x[0]) + $max_livetime)) {
public static function checkFormSecurityTokenRedirectOnError($err_redirect, $typename = '', $formname = 'form_security_token')
{
if (!self::checkFormSecurityToken($typename, $formname)) {
- $a = \get_app();
+ $a = DI::app();
Logger::log('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), Logger::DATA);
notice(self::getFormSecurityStandardErrorMessage());
public static function checkFormSecurityTokenForbiddenOnError($typename = '', $formname = 'form_security_token')
{
if (!self::checkFormSecurityToken($typename, $formname)) {
- $a = \get_app();
+ $a = DI::app();
Logger::log('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), Logger::DATA);
namespace Friendica\Console;
+use Friendica\App;
+
/**
* When I installed docblox, I had the experience that it does not generate any output at all.
* This script may be used to find that kind of problems with the documentation build process.
protected $helpOptions = ['h', 'help', '?'];
+ /** @var App */
+ private $app;
+
+ public function __construct(App $app, array $argv = null)
+ {
+ parent::__construct($argv);
+
+ $this->app = $app;
+ }
+
protected function getHelp()
{
$help = <<<HELP
throw new \RuntimeException('DocBlox isn\'t available.');
}
- $dir = \get_app()->getBasePath();
+ $dir = $this->app->getBasePath();
//stack for dirs to search
$dirstack = [];
namespace Friendica\Console;
+use Friendica\App;
+
/**
* Read a strings.php file and create messages.po in the same directory
*
private $normBaseMsgIds = [];
const NORM_REGEXP = "|[\\\]|";
+ /** @var App */
+ private $app;
+
+ public function __construct(App $app, array $argv = null)
+ {
+ parent::__construct($argv);
+
+ $this->app = $app;
+ }
+
protected function getHelp()
{
$help = <<<HELP
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
- $a = \get_app();
+ $a = $this->app;
$phpfile = realpath($this->getArgument(0));
{
$embedurl = trim($embedurl, '\'"');
- $a = \get_app();
+ $a = DI::app();
$cache_key = 'oembed:' . $a->videowidth . ':' . $embedurl;
use Friendica\Core\L10n;
use Friendica\Core\Config;
use Friendica\Core\Renderer;
+use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Util\Network;
use Friendica\Util\Proxy as ProxyUtils;
*/
public static function contactBlock()
{
- $a = \get_app();
+ $a = DI::app();
return ContactBlock::getHTML($a->profile);
}
*/
public static function categories($baseurl, $selected = '')
{
- $a = \get_app();
+ $a = DI::app();
$uid = intval($a->profile['profile_uid']);
*/
public static function tagCloud($limit = 50)
{
- $a = \get_app();
+ $a = DI::app();
$uid = intval($a->profile['profile_uid']);
use Friendica\Content\Feature;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
+use Friendica\DI;
/**
* TagCloud widget
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function getHTML() {
- $a = \get_app();
+ $a = DI::app();
if (empty($a->data['user'])) {
return;
*/
public static function processQueue($run_cron = true)
{
- $a = \get_app();
-
// Ensure that all "strtotime" operations do run timezone independent
date_default_timezone_set('UTC');
*/
private static function execFunction($queue, $funcname, $argv, $method_call)
{
- $a = \get_app();
+ $a = DI::app();
$argc = count($argv);
$args = ['no_cron' => !$do_cron];
- $a = get_app();
+ $a = DI::app();
$process = new Core\Process(DI::logger(), DI::mode(), DI::config(), $a->getBasePath());
$process->run($command, $args);
{
$result = ['cid' => -1, 'success' => false, 'message' => ''];
- $a = \get_app();
+ $a = DI::app();
// remove ajax junk, e.g. Twitter
$url = str_replace('/#!/', '/', $url);
*/
public static function send($recipient = 0, $body = '', $subject = '', $replyto = '')
{
- $a = \get_app();
+ $a = DI::app();
if (!$recipient) {
return -1;
$micro = DI::baseUrl() . "/photo/" . $resource_id . "-6." . $Image->getExt() . $suffix;
// Remove the cached photo
- $a = \get_app();
+ $a = DI::app();
$basepath = $a->getBasePath();
if (is_dir($basepath . "/photo")) {
public static function getBirthdays()
{
- $a = \get_app();
+ $a = DI::app();
$o = '';
if (!local_user() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
public static function getEventsReminderHTML()
{
- $a = \get_app();
+ $a = DI::app();
$o = '';
if (!local_user() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
*/
public static function addVisitorCookieForHandle($handle)
{
- $a = \get_app();
+ $a = DI::app();
// Try to find the public contact entry of the visitor.
$cid = Contact::getIdForURL($handle);
*/
public static function openWebAuthInit($token)
{
- $a = \get_app();
+ $a = DI::app();
// Clean old OpenWebAuthToken entries.
OpenWebAuthToken::purge('owt', '3 MINUTE');
*/
public static function feed($dfrn_id, $owner_nick, $last_update, $direction = 0, $onlyheader = false)
{
- $a = \get_app();
+ $a = DI::app();
$sitefeed = ((strlen($owner_nick)) ? false : true); // not yet implemented, need to rewrite huge chunks of following logic
$public_feed = (($dfrn_id) ? false : true);
*/
namespace Friendica\Render;
+use Friendica\DI;
use Smarty;
use Friendica\Core\Renderer;
{
parent::__construct();
- $a = \get_app();
+ $a = DI::app();
$theme = $a->getCurrentTheme();
// setTemplateDir can be set to an array, which Smarty will parse in order.
namespace Friendica\Render;
use Friendica\Core\Hook;
+use Friendica\DI;
/**
* Smarty implementation of the Friendica template engine interface
$s = new FriendicaSmarty();
}
- $r['$APP'] = \get_app();
+ $r['$APP'] = DI::app();
// "middleware": inject variables into templates
$arr = [
public function getTemplateFile($file, $root = '')
{
- $a = \get_app();
+ $a = DI::app();
$template = new FriendicaSmarty();
// Make sure $root ends with a slash /
{
$stamp1 = microtime(true);
- $a = \get_app();
+ $a = DI::app();
if (strlen($url) > 1000) {
Logger::log('URL is longer than 1000 characters. Callstack: ' . System::callstack(20), Logger::DEBUG);
return CurlResult::createErrorCurl($url);
}
- $a = \get_app();
+ $a = DI::app();
$ch = curl_init($url);
if (($redirects > 8) || (!$ch)) {
*/
public static function finalUrl(string $url, int $depth = 1, bool $fetchbody = false)
{
- $a = \get_app();
+ $a = DI::app();
$url = self::stripTrackingQueryParams($url);
'type' => 'image/png'
]
];
- $app = \get_app();
+ $app = DI::app();
$app->argc = 2;
$result = api_media_upload();
*/
use Friendica\Core\PConfig;
+use Friendica\DI;
use Friendica\Util\Strings;
function get_scheme_info($scheme)
{
- $theme = \get_app()->getCurrentTheme();
+ $theme = DI::app()->getCurrentTheme();
$themepath = 'view/theme/' . $theme . '/';
if (empty($scheme)) {
$scheme = PConfig::get(local_user(), 'frio', 'scheme', PConfig::get(local_user(), 'frio', 'schema'));
function vier_community_info()
{
- $a = \get_app();
+ $a = DI::app();
$show_pages = get_vier_config("show_pages", 1);
$show_profiles = get_vier_config("show_profiles", 1);