diff --git a/boot.php b/boot.php
index 497451224..5b497632e 100644
--- a/boot.php
+++ b/boot.php
@@ -1294,10 +1294,6 @@ class App {
*/
function max_processes_reached() {
- // Is the function called statically?
- if (!is_object($this))
- return(self::$a->max_processes_reached());
-
if ($this->is_backend()) {
$process = "backend";
$max_processes = get_config('system', 'max_processes_backend');
@@ -1329,10 +1325,6 @@ class App {
*/
function maxload_reached() {
- // Is the function called statically?
- if (!is_object($this))
- return(self::$a->maxload_reached());
-
if ($this->is_backend()) {
$process = "backend";
$maxsysload = intval(get_config('system', 'maxloadavg'));
@@ -1479,14 +1471,14 @@ function system_unavailable() {
function clean_urls() {
- global $a;
+ $a = get_app();
// if($a->config['system']['clean_urls'])
return true;
// return false;
}
function z_path() {
- global $a;
+ $a = get_app();
$base = $a->get_baseurl();
if(! clean_urls())
$base .= '/?q=';
@@ -1501,7 +1493,7 @@ function z_path() {
* @return string
*/
function z_root() {
- global $a;
+ $a = get_app();
return $a->get_baseurl();
}
@@ -1903,7 +1895,7 @@ function info($s) {
* @return int
*/
function get_max_import_size() {
- global $a;
+ $a = get_app();
return ((x($a->config,'max_import_size')) ? $a->config['max_import_size'] : 0 );
}
@@ -2100,7 +2092,7 @@ function current_theme(){
* @return string
*/
function current_theme_url() {
- global $a;
+ $a = get_app();
$t = current_theme();
diff --git a/include/Core/Config.php b/include/Core/Config.php
index a5eca0570..0d29c9956 100644
--- a/include/Core/Config.php
+++ b/include/Core/Config.php
@@ -30,7 +30,7 @@ class Config {
* @return void
*/
public static function load($family) {
- global $a;
+ $a = get_app();
$r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s' ORDER BY `cat`, `k`, `id`", dbesc($family));
if (count($r)) {
@@ -72,7 +72,7 @@ class Config {
*/
public static function get($family, $key, $default_value = null, $refresh = false) {
- global $a;
+ $a = get_app();
if (!$refresh) {
// Looking if the whole family isn't set
@@ -123,7 +123,7 @@ class Config {
* @return mixed Stored $value or false if the database update failed
*/
public static function set($family, $key, $value) {
- global $a;
+ $a = get_app();
$stored = self::get($family, $key);
@@ -171,7 +171,7 @@ class Config {
*/
public static function delete($family, $key) {
- global $a;
+ $a = get_app();
if (x($a->config[$family],$key)) {
unset($a->config[$family][$key]);
}
diff --git a/include/Core/PConfig.php b/include/Core/PConfig.php
index 63d204b3a..351f63e00 100644
--- a/include/Core/PConfig.php
+++ b/include/Core/PConfig.php
@@ -28,7 +28,7 @@ class PConfig {
* @return void
*/
public static function load($uid, $family) {
- global $a;
+ $a = get_app();
$r = q("SELECT `v`,`k` FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d ORDER BY `cat`, `k`, `id`",
dbesc($family),
intval($uid)
@@ -65,7 +65,7 @@ class PConfig {
*/
public static function get($uid, $family, $key, $default_value = null, $refresh = false) {
- global $a;
+ $a = get_app();
if (!$refresh) {
// Looking if the whole family isn't set
@@ -120,7 +120,7 @@ class PConfig {
*/
public static function set($uid, $family, $key, $value) {
- global $a;
+ $a = get_app();
$stored = self::get($uid, $family, $key);
@@ -171,7 +171,7 @@ class PConfig {
*/
public static function delete($uid,$family,$key) {
- global $a;
+ $a = get_app();
if (x($a->config[$uid][$family], $key)) {
unset($a->config[$uid][$family][$key]);
diff --git a/include/Probe.php b/include/Probe.php
index 14e8d5bca..4e69cc8ef 100644
--- a/include/Probe.php
+++ b/include/Probe.php
@@ -232,7 +232,7 @@ class Probe {
if ($data["photo"] != "")
$data["baseurl"] = matching_url(normalise_link($data["baseurl"]), normalise_link($data["photo"]));
else
- $data["photo"] = App::get_baseurl().'/images/person-175.jpg';
+ $data["photo"] = $a->get_baseurl().'/images/person-175.jpg';
if (!isset($data["name"]) OR ($data["name"] == "")) {
if (isset($data["nick"]))
diff --git a/include/api.php b/include/api.php
index 1f3c76298..04d614d02 100644
--- a/include/api.php
+++ b/include/api.php
@@ -409,12 +409,12 @@
$arr['$user'] = $user_info;
$arr['$rss'] = array(
'alternate' => $user_info['url'],
- 'self' => App::get_baseurl(). "/". $a->query_string,
- 'base' => App::get_baseurl(),
+ 'self' => $a->get_baseurl(). "/". $a->query_string,
+ 'base' => $a->get_baseurl(),
'updated' => api_date(null),
'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME),
'language' => $user_info['language'],
- 'logo' => App::get_baseurl()."/images/friendica-32.png",
+ 'logo' => $a->get_baseurl()."/images/friendica-32.png",
);
return $arr;
@@ -693,7 +693,7 @@
'follow_request_sent' => false,
'statusnet_blocking' => false,
'notifications' => false,
- //'statusnet_profile_url' => App::get_baseurl()."/contacts/".$uinfo[0]['cid'],
+ //'statusnet_profile_url' => $a->get_baseurl()."/contacts/".$uinfo[0]['cid'],
'statusnet_profile_url' => $uinfo[0]['url'],
'uid' => intval($uinfo[0]['uid']),
'cid' => intval($uinfo[0]['cid']),
@@ -1078,8 +1078,8 @@
if ($r) {
$phototypes = Photo::supportedTypes();
$ext = $phototypes[$r[0]['type']];
- $_REQUEST['body'] .= "\n\n".'[url='.App::get_baseurl().'/photos/'.$r[0]['nickname'].'/image/'.$r[0]['resource-id'].']';
- $_REQUEST['body'] .= '[img]'.App::get_baseurl()."/photo/".$r[0]['resource-id']."-".$r[0]['scale'].".".$ext."[/img][/url]";
+ $_REQUEST['body'] .= "\n\n".'[url='.$a->get_baseurl().'/photos/'.$r[0]['nickname'].'/image/'.$r[0]['resource-id'].']';
+ $_REQUEST['body'] .= '[img]'.$a->get_baseurl()."/photo/".$r[0]['resource-id']."-".$r[0]['scale'].".".$ext."[/img][/url]";
}
}
@@ -1777,7 +1777,7 @@
$start = $page*$count;
// Ugly code - should be changed
- $myurl = App::get_baseurl() . '/profile/'. $a->user['nickname'];
+ $myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname'];
$myurl = substr($myurl,strpos($myurl,'://')+3);
//$myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
$myurl = str_replace('www.','',$myurl);
@@ -2302,7 +2302,7 @@
$text = preg_replace_callback(
"|data:image/([^;]+)[^=]+=*|m",
function($match) use ($item) {
- return App::get_baseurl()."/display/".$item['guid'];
+ return $a->get_baseurl()."/display/".$item['guid'];
},
$text);
return $text;
@@ -2690,7 +2690,7 @@
$name = $a->config['sitename'];
$server = $a->get_hostname();
- $logo = App::get_baseurl() . '/images/friendica-64.png';
+ $logo = $a->get_baseurl() . '/images/friendica-64.png';
$email = $a->config['admin_email'];
$closed = (($a->config['register_policy'] == REGISTER_CLOSED) ? 'true' : 'false');
$private = (($a->config['system']['block_public']) ? 'true' : 'false');
@@ -2698,7 +2698,7 @@
if($a->config['api_import_size'])
$texlimit = string($a->config['api_import_size']);
$ssl = (($a->config['system']['have_ssl']) ? 'true' : 'false');
- $sslserver = (($ssl === 'true') ? str_replace('http:','https:',App::get_baseurl()) : '');
+ $sslserver = (($ssl === 'true') ? str_replace('http:','https:',$a->get_baseurl()) : '');
$config = array(
'site' => array('name' => $name,'server' => $server, 'theme' => 'default', 'path' => '',
@@ -3075,7 +3075,7 @@
$photo['album'] = $rr['album'];
$photo['filename'] = $rr['filename'];
$photo['type'] = $rr['type'];
- $thumb = App::get_baseurl()."/photo/".$rr['resource-id']."-".$rr['scale'].".".$typetoext[$rr['type']];
+ $thumb = $a->get_baseurl()."/photo/".$rr['resource-id']."-".$rr['scale'].".".$typetoext[$rr['type']];
if ($type == "xml")
$data['photo'][] = array("@attributes" => $photo, "1" => $thumb);
@@ -3124,11 +3124,11 @@
for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++)
$data['photo']['links'][$k.":link"]["@attributes"] = array("type" => $data['photo']['type'],
"scale" => $k,
- "href" => App::get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']]);
+ "href" => $a->get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']]);
} else {
$data['photo']['link'] = array();
for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++) {
- $data['photo']['link'][$k] = App::get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']];
+ $data['photo']['link'][$k] = $a->get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']];
}
}
unset($data['photo']['resource-id']);
diff --git a/include/auth_ejabberd.php b/include/auth_ejabberd.php
index e1900dc73..e12da35ef 100755
--- a/include/auth_ejabberd.php
+++ b/include/auth_ejabberd.php
@@ -146,7 +146,7 @@ class exAuth {
* @param array $aCommand The command array
*/
private function isuser($aCommand) {
- global $a;
+ $a = get_app();
// Check if there is a username
if (!isset($aCommand[1])) {
@@ -214,7 +214,7 @@ class exAuth {
* @param array $aCommand The command array
*/
private function auth($aCommand) {
- global $a;
+ $a = get_app();
// check user authentication
if (sizeof($aCommand) != 4) {
diff --git a/include/cron.php b/include/cron.php
index c92396dc7..9807043b1 100644
--- a/include/cron.php
+++ b/include/cron.php
@@ -42,7 +42,7 @@ function cron_run(&$argv, &$argc){
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
- if (App::maxload_reached())
+ if ($a->maxload_reached())
return;
if (App::is_already_running('cron', 'include/cron.php', 540))
return;
diff --git a/include/cronhooks.php b/include/cronhooks.php
index 4bb1e5f65..7524a0c3a 100644
--- a/include/cronhooks.php
+++ b/include/cronhooks.php
@@ -25,7 +25,7 @@ function cronhooks_run(&$argv, &$argc){
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
- if (App::maxload_reached())
+ if ($a->maxload_reached())
return;
if (App::is_already_running('cronhooks', 'include/cronhooks.php', 1140))
return;
diff --git a/include/dba.php b/include/dba.php
index 16d2dc54d..920027cbc 100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -35,7 +35,7 @@ class dba {
public $error = false;
function __construct($server, $user, $pass, $db, $install = false) {
- global $a;
+ $a = get_app();
$stamp1 = microtime(true);
@@ -139,7 +139,7 @@ class dba {
}
public function q($sql, $onlyquery = false) {
- global $a;
+ $a = get_app();
if (!$this->db || !$this->connected) {
return false;
diff --git a/include/dba_pdo.php b/include/dba_pdo.php
index 7b720fb6c..a44c447af 100644
--- a/include/dba_pdo.php
+++ b/include/dba_pdo.php
@@ -44,7 +44,7 @@ class dba {
public $error = false;
function __construct($server,$user,$pass,$db,$install = false) {
- global $a;
+ $a = get_app();
# work around, to store the database - configuration in DDDBL
$objDataObjectPool = new \DDDBL\DataObjectPool('Database-Definition');
@@ -99,7 +99,7 @@ class dba {
}
public function q($sql, $onlyquery = false) {
- global $a;
+ $a = get_app();
$strHandler = (true === $onlyquery) ? 'PDOStatement' : 'MULTI';
diff --git a/include/delivery.php b/include/delivery.php
index 8fce98774..094d0497b 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -57,7 +57,7 @@ function delivery_run(&$argv, &$argc){
continue;
}
- if (App::maxload_reached())
+ if ($a->maxload_reached())
return;
// It's ours to deliver. Remove it from the queue.
diff --git a/include/dfrn.php b/include/dfrn.php
index 272105128..ce7bdc719 100644
--- a/include/dfrn.php
+++ b/include/dfrn.php
@@ -1443,6 +1443,7 @@ class dfrn {
* @param array $importer Record of the importer user mixed with contact of the content
*/
private function process_suggestion($xpath, $suggestion, $importer) {
+ $a = get_app();
logger("Processing suggestions");
@@ -1524,7 +1525,7 @@ class dfrn {
"to_email" => $importer["email"],
"uid" => $importer["importer_uid"],
"item" => $suggest,
- "link" => App::get_baseurl()."/notifications/intros",
+ "link" => $a->get_baseurl()."/notifications/intros",
"source_name" => $importer["name"],
"source_link" => $importer["url"],
"source_photo" => $importer["photo"],
@@ -1791,6 +1792,8 @@ class dfrn {
* @param int $posted_id The record number of item record that was just posted
*/
private function do_poke($item, $importer, $posted_id) {
+ $a = get_app();
+
$verb = urldecode(substr($item["verb"],strpos($item["verb"], "#")+1));
if(!$verb)
return;
@@ -1810,7 +1813,7 @@ class dfrn {
}
}
- if($Blink && link_compare($Blink,App::get_baseurl()."/profile/".$importer["nickname"])) {
+ if($Blink && link_compare($Blink,$a->get_baseurl()."/profile/".$importer["nickname"])) {
// send a notification
notification(array(
@@ -1821,7 +1824,7 @@ class dfrn {
"to_email" => $importer["email"],
"uid" => $importer["importer_uid"],
"item" => $item,
- "link" => App::get_baseurl()."/display/".urlencode(get_item_guid($posted_id)),
+ "link" => $a->get_baseurl()."/display/".urlencode(get_item_guid($posted_id)),
"source_name" => stripslashes($item["author-name"]),
"source_link" => $item["author-link"],
"source_photo" => ((link_compare($item["author-link"],$importer["url"]))
diff --git a/include/discover_poco.php b/include/discover_poco.php
index 0b468faea..bf3e47edd 100644
--- a/include/discover_poco.php
+++ b/include/discover_poco.php
@@ -26,7 +26,7 @@ function discover_poco_run(&$argv, &$argc){
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run")
- if (App::maxload_reached())
+ if ($a->maxload_reached())
return;
if(($argc > 2) && ($argv[1] == "dirsearch")) {
diff --git a/include/enotify.php b/include/enotify.php
index 5b2bea297..99258c64c 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -648,6 +648,7 @@ function notification($params) {
* @param str $defaulttype (Optional) Forces a notification with this type.
*/
function check_item_notification($itemid, $uid, $defaulttype = "") {
+ $a = get_app();
$notification_data = array("uid" => $uid, "profiles" => array());
call_hooks('check_item_notification', $notification_data);
@@ -666,7 +667,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$profiles[] = $owner[0]["url"];
// Notifications from Diaspora are often with an URL in the Diaspora format
- $profiles[] = App::get_baseurl()."/u/".$user[0]["nickname"];
+ $profiles[] = $a->get_baseurl()."/u/".$user[0]["nickname"];
$profiles2 = array();
@@ -720,7 +721,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$params["to_email"] = $user[0]["email"];
$params["item"] = $item[0];
$params["parent"] = $item[0]["parent"];
- $params["link"] = App::get_baseurl().'/display/'.urlencode($item[0]["guid"]);
+ $params["link"] = $a->get_baseurl().'/display/'.urlencode($item[0]["guid"]);
$params["otype"] = 'item';
$params["source_name"] = $item[0]["author-name"];
$params["source_link"] = $item[0]["author-link"];
diff --git a/include/event.php b/include/event.php
index 6c0e2bdec..3a66a4a6d 100644
--- a/include/event.php
+++ b/include/event.php
@@ -590,7 +590,7 @@ function process_events ($arr) {
$is_first = ($d !== $last_date);
$last_date = $d;
- $edit = ((! $rr['cid']) ? array(App::get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null);
+ $edit = ((! $rr['cid']) ? array($a->get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null);
$title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
if(! $title) {
list($title, $_trash) = explode("
embedurl;
@@ -165,7 +167,7 @@ function oembed_format_object($j){
$th=120; $tw = $th*$tr;
$tpl=get_markup_template('oembed_video.tpl');
$ret.=replace_macros($tpl, array(
- '$baseurl' => App::get_baseurl(),
+ '$baseurl' => $a->get_baseurl(),
'$embedurl'=>$embedurl,
'$escapedhtml'=>base64_encode($jhtml),
'$tw'=>$tw,
@@ -255,12 +257,14 @@ function oembed_format_object($j){
* @see oembed_format_object()
*/
function oembed_iframe($src, $width, $height) {
+ $a = get_app();
+
if (!$height || strstr($height,'%')) {
$height = '200';
}
$width = '100%';
- $s = App::get_baseurl() . '/oembed/'.base64url_encode($src);
+ $s = $a->get_baseurl() . '/oembed/'.base64url_encode($src);
return '';
}
diff --git a/include/pgettext.php b/include/pgettext.php
index de7cdda9e..fb87798ff 100644
--- a/include/pgettext.php
+++ b/include/pgettext.php
@@ -98,7 +98,7 @@ if(! function_exists('load_translation_table')) {
* @param string $lang language code to load
*/
function load_translation_table($lang) {
- global $a;
+ $a = get_app();
$a->strings = array();
// load enabled plugins strings
diff --git a/include/poller.php b/include/poller.php
index 925de3fe5..44f4895cd 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -39,7 +39,7 @@ function poller_run($argv, $argc){
return;
}
- if (App::maxload_reached()) {
+ if ($a->maxload_reached()) {
return;
}
diff --git a/include/socgraph.php b/include/socgraph.php
index 765ed5d89..d87be91b7 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -1728,6 +1728,8 @@ function update_gcontact_from_probe($url) {
* @param int $uid User ID
*/
function update_gcontact_for_user($uid) {
+ $a = get_app();
+
$r = q("SELECT `profile`.`locality`, `profile`.`region`, `profile`.`country-name`,
`profile`.`name`, `profile`.`about`, `profile`.`gender`,
`profile`.`pub_keywords`, `profile`.`dob`, `profile`.`photo`,
@@ -1744,7 +1746,7 @@ function update_gcontact_for_user($uid) {
// The "addr" field was added in 3.4.3 so it can be empty for older users
if ($r[0]["addr"] != "")
- $addr = $r[0]["nickname"].'@'.str_replace(array("http://", "https://"), "", App::get_baseurl());
+ $addr = $r[0]["nickname"].'@'.str_replace(array("http://", "https://"), "", $a->get_baseurl());
else
$addr = $r[0]["addr"];
@@ -1754,7 +1756,7 @@ function update_gcontact_for_user($uid) {
"notify" => $r[0]["notify"], "url" => $r[0]["url"],
"hide" => ($r[0]["hidewall"] OR !$r[0]["net-publish"]),
"nick" => $r[0]["nickname"], "addr" => $addr,
- "connect" => $addr, "server_url" => App::get_baseurl(),
+ "connect" => $addr, "server_url" => $a->get_baseurl(),
"generation" => 1, "network" => NETWORK_DFRN);
update_gcontact($gcontact);
diff --git a/include/tags.php b/include/tags.php
index a8bcae86d..6c1d01d74 100644
--- a/include/tags.php
+++ b/include/tags.php
@@ -1,6 +1,6 @@
get_baseurl();
$profile_data = parse_url($profile_base);
diff --git a/include/text.php b/include/text.php
index 1197f24ee..61abc359c 100644
--- a/include/text.php
+++ b/include/text.php
@@ -699,7 +699,7 @@ $LOGGER_LEVELS = array();
* @param int $level
*/
function logger($msg, $level = 0) {
- global $a;
+ $a = get_app();
global $db;
global $LOGGER_LEVELS;
diff --git a/mod/fbrowser.php b/mod/fbrowser.php
index 110ca9585..11ac2d825 100644
--- a/mod/fbrowser.php
+++ b/mod/fbrowser.php
@@ -63,7 +63,7 @@ function fbrowser_content($a){
);
function _map_files1($rr){
- global $a;
+ $a = get_app();
$types = Photo::supportedTypes();
$ext = $types[$rr['type']];
@@ -110,7 +110,8 @@ function fbrowser_content($a){
intval(local_user())
);
- function _map_files2($rr){ global $a;
+ function _map_files2($rr){
+ $a = get_app();
list($m1,$m2) = explode("/",$rr['filetype']);
$filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
diff --git a/mod/fetch.php b/mod/fetch.php
index 1c73ad371..6e4c7bb16 100644
--- a/mod/fetch.php
+++ b/mod/fetch.php
@@ -27,7 +27,7 @@ function fetch_init($a){
$parts = parse_url($r[0]["author-link"]);
$host = $parts["scheme"]."://".$parts["host"];
- if (normalise_link($host) != normalise_link(App::get_baseurl())) {
+ if (normalise_link($host) != normalise_link($a->get_baseurl())) {
$location = $host."/fetch/".$a->argv[1]."/".urlencode($guid);
header("HTTP/1.1 301 Moved Permanently");
diff --git a/mod/p.php b/mod/p.php
index 8da044e93..6928bb0b9 100644
--- a/mod/p.php
+++ b/mod/p.php
@@ -31,7 +31,7 @@ function p_init($a){
$parts = parse_url($r[0]["author-link"]);
$host = $parts["scheme"]."://".$parts["host"];
- if (normalise_link($host) != normalise_link(App::get_baseurl())) {
+ if (normalise_link($host) != normalise_link($a->get_baseurl())) {
$location = $host."/p/".urlencode($guid).".xml";
header("HTTP/1.1 301 Moved Permanently");
diff --git a/object/BaseObject.php b/object/BaseObject.php
index 14f0d8fd0..2666dc1de 100644
--- a/object/BaseObject.php
+++ b/object/BaseObject.php
@@ -21,8 +21,7 @@ class BaseObject {
if(self::$app)
return self::$app;
- global $a;
- self::$app = $a;
+ self::$app = get_app();
return self::$app;
}
diff --git a/object/Conversation.php b/object/Conversation.php
index 36c06c6d6..eb5b3b9b4 100644
--- a/object/Conversation.php
+++ b/object/Conversation.php
@@ -127,7 +127,7 @@ class Conversation extends BaseObject {
* _ false on failure
*/
public function get_template_data($conv_responses) {
- global $a;
+ $a = get_app();
$result = array();
$i = 0;