]> git.mxchange.org Git - friendica.git/commitdiff
Move App to src
authorHypolite Petovan <mrpetovan@gmail.com>
Sun, 30 Apr 2017 04:07:00 +0000 (00:07 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Wed, 3 May 2017 02:59:36 +0000 (22:59 -0400)
- Add `use Friendica\App;` wherever needed

197 files changed:
boot.php
include/Contact.php
include/ForumManager.php
include/Photo.php
include/Probe.php
include/acl_selectors.php
include/api.php
include/auth.php
include/bbcode.php
include/cli_startup.php
include/contact_widgets.php
include/conversation.php
include/cronjobs.php
include/dbstructure.php
include/delivery.php
include/dfrn.php
include/diaspora.php
include/enotify.php
include/event.php
include/follow.php
include/identity.php
include/items.php
include/like.php
include/message.php
include/nav.php
include/network.php
include/notifier.php
include/oauth.php
include/oembed.php
include/ostatus.php
include/plaintext.php
include/plugin.php
include/poller.php
include/pubsubpublish.php
include/redir.php
include/security.php
include/shadowupdate.php
include/socgraph.php
include/tags.php
include/text.php
include/threads.php
include/uimport.php
index.php
mod/_well_known.php
mod/acctlink.php
mod/acl.php
mod/admin.php
mod/allfriends.php
mod/amcd.php
mod/api.php
mod/apps.php
mod/attach.php
mod/babel.php
mod/bookmarklet.php
mod/cal.php
mod/cb.php
mod/common.php
mod/community.php
mod/contactgroup.php
mod/contacts.php
mod/content.php
mod/credits.php
mod/crepair.php
mod/delegate.php
mod/dfrn_confirm.php
mod/dfrn_notify.php
mod/dfrn_poll.php
mod/dfrn_request.php
mod/directory.php
mod/dirfind.php
mod/display.php
mod/editpost.php
mod/events.php
mod/fbrowser.php
mod/fetch.php
mod/filer.php
mod/filerm.php
mod/follow.php
mod/friendica.php
mod/fsuggest.php
mod/group.php
mod/hcard.php
mod/help.php
mod/home.php
mod/hostxrd.php
mod/hovercard.php
mod/ignored.php
mod/install.php
mod/invite.php
mod/item.php
mod/like.php
mod/localtime.php
mod/lockview.php
mod/login.php
mod/lostpass.php
mod/maintenance.php
mod/manage.php
mod/manifest.php
mod/match.php
mod/message.php
mod/modexp.php
mod/mood.php
mod/msearch.php
mod/navigation.php
mod/network.php
mod/newmember.php
mod/nodeinfo.php
mod/nogroup.php
mod/noscrape.php
mod/notes.php
mod/notice.php
mod/notifications.php
mod/notify.php
mod/oembed.php
mod/oexchange.php
mod/openid.php
mod/opensearch.php
mod/ostatus_subscribe.php
mod/p.php
mod/parse_url.php
mod/photo.php
mod/photos.php
mod/ping.php
mod/poco.php
mod/poke.php
mod/post.php
mod/pretheme.php
mod/probe.php
mod/profile.php
mod/profile_photo.php
mod/profiles.php
mod/profperm.php
mod/proxy.php
mod/pubsub.php
mod/pubsubhubbub.php
mod/qsearch.php
mod/randprof.php
mod/receive.php
mod/redir.php
mod/register.php
mod/regmod.php
mod/removeme.php
mod/repair_ostatus.php
mod/robots_txt.php
mod/rsd_xml.php
mod/salmon.php
mod/search.php
mod/session.php
mod/settings.php
mod/share.php
mod/smilies.php
mod/starred.php
mod/statistics_json.php
mod/subthread.php
mod/suggest.php
mod/tagger.php
mod/tagrm.php
mod/toggle_mobile.php
mod/uexport.php
mod/uimport.php
mod/update_community.php
mod/update_display.php
mod/update_network.php
mod/update_notes.php
mod/update_profile.php
mod/videos.php
mod/viewcontacts.php
mod/viewsrc.php
mod/wall_attach.php
mod/wall_upload.php
mod/wallmessage.php
mod/webfinger.php
mod/xrd.php
src/App.php [new file with mode: 0644]
util/db_update.php
util/maintenance.php
util/php2po.php
util/typo.php
view/php/default.php
view/php/minimal.php
view/theme/duepuntozero/config.php
view/theme/duepuntozero/theme.php
view/theme/frio/config.php
view/theme/frio/php/default.php
view/theme/frio/php/frio_boot.php
view/theme/frio/php/standard.php
view/theme/frio/theme.php
view/theme/frost-mobile/php/default.php
view/theme/frost-mobile/theme.php
view/theme/frost/php/default.php
view/theme/frost/theme.php
view/theme/quattro/config.php
view/theme/quattro/theme.php
view/theme/smoothly/php/default.php
view/theme/smoothly/theme.php
view/theme/vier/config.php
view/theme/vier/theme.php

index afee3ac77d68db5f30c7c82e39de9aa684a2ee5c..a26d503271185117fdd3c4b96a7dc75f45d04fb3 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -19,6 +19,7 @@
 
 require_once(__DIR__ . DIRECTORY_SEPARATOR. 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once('include/config.php');
@@ -502,988 +503,6 @@ function startup() {
 
 }
 
-/**
- *
- * class: App
- *
- * @brief Our main application structure for the life of this page.
- *
- * Primarily deals with the URL that got us here
- * and tries to make some sense of it, and
- * stores our page contents and config storage
- * and anything else that might need to be passed around
- * before we spit the page out.
- *
- */
-class App {
-
-       /// @TODO decide indending as a colorful mixure is ahead ...
-       public  $module_loaded = false;
-       public  $query_string;
-       public  $config;
-       public  $page;
-       public  $profile;
-       public  $profile_uid;
-       public  $user;
-       public  $cid;
-       public  $contact;
-       public  $contacts;
-       public  $page_contact;
-       public  $content;
-       public  $data = array();
-       public  $error = false;
-       public  $cmd;
-       public  $argv;
-       public  $argc;
-       public  $module;
-       public  $pager;
-       public  $strings;
-       public  $path;
-       public  $hooks;
-       public  $timezone;
-       public  $interactive = true;
-       public  $plugins;
-       public  $apps = array();
-       public  $identities;
-       public  $is_mobile = false;
-       public  $is_tablet = false;
-       public  $is_friendica_app;
-       public  $performance = array();
-       public  $callstack = array();
-       public  $theme_info = array();
-       public  $backend = true;
-
-       public $nav_sel;
-
-       public $category;
-
-
-       // Allow themes to control internal parameters
-       // by changing App values in theme.php
-
-       public  $sourcename = '';
-       public  $videowidth = 425;
-       public  $videoheight = 350;
-       public  $force_max_items = 0;
-       public  $theme_thread_allow = true;
-       public  $theme_events_in_profile = true;
-
-       /**
-        * @brief An array for all theme-controllable parameters
-        *
-        * Mostly unimplemented yet. Only options 'template_engine' and
-        * beyond are used.
-        */
-       public  $theme = array(
-               'sourcename'      => '',
-               'videowidth'      => 425,
-               'videoheight'     => 350,
-               'force_max_items' => 0,
-               'thread_allow'    => true,
-               'stylesheet'      => '',
-               'template_engine' => 'smarty3',
-       );
-
-       /**
-        * @brief An array of registered template engines ('name'=>'class name')
-        */
-       public $template_engines = array();
-       /**
-        * @brief An array of instanced template engines ('name'=>'instance')
-        */
-       public $template_engine_instance = array();
-
-       public $process_id;
-
-       private $ldelim = array(
-               'internal' => '',
-               'smarty3' => '{{'
-       );
-       private $rdelim = array(
-               'internal' => '',
-               'smarty3' => '}}'
-       );
-
-       private $scheme;
-       private $hostname;
-       private $db;
-
-       private $curl_code;
-       private $curl_content_type;
-       private $curl_headers;
-
-       private $cached_profile_image;
-       private $cached_profile_picdate;
-
-       private static $a;
-
-       /**
-        * @brief App constructor.
-        */
-       function __construct() {
-
-               global $default_timezone;
-
-               $hostname = "";
-
-               if (file_exists(".htpreconfig.php")) {
-                       include ".htpreconfig.php";
-               }
-
-               $this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');
-
-               date_default_timezone_set($this->timezone);
-
-               $this->performance["start"] = microtime(true);
-               $this->performance["database"] = 0;
-               $this->performance["database_write"] = 0;
-               $this->performance["network"] = 0;
-               $this->performance["file"] = 0;
-               $this->performance["rendering"] = 0;
-               $this->performance["parser"] = 0;
-               $this->performance["marktime"] = 0;
-               $this->performance["markstart"] = microtime(true);
-
-               $this->callstack["database"] = array();
-               $this->callstack["database_write"] = array();
-               $this->callstack["network"] = array();
-               $this->callstack["file"] = array();
-               $this->callstack["rendering"] = array();
-               $this->callstack["parser"] = array();
-
-               $this->config = array();
-               $this->page = array();
-               $this->pager= array();
-
-               $this->query_string = '';
-
-               $this->process_id = uniqid("log", true);
-
-               startup();
-
-               set_include_path(
-                               get_include_path() . PATH_SEPARATOR
-                               . 'include' . PATH_SEPARATOR
-                               . 'library' . PATH_SEPARATOR
-                               . 'library/langdet' . PATH_SEPARATOR
-                               . '.' );
-
-               $this->scheme = 'http';
-
-               if ((x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) ||
-                               (x($_SERVER, 'HTTP_FORWARDED') && preg_match("/proto=https/", $_SERVER['HTTP_FORWARDED'])) ||
-                               (x($_SERVER, 'HTTP_X_FORWARDED_PROTO') && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
-                               (x($_SERVER, 'HTTP_X_FORWARDED_SSL') && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') ||
-                               (x($_SERVER, 'FRONT_END_HTTPS') && $_SERVER['FRONT_END_HTTPS'] == 'on') ||
-                               (x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much?
-                               ) {
-                       $this->scheme = 'https';
-               }
-
-               if (x($_SERVER, 'SERVER_NAME')) {
-                       $this->hostname = $_SERVER['SERVER_NAME'];
-
-                       if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
-                               $this->hostname .= ':' . $_SERVER['SERVER_PORT'];
-                       }
-                       /*
-                        * Figure out if we are running at the top of a domain
-                        * or in a sub-directory and adjust accordingly
-                        */
-
-                       /// @TODO This kind of escaping breaks syntax-highlightning on CoolEdit (Midnight Commander)
-                       $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
-                       if (isset($path) && strlen($path) && ($path != $this->path)) {
-                               $this->path = $path;
-                       }
-               }
-
-               if ($hostname != "") {
-                       $this->hostname = $hostname;
-               }
-
-               if (is_array($_SERVER["argv"]) && $_SERVER["argc"] > 1 && substr(end($_SERVER["argv"]), 0, 4) == "http" ) {
-                       $this->set_baseurl(array_pop($_SERVER["argv"]));
-                       $_SERVER["argc"] --;
-               }
-
-               if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 9) === "pagename=") {
-                       $this->query_string = substr($_SERVER['QUERY_STRING'], 9);
-
-                       // removing trailing / - maybe a nginx problem
-                       $this->query_string = ltrim($this->query_string, '/');
-               } elseif ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
-                       $this->query_string = substr($_SERVER['QUERY_STRING'], 2);
-
-                       // removing trailing / - maybe a nginx problem
-                       $this->query_string = ltrim($this->query_string, '/');
-               }
-
-               if (x($_GET, 'pagename')) {
-                       $this->cmd = trim($_GET['pagename'], '/\\');
-               } elseif (x($_GET, 'q')) {
-                       $this->cmd = trim($_GET['q'], '/\\');
-               }
-
-
-               // fix query_string
-               $this->query_string = str_replace($this->cmd . "&", $this->cmd . "?", $this->query_string);
-
-               // unix style "homedir"
-               if (substr($this->cmd, 0, 1) === '~') {
-                       $this->cmd = 'profile/' . substr($this->cmd, 1);
-               }
-
-               // Diaspora style profile url
-               if (substr($this->cmd, 0, 2) === 'u/') {
-                       $this->cmd = 'profile/' . substr($this->cmd, 2);
-               }
-
-
-               /*
-                * Break the URL path into C style argc/argv style arguments for our
-                * modules. Given "http://example.com/module/arg1/arg2", $this->argc
-                * will be 3 (integer) and $this->argv will contain:
-                *   [0] => 'module'
-                *   [1] => 'arg1'
-                *   [2] => 'arg2'
-                *
-                *
-                * There will always be one argument. If provided a naked domain
-                * URL, $this->argv[0] is set to "home".
-                */
-
-               $this->argv = explode('/', $this->cmd);
-               $this->argc = count($this->argv);
-               if ((array_key_exists('0', $this->argv)) && strlen($this->argv[0])) {
-                       $this->module = str_replace(".", "_", $this->argv[0]);
-                       $this->module = str_replace("-", "_", $this->module);
-               } else {
-                       $this->argc = 1;
-                       $this->argv = array('home');
-                       $this->module = 'home';
-               }
-
-               /*
-                * See if there is any page number information, and initialise
-                * pagination
-                */
-
-               $this->pager['page'] = ((x($_GET, 'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);
-               $this->pager['itemspage'] = 50;
-               $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
-
-               if ($this->pager['start'] < 0) {
-                       $this->pager['start'] = 0;
-               }
-               $this->pager['total'] = 0;
-
-               /*
-                * Detect mobile devices
-                */
-
-               $mobile_detect = new Mobile_Detect();
-               $this->is_mobile = $mobile_detect->isMobile();
-               $this->is_tablet = $mobile_detect->isTablet();
-
-               // Friendica-Client
-               $this->is_friendica_app = ($_SERVER['HTTP_USER_AGENT'] == "Apache-HttpClient/UNAVAILABLE (java 1.4)");
-
-               /*
-                * register template engines
-                */
-               $dc = get_declared_classes();
-               foreach ($dc as $k) {
-                       if (in_array("ITemplateEngine", class_implements($k))){
-                               $this->register_template_engine($k);
-                       }
-               }
-
-               self::$a = $this;
-
-       }
-
-       public static function get_basepath() {
-
-               $basepath = get_config("system", "basepath");
-
-               if ($basepath == "") {
-                       $basepath = dirname(__FILE__);
-               }
-
-               if ($basepath == "") {
-                       $basepath = $_SERVER["DOCUMENT_ROOT"];
-               }
-
-               if ($basepath == "") {
-                       $basepath = $_SERVER["PWD"];
-               }
-
-               return $basepath;
-       }
-
-       function get_scheme() {
-               return $this->scheme;
-       }
-
-       /**
-        * @brief Retrieves the Friendica instance base URL
-        *
-        * This function assembles the base URL from multiple parts:
-        * - Protocol is determined either by the request or a combination of
-        * system.ssl_policy and the $ssl parameter.
-        * - Host name is determined either by system.hostname or inferred from request
-        * - Path is inferred from SCRIPT_NAME
-        *
-        * Note: $ssl parameter value doesn't directly correlate with the resulting protocol
-        *
-        * @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN
-        * @return string Friendica server base URL
-        */
-       function get_baseurl($ssl = false) {
-
-               // Is the function called statically?
-               if (!(isset($this) && get_class($this) == __CLASS__)) {
-                       return self::$a->get_baseurl($ssl);
-               }
-
-               $scheme = $this->scheme;
-
-               if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) {
-                       $scheme = 'https';
-               }
-
-               //      Basically, we have $ssl = true on any links which can only be seen by a logged in user
-               //      (and also the login link). Anything seen by an outsider will have it turned off.
-
-               if (Config::get('system', 'ssl_policy') == SSL_POLICY_SELFSIGN) {
-                       if ($ssl) {
-                               $scheme = 'https';
-                       } else {
-                               $scheme = 'http';
-                       }
-               }
-
-               if (Config::get('config', 'hostname') != '') {
-                       $this->hostname = Config::get('config', 'hostname');
-               }
-
-               return $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );
-       }
-
-       /**
-        * @brief Initializes the baseurl components
-        *
-        * Clears the baseurl cache to prevent inconstistencies
-        *
-        * @param string $url
-        */
-       function set_baseurl($url) {
-               $parsed = @parse_url($url);
-
-               if ($parsed) {
-                       $this->scheme = $parsed['scheme'];
-
-                       $hostname = $parsed['host'];
-                       if (x($parsed, 'port')) {
-                               $hostname .= ':' . $parsed['port'];
-                       }
-                       if (x($parsed, 'path')) {
-                               $this->path = trim($parsed['path'], '\\/');
-                       }
-
-                       if (file_exists(".htpreconfig.php")) {
-                               include ".htpreconfig.php";
-                       }
-
-                       if (get_config('config', 'hostname') != '') {
-                               $this->hostname = get_config('config', 'hostname');
-                       }
-
-                       if (!isset($this->hostname) OR ($this->hostname == '')) {
-                               $this->hostname = $hostname;
-                       }
-               }
-       }
-
-       function get_hostname() {
-               if (get_config('config', 'hostname') != "") {
-                       $this->hostname = get_config('config', 'hostname');
-               }
-
-               return $this->hostname;
-       }
-
-       function set_hostname($h) {
-               $this->hostname = $h;
-       }
-
-       function set_path($p) {
-               $this->path = trim(trim($p), '/');
-       }
-
-       function get_path() {
-               return $this->path;
-       }
-
-       function set_pager_total($n) {
-               $this->pager['total'] = intval($n);
-       }
-
-       function set_pager_itemspage($n) {
-               $this->pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0);
-               $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
-       }
-
-       function set_pager_page($n) {
-               $this->pager['page'] = $n;
-               $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
-       }
-
-       function init_pagehead() {
-               $interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 40000);
-
-               // If the update is "deactivated" set it to the highest integer number (~24 days)
-               if ($interval < 0) {
-                       $interval = 2147483647;
-               }
-
-               if ($interval < 10000) {
-                       $interval = 40000;
-               }
-
-               // compose the page title from the sitename and the
-               // current module called
-               if (!$this->module == '') {
-                   $this->page['title'] = $this->config['sitename'] . ' (' . $this->module . ')';
-               } else {
-                       $this->page['title'] = $this->config['sitename'];
-               }
-
-               /* put the head template at the beginning of page['htmlhead']
-                * since the code added by the modules frequently depends on it
-                * being first
-                */
-               if (!isset($this->page['htmlhead'])) {
-                       $this->page['htmlhead'] = '';
-               }
-
-               // If we're using Smarty, then doing replace_macros() will replace
-               // any unrecognized variables with a blank string. Since we delay
-               // replacing $stylesheet until later, we need to replace it now
-               // with another variable name
-               if ($this->theme['template_engine'] === 'smarty3') {
-                       $stylesheet = $this->get_template_ldelim('smarty3') . '$stylesheet' . $this->get_template_rdelim('smarty3');
-               } else {
-                       $stylesheet = '$stylesheet';
-               }
-
-               $shortcut_icon = get_config("system", "shortcut_icon");
-               if ($shortcut_icon == "") {
-                       $shortcut_icon = "images/friendica-32.png";
-               }
-
-               $touch_icon = get_config("system", "touch_icon");
-               if ($touch_icon == "") {
-                       $touch_icon = "images/friendica-128.png";
-               }
-
-               // get data wich is needed for infinite scroll on the network page
-               $invinite_scroll = infinite_scroll_data($this->module);
-
-               $tpl = get_markup_template('head.tpl');
-               $this->page['htmlhead'] = replace_macros($tpl,array(
-                       '$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!!
-                       '$local_user' => local_user(),
-                       '$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,
-                       '$delitem' => t('Delete this item?'),
-                       '$showmore' => t('show more'),
-                       '$showfewer' => t('show fewer'),
-                       '$update_interval' => $interval,
-                       '$shortcut_icon' => $shortcut_icon,
-                       '$touch_icon' => $touch_icon,
-                       '$stylesheet' => $stylesheet,
-                       '$infinite_scroll' => $invinite_scroll,
-               )) . $this->page['htmlhead'];
-       }
-
-       function init_page_end() {
-               if (!isset($this->page['end'])) {
-                       $this->page['end'] = '';
-               }
-               $tpl = get_markup_template('end.tpl');
-               $this->page['end'] = replace_macros($tpl,array(
-                       '$baseurl' => $this->get_baseurl() // FIXME for z_path!!!!
-               )) . $this->page['end'];
-       }
-
-       function set_curl_code($code) {
-               $this->curl_code = $code;
-       }
-
-       function get_curl_code() {
-               return $this->curl_code;
-       }
-
-       function set_curl_content_type($content_type) {
-               $this->curl_content_type = $content_type;
-       }
-
-       function get_curl_content_type() {
-               return $this->curl_content_type;
-       }
-
-       function set_curl_headers($headers) {
-               $this->curl_headers = $headers;
-       }
-
-       function get_curl_headers() {
-               return $this->curl_headers;
-       }
-
-       function get_cached_avatar_image($avatar_image){
-               return $avatar_image;
-       }
-
-
-       /**
-        * @brief Removes the baseurl from an url. This avoids some mixed content problems.
-        *
-        * @param string $orig_url
-        *
-        * @return string The cleaned url
-        */
-       function remove_baseurl($orig_url){
-
-               // Is the function called statically?
-               if (!(isset($this) && get_class($this) == __CLASS__)) {
-                       return self::$a->remove_baseurl($orig_url);
-               }
-
-               // Remove the hostname from the url if it is an internal link
-               $nurl = normalise_link($orig_url);
-               $base = normalise_link($this->get_baseurl());
-               $url = str_replace($base."/", "", $nurl);
-
-               // if it is an external link return the orignal value
-               if ($url == normalise_link($orig_url)) {
-                       return $orig_url;
-               } else {
-                       return $url;
-               }
-       }
-
-       /**
-        * @brief Register template engine class
-        *
-        * If $name is "", is used class static property $class::$name
-        *
-        * @param string $class
-        * @param string $name
-        */
-       function register_template_engine($class, $name = '') {
-               /// @TODO Really === and not just == ?
-               if ($name === "") {
-                       $v = get_class_vars( $class );
-                       if (x($v,"name")) $name = $v['name'];
-               }
-               if ($name === "") {
-                       echo "template engine <tt>$class</tt> cannot be registered without a name.\n";
-                       killme();
-               }
-               $this->template_engines[$name] = $class;
-       }
-
-       /**
-        * @brief Return template engine instance.
-        *
-        * If $name is not defined, return engine defined by theme,
-        * or default
-        *
-        * @param strin $name Template engine name
-        * @return object Template Engine instance
-        */
-       function template_engine($name = '') {
-               /// @TODO really type-check included?
-               if ($name !== "") {
-                       $template_engine = $name;
-               } else {
-                       $template_engine = 'smarty3';
-                       if (x($this->theme, 'template_engine')) {
-                               $template_engine = $this->theme['template_engine'];
-                       }
-               }
-
-               if (isset($this->template_engines[$template_engine])){
-                       if (isset($this->template_engine_instance[$template_engine])){
-                               return $this->template_engine_instance[$template_engine];
-                       } else {
-                               $class = $this->template_engines[$template_engine];
-                               $obj = new $class;
-                               $this->template_engine_instance[$template_engine] = $obj;
-                               return $obj;
-                       }
-               }
-
-               echo "template engine <tt>$template_engine</tt> is not registered!\n"; killme();
-       }
-
-       /**
-        * @brief Returns the active template engine.
-        *
-        * @return string
-        */
-       function get_template_engine() {
-               return $this->theme['template_engine'];
-       }
-
-       function set_template_engine($engine = 'smarty3') {
-               $this->theme['template_engine'] = $engine;
-       }
-
-       function get_template_ldelim($engine = 'smarty3') {
-               return $this->ldelim[$engine];
-       }
-
-       function get_template_rdelim($engine = 'smarty3') {
-               return $this->rdelim[$engine];
-       }
-
-       function save_timestamp($stamp, $value) {
-               if (!isset($this->config['system']['profiler']) || !$this->config['system']['profiler']) {
-                       return;
-               }
-
-               $duration = (float)(microtime(true)-$stamp);
-
-               if (!isset($this->performance[$value])) {
-                       // Prevent ugly E_NOTICE
-                       $this->performance[$value] = 0;
-               }
-
-               $this->performance[$value] += (float)$duration;
-               $this->performance["marktime"] += (float)$duration;
-
-               $callstack = $this->callstack();
-
-               if (!isset($this->callstack[$value][$callstack])) {
-                       // Prevent ugly E_NOTICE
-                       $this->callstack[$value][$callstack] = 0;
-               }
-
-               $this->callstack[$value][$callstack] += (float)$duration;
-
-       }
-
-       /**
-        * @brief Log active processes into the "process" table
-        */
-       function start_process() {
-               $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
-
-               $command = basename($trace[0]["file"]);
-
-               $this->remove_inactive_processes();
-
-               q("START TRANSACTION");
-
-               $r = q("SELECT `pid` FROM `process` WHERE `pid` = %d", intval(getmypid()));
-               if (!dbm::is_result($r)) {
-                       q("INSERT INTO `process` (`pid`,`command`,`created`) VALUES (%d, '%s', '%s')",
-                               intval(getmypid()),
-                               dbesc($command),
-                               dbesc(datetime_convert()));
-               }
-               q("COMMIT");
-       }
-
-       /**
-        * @brief Remove inactive processes
-        */
-       function remove_inactive_processes() {
-               q("START TRANSACTION");
-
-               $r = q("SELECT `pid` FROM `process`");
-               if (dbm::is_result($r)) {
-                       foreach ($r AS $process) {
-                               if (!posix_kill($process["pid"], 0)) {
-                                       q("DELETE FROM `process` WHERE `pid` = %d", intval($process["pid"]));
-                               }
-                       }
-               }
-               q("COMMIT");
-       }
-
-       /**
-        * @brief Remove the active process from the "process" table
-        */
-       function end_process() {
-               q("DELETE FROM `process` WHERE `pid` = %d", intval(getmypid()));
-       }
-
-       /**
-        * @brief Returns a string with a callstack. Can be used for logging.
-        *
-        * @return string
-        */
-       function callstack() {
-               $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6);
-
-               // We remove the first two items from the list since they contain data that we don't need.
-               array_shift($trace);
-               array_shift($trace);
-
-               $callstack = array();
-               foreach ($trace AS $func) {
-                       $callstack[] = $func["function"];
-               }
-
-               return implode(", ", $callstack);
-       }
-
-       function get_useragent() {
-               return
-                       FRIENDICA_PLATFORM . " '" .
-                       FRIENDICA_CODENAME . "' " .
-                       FRIENDICA_VERSION . "-" .
-                       DB_UPDATE_VERSION . "; " .
-                       $this->get_baseurl();
-       }
-
-       function is_friendica_app() {
-               return $this->is_friendica_app;
-       }
-
-       /**
-        * @brief Checks if the site is called via a backend process
-        *
-        * This isn't a perfect solution. But we need this check very early.
-        * So we cannot wait until the modules are loaded.
-        *
-        * @return bool Is it a known backend?
-        */
-       function is_backend() {
-               static $backends = array();
-               $backends[] = "_well_known";
-               $backends[] = "api";
-               $backends[] = "dfrn_notify";
-               $backends[] = "fetch";
-               $backends[] = "hcard";
-               $backends[] = "hostxrd";
-               $backends[] = "nodeinfo";
-               $backends[] = "noscrape";
-               $backends[] = "p";
-               $backends[] = "poco";
-               $backends[] = "post";
-               $backends[] = "proxy";
-               $backends[] = "pubsub";
-               $backends[] = "pubsubhubbub";
-               $backends[] = "receive";
-               $backends[] = "rsd_xml";
-               $backends[] = "salmon";
-               $backends[] = "statistics_json";
-               $backends[] = "xrd";
-
-               // Check if current module is in backend or backend flag is set
-               return (in_array($this->module, $backends) || $this->backend);
-       }
-
-       /**
-        * @brief Checks if the maximum number of database processes is reached
-        *
-        * @return bool Is the limit reached?
-        */
-       function max_processes_reached() {
-
-               if ($this->is_backend()) {
-                       $process = "backend";
-                       $max_processes = get_config('system', 'max_processes_backend');
-                       if (intval($max_processes) == 0) {
-                               $max_processes = 5;
-                       }
-               } else {
-                       $process = "frontend";
-                       $max_processes = get_config('system', 'max_processes_frontend');
-                       if (intval($max_processes) == 0) {
-                               $max_processes = 20;
-                       }
-               }
-
-               $processlist = dbm::processlist();
-               if ($processlist["list"] != "") {
-                       logger("Processcheck: Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
-
-                       if ($processlist["amount"] > $max_processes) {
-                               logger("Processcheck: Maximum number of processes for ".$process." tasks (".$max_processes.") reached.", LOGGER_DEBUG);
-                               return true;
-                       }
-               }
-               return false;
-       }
-
-       /**
-        * @brief Checks if the minimal memory is reached
-        *
-        * @return bool Is the memory limit reached?
-        */
-       public function min_memory_reached() {
-               $min_memory = Config::get('system', 'min_memory', 0);
-               if ($min_memory == 0) {
-                       return false;
-               }
-
-               if (!is_readable("/proc/meminfo")) {
-                       return false;
-               }
-
-               $memdata = explode("\n", file_get_contents('/proc/meminfo'));
-
-               $meminfo = array();
-               foreach ($memdata as $line) {
-                       list($key, $val) = explode(":", $line);
-                       $meminfo[$key] = (int)trim(str_replace("kB", "", $val));
-                       $meminfo[$key] = (int)($meminfo[$key] / 1024);
-               }
-
-               if (!isset($meminfo['MemAvailable']) OR !isset($meminfo['MemFree'])) {
-                       return false;
-               }
-
-               $free = $meminfo['MemAvailable'] + $meminfo['MemFree'];
-
-               $reached = ($free < $min_memory);
-
-               if ($reached) {
-                       logger('Minimal memory reached: '.$free.'/'.$meminfo['MemTotal'].' - limit '.$min_memory, LOGGER_DEBUG);
-               }
-
-               return $reached;
-       }
-
-       /**
-        * @brief Checks if the maximum load is reached
-        *
-        * @return bool Is the load reached?
-        */
-       function maxload_reached() {
-
-               if ($this->is_backend()) {
-                       $process = "backend";
-                       $maxsysload = intval(get_config('system', 'maxloadavg'));
-                       if ($maxsysload < 1) {
-                               $maxsysload = 50;
-                       }
-               } else {
-                       $process = "frontend";
-                       $maxsysload = intval(get_config('system','maxloadavg_frontend'));
-                       if ($maxsysload < 1) {
-                               $maxsysload = 50;
-                       }
-               }
-
-               $load = current_load();
-               if ($load) {
-                       if (intval($load) > $maxsysload) {
-                               logger('system: load '.$load.' for '.$process.' tasks ('.$maxsysload.') too high.');
-                               return true;
-                       }
-               }
-               return false;
-       }
-
-       function proc_run($args) {
-
-               if (!function_exists("proc_open")) {
-                       return;
-               }
-
-               // If the last worker fork was less than 10 seconds before then don't fork another one.
-               // This should prevent the forking of masses of workers.
-               $cachekey = "app:proc_run:started";
-               $result = Cache::get($cachekey);
-
-               if (!is_null($result) AND (time() - $result) < 10) {
-                       return;
-               }
-
-               // Set the timestamp of the last proc_run
-               Cache::set($cachekey, time(), CACHE_MINUTE);
-
-               array_unshift($args, ((x($this->config,'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php'));
-
-               // add baseurl to args. cli scripts can't construct it
-               $args[] = $this->get_baseurl();
-
-               for ($x = 0; $x < count($args); $x ++) {
-                       $args[$x] = escapeshellarg($args[$x]);
-               }
-
-               $cmdline = implode($args, " ");
-
-               if ($this->min_memory_reached()) {
-                       return;
-               }
-
-               if (get_config('system', 'proc_windows')) {
-                       $resource = proc_open('cmd /c start /b ' . $cmdline, array(), $foo, dirname(__FILE__));
-               } else {
-                       $resource = proc_open($cmdline . " &", array(), $foo, dirname(__FILE__));
-               }
-               if (!is_resource($resource)) {
-                       logger('We got no resource for command '.$cmdline, LOGGER_DEBUG);
-                       return;
-               }
-               proc_close($resource);
-       }
-
-       /**
-        * @brief Returns the system user that is executing the script
-        *
-        * This mostly returns something like "www-data".
-        *
-        * @return string system username
-        */
-       static function systemuser() {
-               if (!function_exists('posix_getpwuid') OR !function_exists('posix_geteuid')) {
-                       return '';
-               }
-
-               $processUser = posix_getpwuid(posix_geteuid());
-               return $processUser['name'];
-       }
-
-       /**
-        * @brief Checks if a given directory is usable for the system
-        *
-        * @return boolean the directory is usable
-        */
-       static function directory_usable($directory) {
-
-               if ($directory == '') {
-                       logger("Directory is empty. This shouldn't happen.", LOGGER_DEBUG);
-                       return false;
-               }
-
-               if (!file_exists($directory)) {
-                       logger('Path "'.$directory.'" does not exist for user '.self::systemuser(), LOGGER_DEBUG);
-                       return false;
-               }
-               if (is_file($directory)) {
-                       logger('Path "'.$directory.'" is a file for user '.self::systemuser(), LOGGER_DEBUG);
-                       return false;
-               }
-               if (!is_dir($directory)) {
-                       logger('Path "'.$directory.'" is not a directory for user '.self::systemuser(), LOGGER_DEBUG);
-                       return false;
-               }
-               if (!is_writable($directory)) {
-                       logger('Path "'.$directory.'" is not writable for user '.self::systemuser(), LOGGER_DEBUG);
-                       return false;
-               }
-               return true;
-       }
-}
-
 /**
  * @brief Retrieve the App structure
  *
index 6f662cdf151bb13ad620dfc1487290e5b9dd08f7..d635ee872558c649ce49970e97bf11db9f7795f4 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 // Included here for completeness, but this is a very dangerous operation.
 // It is the caller's responsibility to confirm the requestor's intent and
 // authorisation to do this.
index c2a20df29faf069bd0b3fc987b33e3d12b918e7f..8f38ed3a38eac9e5f81d1f325c74abab2eeb4b58 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 /**
  * @file include/ForumManager.php
  * @brief ForumManager class with its methods related to forum functionality *
index 828dce82d7a33088c4bae02e1c350104a6e58114..504f7e94218b4288d1a987bea296e201b4a6c336 100644 (file)
@@ -4,6 +4,8 @@
  * @brief This file contains the Photo class for image processing
  */
 
+use Friendica\App;
+
 require_once("include/photos.php");
 
 class Photo {
index 653e90b535faadfb0af051c36f7c62b4da795559..c9c0530f08da9a90cc0323aebba92e4f47e34b5e 100644 (file)
@@ -5,6 +5,7 @@
  *
  */
 
+use Friendica\App;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 
index f57af575afa3091124e3dff1716d6b288c6c62fe..d5dd911712f07b761777e21d05b71c48962f0ce2 100644 (file)
@@ -4,6 +4,8 @@
  * @file include/acl_selectors.php
  */
 
+use Friendica\App;
+
 require_once "include/contact_selectors.php";
 require_once "include/contact_widgets.php";
 require_once "include/DirSearch.php";
index 2e0409cb7a5fc27ef51a41ffaa3cfe1435901232..2471f602d8d53cd55da53f0c8f7c1b05def2e94c 100644 (file)
@@ -6,6 +6,7 @@
  * @todo Automatically detect if incoming data is HTML or BBCode
  */
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once 'include/HTTPExceptions.php';
index 76662d666cb6d863e27089c7736fc122b67430eb..5dfe9d3e062aa7865ab5a9f8db87412d438b986f 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once('include/security.php');
index 8ccdfd981c1a2c3658762694b63ec82892ae5c4d..d891f23dae4c07f5c4c8091e0a2a5e898130d544 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once 'include/oembed.php';
index 5f0c37bdb345321bcc119184a03a045d2666988c..e8cc9483dbc35311f2dddb12ed6e4f1f2c414881 100644 (file)
@@ -1,5 +1,6 @@
 <?php /** @file */
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once('boot.php');
index 5dd3a8bb4b163996d597902adff6f99b741f07a3..db077b420ff32ca441690fcd4c6431b08b9c1b22 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function follow_widget($value = "") {
 
        return replace_macros(get_markup_template('follow.tpl'), array(
index 3b026f30e62b73aff1080f7e22ee4d1f6f3f810f..27f9578ed8009b9f7bfc3fe8ff0df801a2c64cd3 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once "include/bbcode.php";
 require_once "include/acl_selectors.php";
 
index 10a9d3e3d7a24929ce05d1ee2a91370baadb9c51..ee1ac517acbe91d3038bdbbc3716c0e4efd545aa 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 function cronjobs_run(&$argv, &$argc){
index 80dba04947f4bd7950d70e3a13912b63196e0458..fc2424226d145080ac20878f606fccb5881cbc3b 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once("boot.php");
index 0b43b67f0f075572da412884d9d84c62c2025cd2..3aecf3b7233bbc8fa362e5319ad93f1ef427131a 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once('include/queue_fn.php');
index 5977ed9a0c254c044516c70035bb1acf1b0a963a..9109efce4fcbc41b51e2f501b0c9e1746671a977 100644 (file)
@@ -7,6 +7,8 @@
  * https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
  */
 
+use Friendica\App;
+
 require_once("include/Contact.php");
 require_once("include/ostatus.php");
 require_once("include/enotify.php");
index 08c36c54d360d56e269c2422cfe79c4ad41a8656..21081dd6a7250d7e4891984c47889ad633e4b065 100644 (file)
@@ -8,6 +8,7 @@
  * This will change in the future.
  */
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once 'include/items.php';
index f86174bd40109826025f5fe96f7b57a6f9e6087c..e351f0d115c37ec41c5f5bdb842fce45a37de59f 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once('include/Emailer.php');
 require_once('include/email.php');
 require_once('include/bbcode.php');
index c6ea54fbcfaec8a8108a866127f8320991cdf49d..afb8ea755bc8bc04649a4802c08005ac7a6dd3a4 100644 (file)
@@ -4,6 +4,8 @@
  * @brief functions specific to event handling
  */
 
+use Friendica\App;
+
 require_once 'include/bbcode.php';
 require_once 'include/map.php';
 require_once 'include/datetime.php';
index 57520abe602291011acfb8ca67eeb931442f698c..161e669e949bb26480e07521528aa02b9820125d 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once("include/Scrape.php");
 require_once("include/socgraph.php");
 require_once('include/group.php');
index 1fea5b25d659880ed1e07cb4c501f53c364b4d62..dea044b48ee1f40cb5e233a63bf16a54b339a7e9 100644 (file)
@@ -3,6 +3,8 @@
  * @file include/identity.php
  */
 
+use Friendica\App;
+
 require_once('include/ForumManager.php');
 require_once('include/bbcode.php');
 require_once("mod/proxy.php");
index 83aa13ace952a9cb808b72df40669f9cba2abdff..3c5e88a38ac8cff30a7ad8e85de6b4990515b322 100644 (file)
@@ -4,6 +4,7 @@
  * @file include/items.php
  */
 
+use Friendica\App;
 use Friendica\ParseUrl;
 
 require_once 'include/bbcode.php';
index a53b90c0398ce11f215ad1b9d660eb6fbf0c2c01..4f26002719dcb1fabd5f143dddfce320d7ee3d3b 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once("include/diaspora.php");
 
 /**
index a862c6d3333e9834c3ac63a4839b54e059d79ca1..b857bd604b9bafab31bfde24842563ec8fe21a42 100644 (file)
@@ -2,6 +2,7 @@
 
 // send a private message
 
+use Friendica\App;
 
 function send_message($recipient=0, $body='', $subject='', $replyto=''){
 
index fe4c50818ea583c3e02768b8b4ead0866fdb9422..e2633be0af5eb3dc2ea18d3fa5b2dbc1f0b3a521 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function nav(App $a) {
 
        /*
index 759e53670770752871a571c4e5350e098c024556..72d3ce626c14c473913785e963cc033e40d89f49 100644 (file)
@@ -4,6 +4,7 @@
  * @file include/network.php
  */
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once("include/xml.php");
index 87e827accd0ccb47c8ee35b878e1be8934ae2c52..ad89eacb6d8eb4c99c6f61b281790275a376678d 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once('include/queue_fn.php');
index 9fb15b492af366cb4bef9cf31bc142ebe87feb63..f67e3d2b704df539e39cfd320ead71c555948562 100644 (file)
@@ -5,6 +5,8 @@
  *
  */
 
+use Friendica\App;
+
 define('REQUEST_TOKEN_DURATION', 300);
 define('ACCESS_TOKEN_DURATION', 31536000);
 
index 564626317b38cc81c887b7e3a724db6a5af81c35..80b49fbf046c7095c9724a1e550bc75ed890ab91 100755 (executable)
@@ -4,6 +4,7 @@
  * @file include/oembed.php
  */
 
+use Friendica\App;
 use Friendica\ParseUrl;
 use Friendica\Core\Config;
 
index 40bcdcdcc57d2d7b50f4fa1fc9d422974aec3069..f0f59b272bd385d1c9f13fb133157317b64ee5ac 100644 (file)
@@ -3,6 +3,8 @@
  * @file include/ostatus.php
  */
 
+use Friendica\App;
+
 require_once("include/Contact.php");
 require_once("include/threads.php");
 require_once("include/html2bbcode.php");
index 246f7c31fa911642108b70a94695e03495b0b1be..aa644ee2bea71a8d47f49fae3b7434c9ad57bf3d 100644 (file)
@@ -4,6 +4,7 @@
  * @file include/plaintext.php
  */
 
+use Friendica\App;
 use Friendica\ParseUrl;
 
 require_once("include/Photo.php");
index f7423d7c698fd2bdb3cc71ec2a8d58486517eab6..336b213aa3491324db2582196159a628822dbdb3 100644 (file)
@@ -5,6 +5,7 @@
  * @brief Some functions to handle addons and themes.
  */
 
+use Friendica\App;
 
 /**
  * @brief uninstalls an addon.
index 8dbd98746082b3a2544e4f0c3cdfd1a47f221cc6..f0192f0f0385dc243dbeeb2f6711e2c6d57e16bb 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
index 4106e75fb64204a76305c7415fc8407c841ad544..3796247f7ed3cd90a05d075dc6a57dc654aeb0d7 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once('include/items.php');
index 76e30a6eaca2325950db232bfd119fda8f765d38..36f982b12cd6f76b5293ee6cb4344e6656f5188b 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function auto_redir(App $a, $contact_nick) {
 
        // prevent looping
index 05371f71ca55d1a44559480ffc2c350197cc3add..09ac03c35e9cbfe2cfd64c96b04bda169b90ccf8 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 /**
  * @brief Calculate the hash that is needed for the "Friendica" cookie
  *
index f1cbd2de9c129156f9072a6db8ec7b7002ed0f69..f1888f92e5da4dc68942aefc34fca0d56406e32a 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once("boot.php");
index 1cd8d9f935c65dabf220db65b9ece48acff59743..c8a2fdaf1d055653f204636dfaf921ffb2e46333 100644 (file)
@@ -7,6 +7,7 @@
  * @todo Detect if it is a forum
  */
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once('include/datetime.php');
index d809da2bf5e0115c2f4ce36fc503ae9bd33fec62..9a52097cc448a68ef3ad313706b8401a12347b3e 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 function create_tags_from_item($itemid) {
        $profile_base = App::get_baseurl();
        $profile_data = parse_url($profile_base);
index a877d5cca52a680fa8db59fc7f16291f594586a0..c9babba940f8f06e31770f638407bb5a3839b169 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once("include/template_processor.php");
 require_once("include/friendica_smarty.php");
 require_once("include/Smilies.php");
index 3d0aa05c3c08646abbd9031894a1817d0d9f7f8a..9e0982836e240338b1866f3b7e2b7fc26d7e15be 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 function add_thread($itemid, $onlyshadow = false) {
        $items = q("SELECT `uid`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`,
                        `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`,
index f66d8d3d2cdc77918a4fa8aac66d5cc23e99168a..0ee15952af56ae0ca0d22312eaef250f0c356b47 100644 (file)
@@ -1,5 +1,7 @@
 <?php\r
 \r
+use Friendica\App;\r
+\r
 require_once("include/Photo.php");\r
 define("IMPORT_DEBUG", False);\r
 \r
index cebff92b7fa98e8c0256461d0eaa46ccfb491ee4..098bae2a94e48cb23f956d354a3e88b7860de64b 100644 (file)
--- a/index.php
+++ b/index.php
@@ -13,6 +13,7 @@
  *
  */
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once('boot.php');
index 3956d03f739aaa8c1c66ebc84a8a72b153effdc9..45c1da494cc785da79f753ea3546a6705c1847ff 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once("mod/hostxrd.php");
index 892b59655f01dea4cab10ca8e2b9fbe7d036ebac..bb59d7b94f0feccaaad105f576d0b90a2d22eab9 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/Scrape.php');
 
 function acctlink_init(App $a) {
index 9220bc77a9097198aed0bc2c5b7e3800eaf245a7..e04a3fbc7e1d243727ae7a13a6d973497de15005 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 /* ACL selector json backend */
 
+use Friendica\App;
+
 require_once 'include/acl_selectors.php';
 
 function acl_init(App $a) {
index 4c27c48f0f62e94165cef155af4d44353fa6c583..7a5ff87d3b06bd8051c03d80662d5f2b6b634d5e 100644 (file)
@@ -6,6 +6,7 @@
  * @brief Friendica admin
  */
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once("include/enotify.php");
index f51070bbe86d472216892b3685cc34fb19680520..fe3013a7c4af5fef7bef783e1fcaa151ac2aded5 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/socgraph.php');
 require_once('include/Contact.php');
 require_once('include/contact_selectors.php');
index 2ef890a1b209946efb162206e9cf1d94b2c826cc..0eb295a816058a771a8ab18e51995a9cdd0bb182 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function amcd_content(App $a) {
        echo <<< JSON
 {
index 3916636cfd32f02bbdbdbfa1d28d4a1251db792a..b771af01b2d88c057394b7df17ffa43a1e3db564 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/api.php');
 
 function oauth_get_client($request){
index 85fdf6139b53e5d02f54a23cf3ae19fb0150a396..5ba03bbb6678fcd8f085748f43720f5e90f279eb 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 
 function apps_content(App $a) {
        $privateaddons = get_config('config', 'private_addons');
index dd7154dfe1a61033c370e3ea9cd8fea02111d26d..6155a3f99e9853c723acd623c64a375367eeb9b0 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/security.php');
 
 function attach_init(App $a) {
index f71863bdedaf2253720fb6b3d90ac8aeb8957ac0..0e38dc5750ab41e5ae456418e3f0fa46ca2531c2 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once 'include/bbcode.php';
 require_once 'library/markdown.php';
 require_once 'include/bb2diaspora.php';
index c4ef8457044ed64913eb15f3af0c385a69f5c74d..f7dd256775c4e478a79d62ec4f37646f15aa213f 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/conversation.php');
 require_once('include/items.php');
 
index 7398426bc3dc5256370f1e2dbff7f7b5c3a2ecb1..cd884e50e4b000b02f62512048cd73e7afa43909 100644 (file)
@@ -6,6 +6,8 @@
  *     of the profile owner
  */
 
+use Friendica\App;
+
 require_once('include/event.php');
 require_once('include/redir.php');
 
index 3c5df6e38ba12a861c3fba117ff786d6a9d111e4..030bea4d31849c068a8969c8929fae21530ff421 100644 (file)
@@ -4,6 +4,7 @@
  * General purpose landing page for plugins/addons
  */
 
+use Friendica\App;
 
 function cb_init(App $a) {
        call_hooks('cb_init');
index 5a40663f9eb6445e48f44d5c4e82ac08639e9dc9..87e305e68d0b9ffc09f5d3914dbc215f73a9cfc7 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/socgraph.php');
 require_once('include/Contact.php');
 require_once('include/contact_selectors.php');
index 6d318a539ee7ac33f5fa6a17e0a7b3d1c83fa7d6..5c71667bdcc197c0c83dd1909c2a405e0a70e747 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 function community_init(App $a) {
index 41606ae234aa83f8cd2c3189bea3744d9b6ae83d..2a44e2889655d33254819aefe2a711391c5f6232 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/group.php');
 
 function contactgroup_content(App $a) {
index f2500099c3f44689b37f67b4faf3afb7320ce3dd..ee501fb9dd63f34a92afa820c280976c36f7bd2a 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/Contact.php');
 require_once('include/socgraph.php');
 require_once('include/contact_selectors.php');
index 43f3fc2ba686e9acfb39d119c114262a4700a95c..a8c3130333aa6770d7e63f42227702e65c0f50d6 100644 (file)
@@ -15,6 +15,7 @@
 // fast - e.g. one or two milliseconds to fetch parent items for the current content,
 // and 10-20 milliseconds to fetch all the child items.
 
+use Friendica\App;
 
 function content_content(App $a, $update = 0) {
 
index def2031a000f0efa770304a5cb335049abaddb74..e0e834388fdaf602d4567229a3a9758faa508521 100644 (file)
@@ -6,6 +6,7 @@
  * addons repository will be listed though ATM)
  */
 
+use Friendica\App;
 
 function credits_content(App $a) {
        /* fill the page with credits */
index 902a129303972a7e18b7c426f84aff37231c5fc8..59ac620a374cf1dc4730ef3b1455b3e198ce2182 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once("include/contact_selectors.php");
 require_once("mod/contacts.php");
 
index ade6737f620457f3da988dbb09072258c2f66f19..e99734a33b32f14509d075f53212cf52b661adcc 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once('mod/settings.php');
 
 function delegate_init(App $a) {
index 001fa446891b28eaf205b763d8168dff26005a1f..6ebde734e6ace3dfae9c610c521371afcaab1300 100644 (file)
@@ -18,6 +18,8 @@
  *    https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_confirmation.png
  */
 
+use Friendica\App;
+
 require_once('include/enotify.php');
 require_once('include/group.php');
 require_once('include/Probe.php');
index b42ef9b70a82cee1bc669945d2bd8c3c9fba0a27..44e016599e486862c0d4493499ba10e331838e33 100644 (file)
@@ -5,6 +5,9 @@
  * @brief The dfrn notify endpoint
  * @see PDF with dfrn specs: https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
  */
+
+use Friendica\App;
+
 require_once('include/items.php');
 require_once('include/dfrn.php');
 require_once('include/event.php');
index 9a19cfc8d37b6fe8e34efa3bec8916421d3e6371..91fa49618a7713bdd443be67b5a0591fe1043b3f 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once('include/items.php');
 require_once('include/auth.php');
 require_once('include/dfrn.php');
index 5a25c27f6ae72a25a7ec964b9680dbcc60540a06..18a6b7ebdb21e6b0ae3db8c659b0b22af81b5b8f 100644 (file)
@@ -12,6 +12,8 @@
  *    https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_request.png
  */
 
+use Friendica\App;
+
 require_once('include/enotify.php');
 require_once('include/Scrape.php');
 require_once('include/Probe.php');
index 4f7af868d5a276172b838a3724b27447a6ec2a3b..cb0b1f4cd115d18af37ba4bbd55faf796d02132c 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function directory_init(App $a) {
        $a->set_pager_itemspage(60);
 
index a62eded39d2566887d94ec3db767fd31e2e2df1a..c24ab9dbdb346257e1eed003ffad9f5f96e7a479 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once('include/contact_widgets.php');
 require_once('include/socgraph.php');
 require_once('include/Contact.php');
index c2b5ef17c023e41abebc673a562b36ed4d2cef00..ca6809eba14c6fb9b34c359d2f4db172ce83417f 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function display_init(App $a) {
 
        if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
index f3746317a14ba25e7cf70b9fd2aa8b2c0f925480..c0d903d0c3f8fda06541739af9cd7cc9c6eb41b6 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/acl_selectors.php');
 
 function editpost_content(App $a) {
index 60e7b9f39076bf40c7b361afc05ebe9e987b7d5b..876727608d033937ea542cefcd79570b3188d11b 100644 (file)
@@ -3,6 +3,9 @@
  * @file mod/events.php
  * @brief The events module
  */
+
+use Friendica\App;
+
 require_once 'include/bbcode.php';
 require_once 'include/datetime.php';
 require_once 'include/event.php';
index 9a0e9244c1cbb617511187d7273f58f853e077db..21b9b2e7b416605842ee36378cb24a0d9587247a 100644 (file)
@@ -5,6 +5,8 @@
  * @author             Fabio Comuni <fabrixxm@kirgroup.com>
  */
 
+use Friendica\App;
+
 require_once('include/Photo.php');
 
 /**
index b87fc0e8e025248ada5f1d5bb7fc32dc89153d47..0afd7af1070a9e33ce9d217a7be50b7f289aea38 100644 (file)
@@ -2,6 +2,9 @@
 /*
 This file is part of the Diaspora protocol. It is used for fetching single public posts.
 */
+
+use Friendica\App;
+
 require_once("include/crypto.php");
 require_once("include/diaspora.php");
 require_once("include/xml.php");
index 2f07cb6eee6a7909315cc88155b99a09cc54a209..6259879de2ae9d6d31ad8ac722b9a4747e77ca88 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/security.php');
 require_once('include/bbcode.php');
 require_once('include/items.php');
index 7dd7df2f5ad47fadf6d74702732b757866841903..71e0af08d4543fd77607e9c1836e72ff4a716b06 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function filerm_content(App $a) {
 
        if (! local_user()) {
index 6e1f9069472040cf56b51ad262bbc2f31467235f..c59af73ee7b39c907d5eec8ed92e790f455de1fc 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/Scrape.php');
 require_once('include/follow.php');
 require_once('include/Contact.php');
index f4d7aac105b1d714b2fd90a31ef294f5d38d2c3a..bbfdbfe09688e7c651b1b00f9089b1b6e19566a7 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 function friendica_init(App $a) {
index b3d5439712f5e7e9b9b1410ddee75cc056bf6d1e..32ed63b4c20ae75ed3207ab99df74b541848b500 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 
 function fsuggest_post(App $a) {
 
index 81477c32986b7a14ba570d6cbeb5e1b724d5e027..c01d1cf550c193f77a4f2d981584abdd92fe4f79 100644 (file)
@@ -5,6 +5,7 @@
  *     remove contacts to the contact groups
  */
 
+use Friendica\App;
 
 function group_init(App $a) {
        if (local_user()) {
index 07eb291510653b3d4fd1add4e7b413bba2315dc8..229939a4a347991050c3402c68c65bd54115ffdc 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function hcard_init(App $a) {
 
        $blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
index c380aa39138267de91eca27a5c2919e3d5f36fab..61387753bfc206739e893aadcc3e697a86a12934 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once('library/markdown.php');
 
 if (!function_exists('load_doc_file')) {
index b1708d80a2f02e36fe78b650841581508323a316..bd77a840d0db221cca2c04043c2f2719e95f8814 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 if(! function_exists('home_init')) {
 function home_init(App $a) {
 
index 27dc349db2df12977e428b9cedee672be9e8b281..c9f870a08c1d3235c4c3431cee64d33cfb7f203f 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/crypto.php');
 
 function hostxrd_init(App $a) {
index 9deb071eb3b2c8d04cd6e49e377377e994ba9fdf..1420aae4ef0e118772fa367c2c278036eeb1a5f9 100644 (file)
@@ -8,6 +8,8 @@
  * License: GNU AFFERO GENERAL PUBLIC LICENSE (Version 3)
  */
 
+use Friendica\App;
+
 require_once("include/socgraph.php");
 require_once("include/Contact.php");
 
index 0065d51c58e3b8386b53ac93ea095d1ceca5b76d..a7c3ba6e1d37fdf3bb30263019b70274739bd8a1 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 
 function ignored_init(App $a) {
 
index 0b96e85512cd18dcf8f6cdb7dc6d39258ff6a1b6..aa891dba752b390c495702afa61bb8b93d2d33b8 100755 (executable)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once "include/Photo.php";
 
 $install_wizard_pass = 1;
index f5c60e1ed393713c30e87c7f526492f135cb3ddd..67cd23de745ea34979ac245c17b79edbc2c26c2a 100644 (file)
@@ -7,6 +7,8 @@
  *
  */
 
+use Friendica\App;
+
 require_once('include/email.php');
 
 function invite_post(App $a) {
index d8be579ff95df947234483e6e5c910ddf5d6bae7..4744ec4ad50e380b2d3f5883f4f8676bfa94acf2 100644 (file)
@@ -15,6 +15,8 @@
  * posting categories go through item_store() instead of this function.
  */
 
+use Friendica\App;
+
 require_once 'include/crypto.php';
 require_once 'include/enotify.php';
 require_once 'include/email.php';
index 1f6a233f3dc26599f8a37152ea71f0fef276952b..c542a540abce6a3ae174d844c8c9f67b4768d082 100755 (executable)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/security.php');
 require_once('include/bbcode.php');
 require_once('include/items.php');
index 535308903153af6d3cf81ef4d310ccc8705034db..c32f67976bd4ff37a0003663be40ed74fcfe658f 100644 (file)
@@ -1,7 +1,8 @@
 <?php
 
-require_once('include/datetime.php');
+use Friendica\App;
 
+require_once('include/datetime.php');
 
 function localtime_post(App $a) {
 
index 38a308634e772467381468fe322dd76840cd980a..48227cc1eaf47aa0d973e71a621f34e134f71ebf 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 
 function lockview_content(App $a) {
 
index 1d943b67a58ca5221b0a58e30509b9b7ffd7c752..79bd04862effc17f0b6091e8028c549681fa2889 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function login_content(App $a) {
        if (x($_SESSION, 'theme')) {
                unset($_SESSION['theme']);
index 455a9b1e2eed697580cd17fb8e4dcfe2b53da43d..37ef3e2f82f6a461bc78d7a38381309a35d67486 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/email.php');
 require_once('include/enotify.php');
 require_once('include/text.php');
index b1fb2a53e1d7ce3c89e41e93560f2a7e610a0f2b..2258fc5ce29337029df97a8fe60389d0659cc5f0 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 function maintenance_content(App $a) {
index e85561acfb350fc3d64f462efe8d4d929ae50556..a6ab32c2d8428c713398dc61b6f816d504826b57 100644 (file)
@@ -1,7 +1,8 @@
 <?php
 
-require_once("include/text.php");
+use Friendica\App;
 
+require_once("include/text.php");
 
 function manage_post(App $a) {
 
index 4787862c4f1441741acff859779535b9e0f44088..d38dcb8d922026143e32996e04d5552d04c06b2f 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 function manifest_content(App $a) {
index 77fcbaa72c1d4b2d4a1416853f4c87e1896f59ff..4119bf8e84315c8b8cbeed8b0dd0c337edf36820 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once('include/text.php');
 require_once('include/socgraph.php');
 require_once('include/contact_widgets.php');
index beaa7b1df666af66b426d01f821f0b790f7765d8..c32d5f1dd928c057bfa2b66378f309f4eedd6fc0 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/acl_selectors.php');
 require_once('include/message.php');
 require_once('include/Smilies.php');
index 4cc9522479c182767b60a013ade77205863f0287..3c5d1e35818bfc11658e20cf289d18324bd25d6d 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('library/asn1.php');
 
 function modexp_init(App $a) {
index 967c3e2ce8864323cd8a74af8091dc246857e2e2..c693e7cdc980872949842a11634544ee60ee143b 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/security.php');
 require_once('include/bbcode.php');
 require_once('include/items.php');
index 277242afff803f19eecc1241600f849b75ccafdf..460b9c303919074332576f861e48b770370368a2 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function msearch_post(App $a) {
 
        $perpage = (($_POST['n']) ? $_POST['n'] : 80);
index be1b522e9cba1b20d851f1a0ceb03254230c9729..31b20e8913769bb56671ae58a1af37e606ec6475 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once("include/nav.php");
 
 function navigation_content(App $a) {
index db4bb91309d84b874850432c7461104c74ba62b6..5c840da063c8f0cbe125c3e8c4a78019a8abd41a 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 function network_init(App $a) {
        if (! local_user()) {
                notice( t('Permission denied.') . EOL);
index 5224b986704470f322495c9479033690523c089f..f470327cded444638b9d1eb092f82bde91bcf82e 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 
 function newmember_content(App $a) {
 
index 384f4e8dd6ec7e0c847face37d7c926eb0bbfdc1..fb3fc6ae24a63c2ca1696c7b89210100ec4fa6e2 100644 (file)
@@ -5,6 +5,7 @@
  * Documentation: http://nodeinfo.diaspora.software/schema.html
 */
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once 'include/plugin.php';
index 11b7bdc7aa486c0e512dee4782c159a97090fc24..ecbfb9176e1397be548ec5ddb3be1bf8620194fd 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/Contact.php');
 require_once('include/socgraph.php');
 require_once('include/contact_selectors.php');
index 83ab71ce15884f90cb423172f638eab0e6dba000..a269d7369af90b21ff7f518528afb75caf898e43 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function noscrape_init(App $a) {
 
        if($a->argc > 1)
index c7cfe8d70f1a2d3e13f98249785b6fcf9073a7b1..835627586cada10d58b75113a1783e4a852f4386 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function notes_init(App $a) {
 
        if (! local_user()) {
index 03f0e24037e6e75fb83ce09eec453722afbc5ee5..1114b9a5a452ed4eec5a5a70048c4ab8755623c3 100644 (file)
@@ -2,6 +2,7 @@
 
 /* identi.ca -> friendica items permanent-url compatibility */
 
+use Friendica\App;
 
 function notice_init(App $a) {
 
index fdaec05ccd2449a5916b593906da4bebf754f2bc..396361e91b5bda012716767d3c2f677a8d2c6e29 100644 (file)
@@ -5,6 +5,8 @@
  * @brief The notifications module
  */
 
+use Friendica\App;
+
 require_once("include/NotificationsManager.php");
 require_once("include/contact_selectors.php");
 require_once("include/network.php");
index 0026f5ca6eb6f66556c35326966604e81d6f9899..e3806819342b12dcf67c8cd6c73ea7f2d48b9c5b 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once('include/NotificationsManager.php');
 
 function notify_init(App $a) {
index 7770c62fb0300356dd26476090638e32d88c16c2..3266ad963e110a0956a69a36844252e13f2f0397 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once("include/oembed.php");
 
 function oembed_content(App $a) {
index 4f2d7e0eb8449e97a0c48f8e1332367b05f46d97..930caac7e459f2e2a19aa92d46d4fe2266780c7d 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 function oexchange_init(App $a) {
 
        if (($a->argc > 1) && ($a->argv[1] === 'xrd')) {
index ac90806d0c211dae8aa4796b5b4c4c3c13376d3f..5707b1b72891cc7e28874869aeabc48110a15a8f 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 
 require_once('library/openid.php');
 
index 325d5f59bc249e2027d5f96141e9a8dd27cc6fa6..dc7adeb05c264eb98e627c5745bf64725d4b76e3 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 
 function opensearch_content(App $a) {
 
index a9f7c3a909111ed329904b990807db31b1355bda..a36821aa2ef7569a8c5c82fc4b6058b9aaf481c6 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/Scrape.php');
 require_once('include/follow.php');
 
index 3cd7a9eb7d4676b7c631014e581d50a9eab17943..f66dd43a23e41a0c74e35a79b8ba3baec3fb90dc 100644 (file)
--- a/mod/p.php
+++ b/mod/p.php
@@ -2,6 +2,9 @@
 /*
 This file is part of the Diaspora protocol. It is used for fetching single public posts.
 */
+
+use Friendica\App;
+
 require_once("include/diaspora.php");
 
 function p_init($a){
index b2908455b7913eea7d20e999b0c4d539257d30dc..4fe9256349fe9a863509984d77995fd13c7e7945 100644 (file)
@@ -10,6 +10,7 @@
  * @see ParseUrl::getSiteinfo() for more information about scraping embeddable content
 */
 
+use Friendica\App;
 use Friendica\ParseUrl;
 
 require_once("include/items.php");
index 6562599ca3cf0ccc5b19e997b2734fcbdd408e0d..7506834cf502b27513371e42ec4dc6831adbd8de 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/security.php');
 require_once('include/Photo.php');
 
index 67a8735a59e9e4035c74300f77e804740030cf89..8d6d54ac88c2991c832d0c61ab36ad8579be59d8 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once 'include/Photo.php';
index fa3c8ebcd9e3de66eb0dabf8160e742ceaed788a..17180c74ee98dc0bdcdbe454ec4eeb7af2befd91 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once('include/datetime.php');
 require_once('include/bbcode.php');
 require_once('include/ForumManager.php');
index 30648acab67c05159721ab1d4279b9181428d6e0..7dcf3b4a02e3794a2d2dbbb17a76aa72a751f60a 100644 (file)
@@ -2,6 +2,8 @@
 // See here for a documentation for portable contacts:
 // https://web.archive.org/web/20160405005550/http://portablecontacts.net/draft-spec.html
 
+use Friendica\App;
+
 function poco_init(App $a) {
        require_once("include/bbcode.php");
 
index 82cf4b6d2c21667d9d1e85fe21186d8d212ad714..83f3bf1c735894fcfd37b058f45975387ad55e09 100644 (file)
  *
  * private creates a private conversation with the recipient. Otherwise your profile's default post privacy is used.
  *
- */
  * @file mod/poke.php
+ */
+
+use Friendica\App;
+
 require_once('include/security.php');
 require_once('include/bbcode.php');
 require_once('include/items.php');
 
-
 function poke_init(App $a) {
 
        if (! local_user()) {
index c8a88e66cd329c5bd853084f638a33a52e29e1fb..bfdc62ab7942706b84485281c98aaef8986a3eb7 100644 (file)
@@ -4,6 +4,7 @@
  * Zot endpoint
  */
 
+use Friendica\App;
 
 require_once('include/salmon.php');
 require_once('include/crypto.php');
index 9c52625f63700a2703060c3d43971a0da7e5eb6b..e5bebc4eb7e24e0d230669ca4adedf554790d7fd 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function pretheme_init(App $a) {
 
        if ($_REQUEST['theme']) {
index 73630ded7db41b852fb479a83296c4ef98f0a53b..2911bc05c7fbbdecbd26517f2f39f2062ca759fc 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/Scrape.php');
 
 function probe_content(App $a) {
index 05f18c362790d10df97df604b75a551e4e5bf615..7a11e9bc6b1fe80a261b5328ac77400afecf8bc8 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/contact_widgets.php');
 require_once('include/redir.php');
 
index 8b3d3d371e24ea1d0907cb0addfca14da7e3fb43..b2bf6e3b157899a17d1c948d9be0c5b71f3a6e5e 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once("include/Photo.php");
 
 function profile_photo_init(App $a) {
index bd57f106d72c451409324c920ba05c9df0e1a9d0..42699e5e0c7aab57f376bdb3c39489d09151ebbd 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once("include/Contact.php");
 require_once('include/Probe.php');
 
index a414d8947bf35369a819b9966239585468889b59..c67a0202e057921882477fbf9d55fcec0d726c60 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function profperm_init(App $a) {
 
        if (! local_user()) {
index 8046e4e9639eabc0fd9331d13792543a60908134..9311e55a96c02e4e6be68b50b323bef4906ba5d3 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 // Based upon "Privacy Image Cache" by Tobias Hößl <https://github.com/CatoTH/>
 
+use Friendica\App;
+
 define('PROXY_DEFAULT_TIME', 86400); // 1 Day
 
 define('PROXY_SIZE_MICRO', 'micro');
index 2ba1958a25050cbce35e075d04d6081aa5d71907..ba5e05b0eec4fd9c8dfb499a86cfbd6b100393bd 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function hub_return($valid,$body) {
 
        if($valid) {
index dceb16ae1f260cf9415e9e7378e54582a35ee182..c6f961e6b6966cc6feffe2921ad56c47561ea4c4 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function post_var($name) {
        return (x($_POST, $name)) ? notags(trim($_POST[$name])) : '';
 }
index 76ff2a15e045f061bedbe06448b1f24a89b10754..ba62fce0d7bddc829c884e117f862ef1bb85dcc1 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function qsearch_init(App $a) {
 
        if (! local_user()) {
index d8cffb380ccd46de6552fb72b12cd576b45de058..8d9083ada484019506231cdeaf7c5db6c789a5ca 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 
 function randprof_init(App $a) {
        require_once('include/Contact.php');
index 547e08967238882fba0f8a02d5a88e85e5217a02..abc91ce37e15ee96d296b05d77cb9ede6506812e 100644 (file)
@@ -4,6 +4,7 @@
  * Diaspora endpoint
  */
 
+use Friendica\App;
 
 require_once('include/salmon.php');
 require_once('include/crypto.php');
index 12f53900a7528c8826788aad408b384c23f4d176..366c398867682def7fe2dd0a3694eee81eedd539 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function redir_init(App $a) {
 
        $url = ((x($_GET,'url')) ? $_GET['url'] : '');
index 5e8da4685a0f61d342d180fe68b4d45c0bbfa193..71c13ef396815909c2335eab191f668333397c90 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/enotify.php');
 require_once('include/bbcode.php');
 require_once('include/user.php');
index 1983ca0899ddbf0608b43bcccb601046c355d44b..884790458127285eba43016e92f0e31abb3968e3 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/enotify.php');
 require_once('include/user.php');
 
index 40033624d8889ac330a8be2c7f725febef8e2cfc..639c9be9f457bafcf704ecaa0e23252e5a377bad 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function removeme_post(App $a) {
 
        if (! local_user()) {
index 3e9130e0e8e42a233b5bd5090a383adc3ff599ff..a690680d1f520ea2d416f40f2c606725fa829855 100755 (executable)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/Scrape.php');
 require_once('include/follow.php');
 
index b839d6a03c1bda69c2b76018e70e3d88b9635e6e..8327329bf56f2cce9f46a22c52303817db77d602 100644 (file)
@@ -6,6 +6,7 @@
  * @version 0.1.2
  */
 
+use Friendica\App;
 
 /**
  * @brief Return default robots.txt when init
index 24533d10bc440469561b59c17cc490367359fc3e..1417e9646a2825bafc274be396716a5ed8c0d29a 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 
 function rsd_xml_content(App $a)
 {
index 10b1046b02d1924e9b65d956bcb7191e8e4934d0..f42e05deaa76f207848c1e214ad5854fd78c54a6 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/salmon.php');
 require_once('include/ostatus.php');
 require_once('include/crypto.php');
index a804ca32e0b2e80603a1c5a01ab08c050ae9806a..fd1212ceec2854ae88273e9fc1c5d7f8c7f9bd9b 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once("include/bbcode.php");
 require_once('include/security.php');
 require_once('include/conversation.php');
index a73bcc78fabce3938c021534d5c20c8e52f03873..783d6f306c8593ac7c30d4356ab043d4b335dceb 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function session_content(App $a) {
 
 }
index 1d83251d4b327054c61e481aca3a86ad5361555e..ff05724fed74b2048a9391bac3358be08b956688 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/group.php');
 require_once('include/socgraph.php');
 
index 36a4d5945fcb4cc7b7bb07d8e862324104fa083b..7ddca0f30be8256df542c7c909d500caf51e9f6e 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 function share_init(App $a) {
 
        $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
index f69541824ab63b21111b8c843b9a01212d04897d..289ad887f96bf5e5bfa87e92cbfdf0ded9e86264 100644 (file)
@@ -3,6 +3,7 @@
 /**
  * @file mod/smilies.php
  */
+use Friendica\App;
 
 require_once("include/Smilies.php");
 
index 46d3fcff66835644c0b802bfb98db8a8d3a06edf..e1b38cfc4c9133edf547eeb59303ec81f2b24aec 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 
 function starred_init(App $a) {
 
index 5cb6fb99e99f5e0b7bd1a87ecd9d2d6f44b4c6da..3b9e9c49667e8b396d416b47e6b1dfd6ea705b2e 100644 (file)
@@ -4,6 +4,8 @@
  * @file mod/statistics_json.php
  */
 
+use Friendica\App;
+
 require_once("include/plugin.php");
 
 function statistics_json_init(App $a) {
index 9d5533a03dcb0754b79c93f40144d9cb2fb7eb95..0745fc0eef4948a204f61581aedc7994a0e045c5 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/security.php');
 require_once('include/bbcode.php');
 require_once('include/items.php');
index dd24fc0a2a3a01a120557f7bf659d638c30440cf..a82dca7945d87614da9f90f4fceccb57d38390a6 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/socgraph.php');
 require_once('include/contact_widgets.php');
 
index 8a6973e6ade9fc7c34a3aaa0c5d949a5af4f6ce5..e6619f9fe2d37a148724da85467a21fcca81176f 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/security.php');
 require_once('include/bbcode.php');
 require_once('include/items.php');
index 2e7f8b97082436e8061998997f0150d666147fcb..ea1ab7909dd851102a1215235f10bb48321bb0eb 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/bbcode.php');
 
 function tagrm_post(App $a) {
index 51fdcf41a0346e78f2fe54da98f21829a74b6e14..12a61152733033bb66de307e19e4748592d6a991 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function toggle_mobile_init(App $a) {
 
        if (isset($_GET['off'])) {
index 554c02225b3814f3780d0fd06cd02590490b8c49..d7c8934a5c9874ca55887019adb0469054059b0e 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function uexport_init(App $a) {
        if (!local_user()) {
                killme();
index fd44df4fbc6024df840e079077bda061a77e365c..127933b96e507efe6f8f2801cc0c6ee48f0c9fc5 100644 (file)
@@ -4,6 +4,8 @@
  * View for user import\r
  */\r
 \r
+use Friendica\App;\r
+\r
 require_once("include/uimport.php");\r
 \r
 function uimport_post(App $a) {\r
index 9a39489dcfb822a39143b235b506a0d8c3905fec..f0e96af48c1a519167eeb27c5e8ea7dd683cc18e 100644 (file)
@@ -2,6 +2,8 @@
 
 // See update_profile.php for documentation
 
+use Friendica\App;
+
 require_once("mod/community.php");
 
 function update_community_content(App $a) {
index 86f4db8259f83c4db9fdd580666c91da42060c16..b8538a256bc99ab17eaee30d38c91660d0024358 100644 (file)
@@ -2,6 +2,8 @@
 
 // See update_profile.php for documentation
 
+use Friendica\App;
+
 require_once("mod/display.php");
 require_once("include/group.php");
 
index 869973ace4f07af1b8c2750103849a36f6f85f5d..42172486d83634c2b6e1af4227531fc4dcd1be94 100644 (file)
@@ -2,6 +2,8 @@
 
 // See update_profile.php for documentation
 
+use Friendica\App;
+
 require_once("mod/network.php");
 require_once("include/group.php");
 
index d27cc4ca9672bfcfe1007b2289bfd9bcb14dc71c..9fc886155159b318355ed8e780fbf4a613d080a8 100644 (file)
@@ -5,6 +5,8 @@
  * Purpose: AJAX synchronisation of notes page
  */
 
+use Friendica\App;
+
 require_once("mod/notes.php");
 
 function update_notes_content(App $a) {
index b77a9cdcfc5e4d40755c38bb22172364f9cdb7fb..5b15f06d30360f9f5211abd1a5be0b89e218870a 100644 (file)
@@ -5,6 +5,8 @@
  * Purpose: AJAX synchronisation of profile page
  */
 
+use Friendica\App;
+
 require_once("mod/profile.php");
 
 function update_profile_content(App $a) {
index e8f8356fbd814c6e472fbc94967c6cd6fa617ebb..2ee73c211d438c1787432bebb2069e1f7fe312b2 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once('include/items.php');
 require_once('include/acl_selectors.php');
 require_once('include/bbcode.php');
index 5912f6cc773f8d398135dcc6072e983e22cffb52..f7bf912fdffea333da38b0ed67236dc98b74962a 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once('include/Contact.php');
 require_once('include/contact_selectors.php');
 
index a3f0affb531971cfc1eb63e06fd02d073ce34b74..09158959065afb264d5fff39b936a78688fabd29 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 
 function viewsrc_content(App $a) {
 
index 0fc8b8a6a3aae79a60dc1bf70459de1bde6bed01..8bf1fdbf19d6293b0bada256d2bc4362fc4debae 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/attach.php');
 require_once('include/datetime.php');
 
index 1707040e6c91dfac04c9ad7b5c69551e3b416204..a35e86a5297a098d75aa9d2a89e861e4bcc9470c 100644 (file)
@@ -9,6 +9,7 @@
  * to the url
  */
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once 'include/Photo.php';
index ff90e0dbcf510b6ec6c97eaf762578fb19f97f64..72897c0657f77adc057bc738085d91d1bf9e79d2 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/message.php');
 
 function wallmessage_post(App $a) {
index d823bd2dc217b988c8f5d41839ee22f77bfde8a8..a831fc12cd44937fe07824ec7161bead7a0148f3 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once("include/Probe.php");
 
 function webfinger_content(App $a) {
index 7b812a7f9d94610d804515ba2e454cdf855762b0..c51f41946c59237a493fc60682c0e717e5bf60e3 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 require_once('include/crypto.php');
 
 function xrd_init(App $a) {
diff --git a/src/App.php b/src/App.php
new file mode 100644 (file)
index 0000000..41ee5d3
--- /dev/null
@@ -0,0 +1,961 @@
+<?php\r
+\r
+namespace Friendica;\r
+\r
+use Friendica\Core\Config;\r
+use Friendica\Core\PConfig;\r
+\r
+/**\r
+ *\r
+ * class: App\r
+ *\r
+ * @brief Our main application structure for the life of this page.\r
+ *\r
+ * Primarily deals with the URL that got us here\r
+ * and tries to make some sense of it, and\r
+ * stores our page contents and config storage\r
+ * and anything else that might need to be passed around\r
+ * before we spit the page out.\r
+ *\r
+ */\r
+class App {\r
+\r
+       public $module_loaded = false;\r
+       public $query_string;\r
+       public $config;\r
+       public $page;\r
+       public $profile;\r
+       public $profile_uid;\r
+       public $user;\r
+       public $cid;\r
+       public $contact;\r
+       public $contacts;\r
+       public $page_contact;\r
+       public $content;\r
+       public $data = array();\r
+       public $error = false;\r
+       public $cmd;\r
+       public $argv;\r
+       public $argc;\r
+       public $module;\r
+       public $pager;\r
+       public $strings;\r
+       public $path;\r
+       public $hooks;\r
+       public $timezone;\r
+       public $interactive = true;\r
+       public $plugins;\r
+       public $apps = array();\r
+       public $identities;\r
+       public $is_mobile = false;\r
+       public $is_tablet = false;\r
+       public $is_friendica_app;\r
+       public $performance = array();\r
+       public $callstack = array();\r
+       public $theme_info = array();\r
+       public $backend = true;\r
+       public $nav_sel;\r
+       public $category;\r
+       // Allow themes to control internal parameters\r
+       // by changing App values in theme.php\r
+\r
+       public $sourcename = '';\r
+       public $videowidth = 425;\r
+       public $videoheight = 350;\r
+       public $force_max_items = 0;\r
+       public $theme_thread_allow = true;\r
+       public $theme_events_in_profile = true;\r
+\r
+       /**\r
+        * @brief An array for all theme-controllable parameters\r
+        *\r
+        * Mostly unimplemented yet. Only options 'template_engine' and\r
+        * beyond are used.\r
+        */\r
+       public $theme = array(\r
+               'sourcename' => '',\r
+               'videowidth' => 425,\r
+               'videoheight' => 350,\r
+               'force_max_items' => 0,\r
+               'thread_allow' => true,\r
+               'stylesheet' => '',\r
+               'template_engine' => 'smarty3',\r
+       );\r
+\r
+       /**\r
+        * @brief An array of registered template engines ('name'=>'class name')\r
+        */\r
+       public $template_engines = array();\r
+\r
+       /**\r
+        * @brief An array of instanced template engines ('name'=>'instance')\r
+        */\r
+       public $template_engine_instance = array();\r
+       public $process_id;\r
+       private $ldelim = array(\r
+               'internal' => '',\r
+               'smarty3' => '{{'\r
+       );\r
+       private $rdelim = array(\r
+               'internal' => '',\r
+               'smarty3' => '}}'\r
+       );\r
+       private $scheme;\r
+       private $hostname;\r
+       private $db;\r
+       private $curl_code;\r
+       private $curl_content_type;\r
+       private $curl_headers;\r
+       private $cached_profile_image;\r
+       private $cached_profile_picdate;\r
+       private static $a;\r
+\r
+       /**\r
+        * @brief App constructor.\r
+        */\r
+       function __construct() {\r
+\r
+               global $default_timezone;\r
+\r
+               $hostname = '';\r
+\r
+               if (file_exists('.htpreconfig.php')) {\r
+                       include '.htpreconfig.php';\r
+               }\r
+\r
+               $this->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC');\r
+\r
+               date_default_timezone_set($this->timezone);\r
+\r
+               $this->performance['start'] = microtime(true);\r
+               $this->performance['database'] = 0;\r
+               $this->performance['database_write'] = 0;\r
+               $this->performance['network'] = 0;\r
+               $this->performance['file'] = 0;\r
+               $this->performance['rendering'] = 0;\r
+               $this->performance['parser'] = 0;\r
+               $this->performance['marktime'] = 0;\r
+               $this->performance['markstart'] = microtime(true);\r
+\r
+               $this->callstack['database'] = array();\r
+               $this->callstack['database_write'] = array();\r
+               $this->callstack['network'] = array();\r
+               $this->callstack['file'] = array();\r
+               $this->callstack['rendering'] = array();\r
+               $this->callstack['parser'] = array();\r
+\r
+               $this->config = array();\r
+               $this->page = array();\r
+               $this->pager = array();\r
+\r
+               $this->query_string = '';\r
+\r
+               $this->process_id = uniqid('log', true);\r
+\r
+               startup();\r
+\r
+               set_include_path(\r
+                       get_include_path() . PATH_SEPARATOR\r
+                       . 'include' . PATH_SEPARATOR\r
+                       . 'library' . PATH_SEPARATOR\r
+                       . 'library/langdet' . PATH_SEPARATOR\r
+                       . '.');\r
+\r
+               $this->scheme = 'http';\r
+\r
+               if ((x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) ||\r
+                       (x($_SERVER, 'HTTP_FORWARDED') && preg_match('/proto=https/', $_SERVER['HTTP_FORWARDED'])) ||\r
+                       (x($_SERVER, 'HTTP_X_FORWARDED_PROTO') && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||\r
+                       (x($_SERVER, 'HTTP_X_FORWARDED_SSL') && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') ||\r
+                       (x($_SERVER, 'FRONT_END_HTTPS') && $_SERVER['FRONT_END_HTTPS'] == 'on') ||\r
+                       (x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much?\r
+               ) {\r
+                       $this->scheme = 'https';\r
+               }\r
+\r
+               if (x($_SERVER, 'SERVER_NAME')) {\r
+                       $this->hostname = $_SERVER['SERVER_NAME'];\r
+\r
+                       if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {\r
+                               $this->hostname .= ':' . $_SERVER['SERVER_PORT'];\r
+                       }\r
+                       /*\r
+                        * Figure out if we are running at the top of a domain\r
+                        * or in a sub-directory and adjust accordingly\r
+                        */\r
+\r
+                       /// @TODO This kind of escaping breaks syntax-highlightning on CoolEdit (Midnight Commander)\r
+                       $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');\r
+                       if (isset($path) && strlen($path) && ($path != $this->path)) {\r
+                               $this->path = $path;\r
+                       }\r
+               }\r
+\r
+               if ($hostname != '') {\r
+                       $this->hostname = $hostname;\r
+               }\r
+\r
+               if (is_array($_SERVER['argv']) && $_SERVER['argc'] > 1 && substr(end($_SERVER['argv']), 0, 4) == 'http') {\r
+                       $this->set_baseurl(array_pop($_SERVER['argv']));\r
+                       $_SERVER['argc'] --;\r
+               }\r
+\r
+               if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 9) === 'pagename=') {\r
+                       $this->query_string = substr($_SERVER['QUERY_STRING'], 9);\r
+\r
+                       // removing trailing / - maybe a nginx problem\r
+                       $this->query_string = ltrim($this->query_string, '/');\r
+               } elseif ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === 'q=') {\r
+                       $this->query_string = substr($_SERVER['QUERY_STRING'], 2);\r
+\r
+                       // removing trailing / - maybe a nginx problem\r
+                       $this->query_string = ltrim($this->query_string, '/');\r
+               }\r
+\r
+               if (x($_GET, 'pagename')) {\r
+                       $this->cmd = trim($_GET['pagename'], '/\\');\r
+               } elseif (x($_GET, 'q')) {\r
+                       $this->cmd = trim($_GET['q'], '/\\');\r
+               }\r
+\r
+               // fix query_string\r
+               $this->query_string = str_replace($this->cmd . '&', $this->cmd . '?', $this->query_string);\r
+\r
+               // unix style "homedir"\r
+               if (substr($this->cmd, 0, 1) === '~') {\r
+                       $this->cmd = 'profile/' . substr($this->cmd, 1);\r
+               }\r
+\r
+               // Diaspora style profile url\r
+               if (substr($this->cmd, 0, 2) === 'u/') {\r
+                       $this->cmd = 'profile/' . substr($this->cmd, 2);\r
+               }\r
+\r
+               /*\r
+                * Break the URL path into C style argc/argv style arguments for our\r
+                * modules. Given "http://example.com/module/arg1/arg2", $this->argc\r
+                * will be 3 (integer) and $this->argv will contain:\r
+                *   [0] => 'module'\r
+                *   [1] => 'arg1'\r
+                *   [2] => 'arg2'\r
+                *\r
+                *\r
+                * There will always be one argument. If provided a naked domain\r
+                * URL, $this->argv[0] is set to "home".\r
+                */\r
+\r
+               $this->argv = explode('/', $this->cmd);\r
+               $this->argc = count($this->argv);\r
+               if ((array_key_exists('0', $this->argv)) && strlen($this->argv[0])) {\r
+                       $this->module = str_replace('.', '_', $this->argv[0]);\r
+                       $this->module = str_replace('-', '_', $this->module);\r
+               } else {\r
+                       $this->argc = 1;\r
+                       $this->argv = array('home');\r
+                       $this->module = 'home';\r
+               }\r
+\r
+               // See if there is any page number information, and initialise pagination\r
+               $this->pager['page'] = ((x($_GET, 'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);\r
+               $this->pager['itemspage'] = 50;\r
+               $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];\r
+\r
+               if ($this->pager['start'] < 0) {\r
+                       $this->pager['start'] = 0;\r
+               }\r
+               $this->pager['total'] = 0;\r
+\r
+               // Detect mobile devices\r
+               $mobile_detect = new \Mobile_Detect();\r
+               $this->is_mobile = $mobile_detect->isMobile();\r
+               $this->is_tablet = $mobile_detect->isTablet();\r
+\r
+               // Friendica-Client\r
+               $this->is_friendica_app = ($_SERVER['HTTP_USER_AGENT'] == 'Apache-HttpClient/UNAVAILABLE (java 1.4)');\r
+\r
+               // Register template engines\r
+               $dc = get_declared_classes();\r
+               foreach ($dc as $k) {\r
+                       if (in_array('ITemplateEngine', class_implements($k))) {\r
+                               $this->register_template_engine($k);\r
+                       }\r
+               }\r
+\r
+               self::$a = $this;\r
+       }\r
+\r
+       public static function get_basepath() {\r
+               $basepath = get_config('system', 'basepath');\r
+\r
+               if ($basepath == '') {\r
+                       $basepath = dirname(__FILE__);\r
+               }\r
+\r
+               if ($basepath == '') {\r
+                       $basepath = $_SERVER['DOCUMENT_ROOT'];\r
+               }\r
+\r
+               if ($basepath == '') {\r
+                       $basepath = $_SERVER['PWD'];\r
+               }\r
+\r
+               return $basepath;\r
+       }\r
+\r
+       function get_scheme() {\r
+               return $this->scheme;\r
+       }\r
+\r
+       /**\r
+        * @brief Retrieves the Friendica instance base URL\r
+        *\r
+        * This function assembles the base URL from multiple parts:\r
+        * - Protocol is determined either by the request or a combination of\r
+        * system.ssl_policy and the $ssl parameter.\r
+        * - Host name is determined either by system.hostname or inferred from request\r
+        * - Path is inferred from SCRIPT_NAME\r
+        *\r
+        * Note: $ssl parameter value doesn't directly correlate with the resulting protocol\r
+        *\r
+        * @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN\r
+        * @return string Friendica server base URL\r
+        */\r
+       function get_baseurl($ssl = false) {\r
+               // Is the function called statically?\r
+               if (!(isset($this) && get_class($this) == __CLASS__)) {\r
+                       return self::$a->get_baseurl($ssl);\r
+               }\r
+\r
+               $scheme = $this->scheme;\r
+\r
+               if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) {\r
+                       $scheme = 'https';\r
+               }\r
+\r
+               //      Basically, we have $ssl = true on any links which can only be seen by a logged in user\r
+               //      (and also the login link). Anything seen by an outsider will have it turned off.\r
+\r
+               if (Config::get('system', 'ssl_policy') == SSL_POLICY_SELFSIGN) {\r
+                       if ($ssl) {\r
+                               $scheme = 'https';\r
+                       } else {\r
+                               $scheme = 'http';\r
+                       }\r
+               }\r
+\r
+               if (Config::get('config', 'hostname') != '') {\r
+                       $this->hostname = Config::get('config', 'hostname');\r
+               }\r
+\r
+               return $scheme . '://' . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );\r
+       }\r
+\r
+       /**\r
+        * @brief Initializes the baseurl components\r
+        *\r
+        * Clears the baseurl cache to prevent inconstistencies\r
+        *\r
+        * @param string $url\r
+        */\r
+       function set_baseurl($url) {\r
+               $parsed = @parse_url($url);\r
+\r
+               if ($parsed) {\r
+                       $this->scheme = $parsed['scheme'];\r
+\r
+                       $hostname = $parsed['host'];\r
+                       if (x($parsed, 'port')) {\r
+                               $hostname .= ':' . $parsed['port'];\r
+                       }\r
+                       if (x($parsed, 'path')) {\r
+                               $this->path = trim($parsed['path'], '\\/');\r
+                       }\r
+\r
+                       if (file_exists('.htpreconfig.php')) {\r
+                               include '.htpreconfig.php';\r
+                       }\r
+\r
+                       if (get_config('config', 'hostname') != '') {\r
+                               $this->hostname = get_config('config', 'hostname');\r
+                       }\r
+\r
+                       if (!isset($this->hostname) OR ( $this->hostname == '')) {\r
+                               $this->hostname = $hostname;\r
+                       }\r
+               }\r
+       }\r
+\r
+       function get_hostname() {\r
+               if (get_config('config', 'hostname') != '') {\r
+                       $this->hostname = get_config('config', 'hostname');\r
+               }\r
+\r
+               return $this->hostname;\r
+       }\r
+\r
+       function set_hostname($h) {\r
+               $this->hostname = $h;\r
+       }\r
+\r
+       function set_path($p) {\r
+               $this->path = trim(trim($p), '/');\r
+       }\r
+\r
+       function get_path() {\r
+               return $this->path;\r
+       }\r
+\r
+       function set_pager_total($n) {\r
+               $this->pager['total'] = intval($n);\r
+       }\r
+\r
+       function set_pager_itemspage($n) {\r
+               $this->pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0);\r
+               $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];\r
+       }\r
+\r
+       function set_pager_page($n) {\r
+               $this->pager['page'] = $n;\r
+               $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];\r
+       }\r
+\r
+       function init_pagehead() {\r
+               $interval = ((local_user()) ? get_pconfig(local_user(), 'system', 'update_interval') : 40000);\r
+\r
+               // If the update is 'deactivated' set it to the highest integer number (~24 days)\r
+               if ($interval < 0) {\r
+                       $interval = 2147483647;\r
+               }\r
+\r
+               if ($interval < 10000) {\r
+                       $interval = 40000;\r
+               }\r
+\r
+               // compose the page title from the sitename and the\r
+               // current module called\r
+               if (!$this->module == '') {\r
+                       $this->page['title'] = $this->config['sitename'] . ' (' . $this->module . ')';\r
+               } else {\r
+                       $this->page['title'] = $this->config['sitename'];\r
+               }\r
+\r
+               /* put the head template at the beginning of page['htmlhead']\r
+                * since the code added by the modules frequently depends on it\r
+                * being first\r
+                */\r
+               if (!isset($this->page['htmlhead'])) {\r
+                       $this->page['htmlhead'] = '';\r
+               }\r
+\r
+               // If we're using Smarty, then doing replace_macros() will replace\r
+               // any unrecognized variables with a blank string. Since we delay\r
+               // replacing $stylesheet until later, we need to replace it now\r
+               // with another variable name\r
+               if ($this->theme['template_engine'] === 'smarty3') {\r
+                       $stylesheet = $this->get_template_ldelim('smarty3') . '$stylesheet' . $this->get_template_rdelim('smarty3');\r
+               } else {\r
+                       $stylesheet = '$stylesheet';\r
+               }\r
+\r
+               $shortcut_icon = get_config('system', 'shortcut_icon');\r
+               if ($shortcut_icon == '') {\r
+                       $shortcut_icon = 'images/friendica-32.png';\r
+               }\r
+\r
+               $touch_icon = get_config('system', 'touch_icon');\r
+               if ($touch_icon == '') {\r
+                       $touch_icon = 'images/friendica-128.png';\r
+               }\r
+\r
+               // get data wich is needed for infinite scroll on the network page\r
+               $invinite_scroll = infinite_scroll_data($this->module);\r
+\r
+               $tpl = get_markup_template('head.tpl');\r
+               $this->page['htmlhead'] = replace_macros($tpl, array(\r
+                               '$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!!\r
+                               '$local_user' => local_user(),\r
+                               '$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,\r
+                               '$delitem' => t('Delete this item?'),\r
+                               '$showmore' => t('show more'),\r
+                               '$showfewer' => t('show fewer'),\r
+                               '$update_interval' => $interval,\r
+                               '$shortcut_icon' => $shortcut_icon,\r
+                               '$touch_icon' => $touch_icon,\r
+                               '$stylesheet' => $stylesheet,\r
+                               '$infinite_scroll' => $invinite_scroll,\r
+                       )) . $this->page['htmlhead'];\r
+       }\r
+\r
+       function init_page_end() {\r
+               if (!isset($this->page['end'])) {\r
+                       $this->page['end'] = '';\r
+               }\r
+               $tpl = get_markup_template('end.tpl');\r
+               $this->page['end'] = replace_macros($tpl, array(\r
+                               '$baseurl' => $this->get_baseurl() // FIXME for z_path!!!!\r
+                       )) . $this->page['end'];\r
+       }\r
+\r
+       function set_curl_code($code) {\r
+               $this->curl_code = $code;\r
+       }\r
+\r
+       function get_curl_code() {\r
+               return $this->curl_code;\r
+       }\r
+\r
+       function set_curl_content_type($content_type) {\r
+               $this->curl_content_type = $content_type;\r
+       }\r
+\r
+       function get_curl_content_type() {\r
+               return $this->curl_content_type;\r
+       }\r
+\r
+       function set_curl_headers($headers) {\r
+               $this->curl_headers = $headers;\r
+       }\r
+\r
+       function get_curl_headers() {\r
+               return $this->curl_headers;\r
+       }\r
+\r
+       function get_cached_avatar_image($avatar_image) {\r
+               return $avatar_image;\r
+       }\r
+\r
+       /**\r
+        * @brief Removes the baseurl from an url. This avoids some mixed content problems.\r
+        *\r
+        * @param string $orig_url\r
+        *\r
+        * @return string The cleaned url\r
+        */\r
+       function remove_baseurl($orig_url) {\r
+\r
+               // Is the function called statically?\r
+               if (!(isset($this) && get_class($this) == __CLASS__)) {\r
+                       return self::$a->remove_baseurl($orig_url);\r
+               }\r
+\r
+               // Remove the hostname from the url if it is an internal link\r
+               $nurl = normalise_link($orig_url);\r
+               $base = normalise_link($this->get_baseurl());\r
+               $url = str_replace($base . '/', '', $nurl);\r
+\r
+               // if it is an external link return the orignal value\r
+               if ($url == normalise_link($orig_url)) {\r
+                       return $orig_url;\r
+               } else {\r
+                       return $url;\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @brief Register template engine class\r
+        *\r
+        * If $name is '', is used class static property $class::$name\r
+        *\r
+        * @param string $class\r
+        * @param string $name\r
+        */\r
+       function register_template_engine($class, $name = '') {\r
+               /// @TODO Really === and not just == ?\r
+               if ($name === '') {\r
+                       $v = get_class_vars($class);\r
+                       if (x($v, 'name'))\r
+                               $name = $v['name'];\r
+               }\r
+               if ($name === '') {\r
+                       echo "template engine <tt>$class</tt> cannot be registered without a name.\n";\r
+                       killme();\r
+               }\r
+               $this->template_engines[$name] = $class;\r
+       }\r
+\r
+       /**\r
+        * @brief Return template engine instance.\r
+        *\r
+        * If $name is not defined, return engine defined by theme,\r
+        * or default\r
+        *\r
+        * @param strin $name Template engine name\r
+        * @return object Template Engine instance\r
+        */\r
+       function template_engine($name = '') {\r
+               /// @TODO really type-check included?\r
+               if ($name !== '') {\r
+                       $template_engine = $name;\r
+               } else {\r
+                       $template_engine = 'smarty3';\r
+                       if (x($this->theme, 'template_engine')) {\r
+                               $template_engine = $this->theme['template_engine'];\r
+                       }\r
+               }\r
+\r
+               if (isset($this->template_engines[$template_engine])) {\r
+                       if (isset($this->template_engine_instance[$template_engine])) {\r
+                               return $this->template_engine_instance[$template_engine];\r
+                       } else {\r
+                               $class = $this->template_engines[$template_engine];\r
+                               $obj = new $class;\r
+                               $this->template_engine_instance[$template_engine] = $obj;\r
+                               return $obj;\r
+                       }\r
+               }\r
+\r
+               echo "template engine <tt>$template_engine</tt> is not registered!\n";\r
+               killme();\r
+       }\r
+\r
+       /**\r
+        * @brief Returns the active template engine.\r
+        *\r
+        * @return string\r
+        */\r
+       function get_template_engine() {\r
+               return $this->theme['template_engine'];\r
+       }\r
+\r
+       function set_template_engine($engine = 'smarty3') {\r
+               $this->theme['template_engine'] = $engine;\r
+       }\r
+\r
+       function get_template_ldelim($engine = 'smarty3') {\r
+               return $this->ldelim[$engine];\r
+       }\r
+\r
+       function get_template_rdelim($engine = 'smarty3') {\r
+               return $this->rdelim[$engine];\r
+       }\r
+\r
+       function save_timestamp($stamp, $value) {\r
+               if (!isset($this->config['system']['profiler']) || !$this->config['system']['profiler']) {\r
+                       return;\r
+               }\r
+\r
+               $duration = (float) (microtime(true) - $stamp);\r
+\r
+               if (!isset($this->performance[$value])) {\r
+                       // Prevent ugly E_NOTICE\r
+                       $this->performance[$value] = 0;\r
+               }\r
+\r
+               $this->performance[$value] += (float) $duration;\r
+               $this->performance['marktime'] += (float) $duration;\r
+\r
+               $callstack = $this->callstack();\r
+\r
+               if (!isset($this->callstack[$value][$callstack])) {\r
+                       // Prevent ugly E_NOTICE\r
+                       $this->callstack[$value][$callstack] = 0;\r
+               }\r
+\r
+               $this->callstack[$value][$callstack] += (float) $duration;\r
+       }\r
+\r
+       /**\r
+        * @brief Log active processes into the "process" table\r
+        */\r
+       function start_process() {\r
+               $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);\r
+\r
+               $command = basename($trace[0]['file']);\r
+\r
+               $this->remove_inactive_processes();\r
+\r
+               q('START TRANSACTION');\r
+\r
+               $r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid()));\r
+               if (!dbm::is_result($r)) {\r
+                       q("INSERT INTO `process` (`pid`,`command`,`created`) VALUES (%d, '%s', '%s')", intval(getmypid()), dbesc($command), dbesc(datetime_convert()));\r
+               }\r
+               q('COMMIT');\r
+       }\r
+\r
+       /**\r
+        * @brief Remove inactive processes\r
+        */\r
+       function remove_inactive_processes() {\r
+               q('START TRANSACTION');\r
+\r
+               $r = q('SELECT `pid` FROM `process`');\r
+               if (dbm::is_result($r)) {\r
+                       foreach ($r AS $process) {\r
+                               if (!posix_kill($process['pid'], 0)) {\r
+                                       q('DELETE FROM `process` WHERE `pid` = %d', intval($process['pid']));\r
+                               }\r
+                       }\r
+               }\r
+               q('COMMIT');\r
+       }\r
+\r
+       /**\r
+        * @brief Remove the active process from the "process" table\r
+        */\r
+       function end_process() {\r
+               q('DELETE FROM `process` WHERE `pid` = %d', intval(getmypid()));\r
+       }\r
+\r
+       /**\r
+        * @brief Returns a string with a callstack. Can be used for logging.\r
+        *\r
+        * @return string\r
+        */\r
+       function callstack() {\r
+               $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6);\r
+\r
+               // We remove the first two items from the list since they contain data that we don't need.\r
+               array_shift($trace);\r
+               array_shift($trace);\r
+\r
+               $callstack = array();\r
+               foreach ($trace AS $func) {\r
+                       $callstack[] = $func['function'];\r
+               }\r
+\r
+               return implode(', ', $callstack);\r
+       }\r
+\r
+       function get_useragent() {\r
+               return\r
+                       FRIENDICA_PLATFORM . " '" .\r
+                       FRIENDICA_CODENAME . "' " .\r
+                       FRIENDICA_VERSION . '-' .\r
+                       DB_UPDATE_VERSION . '; ' .\r
+                       $this->get_baseurl();\r
+       }\r
+\r
+       function is_friendica_app() {\r
+               return $this->is_friendica_app;\r
+       }\r
+\r
+       /**\r
+        * @brief Checks if the site is called via a backend process\r
+        *\r
+        * This isn't a perfect solution. But we need this check very early.\r
+        * So we cannot wait until the modules are loaded.\r
+        *\r
+        * @return bool Is it a known backend?\r
+        */\r
+       function is_backend() {\r
+               static $backends = array();\r
+               $backends[] = '_well_known';\r
+               $backends[] = 'api';\r
+               $backends[] = 'dfrn_notify';\r
+               $backends[] = 'fetch';\r
+               $backends[] = 'hcard';\r
+               $backends[] = 'hostxrd';\r
+               $backends[] = 'nodeinfo';\r
+               $backends[] = 'noscrape';\r
+               $backends[] = 'p';\r
+               $backends[] = 'poco';\r
+               $backends[] = 'post';\r
+               $backends[] = 'proxy';\r
+               $backends[] = 'pubsub';\r
+               $backends[] = 'pubsubhubbub';\r
+               $backends[] = 'receive';\r
+               $backends[] = 'rsd_xml';\r
+               $backends[] = 'salmon';\r
+               $backends[] = 'statistics_json';\r
+               $backends[] = 'xrd';\r
+\r
+               // Check if current module is in backend or backend flag is set\r
+               return (in_array($this->module, $backends) || $this->backend);\r
+       }\r
+\r
+       /**\r
+        * @brief Checks if the maximum number of database processes is reached\r
+        *\r
+        * @return bool Is the limit reached?\r
+        */\r
+       function max_processes_reached() {\r
+\r
+               if ($this->is_backend()) {\r
+                       $process = 'backend';\r
+                       $max_processes = get_config('system', 'max_processes_backend');\r
+                       if (intval($max_processes) == 0) {\r
+                               $max_processes = 5;\r
+                       }\r
+               } else {\r
+                       $process = 'frontend';\r
+                       $max_processes = get_config('system', 'max_processes_frontend');\r
+                       if (intval($max_processes) == 0) {\r
+                               $max_processes = 20;\r
+                       }\r
+               }\r
+\r
+               $processlist = dbm::processlist();\r
+               if ($processlist['list'] != '') {\r
+                       logger('Processcheck: Processes: ' . $processlist['amount'] . ' - Processlist: ' . $processlist['list'], LOGGER_DEBUG);\r
+\r
+                       if ($processlist['amount'] > $max_processes) {\r
+                               logger('Processcheck: Maximum number of processes for ' . $process . ' tasks (' . $max_processes . ') reached.', LOGGER_DEBUG);\r
+                               return true;\r
+                       }\r
+               }\r
+               return false;\r
+       }\r
+\r
+       /**\r
+        * @brief Checks if the minimal memory is reached\r
+        *\r
+        * @return bool Is the memory limit reached?\r
+        */\r
+       public function min_memory_reached() {\r
+               $min_memory = Config::get('system', 'min_memory', 0);\r
+               if ($min_memory == 0) {\r
+                       return false;\r
+               }\r
+\r
+               if (!is_readable('/proc/meminfo')) {\r
+                       return false;\r
+               }\r
+\r
+               $memdata = explode("\n", file_get_contents('/proc/meminfo'));\r
+\r
+               $meminfo = array();\r
+               foreach ($memdata as $line) {\r
+                       list($key, $val) = explode(':', $line);\r
+                       $meminfo[$key] = (int) trim(str_replace('kB', '', $val));\r
+                       $meminfo[$key] = (int) ($meminfo[$key] / 1024);\r
+               }\r
+\r
+               if (!isset($meminfo['MemAvailable']) OR ! isset($meminfo['MemFree'])) {\r
+                       return false;\r
+               }\r
+\r
+               $free = $meminfo['MemAvailable'] + $meminfo['MemFree'];\r
+\r
+               $reached = ($free < $min_memory);\r
+\r
+               if ($reached) {\r
+                       logger('Minimal memory reached: ' . $free . '/' . $meminfo['MemTotal'] . ' - limit ' . $min_memory, LOGGER_DEBUG);\r
+               }\r
+\r
+               return $reached;\r
+       }\r
+\r
+       /**\r
+        * @brief Checks if the maximum load is reached\r
+        *\r
+        * @return bool Is the load reached?\r
+        */\r
+       function maxload_reached() {\r
+\r
+               if ($this->is_backend()) {\r
+                       $process = 'backend';\r
+                       $maxsysload = intval(get_config('system', 'maxloadavg'));\r
+                       if ($maxsysload < 1) {\r
+                               $maxsysload = 50;\r
+                       }\r
+               } else {\r
+                       $process = 'frontend';\r
+                       $maxsysload = intval(get_config('system', 'maxloadavg_frontend'));\r
+                       if ($maxsysload < 1) {\r
+                               $maxsysload = 50;\r
+                       }\r
+               }\r
+\r
+               $load = current_load();\r
+               if ($load) {\r
+                       if (intval($load) > $maxsysload) {\r
+                               logger('system: load ' . $load . ' for ' . $process . ' tasks (' . $maxsysload . ') too high.');\r
+                               return true;\r
+                       }\r
+               }\r
+               return false;\r
+       }\r
+\r
+       function proc_run($args) {\r
+\r
+               if (!function_exists('proc_open')) {\r
+                       return;\r
+               }\r
+\r
+               // If the last worker fork was less than 10 seconds before then don't fork another one.\r
+               // This should prevent the forking of masses of workers.\r
+               $cachekey = 'app:proc_run:started';\r
+               $result = Cache::get($cachekey);\r
+\r
+               if (!is_null($result) AND ( time() - $result) < 10) {\r
+                       return;\r
+               }\r
+\r
+               // Set the timestamp of the last proc_run\r
+               Cache::set($cachekey, time(), CACHE_MINUTE);\r
+\r
+               array_unshift($args, ((x($this->config, 'php_path')) && (strlen($this->config['php_path'])) ? $this->config['php_path'] : 'php'));\r
+\r
+               // add baseurl to args. cli scripts can't construct it\r
+               $args[] = $this->get_baseurl();\r
+\r
+               for ($x = 0; $x < count($args); $x ++) {\r
+                       $args[$x] = escapeshellarg($args[$x]);\r
+               }\r
+\r
+               $cmdline = implode($args, ' ');\r
+\r
+               if ($this->min_memory_reached()) {\r
+                       return;\r
+               }\r
+\r
+               if (get_config('system', 'proc_windows')) {\r
+                       $resource = proc_open('cmd /c start /b ' . $cmdline, array(), $foo, dirname(__FILE__));\r
+               } else {\r
+                       $resource = proc_open($cmdline . ' &', array(), $foo, dirname(__FILE__));\r
+               }\r
+               if (!is_resource($resource)) {\r
+                       logger('We got no resource for command ' . $cmdline, LOGGER_DEBUG);\r
+                       return;\r
+               }\r
+               proc_close($resource);\r
+       }\r
+\r
+       /**\r
+        * @brief Returns the system user that is executing the script\r
+        *\r
+        * This mostly returns something like "www-data".\r
+        *\r
+        * @return string system username\r
+        */\r
+       static function systemuser() {\r
+               if (!function_exists('posix_getpwuid') OR ! function_exists('posix_geteuid')) {\r
+                       return '';\r
+               }\r
+\r
+               $processUser = posix_getpwuid(posix_geteuid());\r
+               return $processUser['name'];\r
+       }\r
+\r
+       /**\r
+        * @brief Checks if a given directory is usable for the system\r
+        *\r
+        * @return boolean the directory is usable\r
+        */\r
+       static function directory_usable($directory) {\r
+               if ($directory == '') {\r
+                       logger('Directory is empty. This shouldn\'t happen.', LOGGER_DEBUG);\r
+                       return false;\r
+               }\r
+\r
+               if (!file_exists($directory)) {\r
+                       logger('Path "' . $directory . '" does not exist for user ' . self::systemuser(), LOGGER_DEBUG);\r
+                       return false;\r
+               }\r
+               if (is_file($directory)) {\r
+                       logger('Path "' . $directory . '" is a file for user ' . self::systemuser(), LOGGER_DEBUG);\r
+                       return false;\r
+               }\r
+               if (!is_dir($directory)) {\r
+                       logger('Path "' . $directory . '" is not a directory for user ' . self::systemuser(), LOGGER_DEBUG);\r
+                       return false;\r
+               }\r
+               if (!is_writable($directory)) {\r
+                       logger('Path "' . $directory . '" is not writable for user ' . self::systemuser(), LOGGER_DEBUG);\r
+                       return false;\r
+               }\r
+               return true;\r
+       }\r
+\r
+}\r
index 3e3a89840af00f617763ee18af08f592050a184f..799df063c29a70fbced027341bac1f94c524239b 100644 (file)
@@ -3,6 +3,8 @@
 * @package util
 */
 
+use Friendica\App;
+
 /*
 * require boot.php
 */
index b0728245c65a6770131cbe0a5ad273774d15923e..3b917aef19e2d87328a7d399ecb9f27e6f3f3c39 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use Friendica\App;
 use Friendica\Core\Config;
 
 require_once("boot.php");
index 0dfb6f91c784d6e1324ec762ab35456e6d72aa76..e07f718004b54d428314bac83b02af563b276c59 100644 (file)
@@ -7,6 +7,7 @@
  * Output to <path/to/messages.po>
  */
 
+use Friendica\App;
 
 DEFINE("NORM_REGEXP", "|[\\\]|");
 
index cc05be4ccdd048c5ea7d590fa2649b6aaae49726..0a1879fe06304fa68caa55e60ac4e98f0871d702 100644 (file)
@@ -3,6 +3,7 @@
 // Run this from cmdline in basedir and quickly see if we've
 // got any parse errors in our application files.
 
+use Friendica\App;
 
 error_reporting(E_ERROR | E_WARNING | E_PARSE );
 ini_set('display_errors', '1');
index e51b531b5ae1a7e628e6a04ca1a18be64688b3fc..17d4961fcdd560833f5f75921aacb764fa1c5408 100644 (file)
@@ -2,7 +2,7 @@
 <html itemscope itemtype="http://schema.org/Blog" lang="<?php echo $lang; ?>">\r
 <head>\r
   <title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
-  <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
+  <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>\r
   <?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
 </head>\r
 <body>\r
index e93aac11258ef7665a54e551ba9b8cc67c09973c..39888630a43270e1bb2c58567cb6fa983a6c848a 100644 (file)
@@ -2,7 +2,7 @@
 <html>\r
 <head>\r
   <title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
-  <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
+  <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>\r
   <?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
 </head>\r
 <body>\r
index 6b111d6ad4e7df2073c90c24d3c90043035a9b97..b1ec4bae531c38d46d70daf2faa6130aa85c1696 100644 (file)
@@ -4,6 +4,8 @@
  * Theme settings
  */
 
+use Friendica\App;
+
 function theme_content(App $a) {
        if (!local_user()) {
                return;
index c674a99d99ad848bb250c72667a8372860f80c97..dc8f29b2facfa0db1de9401a0a1e2eea25c1ea29 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\App;
+
 function duepuntozero_init(App $a) {
 
 set_template_engine($a, 'smarty3');
index 57e88265721a27a3814b541510a72827769801a8..229e863e93dc6b37ffa56982c3c3eae2bb2d3981 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Friendica\App;
+
 require_once('view/theme/frio/php/Image.php');
 
 function theme_content(App $a) {
index a0a71bc2252058a349fa35b69d71bdcb338dccf7..ef7e413ad828e1c691cab66c3eb58828d3142ac2 100644 (file)
@@ -15,9 +15,9 @@
 <head>
        <title><?php if(x($page,'title')) echo $page['title'] ?></title>
        <meta request="<?php echo htmlspecialchars($_REQUEST['pagename']) ?>">
-       <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>
+       <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>
        <script>var frio="<?php echo "view/theme/frio"; ?>";</script>
-       <?php $baseurl = App::get_baseurl(); ?>
+       <?php $baseurl = Friendica\App::get_baseurl(); ?>
        <?php $frio = "view/theme/frio"; ?>
        <?php
                // Because we use minimal for modals the header and the included js stuff should be only loaded
index ee7acb979773a47f343b5bf41f062268644ec3e3..17fbb1fbac85a3433fd4e1ad9a3a1720010e4735 100644 (file)
@@ -7,6 +7,7 @@
  *
  */
 
+use Friendica\App;
 
 /**
  * @brief Load page template in dependence of the template mode
index 9e3d2ca638ab0595d1580a8f3481e3888c30d7fb..26a5859efca4bfb7b967b65685acc8d66e7cd9c5 100644 (file)
@@ -10,9 +10,9 @@
        <title><?php if(x($page,'title')) echo $page['title'] ?></title>
        <meta name="viewport" content="initial-scale=1.0">
        <meta request="<?php echo htmlspecialchars($_REQUEST['pagename']) ?>">
-       <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>
+       <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>
        <script>var frio="<?php echo "view/theme/frio"; ?>";</script>
-       <?php $baseurl = App::get_baseurl(); ?>
+       <?php $baseurl = Friendica\App::get_baseurl(); ?>
        <?php $frio = "view/theme/frio"; ?>
        <?php if(x($page,'htmlhead')) echo $page['htmlhead']; ?>
 </head>
index a873e45131ca82a267dc5c4e57b1d0e9bfabed37..0e34709e9c5f6b1bda1e29ea88e37cd3626e85ea 100644 (file)
@@ -7,6 +7,8 @@
  *
  */
 
+use Friendica\App;
+
 $frio = "view/theme/frio";
 
 global $frio;
index d739f56f269fb14f52dc4f8b1688367aac0ae073..062ec3b8a9c97cf520e0b99cf7ecde94d3d3e075 100644 (file)
@@ -2,7 +2,7 @@
 <html lang="<?php echo $lang; ?>">\r
 <head>\r
   <title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
-  <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
+  <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>\r
   <?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
 </head>\r
 <body <?php if($a->module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>>\r
index 7e4262cb6a46fc601c7228765405806d7b3cd752..24f41073e7cdace4aebf85385e4ba3cfce296a39 100644 (file)
@@ -9,6 +9,8 @@
  * Maintainer: Zach P <techcity@f.shmuz.in>
  */
 
+use Friendica\App;
+
 function frost_mobile_init(App $a) {
        $a->sourcename = 'Friendica mobile web';
        $a->videowidth = 250;
index 0fe3404f69c97dc7d157ce3e91ebcf54766fed31..306345d391cc8fa2662d439b1d79bbf1b0c581e6 100644 (file)
@@ -2,7 +2,7 @@
 <html lang="<?php echo $lang; ?>">\r
 <head>\r
   <title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
-  <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
+  <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>\r
   <?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
 </head>\r
 <body <?php if($a->module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>>\r
index 4c22f0a11869664db5a6b58b4b1bfdc172fa0ad3..b09153876d67c09285609c27910d02ea35e33e24 100644 (file)
@@ -9,6 +9,8 @@
  * Maintainer: Zach P <techcity@f.shmuz.in>
  */
 
+use Friendica\App;
+
 function frost_init(App $a) {
        $a->videowidth = 400;
        $a->videoheight = 330;
index 341c2b8310f695c23c3063aef141c9068ad70e9c..47210012caa8f7ce95ae89640781a60ce78502c1 100644 (file)
@@ -4,6 +4,8 @@
  * Theme settings
  */
 
+use Friendica\App;
+
 function theme_content(App $a) {
        if (!local_user()) {
                return;
index fc908522a1862144ccdf2f971dc9b77f44367136..5647fd493a88e1cd3f20a322df9abd54bb5af8e0 100644 (file)
@@ -7,6 +7,8 @@
  * Maintainer: Tobias <https://diekershoff.homeunix.net/friendica/profile/tobias>
  */
 
+use Friendica\App;
+
 function quattro_init(App $a) {
        $a->page['htmlhead'] .= '<script src="'.App::get_baseurl().'/view/theme/quattro/tinycon.min.js"></script>';
        $a->page['htmlhead'] .= '<script src="'.App::get_baseurl().'/view/theme/quattro/js/quattro.js"></script>';;
index 1e97c6b462e70930defe99fa1e97757616482ca6..568f267c1c3e9fd7dc178ae6158f7065a00217e2 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <head>
   <title><?php if(x($page,'title')) echo $page['title'] ?></title>
-  <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>
+  <script>var baseurl="<?php echo Friendica\App::get_baseurl() ?>";</script>
   <script type="text/javascript">
        function ScrollToBottom(){
        window.scrollTo(0,document.body.scrollHeight);
index af998e3b580aaa65f00446cefe262d2b25b1c034..3efcf54f413a4a96c4f691f87c6a81f4964f78e7 100644 (file)
@@ -10,6 +10,8 @@
  * Screenshot: <a href="screenshot.png">Screenshot</a>
  */
 
+use Friendica\App;
+
 function smoothly_init(App $a) {
        set_template_engine($a, 'smarty3');
 
index 9fd19e8abae87c847db7a7de3415f7c6234879ec..0747770d3665052e23fa5dfd0aec419244e21d80 100644 (file)
@@ -1,9 +1,10 @@
 <?php
+
 /**
  * Theme settings
  */
 
-
+use Friendica\App;
 
 function theme_content(App $a) {
        if (!local_user()) {
index a42dfe6e13070d0b4d2cf2c58a8b0be8528ecf14..da2c08335dae02cb42c3e8579b8d7e33ac1b4cb3 100644 (file)
@@ -9,6 +9,8 @@
  * Description: "Vier" is a very compact and modern theme. It uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/
  */
 
+use Friendica\App;
+
 require_once "include/plugin.php";
 require_once "include/socgraph.php";
 require_once "mod/proxy.php";