- 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>
*/
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');
*/
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'));
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=';
* @return string
*/
function z_root() {
- global $a;
+ $a = get_app();
return $a->get_baseurl();
}
* @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 );
}
* @return string
*/
function current_theme_url() {
- global $a;
+ $a = get_app();
$t = current_theme();
* @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)) {
*/
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
* @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);
*/
public static function delete($family, $key) {
- global $a;
+ $a = get_app();
if (x($a->config[$family],$key)) {
unset($a->config[$family][$key]);
}
* @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)
*/
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
*/
public static function set($uid, $family, $key, $value) {
- global $a;
+ $a = get_app();
$stored = self::get($uid, $family, $key);
*/
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]);
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"]))
$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;
'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']),
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]";
}
}
$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);
$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;
$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');
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' => '',
$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);
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']);
* @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])) {
* @param array $aCommand The command array
*/
private function auth($aCommand) {
- global $a;
+ $a = get_app();
// check user authentication
if (sizeof($aCommand) != 4) {
// 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;
// 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;
public $error = false;
function __construct($server, $user, $pass, $db, $install = false) {
- global $a;
+ $a = get_app();
$stamp1 = microtime(true);
}
public function q($sql, $onlyquery = false) {
- global $a;
+ $a = get_app();
if (!$this->db || !$this->connected) {
return false;
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');
}
public function q($sql, $onlyquery = false) {
- global $a;
+ $a = get_app();
$strHandler = (true === $onlyquery) ? 'PDOStatement' : 'MULTI';
continue;
}
- if (App::maxload_reached())
+ if ($a->maxload_reached())
return;
// It's ours to deliver. Remove it from the queue.
* @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");
"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"],
* @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;
}
}
- 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(
"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"]))
// 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")) {
* @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);
$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();
$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"];
$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("<br",bbcode($rr['desc']),2);
<?php
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));
}
function oembed_format_object($j){
+ $a = get_app();
+
require_once("mod/proxy.php");
$embedurl = $j->embedurl;
$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,
* @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 '<iframe onload="resizeIframe(this);" class="embed_rich" height="' . $height . '" width="' . $width . '" src="' . $s . '" allowfullscreen scrolling="no" frameborder="no">' . t('Embedded content') . '</iframe>';
}
* @param string $lang language code to load
*/
function load_translation_table($lang) {
- global $a;
+ $a = get_app();
$a->strings = array();
// load enabled plugins strings
return;
}
- if (App::maxload_reached()) {
+ if ($a->maxload_reached()) {
return;
}
* @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`,
// 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"];
"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);
<?php
function create_tags_from_item($itemid) {
- global $a;
+ $a = get_app();
$profile_base = $a->get_baseurl();
$profile_data = parse_url($profile_base);
* @param int $level
*/
function logger($msg, $level = 0) {
- global $a;
+ $a = get_app();
global $db;
global $LOGGER_LEVELS;
);
function _map_files1($rr){
- global $a;
+ $a = get_app();
$types = Photo::supportedTypes();
$ext = $types[$rr['type']];
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");
$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");
$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");
if(self::$app)
return self::$app;
- global $a;
- self::$app = $a;
+ self::$app = get_app();
return self::$app;
}
* _ false on failure
*/
public function get_template_data($conv_responses) {
- global $a;
+ $a = get_app();
$result = array();
$i = 0;