Some rewrites:

- max_proccesses_reach() and maxload_reached() (why no _ behind max?) are called
  both way, static and with object reference.
- this is strongly discouraged and should be avoided as its support (in PHP) may
  be dropped in future releases.
- used $a = get_app(); to encapsulate code (even when the function does
  currently the same, it may be changed later)

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2016-12-13 10:16:36 +01:00
parent 47c60aa486
commit 293436e5fd
27 changed files with 69 additions and 67 deletions

View File

@ -1294,10 +1294,6 @@ class App {
*/ */
function max_processes_reached() { function max_processes_reached() {
// Is the function called statically?
if (!is_object($this))
return(self::$a->max_processes_reached());
if ($this->is_backend()) { if ($this->is_backend()) {
$process = "backend"; $process = "backend";
$max_processes = get_config('system', 'max_processes_backend'); $max_processes = get_config('system', 'max_processes_backend');
@ -1329,10 +1325,6 @@ class App {
*/ */
function maxload_reached() { function maxload_reached() {
// Is the function called statically?
if (!is_object($this))
return(self::$a->maxload_reached());
if ($this->is_backend()) { if ($this->is_backend()) {
$process = "backend"; $process = "backend";
$maxsysload = intval(get_config('system', 'maxloadavg')); $maxsysload = intval(get_config('system', 'maxloadavg'));
@ -1479,14 +1471,14 @@ function system_unavailable() {
function clean_urls() { function clean_urls() {
global $a; $a = get_app();
// if($a->config['system']['clean_urls']) // if($a->config['system']['clean_urls'])
return true; return true;
// return false; // return false;
} }
function z_path() { function z_path() {
global $a; $a = get_app();
$base = $a->get_baseurl(); $base = $a->get_baseurl();
if(! clean_urls()) if(! clean_urls())
$base .= '/?q='; $base .= '/?q=';
@ -1501,7 +1493,7 @@ function z_path() {
* @return string * @return string
*/ */
function z_root() { function z_root() {
global $a; $a = get_app();
return $a->get_baseurl(); return $a->get_baseurl();
} }
@ -1903,7 +1895,7 @@ function info($s) {
* @return int * @return int
*/ */
function get_max_import_size() { function get_max_import_size() {
global $a; $a = get_app();
return ((x($a->config,'max_import_size')) ? $a->config['max_import_size'] : 0 ); return ((x($a->config,'max_import_size')) ? $a->config['max_import_size'] : 0 );
} }
@ -2100,7 +2092,7 @@ function current_theme(){
* @return string * @return string
*/ */
function current_theme_url() { function current_theme_url() {
global $a; $a = get_app();
$t = current_theme(); $t = current_theme();

View File

@ -30,7 +30,7 @@ class Config {
* @return void * @return void
*/ */
public static function load($family) { 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)); $r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s' ORDER BY `cat`, `k`, `id`", dbesc($family));
if (count($r)) { if (count($r)) {
@ -72,7 +72,7 @@ class Config {
*/ */
public static function get($family, $key, $default_value = null, $refresh = false) { public static function get($family, $key, $default_value = null, $refresh = false) {
global $a; $a = get_app();
if (!$refresh) { if (!$refresh) {
// Looking if the whole family isn't set // 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 * @return mixed Stored $value or false if the database update failed
*/ */
public static function set($family, $key, $value) { public static function set($family, $key, $value) {
global $a; $a = get_app();
$stored = self::get($family, $key); $stored = self::get($family, $key);
@ -171,7 +171,7 @@ class Config {
*/ */
public static function delete($family, $key) { public static function delete($family, $key) {
global $a; $a = get_app();
if (x($a->config[$family],$key)) { if (x($a->config[$family],$key)) {
unset($a->config[$family][$key]); unset($a->config[$family][$key]);
} }

View File

@ -28,7 +28,7 @@ class PConfig {
* @return void * @return void
*/ */
public static function load($uid, $family) { 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`", $r = q("SELECT `v`,`k` FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d ORDER BY `cat`, `k`, `id`",
dbesc($family), dbesc($family),
intval($uid) intval($uid)
@ -65,7 +65,7 @@ class PConfig {
*/ */
public static function get($uid, $family, $key, $default_value = null, $refresh = false) { public static function get($uid, $family, $key, $default_value = null, $refresh = false) {
global $a; $a = get_app();
if (!$refresh) { if (!$refresh) {
// Looking if the whole family isn't set // Looking if the whole family isn't set
@ -120,7 +120,7 @@ class PConfig {
*/ */
public static function set($uid, $family, $key, $value) { public static function set($uid, $family, $key, $value) {
global $a; $a = get_app();
$stored = self::get($uid, $family, $key); $stored = self::get($uid, $family, $key);
@ -171,7 +171,7 @@ class PConfig {
*/ */
public static function delete($uid,$family,$key) { public static function delete($uid,$family,$key) {
global $a; $a = get_app();
if (x($a->config[$uid][$family], $key)) { if (x($a->config[$uid][$family], $key)) {
unset($a->config[$uid][$family][$key]); unset($a->config[$uid][$family][$key]);

View File

@ -232,7 +232,7 @@ class Probe {
if ($data["photo"] != "") if ($data["photo"] != "")
$data["baseurl"] = matching_url(normalise_link($data["baseurl"]), normalise_link($data["photo"])); $data["baseurl"] = matching_url(normalise_link($data["baseurl"]), normalise_link($data["photo"]));
else 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["name"]) OR ($data["name"] == "")) {
if (isset($data["nick"])) if (isset($data["nick"]))

View File

@ -409,12 +409,12 @@
$arr['$user'] = $user_info; $arr['$user'] = $user_info;
$arr['$rss'] = array( $arr['$rss'] = array(
'alternate' => $user_info['url'], 'alternate' => $user_info['url'],
'self' => App::get_baseurl(). "/". $a->query_string, 'self' => $a->get_baseurl(). "/". $a->query_string,
'base' => App::get_baseurl(), 'base' => $a->get_baseurl(),
'updated' => api_date(null), 'updated' => api_date(null),
'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME), 'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME),
'language' => $user_info['language'], 'language' => $user_info['language'],
'logo' => App::get_baseurl()."/images/friendica-32.png", 'logo' => $a->get_baseurl()."/images/friendica-32.png",
); );
return $arr; return $arr;
@ -693,7 +693,7 @@
'follow_request_sent' => false, 'follow_request_sent' => false,
'statusnet_blocking' => false, 'statusnet_blocking' => false,
'notifications' => 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'], 'statusnet_profile_url' => $uinfo[0]['url'],
'uid' => intval($uinfo[0]['uid']), 'uid' => intval($uinfo[0]['uid']),
'cid' => intval($uinfo[0]['cid']), 'cid' => intval($uinfo[0]['cid']),
@ -1078,8 +1078,8 @@
if ($r) { if ($r) {
$phototypes = Photo::supportedTypes(); $phototypes = Photo::supportedTypes();
$ext = $phototypes[$r[0]['type']]; $ext = $phototypes[$r[0]['type']];
$_REQUEST['body'] .= "\n\n".'[url='.App::get_baseurl().'/photos/'.$r[0]['nickname'].'/image/'.$r[0]['resource-id'].']'; $_REQUEST['body'] .= "\n\n".'[url='.$a->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'] .= '[img]'.$a->get_baseurl()."/photo/".$r[0]['resource-id']."-".$r[0]['scale'].".".$ext."[/img][/url]";
} }
} }
@ -1777,7 +1777,7 @@
$start = $page*$count; $start = $page*$count;
// Ugly code - should be changed // 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 = substr($myurl,strpos($myurl,'://')+3);
//$myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); //$myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
$myurl = str_replace('www.','',$myurl); $myurl = str_replace('www.','',$myurl);
@ -2302,7 +2302,7 @@
$text = preg_replace_callback( $text = preg_replace_callback(
"|data:image/([^;]+)[^=]+=*|m", "|data:image/([^;]+)[^=]+=*|m",
function($match) use ($item) { function($match) use ($item) {
return App::get_baseurl()."/display/".$item['guid']; return $a->get_baseurl()."/display/".$item['guid'];
}, },
$text); $text);
return $text; return $text;
@ -2690,7 +2690,7 @@
$name = $a->config['sitename']; $name = $a->config['sitename'];
$server = $a->get_hostname(); $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']; $email = $a->config['admin_email'];
$closed = (($a->config['register_policy'] == REGISTER_CLOSED) ? 'true' : 'false'); $closed = (($a->config['register_policy'] == REGISTER_CLOSED) ? 'true' : 'false');
$private = (($a->config['system']['block_public']) ? 'true' : 'false'); $private = (($a->config['system']['block_public']) ? 'true' : 'false');
@ -2698,7 +2698,7 @@
if($a->config['api_import_size']) if($a->config['api_import_size'])
$texlimit = string($a->config['api_import_size']); $texlimit = string($a->config['api_import_size']);
$ssl = (($a->config['system']['have_ssl']) ? 'true' : 'false'); $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( $config = array(
'site' => array('name' => $name,'server' => $server, 'theme' => 'default', 'path' => '', 'site' => array('name' => $name,'server' => $server, 'theme' => 'default', 'path' => '',
@ -3075,7 +3075,7 @@
$photo['album'] = $rr['album']; $photo['album'] = $rr['album'];
$photo['filename'] = $rr['filename']; $photo['filename'] = $rr['filename'];
$photo['type'] = $rr['type']; $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") if ($type == "xml")
$data['photo'][] = array("@attributes" => $photo, "1" => $thumb); $data['photo'][] = array("@attributes" => $photo, "1" => $thumb);
@ -3124,11 +3124,11 @@
for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++) for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++)
$data['photo']['links'][$k.":link"]["@attributes"] = array("type" => $data['photo']['type'], $data['photo']['links'][$k.":link"]["@attributes"] = array("type" => $data['photo']['type'],
"scale" => $k, "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 { } else {
$data['photo']['link'] = array(); $data['photo']['link'] = array();
for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++) { 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']); unset($data['photo']['resource-id']);

View File

@ -146,7 +146,7 @@ class exAuth {
* @param array $aCommand The command array * @param array $aCommand The command array
*/ */
private function isuser($aCommand) { private function isuser($aCommand) {
global $a; $a = get_app();
// Check if there is a username // Check if there is a username
if (!isset($aCommand[1])) { if (!isset($aCommand[1])) {
@ -214,7 +214,7 @@ class exAuth {
* @param array $aCommand The command array * @param array $aCommand The command array
*/ */
private function auth($aCommand) { private function auth($aCommand) {
global $a; $a = get_app();
// check user authentication // check user authentication
if (sizeof($aCommand) != 4) { if (sizeof($aCommand) != 4) {

View File

@ -42,7 +42,7 @@ function cron_run(&$argv, &$argc){
// Don't check this stuff if the function is called by the poller // Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") { if (App::callstack() != "poller_run") {
if (App::maxload_reached()) if ($a->maxload_reached())
return; return;
if (App::is_already_running('cron', 'include/cron.php', 540)) if (App::is_already_running('cron', 'include/cron.php', 540))
return; return;

View File

@ -25,7 +25,7 @@ function cronhooks_run(&$argv, &$argc){
// Don't check this stuff if the function is called by the poller // Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") { if (App::callstack() != "poller_run") {
if (App::maxload_reached()) if ($a->maxload_reached())
return; return;
if (App::is_already_running('cronhooks', 'include/cronhooks.php', 1140)) if (App::is_already_running('cronhooks', 'include/cronhooks.php', 1140))
return; return;

View File

@ -35,7 +35,7 @@ class dba {
public $error = false; public $error = false;
function __construct($server, $user, $pass, $db, $install = false) { function __construct($server, $user, $pass, $db, $install = false) {
global $a; $a = get_app();
$stamp1 = microtime(true); $stamp1 = microtime(true);
@ -139,7 +139,7 @@ class dba {
} }
public function q($sql, $onlyquery = false) { public function q($sql, $onlyquery = false) {
global $a; $a = get_app();
if (!$this->db || !$this->connected) { if (!$this->db || !$this->connected) {
return false; return false;

View File

@ -44,7 +44,7 @@ class dba {
public $error = false; public $error = false;
function __construct($server,$user,$pass,$db,$install = false) { function __construct($server,$user,$pass,$db,$install = false) {
global $a; $a = get_app();
# work around, to store the database - configuration in DDDBL # work around, to store the database - configuration in DDDBL
$objDataObjectPool = new \DDDBL\DataObjectPool('Database-Definition'); $objDataObjectPool = new \DDDBL\DataObjectPool('Database-Definition');
@ -99,7 +99,7 @@ class dba {
} }
public function q($sql, $onlyquery = false) { public function q($sql, $onlyquery = false) {
global $a; $a = get_app();
$strHandler = (true === $onlyquery) ? 'PDOStatement' : 'MULTI'; $strHandler = (true === $onlyquery) ? 'PDOStatement' : 'MULTI';

View File

@ -57,7 +57,7 @@ function delivery_run(&$argv, &$argc){
continue; continue;
} }
if (App::maxload_reached()) if ($a->maxload_reached())
return; return;
// It's ours to deliver. Remove it from the queue. // It's ours to deliver. Remove it from the queue.

View File

@ -1443,6 +1443,7 @@ class dfrn {
* @param array $importer Record of the importer user mixed with contact of the content * @param array $importer Record of the importer user mixed with contact of the content
*/ */
private function process_suggestion($xpath, $suggestion, $importer) { private function process_suggestion($xpath, $suggestion, $importer) {
$a = get_app();
logger("Processing suggestions"); logger("Processing suggestions");
@ -1524,7 +1525,7 @@ class dfrn {
"to_email" => $importer["email"], "to_email" => $importer["email"],
"uid" => $importer["importer_uid"], "uid" => $importer["importer_uid"],
"item" => $suggest, "item" => $suggest,
"link" => App::get_baseurl()."/notifications/intros", "link" => $a->get_baseurl()."/notifications/intros",
"source_name" => $importer["name"], "source_name" => $importer["name"],
"source_link" => $importer["url"], "source_link" => $importer["url"],
"source_photo" => $importer["photo"], "source_photo" => $importer["photo"],
@ -1791,6 +1792,8 @@ class dfrn {
* @param int $posted_id The record number of item record that was just posted * @param int $posted_id The record number of item record that was just posted
*/ */
private function do_poke($item, $importer, $posted_id) { private function do_poke($item, $importer, $posted_id) {
$a = get_app();
$verb = urldecode(substr($item["verb"],strpos($item["verb"], "#")+1)); $verb = urldecode(substr($item["verb"],strpos($item["verb"], "#")+1));
if(!$verb) if(!$verb)
return; 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 // send a notification
notification(array( notification(array(
@ -1821,7 +1824,7 @@ class dfrn {
"to_email" => $importer["email"], "to_email" => $importer["email"],
"uid" => $importer["importer_uid"], "uid" => $importer["importer_uid"],
"item" => $item, "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_name" => stripslashes($item["author-name"]),
"source_link" => $item["author-link"], "source_link" => $item["author-link"],
"source_photo" => ((link_compare($item["author-link"],$importer["url"])) "source_photo" => ((link_compare($item["author-link"],$importer["url"]))

View File

@ -26,7 +26,7 @@ function discover_poco_run(&$argv, &$argc){
// Don't check this stuff if the function is called by the poller // Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") if (App::callstack() != "poller_run")
if (App::maxload_reached()) if ($a->maxload_reached())
return; return;
if(($argc > 2) && ($argv[1] == "dirsearch")) { if(($argc > 2) && ($argv[1] == "dirsearch")) {

View File

@ -648,6 +648,7 @@ function notification($params) {
* @param str $defaulttype (Optional) Forces a notification with this type. * @param str $defaulttype (Optional) Forces a notification with this type.
*/ */
function check_item_notification($itemid, $uid, $defaulttype = "") { function check_item_notification($itemid, $uid, $defaulttype = "") {
$a = get_app();
$notification_data = array("uid" => $uid, "profiles" => array()); $notification_data = array("uid" => $uid, "profiles" => array());
call_hooks('check_item_notification', $notification_data); call_hooks('check_item_notification', $notification_data);
@ -666,7 +667,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$profiles[] = $owner[0]["url"]; $profiles[] = $owner[0]["url"];
// Notifications from Diaspora are often with an URL in the Diaspora format // 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(); $profiles2 = array();
@ -720,7 +721,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$params["to_email"] = $user[0]["email"]; $params["to_email"] = $user[0]["email"];
$params["item"] = $item[0]; $params["item"] = $item[0];
$params["parent"] = $item[0]["parent"]; $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["otype"] = 'item';
$params["source_name"] = $item[0]["author-name"]; $params["source_name"] = $item[0]["author-name"];
$params["source_link"] = $item[0]["author-link"]; $params["source_link"] = $item[0]["author-link"];

View File

@ -590,7 +590,7 @@ function process_events ($arr) {
$is_first = ($d !== $last_date); $is_first = ($d !== $last_date);
$last_date = $d; $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')); $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
if(! $title) { if(! $title) {
list($title, $_trash) = explode("<br",bbcode($rr['desc']),2); list($title, $_trash) = explode("<br",bbcode($rr['desc']),2);

View File

@ -1,6 +1,6 @@
<?php <?php
function create_files_from_item($itemid) { function create_files_from_item($itemid) {
global $a; $a = get_app();
$messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `file`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid)); $messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `file`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));

View File

@ -149,6 +149,8 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
} }
function oembed_format_object($j){ function oembed_format_object($j){
$a = get_app();
require_once("mod/proxy.php"); require_once("mod/proxy.php");
$embedurl = $j->embedurl; $embedurl = $j->embedurl;
@ -165,7 +167,7 @@ function oembed_format_object($j){
$th=120; $tw = $th*$tr; $th=120; $tw = $th*$tr;
$tpl=get_markup_template('oembed_video.tpl'); $tpl=get_markup_template('oembed_video.tpl');
$ret.=replace_macros($tpl, array( $ret.=replace_macros($tpl, array(
'$baseurl' => App::get_baseurl(), '$baseurl' => $a->get_baseurl(),
'$embedurl'=>$embedurl, '$embedurl'=>$embedurl,
'$escapedhtml'=>base64_encode($jhtml), '$escapedhtml'=>base64_encode($jhtml),
'$tw'=>$tw, '$tw'=>$tw,
@ -255,12 +257,14 @@ function oembed_format_object($j){
* @see oembed_format_object() * @see oembed_format_object()
*/ */
function oembed_iframe($src, $width, $height) { function oembed_iframe($src, $width, $height) {
$a = get_app();
if (!$height || strstr($height,'%')) { if (!$height || strstr($height,'%')) {
$height = '200'; $height = '200';
} }
$width = '100%'; $width = '100%';
$s = App::get_baseurl() . '/oembed/'.base64url_encode($src); $s = $a->get_baseurl() . '/oembed/'.base64url_encode($src);
return '<iframe onload="resizeIframe(this);" class="embed_rich" height="' . $height . '" width="' . $width . '" src="' . $s . '" allowfullscreen scrolling="no" frameborder="no">' . t('Embedded content') . '</iframe>'; return '<iframe onload="resizeIframe(this);" class="embed_rich" height="' . $height . '" width="' . $width . '" src="' . $s . '" allowfullscreen scrolling="no" frameborder="no">' . t('Embedded content') . '</iframe>';
} }

View File

@ -98,7 +98,7 @@ if(! function_exists('load_translation_table')) {
* @param string $lang language code to load * @param string $lang language code to load
*/ */
function load_translation_table($lang) { function load_translation_table($lang) {
global $a; $a = get_app();
$a->strings = array(); $a->strings = array();
// load enabled plugins strings // load enabled plugins strings

View File

@ -39,7 +39,7 @@ function poller_run($argv, $argc){
return; return;
} }
if (App::maxload_reached()) { if ($a->maxload_reached()) {
return; return;
} }

View File

@ -1728,6 +1728,8 @@ function update_gcontact_from_probe($url) {
* @param int $uid User ID * @param int $uid User ID
*/ */
function update_gcontact_for_user($uid) { function update_gcontact_for_user($uid) {
$a = get_app();
$r = q("SELECT `profile`.`locality`, `profile`.`region`, `profile`.`country-name`, $r = q("SELECT `profile`.`locality`, `profile`.`region`, `profile`.`country-name`,
`profile`.`name`, `profile`.`about`, `profile`.`gender`, `profile`.`name`, `profile`.`about`, `profile`.`gender`,
`profile`.`pub_keywords`, `profile`.`dob`, `profile`.`photo`, `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 // The "addr" field was added in 3.4.3 so it can be empty for older users
if ($r[0]["addr"] != "") 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 else
$addr = $r[0]["addr"]; $addr = $r[0]["addr"];
@ -1754,7 +1756,7 @@ function update_gcontact_for_user($uid) {
"notify" => $r[0]["notify"], "url" => $r[0]["url"], "notify" => $r[0]["notify"], "url" => $r[0]["url"],
"hide" => ($r[0]["hidewall"] OR !$r[0]["net-publish"]), "hide" => ($r[0]["hidewall"] OR !$r[0]["net-publish"]),
"nick" => $r[0]["nickname"], "addr" => $addr, "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); "generation" => 1, "network" => NETWORK_DFRN);
update_gcontact($gcontact); update_gcontact($gcontact);

View File

@ -1,6 +1,6 @@
<?php <?php
function create_tags_from_item($itemid) { function create_tags_from_item($itemid) {
global $a; $a = get_app();
$profile_base = $a->get_baseurl(); $profile_base = $a->get_baseurl();
$profile_data = parse_url($profile_base); $profile_data = parse_url($profile_base);

View File

@ -699,7 +699,7 @@ $LOGGER_LEVELS = array();
* @param int $level * @param int $level
*/ */
function logger($msg, $level = 0) { function logger($msg, $level = 0) {
global $a; $a = get_app();
global $db; global $db;
global $LOGGER_LEVELS; global $LOGGER_LEVELS;

View File

@ -63,7 +63,7 @@ function fbrowser_content($a){
); );
function _map_files1($rr){ function _map_files1($rr){
global $a; $a = get_app();
$types = Photo::supportedTypes(); $types = Photo::supportedTypes();
$ext = $types[$rr['type']]; $ext = $types[$rr['type']];
@ -110,7 +110,8 @@ function fbrowser_content($a){
intval(local_user()) intval(local_user())
); );
function _map_files2($rr){ global $a; function _map_files2($rr){
$a = get_app();
list($m1,$m2) = explode("/",$rr['filetype']); list($m1,$m2) = explode("/",$rr['filetype']);
$filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip"); $filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");

View File

@ -27,7 +27,7 @@ function fetch_init($a){
$parts = parse_url($r[0]["author-link"]); $parts = parse_url($r[0]["author-link"]);
$host = $parts["scheme"]."://".$parts["host"]; $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); $location = $host."/fetch/".$a->argv[1]."/".urlencode($guid);
header("HTTP/1.1 301 Moved Permanently"); header("HTTP/1.1 301 Moved Permanently");

View File

@ -31,7 +31,7 @@ function p_init($a){
$parts = parse_url($r[0]["author-link"]); $parts = parse_url($r[0]["author-link"]);
$host = $parts["scheme"]."://".$parts["host"]; $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"; $location = $host."/p/".urlencode($guid).".xml";
header("HTTP/1.1 301 Moved Permanently"); header("HTTP/1.1 301 Moved Permanently");

View File

@ -21,8 +21,7 @@ class BaseObject {
if(self::$app) if(self::$app)
return self::$app; return self::$app;
global $a; self::$app = get_app();
self::$app = $a;
return self::$app; return self::$app;
} }

View File

@ -127,7 +127,7 @@ class Conversation extends BaseObject {
* _ false on failure * _ false on failure
*/ */
public function get_template_data($conv_responses) { public function get_template_data($conv_responses) {
global $a; $a = get_app();
$result = array(); $result = array();
$i = 0; $i = 0;