diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-04-03 21:36:29 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-04-03 21:36:29 -0400 |
commit | 0523b4b2f1012a8b5f3bffb7f136a20dc9a4e43f (patch) | |
tree | a92197de4503ec52889dc05483493f4df1a305b8 /include | |
parent | 99d9456b3addc651a68874ddd391d25684252c4d (diff) | |
parent | b4c1baada1fba46d4d75f40a7e78111d70d54e7a (diff) | |
download | volse-hubzilla-0523b4b2f1012a8b5f3bffb7f136a20dc9a4e43f.tar.gz volse-hubzilla-0523b4b2f1012a8b5f3bffb7f136a20dc9a4e43f.tar.bz2 volse-hubzilla-0523b4b2f1012a8b5f3bffb7f136a20dc9a4e43f.zip |
Merge branch 'master' of https://github.com/redmatrix/hubzilla into contextual-help
Diffstat (limited to 'include')
47 files changed, 771 insertions, 742 deletions
diff --git a/include/Contact.php b/include/Contact.php index 1c61470e1..507c922d0 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -75,12 +75,12 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { $a = get_app(); if(! $xchan) { - if($a->poi) { - $xchan = $a->poi; + if(App::$poi) { + $xchan = App::$poi; } - elseif(is_array($a->profile) && $a->profile['channel_hash']) { + elseif(is_array(App::$profile) && App::$profile['channel_hash']) { $r = q("select * from xchan where xchan_hash = '%s' limit 1", - dbesc($a->profile['channel_hash']) + dbesc(App::$profile['channel_hash']) ); if($r) $xchan = $r[0]; @@ -102,7 +102,7 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { } if(array_key_exists('channel_id',$xchan)) - $a->profile_uid = $xchan['channel_id']; + App::$profile_uid = $xchan['channel_id']; $url = (($observer) ? z_root() . '/magic?f=&dest=' . $xchan['xchan_url'] . '&addr=' . $xchan['xchan_addr'] @@ -111,7 +111,7 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { return replace_macros(get_markup_template('xchan_vcard.tpl'),array( '$name' => $xchan['xchan_name'], - '$photo' => ((is_array($a->profile) && array_key_exists('photo',$a->profile)) ? $a->profile['photo'] : $xchan['xchan_photo_l']), + '$photo' => ((is_array(App::$profile) && array_key_exists('photo',App::$profile)) ? App::$profile['photo'] : $xchan['xchan_photo_l']), '$follow' => $xchan['xchan_addr'], '$link' => zid($xchan['xchan_url']), '$connect' => $connect, @@ -235,7 +235,7 @@ function account_remove($account_id,$local = true,$unset_session=true) { unset($_SESSION['authenticated']); unset($_SESSION['uid']); notice( sprintf(t("User '%s' deleted"),$account_email) . EOL); - goaway(get_app()->get_baseurl()); + goaway(z_root()); } return $r; @@ -333,19 +333,19 @@ function channel_remove($channel_id, $local = true, $unset_session=false) { ); // if this was the default channel, set another one as default - if($a->account['account_default_channel'] == $channel_id) { + if(App::$account['account_default_channel'] == $channel_id) { $r = q("select channel_id from channel where channel_account_id = %d and channel_removed = 0 limit 1", - intval($a->account['account_id']), + intval(App::$account['account_id']), intval(PAGE_REMOVED)); if ($r) { $rr = q("update account set account_default_channel = %d where account_id = %d", intval($r[0]['channel_id']), - intval($a->account['account_id'])); + intval(App::$account['account_id'])); logger("Default channel deleted, changing default to channel_id " . $r[0]['channel_id']); } else { $rr = q("update account set account_default_channel = 0 where account_id = %d", - intval($a->account['account_id']) + intval(App::$account['account_id']) ); } } @@ -390,7 +390,7 @@ function channel_remove($channel_id, $local = true, $unset_session=false) { if($channel_id == local_channel() && $unset_session) { nuke_session(); - goaway($a->get_baseurl()); + goaway(z_root()); } } diff --git a/include/ConversationObject.php b/include/ConversationObject.php index 66f6cca0e..82f381b0c 100644 --- a/include/ConversationObject.php +++ b/include/ConversationObject.php @@ -48,7 +48,7 @@ class Conversation extends BaseObject { $a = $this->get_app(); - $this->observer = $a->get_observer(); + $this->observer = App::get_observer(); $ob_hash = (($this->observer) ? $this->observer['xchan_hash'] : ''); switch($mode) { @@ -57,7 +57,7 @@ class Conversation extends BaseObject { $this->writable = true; break; case 'channel': - $this->profile_owner = $a->profile['profile_uid']; + $this->profile_owner = App::$profile['profile_uid']; $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); break; case 'display': @@ -67,7 +67,7 @@ class Conversation extends BaseObject { $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); break; case 'page': - $this->profile_owner = $a->profile['uid']; + $this->profile_owner = App::$profile['uid']; $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); break; default: diff --git a/include/Import/import_diaspora.php b/include/Import/import_diaspora.php index a0f473b50..a94e73395 100644 --- a/include/Import/import_diaspora.php +++ b/include/Import/import_diaspora.php @@ -8,7 +8,7 @@ require_once('include/photo/photo_driver.php'); function import_diaspora($data) { $a = get_app(); - $account = $a->get_account(); + $account = App::get_account(); if(! $account) return false; diff --git a/include/ItemObject.php b/include/ItemObject.php index d42e993e6..9d5acd95f 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -97,7 +97,7 @@ class Item extends BaseObject { $mode = $conv->get_mode(); if(local_channel() && $observer['xchan_hash'] === $item['author_xchan']) - $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); + $edpost = array(z_root()."/editpost/".$item['id'], t("Edit")); else $edpost = false; @@ -714,7 +714,7 @@ class Item extends BaseObject { '$feature_encrypt' => ((feature_enabled($conv->get_profile_owner(),'content_encrypt')) ? true : false), '$encrypt' => t('Encrypt text'), '$cipher' => $conv->get_cipher(), - '$sourceapp' => get_app()->sourcename + '$sourceapp' => App::$sourcename )); diff --git a/include/account.php b/include/account.php index 4c828003e..c64197b49 100644 --- a/include/account.php +++ b/include/account.php @@ -248,7 +248,7 @@ function verify_email_address($arr) { $res = mail($arr['email'], email_header_encode(sprintf( t('Registration confirmation for %s'), get_config('system','sitename'))), $email_msg, - 'From: ' . 'Administrator' . '@' . get_app()->get_hostname() . "\n" + 'From: ' . 'Administrator' . '@' . App::get_hostname() . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); @@ -314,7 +314,7 @@ function send_reg_approval_email($arr) { $res = mail($admin['email'], sprintf( t('Registration request at %s'), get_config('system','sitename')), $email_msg, - 'From: ' . t('Administrator') . '@' . get_app()->get_hostname() . "\n" + 'From: ' . t('Administrator') . '@' . App::get_hostname() . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); @@ -341,7 +341,7 @@ function send_register_success_email($email,$password) { $res = mail($email, sprintf( t('Registration details for %s'), get_config('system','sitename')), $email_msg, - 'From: ' . t('Administrator') . '@' . get_app()->get_hostname() . "\n" + 'From: ' . t('Administrator') . '@' . App::get_hostname() . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit' ); @@ -655,7 +655,7 @@ function account_service_class_allows($aid, $property, $usage = false) { function service_class_fetch($uid, $property) { $a = get_app(); if($uid == local_channel()) { - $service_class = $a->account['account_service_class']; + $service_class = App::$account['account_service_class']; } else { $r = q("select account_service_class as service_class diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 3c8f34321..92f9436a2 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -23,7 +23,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { // e.g. 'network_pre_group_deny', 'profile_pre_group_allow' - call_hooks($a->module . '_pre_' . $selname, $arr); + call_hooks(App::$module . '_pre_' . $selname, $arr); if($r) { foreach($r as $rr) { @@ -39,7 +39,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { } $o .= "</select>\r\n"; - call_hooks($a->module . '_post_' . $selname, $o); + call_hooks(App::$module . '_post_' . $selname, $o); return $o; @@ -127,7 +127,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow' - call_hooks($a->module . '_pre_' . $selname, $arr); + call_hooks(App::$module . '_pre_' . $selname, $arr); if(count($r)) { foreach($r as $rr) { @@ -145,7 +145,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { $o .= "</select>\r\n"; - call_hooks($a->module . '_post_' . $selname, $o); + call_hooks(App::$module . '_post_' . $selname, $o); return $o; }*/ @@ -182,7 +182,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow' - call_hooks($a->module . '_pre_' . $selname, $arr); + call_hooks(App::$module . '_pre_' . $selname, $arr); if($r) { foreach($r as $rr) { @@ -200,7 +200,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $o .= "</select>\r\n"; - call_hooks($a->module . '_post_' . $selname, $o); + call_hooks(App::$module . '_post_' . $selname, $o); return $o; } diff --git a/include/activities.php b/include/activities.php index df43f1f6f..9ba191391 100644 --- a/include/activities.php +++ b/include/activities.php @@ -11,7 +11,7 @@ function profile_activity($changed, $value) { require_once('include/items.php'); - $self = $a->get_channel(); + $self = App::get_channel(); if(! count($self)) return; diff --git a/include/api.php b/include/api.php index e78e6cc37..41837ad88 100644 --- a/include/api.php +++ b/include/api.php @@ -34,7 +34,7 @@ require_once('include/api_auth.php'); function api_user() { $aid = get_account_id(); - $channel = get_app()->get_channel(); + $channel = App::get_channel(); if(($aid) && (x($_REQUEST,'channel'))) { @@ -79,7 +79,7 @@ require_once('include/api_auth.php'); $type="json"; foreach ($API as $p=>$info){ - if (strpos($a->query_string, $p)===0){ + if (strpos(App::$query_string, $p)===0){ $called_api= explode("/",$p); //unset($_SERVER['PHP_AUTH_USER']); if ($info['auth'] === true && api_user() === false) { @@ -88,18 +88,18 @@ require_once('include/api_auth.php'); load_contact_links(api_user()); - $channel = $a->get_channel(); + $channel = App::get_channel(); - logger('API call for ' . $channel['channel_name'] . ': ' . $a->query_string); + logger('API call for ' . $channel['channel_name'] . ': ' . App::$query_string); logger('API parameters: ' . print_r($_REQUEST,true)); $type="json"; - if (strpos($a->query_string, ".xml")>0) $type="xml"; - if (strpos($a->query_string, ".json")>0) $type="json"; - if (strpos($a->query_string, ".rss")>0) $type="rss"; - if (strpos($a->query_string, ".atom")>0) $type="atom"; - if (strpos($a->query_string, ".as")>0) $type="as"; + if (strpos(App::$query_string, ".xml")>0) $type="xml"; + if (strpos(App::$query_string, ".json")>0) $type="json"; + if (strpos(App::$query_string, ".rss")>0) $type="rss"; + if (strpos(App::$query_string, ".atom")>0) $type="atom"; + if (strpos(App::$query_string, ".as")>0) $type="as"; $r = call_user_func($info['func'], $a, $type); if ($r===false) return; @@ -141,7 +141,7 @@ require_once('include/api_auth.php'); } } header("HTTP/1.1 404 Not Found"); - logger('API call not implemented: '.$a->query_string." - ".print_r($_REQUEST,true)); + logger('API call not implemented: '.App::$query_string." - ".print_r($_REQUEST,true)); $r = '<status><error>not implemented</error></status>'; switch($type){ case "xml": @@ -171,12 +171,12 @@ require_once('include/api_auth.php'); $arr['$user'] = $user_info; $arr['$rss'] = array( 'alternate' => $user_info['url'], - 'self' => $a->get_baseurl(). "/". $a->query_string, - 'base' => $a->get_baseurl(), + 'self' => z_root(). "/". App::$query_string, + 'base' => z_root(), 'updated' => api_date(null), 'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME), 'language' => $user_info['language'], - 'logo' => $a->get_baseurl()."/images/rm-64.png", + 'logo' => z_root()."/images/rm-64.png", ); return $arr; @@ -213,7 +213,7 @@ require_once('include/api_auth.php'); $extra_query .= " AND abook_channel = ".intval(api_user()); } - if (is_null($user) && argc() > (count($called_api)-1) && (strstr($a->cmd,'/users'))){ + if (is_null($user) && argc() > (count($called_api)-1) && (strstr(App::$cmd,'/users'))){ $argid = count($called_api); list($xx, $null) = explode(".",argv($argid)); if(is_numeric($xx)){ @@ -318,7 +318,7 @@ require_once('include/api_auth.php'); 'location' => ($usr) ? $usr[0]['channel_location'] : '', 'profile_image_url' => $uinfo[0]['xchan_photo_l'], 'url' => $uinfo[0]['xchan_url'], - 'contact_url' => $a->get_baseurl() . "/connections/".$uinfo[0]['abook_id'], + 'contact_url' => z_root() . "/connections/".$uinfo[0]['abook_id'], 'protected' => false, 'friends_count' => intval($countfriends), 'created_at' => api_date($uinfo[0]['abook_created']), @@ -326,7 +326,7 @@ require_once('include/api_auth.php'); 'time_zone' => 'UTC', //$uinfo[0]['timezone'], 'geo_enabled' => false, 'statuses_count' => intval($countitms), //#XXX: fix me - 'lang' => get_app()->language, + 'lang' => App::$language, 'description' => (($profile) ? $profile[0]['pdesc'] : ''), 'followers_count' => intval($countfollowers), 'favourites_count' => intval($starred), @@ -635,13 +635,13 @@ require_once('include/api_auth.php'); function api_albums(&$a,$type) { - json_return_and_die(photos_albums_list($a->get_channel(),$a->get_observer())); + json_return_and_die(photos_albums_list(App::get_channel(),App::get_observer())); } api_register_func('api/red/albums','api_albums', true); function api_photos(&$a,$type) { $album = $_REQUEST['album']; - json_return_and_die(photos_list_photos($a->get_channel(),$a->get_observer(),$album)); + json_return_and_die(photos_list_photos(App::get_channel(),App::get_observer(),$album)); } api_register_func('api/red/photos','api_photos', true); @@ -768,7 +768,7 @@ require_once('include/api_auth.php'); } $txt = html2bbcode($txt); - $a->argv[1] = $user_info['screen_name']; + App::$argv[1] = $user_info['screen_name']; $_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo $_FILES['userfile'] = $_FILES['media']; @@ -872,7 +872,7 @@ require_once('include/api_auth.php'); // upload each image if we have any $_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo require_once('mod/wall_attach.php'); - $a->data['api_info'] = $user_info; + App::$data['api_info'] = $user_info; $media = wall_attach_post($a); if(strlen($media)>0) @@ -885,7 +885,7 @@ require_once('include/api_auth.php'); // upload each image if we have any $_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo require_once('mod/wall_attach.php'); - $a->data['api_info'] = $user_info; + App::$data['api_info'] = $user_info; $media = wall_attach_post($a); if(strlen($media)>0) @@ -960,7 +960,7 @@ require_once('include/api_auth.php'); $arr['records'] = 999999; $arr['item_type'] = '*'; - $i = items_fetch($arr,$a->get_channel(),get_observer_hash()); + $i = items_fetch($arr,App::get_channel(),get_observer_hash()); if(! $i) json_return_and_die(array()); @@ -1230,7 +1230,7 @@ require_once('include/api_auth.php'); $sql_extra .= ' AND `item`.`parent` = `item`.`id`'; if (api_user() != $user_info['uid']) { - $observer = get_app()->get_observer(); + $observer = App::get_observer(); require_once('include/permissions.php'); if(! perm_is_allowed($user_info['uid'],(($observer) ? $observer['xchan_hash'] : ''),'view_stream')) return ''; @@ -1272,8 +1272,8 @@ require_once('include/api_auth.php'); break; case "as": $as = api_format_as($a, $ret, $user_info); - $as['title'] = $a->config['sitename']." Home Timeline"; - $as['link']['url'] = $a->get_baseurl()."/".$user_info["screen_name"]."/all"; + $as['title'] = App::$config['sitename']." Home Timeline"; + $as['link']['url'] = z_root()."/".$user_info["screen_name"]."/all"; return($as); break; } @@ -1333,8 +1333,8 @@ require_once('include/api_auth.php'); break; case "as": $as = api_format_as($a, $ret, $user_info); - $as['title'] = $a->config['sitename']. " " . t('Public Timeline'); - $as['link']['url'] = $a->get_baseurl()."/"; + $as['title'] = App::$config['sitename']. " " . t('Public Timeline'); + $as['link']['url'] = z_root()."/"; return($as); break; } @@ -1409,7 +1409,7 @@ require_once('include/api_auth.php'); //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); - $observer = get_app()->get_observer(); + $observer = App::get_observer(); $item_normal = item_normal(); @@ -1526,7 +1526,7 @@ require_once('include/api_auth.php'); //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); - $myurl = $a->get_baseurl() . '/channel/'. $a->user['nickname']; + $myurl = z_root() . '/channel/'. App::$user['nickname']; $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/channel/','/u/',$myurl); @@ -1561,8 +1561,8 @@ require_once('include/api_auth.php'); break; case "as": $as = api_format_as($a, $ret, $user_info); - $as["title"] = $a->config['sitename']." Mentions"; - $as['link']['url'] = $a->get_baseurl()."/"; + $as["title"] = App::$config['sitename']." Mentions"; + $as['link']['url'] = z_root()."/"; return($as); break; } @@ -1633,7 +1633,7 @@ require_once('include/api_auth.php'); $arr['cid'] = $user_info['id']; - $r = items_fetch($arr,get_app()->get_channel(),get_observer_hash()); + $r = items_fetch($arr,App::get_channel(),get_observer_hash()); $ret = api_format_items($r,$user_info); @@ -1752,7 +1752,7 @@ require_once('include/api_auth.php'); $sql_extra .= ' AND `item`.`parent` = `item`.`id`'; if (api_user() != $user_info['uid']) { - $observer = get_app()->get_observer(); + $observer = App::get_observer(); require_once('include/permissions.php'); if(! perm_is_allowed($user_info['uid'],(($observer) ? $observer['xchan_hash'] : ''),'view_stream')) return ''; @@ -1783,8 +1783,8 @@ require_once('include/api_auth.php'); break; case "as": $as = api_format_as($a, $ret, $user_info); - $as['title'] = $a->config['sitename']." Home Timeline"; - $as['link']['url'] = $a->get_baseurl()."/".$user_info["screen_name"]."/all"; + $as['title'] = App::$config['sitename']." Home Timeline"; + $as['link']['url'] = z_root()."/".$user_info["screen_name"]."/all"; return($as); break; } @@ -1801,7 +1801,7 @@ require_once('include/api_auth.php'); function api_format_as($a, $ret, $user_info) { $as = array(); - $as['title'] = $a->config['sitename']." Public Timeline"; + $as['title'] = App::$config['sitename']." Public Timeline"; $items = array(); foreach ($ret as $item) { $singleitem["actor"]["displayName"] = $item["user"]["name"]; @@ -1857,7 +1857,7 @@ require_once('include/api_auth.php'); $items[] = $singleitem; } $as['items'] = $items; - $as['link']['url'] = $a->get_baseurl()."/".$user_info["screen_name"]."/all"; + $as['link']['url'] = z_root()."/".$user_info["screen_name"]."/all"; $as['link']['rel'] = "alternate"; $as['link']['type'] = "text/html"; return($as); @@ -1978,8 +1978,8 @@ require_once('include/api_auth.php'); 'entities' => '', 'objecttype' => (($item['obj_type']) ? $item['obj_type'] : ACTIVITY_OBJ_NOTE), 'verb' => (($item['verb']) ? $item['verb'] : ACTIVITY_POST), - 'self' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type, - 'edit' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type, + 'self' => z_root()."/api/statuses/show/".$item['id'].".".$type, + 'edit' => z_root()."/api/statuses/show/".$item['id'].".".$type, ); $status = array_merge($status, $status2); @@ -2088,8 +2088,8 @@ require_once('include/api_auth.php'); load_config('system'); $name = get_config('system','sitename'); - $server = $a->get_hostname(); - $logo = $a->get_baseurl() . '/images/rm-64.png'; + $server = App::get_hostname(); + $logo = z_root() . '/images/rm-64.png'; $email = get_config('system','admin_email'); $closed = ((get_config('system','register_policy') == REGISTER_CLOSED) ? 'true' : 'false'); $private = ((get_config('system','block_public')) ? 'true' : 'false'); @@ -2097,7 +2097,7 @@ require_once('include/api_auth.php'); if(get_config('system','api_import_size')) $texlimit = string(get_config('system','api_import_size')); $ssl = ((get_config('system','have_ssl')) ? 'true' : 'false'); - $sslserver = (($ssl === 'true') ? str_replace('http:','https:',$a->get_baseurl()) : ''); + $sslserver = (($ssl === 'true') ? str_replace('http:','https:',z_root()) : ''); $config = array( 'site' => array('name' => $name,'server' => $server, 'theme' => 'default', 'path' => '', @@ -2270,9 +2270,9 @@ require_once('include/api_auth.php'); if ($page<0) $page=0; $start = $page*$count; - $channel = $a->get_channel(); + $channel = App::get_channel(); - $profile_url = $a->get_baseurl() . '/channel/' . $channel['channel_address']; + $profile_url = z_root() . '/channel/' . $channel['channel_address']; if ($box=="sentbox") { $sql_extra = "`from_xchan`='".dbesc( $channel['channel_hash'] )."'"; } diff --git a/include/api_auth.php b/include/api_auth.php index 26a9df8d4..dc8492b20 100644 --- a/include/api_auth.php +++ b/include/api_auth.php @@ -20,9 +20,9 @@ function api_login(&$a){ if (!is_null($token)){ $oauth->loginUser($token->uid); - $a->set_oauth_key($consumer->key); + App::set_oauth_key($consumer->key); - call_hooks('logged_in', $a->user); + call_hooks('logged_in', App::$user); return; } killme(); diff --git a/include/apps.php b/include/apps.php index 0a62dc5a8..fac58b850 100644 --- a/include/apps.php +++ b/include/apps.php @@ -48,12 +48,12 @@ function parse_app_description($f) { $ret = array(); $baseurl = z_root(); - $channel = get_app()->get_channel(); + $channel = App::get_channel(); $address = (($channel) ? $channel['channel_address'] : ''); //future expansion - $observer = get_app()->get_observer(); + $observer = App::get_observer(); $lines = @file($f); @@ -217,7 +217,7 @@ function app_render($papp,$mode = 'view') { return ''; break; case 'observer': - $observer = get_app()->get_observer(); + $observer = App::get_observer(); if(! $observer) return ''; break; @@ -239,7 +239,7 @@ function app_render($papp,$mode = 'view') { $hosturl = z_root() . '/'; } elseif(remote_channel()) { - $observer = get_app()->get_observer(); + $observer = App::get_observer(); if($observer && $observer['xchan_network'] === 'zot') { // some folks might have xchan_url redirected offsite, use the connurl $x = parse_url($observer['xchan_connurl']); @@ -354,7 +354,7 @@ function app_store($arr) { } - $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string(). '.' . get_app()->get_hostname()); + $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string(). '.' . App::get_hostname()); $darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); $darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash()); $darray['app_name'] = ((x($arr,'name')) ? escape_tags($arr['name']) : t('Unknown')); diff --git a/include/attach.php b/include/attach.php index 343922a52..4ecc273e9 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1477,7 +1477,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, require_once('include/items.php'); - $poster = get_app()->get_observer(); + $poster = App::get_observer(); //if we got no object something went wrong if(!$object) @@ -1696,7 +1696,7 @@ function recursive_activity_recipients($arr_allow_cid, $arr_allow_gid, $arr_deny $ret = array(); $parent_arr = array(); $count_values = array(); - $poster = get_app()->get_observer(); + $poster = App::get_observer(); //turn allow_gid into allow_cid's foreach($arr_allow_gid as $gid) { diff --git a/include/auth.php b/include/auth.php index 1a7110c20..aaec45c40 100644 --- a/include/auth.php +++ b/include/auth.php @@ -97,7 +97,7 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && // process a logout request - if(((x($_POST, 'auth-params')) && ($_POST['auth-params'] === 'logout')) || ($a->module === 'logout')) { + if(((x($_POST, 'auth-params')) && ($_POST['auth-params'] === 'logout')) || (App::$module === 'logout')) { // process logout request $args = array('channel_id' => local_channel()); call_hooks('logging_out', $args); @@ -128,13 +128,13 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && dbesc($_SESSION['visitor_id']) ); if($r) { - get_app()->set_observer($r[0]); + App::set_observer($r[0]); } else { unset($_SESSION['visitor_id']); unset($_SESSION['authenticated']); } - $a->set_groups(init_groups_visitor($_SESSION['visitor_id'])); + App::set_groups(init_groups_visitor($_SESSION['visitor_id'])); } // already logged in user returning @@ -183,7 +183,7 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && ); if(($r) && (($r[0]['account_flags'] == ACCOUNT_OK) || ($r[0]['account_flags'] == ACCOUNT_UNVERIFIED))) { - get_app()->account = $r[0]; + App::$account = $r[0]; $login_refresh = false; if(! x($_SESSION,'last_login_date')) { $_SESSION['last_login_date'] = datetime_convert('UTC','UTC'); @@ -237,16 +237,16 @@ else { $record = $addon_auth['user_record']; } else { - $record = get_app()->account = account_verify_password($_POST['username'], $_POST['password']); + $record = App::$account = account_verify_password($_POST['username'], $_POST['password']); - if(get_app()->account) { - $_SESSION['account_id'] = get_app()->account['account_id']; + if(App::$account) { + $_SESSION['account_id'] = App::$account['account_id']; } else { notice( t('Failed authentication') . EOL); } - logger('authenticate: ' . print_r(get_app()->account, true), LOGGER_DEBUG); + logger('authenticate: ' . print_r(App::$account, true), LOGGER_DEBUG); } if((! $record) || (! count($record))) { diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 81b95b30b..1ed57bfd4 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -473,7 +473,7 @@ function format_event_diaspora($ev) { $ev['start'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['start'] , $bd_format))) - . '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n"; + . '](' . z_root() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n"; if(! $ev['nofinish']) $o .= t('Finishes:') . ' ' . '[' @@ -481,7 +481,7 @@ function format_event_diaspora($ev) { $ev['finish'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['finish'] , $bd_format ))) - . '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n"; + . '](' . z_root() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n"; if(strlen($ev['location'])) $o .= t('Location:') . bb2diaspora($ev['location']) diff --git a/include/bbcode.php b/include/bbcode.php index eefe7fe98..c2ff5d7c8 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -37,7 +37,7 @@ function tryzrlvideo($match) { if($zrl) $link = zid($link); - return '<video controls="controls" preload="none" src="' . str_replace(' ','%20',$link) . '" style="width:100%; max-width:' . get_app()->videowidth . 'px"><a href="' . str_replace(' ','%20',$link) . '">' . $link . '</a></video>'; + return '<video controls="controls" preload="none" src="' . str_replace(' ','%20',$link) . '" style="width:100%; max-width:' . App::$videowidth . 'px"><a href="' . str_replace(' ','%20',$link) . '">' . $link . '</a></video>'; } // [noparse][i]italic[/i][/noparse] turns into @@ -280,9 +280,9 @@ function bb_location($match) { function bb_iframe($match) { $a = get_app(); - $sandbox = ((strpos($match[1], $a->get_hostname())) ? ' sandbox="allow-scripts" ' : ''); + $sandbox = ((strpos($match[1], App::get_hostname())) ? ' sandbox="allow-scripts" ' : ''); - return '<iframe ' . $sandbox . ' src="' . $match[1] . '" width="' . $a->videowidth . '" height="' . $a->videoheight . '"><a href="' . $match[1] . '">' . $match[1] . '</a></iframe>'; + return '<iframe ' . $sandbox . ' src="' . $match[1] . '" width="' . App::$videowidth . '" height="' . App::$videoheight . '"><a href="' . $match[1] . '">' . $match[1] . '</a></iframe>'; } function bb_ShareAttributesSimple($match) { @@ -315,9 +315,9 @@ function bb_ShareAttributesSimple($match) { function rpost_callback($match) { if ($match[2]) { - return str_replace($match[0], get_rpost_path(get_app()->get_observer()) . '&title=' . urlencode($match[2]) . '&body=' . urlencode($match[3]), $match[0]); + return str_replace($match[0], get_rpost_path(App::get_observer()) . '&title=' . urlencode($match[2]) . '&body=' . urlencode($match[3]), $match[0]); } else { - return str_replace($match[0], get_rpost_path(get_app()->get_observer()) . '&body=' . urlencode($match[3]), $match[0]); + return str_replace($match[0], get_rpost_path(App::get_observer()) . '&body=' . urlencode($match[3]), $match[0]); } } @@ -401,7 +401,7 @@ function bb_observer($Text) { $a = get_app(); - $observer = $a->get_observer(); + $observer = App::get_observer(); if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) { if ($observer) { @@ -415,7 +415,7 @@ function bb_observer($Text) { } } - $channel = $a->get_channel(); + $channel = App::get_channel(); if (strpos($Text,'[/channel]') !== false) { if ($channel) { @@ -477,7 +477,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) if($cache) $observer = false; else - $observer = $a->get_observer(); + $observer = App::get_observer(); if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) { if ($observer) { @@ -494,7 +494,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) if($cache) $channel = false; else - $channel = $a->get_channel(); + $channel = App::get_channel(); if (strpos($Text,'[/channel]') !== false) { if ($channel) { @@ -850,7 +850,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) // crypt if (strpos($Text,'[/crypt]') !== false) { $x = random_string(); - $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br /><div id="' . $x . '"><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" onclick="red_decrypt(\'rot13\',\'\',\'$1\',\'#' . $x . '\');" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br /></div>', $Text); + $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br /><div id="' . $x . '"><img src="' .z_root() . '/images/lock_icon.gif" onclick="red_decrypt(\'rot13\',\'\',\'$1\',\'#' . $x . '\');" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br /></div>', $Text); $Text = preg_replace_callback("/\[crypt (.*?)\](.*?)\[\/crypt\]/ism", 'bb_parse_crypt', $Text); } @@ -930,7 +930,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) // $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism", '[youtube]$1[/youtube]', $Text); // if ($tryoembed) -// $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="http://www.youtube.com/embed/$1" frameborder="0"></iframe>', $Text); +// $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . App::$videowidth . '" height="' . App::$videoheight . '" src="http://www.youtube.com/embed/$1" frameborder="0"></iframe>', $Text); // else // $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", "http://www.youtube.com/watch?v=$1", $Text); // } @@ -944,7 +944,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) // $Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism", '[vimeo]$1[/vimeo]', $Text); // if ($tryoembed) -// $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="http://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $Text); +// $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . App::$videowidth . '" height="' . App::$videoheight . '" src="http://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $Text); // else // $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", "http://vimeo.com/$1", $Text); // } diff --git a/include/chat.php b/include/chat.php index 81c5c5d62..604402045 100644 --- a/include/chat.php +++ b/include/chat.php @@ -202,7 +202,7 @@ function chatroom_list($uid) { require_once('include/security.php'); $sql_extra = permissions_sql($uid); - $r = q("select cr_name, cr_id, count(cp_id) as cr_inroom from chatroom left join chatpresence on cr_id = cp_room where cr_uid = %d $sql_extra group by cr_name, cr_id order by cr_name", + $r = q("select allow_cid, allow_gid, deny_cid, deny_gid, cr_name, cr_expire, cr_id, count(cp_id) as cr_inroom from chatroom left join chatpresence on cr_id = cp_room where cr_uid = %d $sql_extra group by cr_name, cr_id order by cr_name", intval($uid) ); diff --git a/include/cli_startup.php b/include/cli_startup.php index 70ab1a24a..b0e4fcf10 100644 --- a/include/cli_startup.php +++ b/include/cli_startup.php @@ -9,17 +9,21 @@ function cli_startup() { global $a, $db, $default_timezone; if(is_null($a)) { - $a = new App; + $a = new miniApp; } + + App::init(); if(is_null($db)) { @include(".htconfig.php"); + $a->convert(); + if(! defined('UNO')) define('UNO', 0); - $a->timezone = ((x($default_timezone)) ? $default_timezone : 'UTC'); - date_default_timezone_set($a->timezone); + App::$timezone = ((x($default_timezone)) ? $default_timezone : 'UTC'); + date_default_timezone_set(App::$timezone); require_once('include/dba/dba_driver.php'); $db = dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type); @@ -30,7 +34,7 @@ function cli_startup() { load_config('system'); - $a->set_baseurl(get_config('system','baseurl')); + App::set_baseurl(get_config('system','baseurl')); load_hooks(); diff --git a/include/comanche.php b/include/comanche.php index ddf331321..4d55aee19 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -56,34 +56,34 @@ function comanche_parser(&$a, $s, $pass = 0) { if($pass == 0) { $cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $s, $matches); if($cnt) - $a->page['template'] = trim($matches[1]); + App::$page['template'] = trim($matches[1]); $cnt = preg_match("/\[template=(.*?)\](.*?)\[\/template\]/ism", $s, $matches); if($cnt) { - $a->page['template'] = trim($matches[2]); - $a->page['template_style'] = trim($matches[2]) . '_' . $matches[1]; + App::$page['template'] = trim($matches[2]); + App::$page['template_style'] = trim($matches[2]) . '_' . $matches[1]; } $cnt = preg_match("/\[template\](.*?)\[\/template\]/ism", $s, $matches); if($cnt) { - $a->page['template'] = trim($matches[1]); + App::$page['template'] = trim($matches[1]); } $cnt = preg_match("/\[theme=(.*?)\](.*?)\[\/theme\]/ism", $s, $matches); if($cnt) { - $a->layout['schema'] = trim($matches[1]); - $a->layout['theme'] = trim($matches[2]); + App::$layout['schema'] = trim($matches[1]); + App::$layout['theme'] = trim($matches[2]); } $cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $s, $matches); if($cnt) - $a->layout['theme'] = trim($matches[1]); + App::$layout['theme'] = trim($matches[1]); $cnt = preg_match_all("/\[webpage\](.*?)\[\/webpage\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { // only the last webpage definition is used if there is more than one foreach($matches as $mtch) { - $a->layout['webpage'] = comanche_webpage($a,$mtch[1]); + App::$layout['webpage'] = comanche_webpage($a,$mtch[1]); } } @@ -92,7 +92,7 @@ function comanche_parser(&$a, $s, $pass = 0) { $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { - $a->layout['region_' . $mtch[1]] = comanche_region($a,$mtch[2]); + App::$layout['region_' . $mtch[1]] = comanche_region($a,$mtch[2]); } } @@ -122,8 +122,8 @@ function comanche_menu($s, $class = '') { function comanche_replace_region($match) { $a = get_app(); - if (array_key_exists($match[1], $a->page)) { - return $a->page[$match[1]]; + if (array_key_exists($match[1], App::$page)) { + return App::$page[$match[1]]; } } @@ -136,7 +136,7 @@ function comanche_replace_region($match) { * @return channel_id */ function comanche_get_channel_id() { - $channel_id = ((is_array(get_app()->profile)) ? get_app()->profile['profile_uid'] : 0); + $channel_id = ((is_array(App::$profile)) ? App::$profile['profile_uid'] : 0); if ((! $channel_id) && (local_channel())) $channel_id = local_channel(); @@ -190,7 +190,7 @@ function comanche_block($s, $class = '') { } if(trim($r[0]['body']) === '$content') { - $o .= get_app()->page['content']; + $o .= App::$page['content']; } else { $o .= prepare_text($r[0]['body'], $r[0]['mimetype']); @@ -378,6 +378,6 @@ function comanche_region(&$a, $s) { function register_page_template($arr) { - get_app()->page_layouts[$arr['template']] = array($arr['variant']); + App::$page_layouts[$arr['template']] = array($arr['variant']); return; } diff --git a/include/config.php b/include/config.php index 51d4e99ac..712b4ca11 100644 --- a/include/config.php +++ b/include/config.php @@ -22,7 +22,7 @@ * an identifier. This is for example for people who do not have a local account. * The storage is of size MEDIUMTEXT. * @code{.php} - * $observer = $a->get_observer_hash(); + * $observer = App::get_observer_hash(); * if ($observer) { * $var = get_xconfig($observer, 'category', 'key'); * }@endcode @@ -38,7 +38,7 @@ * @brief Loads the hub's configuration from database to a cached storage. * * Retrieve a category ($family) of config variables from database to a cached - * storage in the global $a->config[$family]. + * storage in the global App::$config[$family]. * * @param string $family * The category of the configuration value @@ -46,19 +46,19 @@ function load_config($family) { global $a; - if(! array_key_exists($family, $a->config)) - $a->config[$family] = array(); + if(! array_key_exists($family, App::$config)) + App::$config[$family] = array(); - if(! array_key_exists('config_loaded', $a->config[$family])) { + if(! array_key_exists('config_loaded', App::$config[$family])) { $r = q("SELECT * FROM config WHERE cat = '%s'", dbesc($family)); if($r !== false) { if($r) { foreach($r as $rr) { $k = $rr['k']; - $a->config[$family][$k] = $rr['v']; + App::$config[$family][$k] = $rr['v']; } } - $a->config[$family]['config_loaded'] = true; + App::$config[$family]['config_loaded'] = true; } } } @@ -68,7 +68,7 @@ function load_config($family) { * and a key. * * Get a particular config variable from the given category ($family) and the - * $key from a cached storage in $a->config[$family]. If a key is found in the + * $key from a cached storage in App::$config[$family]. If a key is found in the * DB but does not exist in local config cache, pull it into the cache so we * do not have to hit the DB again for this item. * @@ -83,16 +83,16 @@ function load_config($family) { function get_config($family, $key) { global $a; - if((! array_key_exists($family, $a->config)) || (! array_key_exists('config_loaded', $a->config[$family]))) + if((! array_key_exists($family, App::$config)) || (! array_key_exists('config_loaded', App::$config[$family]))) load_config($family); - if(array_key_exists('config_loaded', $a->config[$family])) { - if(! array_key_exists($key, $a->config[$family])) { + if(array_key_exists('config_loaded', App::$config[$family])) { + if(! array_key_exists($key, App::$config[$family])) { return false; } - return ((! is_array($a->config[$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', $a->config[$family][$key])) - ? unserialize($a->config[$family][$key]) - : $a->config[$family][$key] + return ((! is_array(App::$config[$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', App::$config[$family][$key])) + ? unserialize(App::$config[$family][$key]) + : App::$config[$family][$key] ); } return false; @@ -148,7 +148,7 @@ function set_config($family, $key, $value) { dbesc($dbvalue) ); if($ret) { - $a->config[$family][$key] = $value; + App::$config[$family][$key] = $value; $ret = $value; } return $ret; @@ -161,7 +161,7 @@ function set_config($family, $key, $value) { ); if($ret) { - $a->config[$family][$key] = $value; + App::$config[$family][$key] = $value; $ret = $value; } return $ret; @@ -170,7 +170,7 @@ function set_config($family, $key, $value) { /** * @brief Deletes the given key from the hub's configuration database. * - * Removes the configured value from the stored cache in $a->config[$family] + * Removes the configured value from the stored cache in App::$config[$family] * and removes it from the database. * * @param string $family @@ -183,8 +183,8 @@ function del_config($family, $key) { global $a; $ret = false; - if(array_key_exists($family, $a->config) && array_key_exists($key, $a->config[$family])) - unset($a->config[$family][$key]); + if(array_key_exists($family, App::$config) && array_key_exists($key, App::$config[$family])) + unset(App::$config[$family][$key]); $ret = q("DELETE FROM config WHERE cat = '%s' AND k = '%s'", dbesc($family), dbesc($key) @@ -197,7 +197,7 @@ function del_config($family, $key) { * @brief Loads all configuration values of a channel into a cached storage. * * All configuration values of the given channel are stored in global cache - * which is available under the global variable $a->config[$uid]. + * which is available under the global variable App::$config[$uid]. * * @param string $uid * The channel_id @@ -209,8 +209,8 @@ function load_pconfig($uid) { if($uid === false) return false; - if(! array_key_exists($uid, $a->config)) - $a->config[$uid] = array(); + if(! array_key_exists($uid, App::$config)) + App::$config[$uid] = array(); $r = q("SELECT * FROM pconfig WHERE uid = %d", intval($uid) @@ -220,11 +220,11 @@ function load_pconfig($uid) { foreach($r as $rr) { $k = $rr['k']; $c = $rr['cat']; - if(! array_key_exists($c, $a->config[$uid])) { - $a->config[$uid][$c] = array(); - $a->config[$uid][$c]['config_loaded'] = true; + if(! array_key_exists($c, App::$config[$uid])) { + App::$config[$uid][$c] = array(); + App::$config[$uid][$c]['config_loaded'] = true; } - $a->config[$uid][$c][$k] = $rr['v']; + App::$config[$uid][$c][$k] = $rr['v']; } } } @@ -234,7 +234,7 @@ function load_pconfig($uid) { * ($family) and a key. * * Get a particular channel's config value from the given category ($family) - * and the $key from a cached storage in $a->config[$uid]. + * and the $key from a cached storage in App::$config[$uid]. * * Returns false if not set. * @@ -254,15 +254,15 @@ function get_pconfig($uid, $family, $key, $instore = false) { if($uid === false) return false; - if(! array_key_exists($uid, $a->config)) + if(! array_key_exists($uid, App::$config)) load_pconfig($uid); - if((! array_key_exists($family, $a->config[$uid])) || (! array_key_exists($key, $a->config[$uid][$family]))) + if((! array_key_exists($family, App::$config[$uid])) || (! array_key_exists($key, App::$config[$uid][$family]))) return false; - return ((! is_array($a->config[$uid][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', $a->config[$uid][$family][$key])) - ? unserialize($a->config[$uid][$family][$key]) - : $a->config[$uid][$family][$key] + return ((! is_array(App::$config[$uid][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', App::$config[$uid][$family][$key])) + ? unserialize(App::$config[$uid][$family][$key]) + : App::$config[$uid][$family][$key] ); } @@ -287,27 +287,38 @@ function get_pconfig($uid, $family, $key, $instore = false) { function set_pconfig($uid, $family, $key, $value) { global $a; + // this catches subtle errors where this function has been called + // with local_channel() when not logged in (which returns false) + // and throws an error in array_key_exists below. + // we provide a function backtrace in the logs so that we can find + // and fix the calling function. + + if($uid === false) { + btlogger('UID is FALSE!', LOGGER_NORMAL, LOG_ERR); + return; + } + // manage array value $dbvalue = ((is_array($value)) ? serialize($value) : $value); $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue); if(get_pconfig($uid, $family, $key) === false) { - if(! array_key_exists($uid, $a->config)) - $a->config[$uid] = array(); - if(! array_key_exists($family, $a->config[$uid])) - $a->config[$uid][$family] = array(); + if(! array_key_exists($uid, App::$config)) + App::$config[$uid] = array(); + if(! array_key_exists($family, App::$config[$uid])) + App::$config[$uid][$family] = array(); // keep a separate copy for all variables which were // set in the life of this page. We need this to // synchronise channel clones. - if(! array_key_exists('transient', $a->config[$uid])) - $a->config[$uid]['transient'] = array(); - if(! array_key_exists($family, $a->config[$uid]['transient'])) - $a->config[$uid]['transient'][$family] = array(); + if(! array_key_exists('transient', App::$config[$uid])) + App::$config[$uid]['transient'] = array(); + if(! array_key_exists($family, App::$config[$uid]['transient'])) + App::$config[$uid]['transient'][$family] = array(); - $a->config[$uid][$family][$key] = $value; - $a->config[$uid]['transient'][$family][$key] = $value; + App::$config[$uid][$family][$key] = $value; + App::$config[$uid]['transient'][$family][$key] = $value; $ret = q("INSERT INTO pconfig ( uid, cat, k, v ) VALUES ( %d, '%s', '%s', '%s' ) ", intval($uid), @@ -332,13 +343,13 @@ function set_pconfig($uid, $family, $key, $value) { // set in the life of this page. We need this to // synchronise channel clones. - if(! array_key_exists('transient', $a->config[$uid])) - $a->config[$uid]['transient'] = array(); - if(! array_key_exists($family, $a->config[$uid]['transient'])) - $a->config[$uid]['transient'][$family] = array(); + if(! array_key_exists('transient', App::$config[$uid])) + App::$config[$uid]['transient'] = array(); + if(! array_key_exists($family, App::$config[$uid]['transient'])) + App::$config[$uid]['transient'][$family] = array(); - $a->config[$uid][$family][$key] = $value; - $a->config[$uid]['transient'][$family][$key] = $value; + App::$config[$uid][$family][$key] = $value; + App::$config[$uid]['transient'][$family][$key] = $value; if($ret) return $value; @@ -349,7 +360,7 @@ function set_pconfig($uid, $family, $key, $value) { /** * @brief Deletes the given key from the channel's configuration. * - * Removes the configured value from the stored cache in $a->config[$uid] + * Removes the configured value from the stored cache in App::$config[$uid] * and removes it from the database. * * @param string $uid @@ -364,8 +375,8 @@ function del_pconfig($uid, $family, $key) { global $a; $ret = false; - if (x($a->config[$uid][$family], $key)) - unset($a->config[$uid][$family][$key]); + if (x(App::$config[$uid][$family], $key)) + unset(App::$config[$uid][$family][$key]); $ret = q("DELETE FROM pconfig WHERE uid = %d AND cat = '%s' AND k = '%s'", intval($uid), dbesc($family), @@ -380,7 +391,7 @@ function del_pconfig($uid, $family, $key) { * @brief Loads a full xchan's configuration into a cached storage. * * All configuration values of the given observer hash are stored in global - * cache which is available under the global variable $a->config[$xchan]. + * cache which is available under the global variable App::$config[$xchan]. * * @param string $xchan * The observer's hash @@ -392,8 +403,8 @@ function load_xconfig($xchan) { if(! $xchan) return false; - if(! array_key_exists($xchan, $a->config)) - $a->config[$xchan] = array(); + if(! array_key_exists($xchan, App::$config)) + App::$config[$xchan] = array(); $r = q("SELECT * FROM xconfig WHERE xchan = '%s'", dbesc($xchan) @@ -403,11 +414,11 @@ function load_xconfig($xchan) { foreach($r as $rr) { $k = $rr['k']; $c = $rr['cat']; - if(! array_key_exists($c, $a->config[$xchan])) { - $a->config[$xchan][$c] = array(); - $a->config[$xchan][$c]['config_loaded'] = true; + if(! array_key_exists($c, App::$config[$xchan])) { + App::$config[$xchan][$c] = array(); + App::$config[$xchan][$c]['config_loaded'] = true; } - $a->config[$xchan][$c][$k] = $rr['v']; + App::$config[$xchan][$c][$k] = $rr['v']; } } } @@ -417,7 +428,7 @@ function load_xconfig($xchan) { * name ($family) and a key. * * Get a particular observer's config value from the given category ($family) - * and the $key from a cached storage in $a->config[$xchan]. + * and the $key from a cached storage in App::$config[$xchan]. * * Returns false if not set. * @@ -435,15 +446,15 @@ function get_xconfig($xchan, $family, $key) { if(! $xchan) return false; - if(! array_key_exists($xchan, $a->config)) + if(! array_key_exists($xchan, App::$config)) load_xconfig($xchan); - if((! array_key_exists($family, $a->config[$xchan])) || (! array_key_exists($key, $a->config[$xchan][$family]))) + if((! array_key_exists($family, App::$config[$xchan])) || (! array_key_exists($key, App::$config[$xchan][$family]))) return false; - return ((! is_array($a->config[$xchan][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', $a->config[$xchan][$family][$key])) - ? unserialize($a->config[$xchan][$family][$key]) - : $a->config[$xchan][$family][$key] + return ((! is_array(App::$config[$xchan][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', App::$config[$xchan][$family][$key])) + ? unserialize(App::$config[$xchan][$family][$key]) + : App::$config[$xchan][$family][$key] ); } @@ -473,12 +484,12 @@ function set_xconfig($xchan, $family, $key, $value) { $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue); if(get_xconfig($xchan, $family, $key) === false) { - if(! array_key_exists($xchan, $a->config)) - $a->config[$xchan] = array(); - if(! array_key_exists($family, $a->config[$xchan])) - $a->config[$xchan][$family] = array(); + if(! array_key_exists($xchan, App::$config)) + App::$config[$xchan] = array(); + if(! array_key_exists($family, App::$config[$xchan])) + App::$config[$xchan][$family] = array(); - $a->config[$xchan][$family][$key] = $value; + App::$config[$xchan][$family][$key] = $value; $ret = q("INSERT INTO xconfig ( xchan, cat, k, v ) VALUES ( '%s', '%s', '%s', '%s' ) ", dbesc($xchan), dbesc($family), @@ -497,7 +508,7 @@ function set_xconfig($xchan, $family, $key, $value) { dbesc($key) ); - $a->config[$xchan][$family][$key] = $value; + App::$config[$xchan][$family][$key] = $value; if($ret) return $value; @@ -507,7 +518,7 @@ function set_xconfig($xchan, $family, $key, $value) { /** * @brief Deletes the given key from the observer's config. * - * Removes the configured value from the stored cache in $a->config[$xchan] + * Removes the configured value from the stored cache in App::$config[$xchan] * and removes it from the database. * * @param string $xchan @@ -522,8 +533,8 @@ function del_xconfig($xchan, $family, $key) { global $a; $ret = false; - if(x($a->config[$xchan][$family], $key)) - unset($a->config[$xchan][$family][$key]); + if(x(App::$config[$xchan][$family], $key)) + unset(App::$config[$xchan][$family][$key]); $ret = q("DELETE FROM xconfig WHERE xchan = '%s' AND cat = '%s' AND k = '%s'", dbesc($xchan), dbesc($family), diff --git a/include/contact_widgets.php b/include/contact_widgets.php index a60b8b1c3..ba1241fcb 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -10,7 +10,7 @@ function findpeople_widget() { if(get_config('system','invitation_only')) { $x = get_pconfig(local_channel(),'system','invites_remaining'); if($x || is_site_admin()) { - $a->page['aside'] .= '<div class="side-link" id="side-invite-remain">' + App::$page['aside'] .= '<div class="side-link" id="side-invite-remain">' . sprintf( tt('%d invitation available','%d invitations available',$x), $x) . '</div>' . $inv; } @@ -68,7 +68,7 @@ function categories_widget($baseurl,$selected = '') { $a = get_app(); - if(! feature_enabled($a->profile['profile_uid'],'categories')) + if(! feature_enabled(App::$profile['profile_uid'],'categories')) return ''; $item_normal = item_normal(); @@ -83,9 +83,9 @@ function categories_widget($baseurl,$selected = '') { and item.item_wall = 1 $item_normal order by term.term asc", - intval($a->profile['profile_uid']), + intval(App::$profile['profile_uid']), intval(TERM_CATEGORY), - dbesc($a->profile['channel_hash']) + dbesc(App::$profile['channel_hash']) ); if($r && count($r)) { foreach($r as $rr) @@ -126,7 +126,7 @@ function common_friends_visitor_widget($profile_uid) { return replace_macros(get_markup_template('remote_friends_common.tpl'), array( '$desc' => sprintf( tt("%d connection in common", "%d connections in common", $t), $t), - '$base' => $a->get_baseurl(), + '$base' => z_root(), '$uid' => $profile_uid, '$cid' => $observer, '$linkmore' => (($t > 5) ? 'true' : ''), diff --git a/include/conversation.php b/include/conversation.php index 676067f86..829e85382 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -54,7 +54,7 @@ function item_redir_and_replace_images($body, $images, $cid) { $origbody = $body; $newbody = ''; - $observer = get_app()->get_observer(); + $observer = App::get_observer(); $obhash = (($observer) ? $observer['xchan_hash'] : ''); $obaddr = (($observer) ? $observer['xchan_addr'] : ''); @@ -489,7 +489,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ $live_update_div = '<div id="live-network"></div>' . "\r\n" . "<script> var profile_uid = " . $_SESSION['uid'] - . "; var netargs = '" . substr($a->cmd,8) + . "; var netargs = '" . substr(App::$cmd,8) . '?f=' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '') . ((x($_GET,'search')) ? '&search=' . $_GET['search'] : '') @@ -504,12 +504,12 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ . ((x($_GET,'cmax')) ? '&cmax=' . $_GET['cmax'] : '') . ((x($_GET,'file')) ? '&file=' . $_GET['file'] : '') . ((x($_GET,'uri')) ? '&uri=' . $_GET['uri'] : '') - . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n"; + . "'; var profile_page = " . App::$pager['page'] . "; </script>\r\n"; } } elseif ($mode === 'channel') { - $profile_owner = $a->profile['profile_uid']; + $profile_owner = App::$profile['profile_uid']; $page_writeable = ($profile_owner == local_channel()); if (!$update) { @@ -519,8 +519,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ // because browser prefetching might change it on us. We have to deliver it with the page. $live_update_div = '<div id="live-channel"></div>' . "\r\n" - . "<script> var profile_uid = " . $a->profile['profile_uid'] - . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n"; + . "<script> var profile_uid = " . App::$profile['profile_uid'] + . "; var netargs = '?f='; var profile_page = " . App::$pager['page'] . "; </script>\r\n"; } } } @@ -532,7 +532,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ } elseif ($mode === 'page') { - $profile_owner = $a->profile['uid']; + $profile_owner = App::$profile['uid']; $page_writeable = ($profile_owner == local_channel()); $live_update_div = '<div id="live-page"></div>' . "\r\n"; } @@ -542,11 +542,11 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ } elseif ($mode === 'photos') { - $profile_onwer = $a->profile['profile_uid']; + $profile_onwer = App::$profile['profile_uid']; $page_writeable = ($profile_owner == local_channel()); $live_update_div = '<div id="live-photos"></div>' . "\r\n"; // for photos we've already formatted the top-level item (the photo) - $content_html = $a->data['photo_html']; + $content_html = App::$data['photo_html']; } $page_dropping = ((local_channel() && local_channel() == $profile_owner) ? true : false); @@ -555,13 +555,13 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ $page_dropping = false; - $channel = $a->get_channel(); - $observer = $a->get_observer(); + $channel = App::get_channel(); + $observer = App::get_observer(); if($update) $return_url = $_SESSION['return_url']; else - $return_url = $_SESSION['return_url'] = $a->query_string; + $return_url = $_SESSION['return_url'] = App::$query_string; load_contact_links(local_channel()); @@ -623,7 +623,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ $nickname = $item['nickname']; } else - $nickname = $a->user['nickname']; + $nickname = App::$user['nickname']; $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']); if($item['author-link'] && (! $item['author-name'])) @@ -844,12 +844,12 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ $o .= replace_macros($page_template, array( - '$baseurl' => $a->get_baseurl($ssl_state), + '$baseurl' => z_root(), '$photo_item' => $content_html, '$live_update' => $live_update_div, '$remove' => t('remove'), '$mode' => $mode, - '$user' => $a->user, + '$user' => App::$user, '$threads' => $threads, '$wait' => t('Loading...'), '$dropping' => ($page_dropping?t('Delete Selected Items'):False), @@ -869,13 +869,13 @@ function best_link_url($item) { $clean_url = normalise_link($item['author-link']); if((local_channel()) && (local_channel() == $item['uid'])) { - if(isset($a->contacts) && x($a->contacts,$clean_url)) { - if($a->contacts[$clean_url]['network'] === NETWORK_DFRN) { - $best_url = $a->get_baseurl($ssl_state) . '/redir/' . $a->contacts[$clean_url]['id']; + if(isset(App::$contacts) && x(App::$contacts,$clean_url)) { + if(App::$contacts[$clean_url]['network'] === NETWORK_DFRN) { + $best_url = z_root() . '/redir/' . App::$contacts[$clean_url]['id']; $sparkle = true; } else - $best_url = $a->contacts[$clean_url]['url']; + $best_url = App::$contacts[$clean_url]['url']; } } if(! $best_url) { @@ -907,9 +907,9 @@ function item_photo_menu($item){ if($local_channel) { $ssl_state = true; - if(! count($a->contacts)) + if(! count(App::$contacts)) load_contact_links($local_channel); - $channel = $a->get_channel(); + $channel = App::get_channel(); $channel_hash = (($channel) ? $channel['channel_hash'] : ''); } @@ -925,19 +925,19 @@ function item_photo_menu($item){ $profile_link = chanlink_hash($item['author_xchan']); if($item['uid'] > 0) - $pm_url = $a->get_baseurl($ssl_state) . '/mail/new/?f=&hash=' . $item['author_xchan']; + $pm_url = z_root() . '/mail/new/?f=&hash=' . $item['author_xchan']; - if($a->contacts && array_key_exists($item['author_xchan'],$a->contacts)) - $contact = $a->contacts[$item['author_xchan']]; + if(App::$contacts && array_key_exists($item['author_xchan'],App::$contacts)) + $contact = App::$contacts[$item['author_xchan']]; else if($local_channel && $item['author']['xchan_addr']) $follow_url = z_root() . '/follow/?f=&url=' . $item['author']['xchan_addr']; if($contact) { - $poke_link = $a->get_baseurl($ssl_state) . '/poke/?f=&c=' . $contact['abook_id']; + $poke_link = z_root() . '/poke/?f=&c=' . $contact['abook_id']; if (! intval($contact['abook_self'])) - $contact_url = $a->get_baseurl($ssl_state) . '/connedit/' . $contact['abook_id']; - $posts_link = $a->get_baseurl($ssl_state) . '/network/?cid=' . $contact['abook_id']; + $contact_url = z_root() . '/connedit/' . $contact['abook_id']; + $posts_link = z_root() . '/network/?cid=' . $contact['abook_id']; $clean_url = normalise_link($item['author-link']); } @@ -1159,9 +1159,9 @@ function status_editor($a, $x, $popup = false) { $tpl = get_markup_template('jot-header.tpl'); - $a->page['htmlhead'] .= replace_macros($tpl, array( + App::$page['htmlhead'] .= replace_macros($tpl, array( '$newpost' => 'true', - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => z_root(), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$pretext' => ((x($x,'pretext')) ? $x['pretext'] : ''), '$geotag' => $geotag, @@ -1202,8 +1202,8 @@ function status_editor($a, $x, $popup = false) { call_hooks('jot_networks', $jotnets); $o .= replace_macros($tpl, array( - '$return_path' => ((x($x, 'return_path')) ? $x['return_path'] : $a->query_string), - '$action' => $a->get_baseurl(true) . '/item', + '$return_path' => ((x($x, 'return_path')) ? $x['return_path'] : App::$query_string), + '$action' => z_root() . '/item', '$share' => (x($x,'button') ? $x['button'] : t('Share')), '$webpage' => $webpage, '$placeholdpagetitle' => ((x($x,'ptlabel')) ? $x['ptlabel'] : t('Page link name')), @@ -1246,7 +1246,7 @@ function status_editor($a, $x, $popup = false) { '$content' => ((x($x,'body')) ? htmlspecialchars($x['body'], ENT_COMPAT,'UTF-8') : ''), '$attachment' => ((x($x, 'attachment')) ? $x['attachment'] : ''), '$post_id' => '', - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => z_root(), '$defloc' => $x['default_location'], '$visitor' => $x['visitor'], '$public' => t('Public post'), @@ -1424,12 +1424,12 @@ function prepare_page($item) { $a = get_app(); $naked = 1; // $naked = ((get_pconfig($item['uid'],'system','nakedpage')) ? 1 : 0); - $observer = $a->get_observer(); + $observer = App::get_observer(); //240 chars is the longest we can have before we start hitting problems with suhosin sites $preview = substr(urlencode($item['body']), 0, 240); - $link = z_root() . '/' . $a->cmd; - if(array_key_exists('webpage',$a->layout) && array_key_exists('authored',$a->layout['webpage'])) { - if($a->layout['webpage']['authored'] === 'none') + $link = z_root() . '/' . App::$cmd; + if(array_key_exists('webpage',App::$layout) && array_key_exists('authored',App::$layout['webpage'])) { + if(App::$layout['webpage']['authored'] === 'none') $naked = 1; // ... other possible options } @@ -1508,7 +1508,7 @@ function network_tabs() { if ($no_active=='active') $all_active='active'; - $cmd = $a->cmd; + $cmd = App::$cmd; // tabs $tabs = array(); @@ -1592,16 +1592,16 @@ function network_tabs() { function profile_tabs($a, $is_owner = false, $nickname = null){ // Don't provide any profile tabs if we're running as the sys channel - if ($a->is_sys) + if (App::$is_sys) return; - $channel = $a->get_channel(); + $channel = App::get_channel(); if (is_null($nickname)) $nickname = $channel['channel_address']; - $uid = (($a->profile['profile_uid']) ? $a->profile['profile_uid'] : local_channel()); + $uid = ((App::$profile['profile_uid']) ? App::$profile['profile_uid'] : local_channel()); if($uid == local_channel()) { $cal_link = ''; @@ -1617,8 +1617,8 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ if (x($_GET, 'tab')) $tab = notags(trim($_GET['tab'])); - $url = $a->get_baseurl() . '/channel/' . $nickname; - $pr = $a->get_baseurl() . '/profile/' . $nickname; + $url = z_root() . '/channel/' . $nickname; + $pr = z_root() . '/profile/' . $nickname; $tabs = array( array( @@ -1644,14 +1644,14 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ if ($p['view_storage']) { $tabs[] = array( 'label' => t('Photos'), - 'url' => $a->get_baseurl() . '/photos/' . $nickname, + 'url' => z_root() . '/photos/' . $nickname, 'sel' => ((argv(0) == 'photos') ? 'active' : ''), 'title' => t('Photo Albums'), 'id' => 'photo-tab', ); $tabs[] = array( 'label' => t('Files'), - 'url' => $a->get_baseurl() . '/cloud/' . $nickname, + 'url' => z_root() . '/cloud/' . $nickname, 'sel' => ((argv(0) == 'cloud' || argv(0) == 'sharedwithme') ? 'active' : ''), 'title' => t('Files and Storage'), 'id' => 'files-tab', @@ -1661,7 +1661,7 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ if($p['view_stream'] && $cal_link) { $tabs[] = array( 'label' => t('Events'), - 'url' => $a->get_baseurl() . $cal_link, + 'url' => z_root() . $cal_link, 'sel' => ((argv(0) == 'cal' || argv(0) == 'events') ? 'active' : ''), 'title' => t('Events'), 'id' => 'event-tab', @@ -1675,7 +1675,7 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ if ($has_chats) { $tabs[] = array( 'label' => t('Chatrooms'), - 'url' => $a->get_baseurl() . '/chat/' . $nickname, + 'url' => z_root() . '/chat/' . $nickname, 'sel' => ((argv(0) == 'chat') ? 'active' : '' ), 'title' => t('Chatrooms'), 'id' => 'chat-tab', @@ -1688,7 +1688,7 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ if ($is_owner && $has_bookmarks) { $tabs[] = array( 'label' => t('Bookmarks'), - 'url' => $a->get_baseurl() . '/bookmarks', + 'url' => z_root() . '/bookmarks', 'sel' => ((argv(0) == 'bookmarks') ? 'active' : ''), 'title' => t('Saved Bookmarks'), 'id' => 'bookmarks-tab', @@ -1698,7 +1698,7 @@ function profile_tabs($a, $is_owner = false, $nickname = null){ if ($p['write_pages'] && feature_enabled($uid,'webpages')) { $tabs[] = array( 'label' => t('Webpages'), - 'url' => $a->get_baseurl() . '/webpages/' . $nickname, + 'url' => z_root() . '/webpages/' . $nickname, 'sel' => ((argv(0) == 'webpages') ? 'active' : ''), 'title' => t('Manage Webpages'), 'id' => 'webpages-tab', diff --git a/include/crypto.php b/include/crypto.php index d82ee5114..d636c6848 100644 --- a/include/crypto.php +++ b/include/crypto.php @@ -25,16 +25,7 @@ function rsa_verify($data,$sig,$key,$alg = 'sha256') { if(! $verify) { while($msg = openssl_error_string()) logger('openssl_verify: ' . $msg,LOGGER_NORMAL,LOG_ERR); - logger('openssl_verify: key: ' . $key, LOGGER_DEBUG, LOG_ERR); - // provide a backtrace so that we can debug key issues - if(version_compare(PHP_VERSION, '5.4.0') >= 0) { - $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - if($stack) { - foreach($stack as $s) { - logger('stack: ' . basename($s['file']) . ':' . $s['line'] . ':' . $s['function'] . '()',LOGGER_DEBUG,LOG_ERR); - } - } - } + btlogger('openssl_verify: key: ' . $key, LOGGER_DEBUG, LOG_ERR); } return $verify; diff --git a/include/datetime.php b/include/datetime.php index 8ee70a6fa..83fb49d04 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -135,7 +135,7 @@ function dob($dob) { 'dob', t('Birthday'), $value, - ((intval($value)) ? t('Age: ') . age($value,$a->user['timezone'],$a->user['timezone']) : ''), + ((intval($value)) ? t('Age: ') . age($value,App::$user['timezone'],App::$user['timezone']) : ''), '', 'placeholder="' . t('YYYY-MM-DD or MM-DD') .'"' ))); diff --git a/include/dir_fns.php b/include/dir_fns.php index fd2a5835d..1c3149081 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -421,7 +421,7 @@ function local_dir_update($uid, $force) { $arr = array('channel_id' => $uid, 'hash' => $hash, 'profile' => $profile); call_hooks('local_dir_update', $arr); - $address = $p[0]['channel_address'] . '@' . get_app()->get_hostname(); + $address = $p[0]['channel_address'] . '@' . App::get_hostname(); if (perm_is_allowed($uid, '', 'view_profile')) { import_directory_profile($hash, $arr['profile'], $address, 0); @@ -436,6 +436,6 @@ function local_dir_update($uid, $force) { } } - $ud_hash = random_string() . '@' . get_app()->get_hostname(); - update_modtime($hash, $ud_hash, $p[0]['channel_address'] . '@' . get_app()->get_hostname(),(($force) ? UPDATE_FLAGS_FORCED : UPDATE_FLAGS_UPDATED)); + $ud_hash = random_string() . '@' . App::get_hostname(); + update_modtime($hash, $ud_hash, $p[0]['channel_address'] . '@' . App::get_hostname(),(($force) ? UPDATE_FLAGS_FORCED : UPDATE_FLAGS_UPDATED)); } diff --git a/include/enotify.php b/include/enotify.php index e182377c0..d87c5af11 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -56,13 +56,13 @@ function notification($params) { $banner = t('$Projectname Notification'); $product = t('$projectname'); // PLATFORM_NAME; - $siteurl = $a->get_baseurl(true); + $siteurl = z_root(); $thanks = t('Thank You,'); $sitename = get_config('system','sitename'); $site_admin = sprintf( t('%s Administrator'), $sitename); $sender_name = $product; - $hostname = $a->get_hostname(); + $hostname = App::get_hostname(); if(strpos($hostname,':')) $hostname = substr($hostname,0,strpos($hostname,':')); @@ -419,12 +419,12 @@ function notification($params) { return; } - $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id; + $itemlink = z_root() . '/notify/view/' . $notify_id; $msg = str_replace('$itemlink',$itemlink,$epreamble); // wretched hack, but we don't want to duplicate all the preamble variations and we also don't want to screw up a translation - if (($a->language === 'en' || (! $a->language)) && strpos($msg,', ')) + if ((App::$language === 'en' || (! App::$language)) && strpos($msg,', ')) $msg = substr($msg,strpos($msg,', ')+1); $r = q("update notify set msg = '%s' where id = %d and uid = %d", @@ -441,7 +441,7 @@ function notification($params) { logger('notification: sending notification email'); $hn = get_pconfig($recip['channel_id'],'system','email_notify_host'); - if($hn && (! stristr(get_app()->get_hostname(),$hn))) { + if($hn && (! stristr(App::get_hostname(),$hn))) { // this isn't the email notification host pop_lang(); return; @@ -455,7 +455,7 @@ function notification($params) { // use $_SESSION['zid_override'] to force zid() to use // the recipient address instead of the current observer - $_SESSION['zid_override'] = $recip['channel_address'] . '@' . get_app()->get_hostname(); + $_SESSION['zid_override'] = $recip['channel_address'] . '@' . App::get_hostname(); $_SESSION['zrl_override'] = z_root() . '/channel/' . $recip['channel_address']; $textversion = zidify_links($textversion); diff --git a/include/event.php b/include/event.php index 2969f4f61..7a99bc746 100644 --- a/include/event.php +++ b/include/event.php @@ -67,7 +67,7 @@ function ical_wrapper($ev) { $o .= "BEGIN:VCALENDAR"; $o .= "\r\nVERSION:2.0"; $o .= "\r\nMETHOD:PUBLISH"; - $o .= "\r\nPRODID:-//" . get_config('system','sitename') . "//" . Zotlabs\Project\System::get_platform_name() . "//" . strtoupper(get_app()->language). "\r\n"; + $o .= "\r\nPRODID:-//" . get_config('system','sitename') . "//" . Zotlabs\Project\System::get_platform_name() . "//" . strtoupper(App::$language). "\r\n"; if(array_key_exists('start', $ev)) $o .= format_event_ical($ev); else { @@ -361,7 +361,7 @@ function event_store_event($arr) { if(array_key_exists('external_id',$arr)) $hash = $arr['external_id']; else - $hash = random_string() . '@' . get_app()->get_hostname(); + $hash = random_string() . '@' . App::get_hostname(); $r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary,description,location,type, adjust,nofinish, event_status, event_status_date, event_percent, event_repeat, event_sequence, event_priority, allow_cid,allow_gid,deny_cid,deny_gid) diff --git a/include/identity.php b/include/identity.php index 5d18d69e0..849742c8e 100644 --- a/include/identity.php +++ b/include/identity.php @@ -174,7 +174,6 @@ function channel_total() { */ function create_identity($arr) { - $a = get_app(); $ret = array('success' => false); if(! $arr['account_id']) { @@ -275,7 +274,7 @@ function create_identity($arr) { intval($pageflags), intval($system), intval($expire), - dbesc($a->timezone) + dbesc(App::$timezone) ); $r = q("select * from channel where channel_account_id = %d @@ -302,11 +301,11 @@ function create_identity($arr) { dbesc($guid), dbesc($sig), dbesc($hash), - dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()), + dbesc($ret['channel']['channel_address'] . '@' . App::get_hostname()), intval($primary), dbesc(z_root()), dbesc(base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey']))), - dbesc(get_app()->get_hostname()), + dbesc(App::get_hostname()), dbesc(z_root() . '/post'), dbesc(get_config('system','pubkey')), dbesc('zot') @@ -321,10 +320,10 @@ function create_identity($arr) { dbesc($guid), dbesc($sig), dbesc($key['pubkey']), - dbesc($a->get_baseurl() . "/photo/profile/l/{$newuid}"), - dbesc($a->get_baseurl() . "/photo/profile/m/{$newuid}"), - dbesc($a->get_baseurl() . "/photo/profile/s/{$newuid}"), - dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()), + dbesc(z_root() . "/photo/profile/l/{$newuid}"), + dbesc(z_root() . "/photo/profile/m/{$newuid}"), + dbesc(z_root() . "/photo/profile/s/{$newuid}"), + dbesc($ret['channel']['channel_address'] . '@' . App::get_hostname()), dbesc(z_root() . '/channel/' . $ret['channel']['channel_address']), dbesc(z_root() . '/follow?f=&url=%s'), dbesc(z_root() . '/poco/' . $ret['channel']['channel_address']), @@ -347,8 +346,8 @@ function create_identity($arr) { 1, $publish, dbesc($ret['channel']['channel_name']), - dbesc($a->get_baseurl() . "/photo/profile/l/{$newuid}"), - dbesc($a->get_baseurl() . "/photo/profile/m/{$newuid}") + dbesc(z_root() . "/photo/profile/l/{$newuid}"), + dbesc(z_root() . "/photo/profile/m/{$newuid}") ); if($role_permissions) { @@ -780,14 +779,14 @@ function profile_load(&$a, $nickname, $profile = '') { ); if(! $user) { - logger('profile error: ' . $a->query_string, LOGGER_DEBUG); + logger('profile error: ' . App::$query_string, LOGGER_DEBUG); notice( t('Requested channel is not available.') . EOL ); - $a->error = 404; + App::$error = 404; return; } // get the current observer - $observer = $a->get_observer(); + $observer = App::get_observer(); $can_view_profile = true; @@ -826,9 +825,9 @@ function profile_load(&$a, $nickname, $profile = '') { } if(! $p) { - logger('profile error: ' . $a->query_string, LOGGER_DEBUG); + logger('profile error: ' . App::$query_string, LOGGER_DEBUG); notice( t('Requested profile is not available.') . EOL ); - $a->error = 404; + App::$error = 404; return; } @@ -885,23 +884,23 @@ function profile_load(&$a, $nickname, $profile = '') { if($p[0]['keywords']) { $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$p[0]['keywords']); if(strlen($keywords) && $can_view_profile) - $a->page['htmlhead'] .= '<meta name="keywords" content="' . htmlentities($keywords,ENT_COMPAT,'UTF-8') . '" />' . "\r\n" ; + App::$page['htmlhead'] .= '<meta name="keywords" content="' . htmlentities($keywords,ENT_COMPAT,'UTF-8') . '" />' . "\r\n" ; } - $a->profile = $p[0]; - $a->profile_uid = $p[0]['profile_uid']; - $a->page['title'] = $a->profile['channel_name'] . " - " . $a->profile['channel_address'] . "@" . $a->get_hostname(); + App::$profile = $p[0]; + App::$profile_uid = $p[0]['profile_uid']; + App::$page['title'] = App::$profile['channel_name'] . " - " . App::$profile['channel_address'] . "@" . App::get_hostname(); - $a->profile['permission_to_view'] = $can_view_profile; + App::$profile['permission_to_view'] = $can_view_profile; if($can_view_profile) { $online = get_online_status($nickname); - $a->profile['online_status'] = $online['result']; + App::$profile['online_status'] = $online['result']; } if(local_channel()) { - $a->profile['channel_mobile_theme'] = get_pconfig(local_channel(),'system', 'mobile_theme'); - $_SESSION['mobile_theme'] = $a->profile['channel_mobile_theme']; + App::$profile['channel_mobile_theme'] = get_pconfig(local_channel(),'system', 'mobile_theme'); + $_SESSION['mobile_theme'] = App::$profile['channel_mobile_theme']; } /* @@ -914,7 +913,6 @@ function profile_load(&$a, $nickname, $profile = '') { function profile_edit_menu($uid) { - $a = get_app(); $ret = array(); $is_owner = (($uid == local_channel()) ? true : false); @@ -929,11 +927,11 @@ function profile_edit_menu($uid) { $multi_profiles = feature_enabled(local_channel(), 'multi_profiles'); if($multi_profiles) { $ret['multi'] = 1; - $ret['edit'] = array($a->get_baseurl(). '/profiles', t('Edit Profiles'), '', t('Edit')); + $ret['edit'] = array(z_root(). '/profiles', t('Edit Profiles'), '', t('Edit')); $ret['menu']['cr_new'] = t('Create New Profile'); } else { - $ret['edit'] = array($a->get_baseurl() . '/profiles/' . $uid, t('Edit Profile'), '', t('Edit')); + $ret['edit'] = array(z_root() . '/profiles/' . $uid, t('Edit Profile'), '', t('Edit')); } $r = q("SELECT * FROM profile WHERE uid = %d", @@ -976,9 +974,7 @@ function profile_edit_menu($uid) { */ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = false) { - $a = get_app(); - - $observer = $a->get_observer(); + $observer = App::get_observer(); $o = ''; $location = false; @@ -1010,7 +1006,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa $connect_url = rconnect_url($profile['uid'],get_observer_hash()); $connect = (($connect_url) ? t('Connect') : ''); if($connect_url) - $connect_url = sprintf($connect_url,urlencode($profile['channel_address'] . '@' . $a->get_hostname())); + $connect_url = sprintf($connect_url,urlencode($profile['channel_address'] . '@' . App::get_hostname())); // premium channel - over-ride @@ -1112,7 +1108,6 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa */ function get_birthdays() { - $a = get_app(); $o = ''; if(! local_channel()) @@ -1159,12 +1154,12 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa $url = $rr['url']; if($rr['network'] === NETWORK_DFRN) { $sparkle = " sparkle"; - $url = $a->get_baseurl() . '/redir/' . $rr['cid']; + $url = z_root() . '/redir/' . $rr['cid']; } $rr['link'] = $url; $rr['title'] = $rr['name']; - $rr['date'] = day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : ''); + $rr['date'] = day_translate(datetime_convert('UTC', App::$timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : ''); $rr['startime'] = Null; $rr['today'] = $today; } @@ -1172,7 +1167,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa } $tpl = get_markup_template("birthdays_reminder.tpl"); return replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => z_root(), '$classtoday' => $classtoday, '$count' => $total, '$event_reminders' => t('Birthday Reminders'), @@ -1191,8 +1186,6 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa require_once('include/bbcode.php'); - $a = get_app(); - if(! local_channel()) return $o; @@ -1214,15 +1207,15 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa if(strlen($rr['name'])) $total ++; - $strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start'],'Y-m-d'); - if($strt === datetime_convert('UTC',$a->timezone,'now','Y-m-d')) + $strt = datetime_convert('UTC',$rr['convert'] ? App::$timezone : 'UTC',$rr['start'],'Y-m-d'); + if($strt === datetime_convert('UTC',App::$timezone,'now','Y-m-d')) $istoday = true; } $classtoday = (($istoday) ? 'event-today' : ''); foreach($r as &$rr) { if($rr['adjust']) - $md = datetime_convert('UTC',$a->timezone,$rr['start'],'Y/m'); + $md = datetime_convert('UTC',App::$timezone,$rr['start'],'Y/m'); else $md = datetime_convert('UTC','UTC',$rr['start'],'Y/m'); $md .= "/#link-".$rr['id']; @@ -1231,12 +1224,12 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa if(! $title) $title = t('[No description]'); - $strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start']); - $today = ((substr($strt,0,10) === datetime_convert('UTC',$a->timezone,'now','Y-m-d')) ? true : false); + $strt = datetime_convert('UTC',$rr['convert'] ? App::$timezone : 'UTC',$rr['start']); + $today = ((substr($strt,0,10) === datetime_convert('UTC',App::$timezone,'now','Y-m-d')) ? true : false); $rr['link'] = $md; $rr['title'] = $title; - $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); + $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? App::$timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); $rr['startime'] = $strt; $rr['today'] = $today; } @@ -1244,7 +1237,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa $tpl = get_markup_template("events_reminder.tpl"); return replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => z_root(), '$classtoday' => $classtoday, '$count' => count($r), '$event_reminders' => t('Event Reminders'), @@ -1256,15 +1249,15 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa function advanced_profile(&$a) { require_once('include/text.php'); - if(! perm_is_allowed($a->profile['profile_uid'],get_observer_hash(),'view_profile')) + if(! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'view_profile')) return ''; - if($a->profile['name']) { + if(App::$profile['name']) { $profile_fields_basic = get_profile_fields_basic(); $profile_fields_advanced = get_profile_fields_advanced(); - $advanced = ((feature_enabled($a->profile['profile_uid'],'advanced_profiles')) ? true : false); + $advanced = ((feature_enabled(App::$profile['profile_uid'],'advanced_profiles')) ? true : false); if($advanced) $fields = $profile_fields_advanced; else @@ -1283,19 +1276,19 @@ function advanced_profile(&$a) { $profile = array(); - $profile['fullname'] = array( t('Full Name:'), $a->profile['name'] ) ; + $profile['fullname'] = array( t('Full Name:'), App::$profile['name'] ) ; - if($a->profile['gender']) $profile['gender'] = array( t('Gender:'), $a->profile['gender'] ); + if(App::$profile['gender']) $profile['gender'] = array( t('Gender:'), App::$profile['gender'] ); $ob_hash = get_observer_hash(); - if($ob_hash && perm_is_allowed($a->profile['profile_uid'],$ob_hash,'post_like')) { + if($ob_hash && perm_is_allowed(App::$profile['profile_uid'],$ob_hash,'post_like')) { $profile['canlike'] = true; $profile['likethis'] = t('Like this channel'); - $profile['profile_guid'] = $a->profile['profile_guid']; + $profile['profile_guid'] = App::$profile['profile_guid']; } $likers = q("select liker, xchan.* from likes left join xchan on liker = xchan_hash where channel_id = %d and target_type = '%s' and verb = '%s'", - intval($a->profile['profile_uid']), + intval(App::$profile['profile_uid']), dbesc(ACTIVITY_OBJ_PROFILE), dbesc(ACTIVITY_LIKE) ); @@ -1307,87 +1300,87 @@ function advanced_profile(&$a) { $profile['likers'][] = array('name' => $l['xchan_name'],'photo' => zid($l['xchan_photo_s']), 'url' => zid($l['xchan_url'])); } - if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) { + if((App::$profile['dob']) && (App::$profile['dob'] != '0000-00-00')) { $val = ''; - if((substr($a->profile['dob'],5,2) === '00') || (substr($a->profile['dob'],8,2) === '00')) - $val = substr($a->profile['dob'],0,4); + if((substr(App::$profile['dob'],5,2) === '00') || (substr(App::$profile['dob'],8,2) === '00')) + $val = substr(App::$profile['dob'],0,4); $year_bd_format = t('j F, Y'); $short_bd_format = t('j F'); if(! $val) { - $val = ((intval($a->profile['dob'])) - ? day_translate(datetime_convert('UTC','UTC',$a->profile['dob'] . ' 00:00 +00:00',$year_bd_format)) - : day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],5) . ' 00:00 +00:00',$short_bd_format))); + $val = ((intval(App::$profile['dob'])) + ? day_translate(datetime_convert('UTC','UTC',App::$profile['dob'] . ' 00:00 +00:00',$year_bd_format)) + : day_translate(datetime_convert('UTC','UTC','2001-' . substr(App::$profile['dob'],5) . ' 00:00 +00:00',$short_bd_format))); } $profile['birthday'] = array( t('Birthday:'), $val); } - if($age = age($a->profile['dob'],$a->profile['timezone'],'')) + if($age = age(App::$profile['dob'],App::$profile['timezone'],'')) $profile['age'] = array( t('Age:'), $age ); - if($a->profile['marital']) - $profile['marital'] = array( t('Status:'), $a->profile['marital']); + if(App::$profile['marital']) + $profile['marital'] = array( t('Status:'), App::$profile['marital']); - if($a->profile['with']) - $profile['marital']['with'] = bbcode($a->profile['with']); + if(App::$profile['with']) + $profile['marital']['with'] = bbcode(App::$profile['with']); - if(strlen($a->profile['howlong']) && $a->profile['howlong'] !== NULL_DATE) { - $profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s')); + if(strlen(App::$profile['howlong']) && App::$profile['howlong'] !== NULL_DATE) { + $profile['howlong'] = relative_date(App::$profile['howlong'], t('for %1$d %2$s')); } - if($a->profile['sexual']) $profile['sexual'] = array( t('Sexual Preference:'), $a->profile['sexual'] ); + if(App::$profile['sexual']) $profile['sexual'] = array( t('Sexual Preference:'), App::$profile['sexual'] ); - if($a->profile['homepage']) $profile['homepage'] = array( t('Homepage:'), linkify($a->profile['homepage']) ); + if(App::$profile['homepage']) $profile['homepage'] = array( t('Homepage:'), linkify(App::$profile['homepage']) ); - if($a->profile['hometown']) $profile['hometown'] = array( t('Hometown:'), linkify($a->profile['hometown']) ); + if(App::$profile['hometown']) $profile['hometown'] = array( t('Hometown:'), linkify(App::$profile['hometown']) ); - if($a->profile['keywords']) $profile['keywords'] = array( t('Tags:'), $a->profile['keywords']); + if(App::$profile['keywords']) $profile['keywords'] = array( t('Tags:'), App::$profile['keywords']); - if($a->profile['politic']) $profile['politic'] = array( t('Political Views:'), $a->profile['politic']); + if(App::$profile['politic']) $profile['politic'] = array( t('Political Views:'), App::$profile['politic']); - if($a->profile['religion']) $profile['religion'] = array( t('Religion:'), $a->profile['religion']); + if(App::$profile['religion']) $profile['religion'] = array( t('Religion:'), App::$profile['religion']); - if($txt = prepare_text($a->profile['about'])) $profile['about'] = array( t('About:'), $txt ); + if($txt = prepare_text(App::$profile['about'])) $profile['about'] = array( t('About:'), $txt ); - if($txt = prepare_text($a->profile['interest'])) $profile['interest'] = array( t('Hobbies/Interests:'), $txt); + if($txt = prepare_text(App::$profile['interest'])) $profile['interest'] = array( t('Hobbies/Interests:'), $txt); - if($txt = prepare_text($a->profile['likes'])) $profile['likes'] = array( t('Likes:'), $txt); + if($txt = prepare_text(App::$profile['likes'])) $profile['likes'] = array( t('Likes:'), $txt); - if($txt = prepare_text($a->profile['dislikes'])) $profile['dislikes'] = array( t('Dislikes:'), $txt); + if($txt = prepare_text(App::$profile['dislikes'])) $profile['dislikes'] = array( t('Dislikes:'), $txt); - if($txt = prepare_text($a->profile['contact'])) $profile['contact'] = array( t('Contact information and Social Networks:'), $txt); + if($txt = prepare_text(App::$profile['contact'])) $profile['contact'] = array( t('Contact information and Social Networks:'), $txt); - if($txt = prepare_text($a->profile['channels'])) $profile['channels'] = array( t('My other channels:'), $txt); + if($txt = prepare_text(App::$profile['channels'])) $profile['channels'] = array( t('My other channels:'), $txt); - if($txt = prepare_text($a->profile['music'])) $profile['music'] = array( t('Musical interests:'), $txt); + if($txt = prepare_text(App::$profile['music'])) $profile['music'] = array( t('Musical interests:'), $txt); - if($txt = prepare_text($a->profile['book'])) $profile['book'] = array( t('Books, literature:'), $txt); + if($txt = prepare_text(App::$profile['book'])) $profile['book'] = array( t('Books, literature:'), $txt); - if($txt = prepare_text($a->profile['tv'])) $profile['tv'] = array( t('Television:'), $txt); + if($txt = prepare_text(App::$profile['tv'])) $profile['tv'] = array( t('Television:'), $txt); - if($txt = prepare_text($a->profile['film'])) $profile['film'] = array( t('Film/dance/culture/entertainment:'), $txt); + if($txt = prepare_text(App::$profile['film'])) $profile['film'] = array( t('Film/dance/culture/entertainment:'), $txt); - if($txt = prepare_text($a->profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt); + if($txt = prepare_text(App::$profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt); - if($txt = prepare_text($a->profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt); + if($txt = prepare_text(App::$profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt); - if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $txt ); + if($txt = prepare_text(App::$profile['education'])) $profile['education'] = array( t('School/education:'), $txt ); - if($a->profile['extra_fields']) { - foreach($a->profile['extra_fields'] as $f) { + if(App::$profile['extra_fields']) { + foreach(App::$profile['extra_fields'] as $f) { $x = q("select * from profdef where field_name = '%s' limit 1", dbesc($f) ); - if($x && $txt = prepare_text($a->profile[$f])) + if($x && $txt = prepare_text(App::$profile[$f])) $profile[$f] = array( $x[0]['field_desc'] . ':',$txt); } - $profile['extra_fields'] = $a->profile['extra_fields']; + $profile['extra_fields'] = App::$profile['extra_fields']; } - $things = get_things($a->profile['profile_guid'],$a->profile['profile_uid']); + $things = get_things(App::$profile['profile_guid'],App::$profile['profile_uid']); // logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA); @@ -1397,7 +1390,7 @@ function advanced_profile(&$a) { '$likethis' => t('Like this thing'), '$profile' => $profile, '$fields' => $clean_fields, - '$editmenu' => profile_edit_menu($a->profile['profile_uid']), + '$editmenu' => profile_edit_menu(App::$profile['profile_uid']), '$things' => $things )); } @@ -1440,7 +1433,7 @@ function zid_init(&$a) { $tmp_str = get_my_address(); if(validate_email($tmp_str)) { proc_run('php','include/gprobe.php',bin2hex($tmp_str)); - $arr = array('zid' => $tmp_str, 'url' => $a->cmd); + $arr = array('zid' => $tmp_str, 'url' => App::$cmd); call_hooks('zid_init',$arr); if(! local_channel()) { $r = q("select * from hubloc where hubloc_addr = '%s' order by hubloc_connected desc limit 1", @@ -1450,7 +1443,7 @@ function zid_init(&$a) { return; logger('zid_init: not authenticated. Invoking reverse magic-auth for ' . $tmp_str); // try to avoid recursion - but send them home to do a proper magic auth - $query = $a->query_string; + $query = App::$query_string; $query = str_replace(array('?zid=','&zid='),array('?rzid=','&rzid='),$query); $dest = '/' . urlencode($query); if($r && ($r[0]['hubloc_url'] != z_root()) && (! strstr($dest,'/magic')) && (! strstr($dest,'/rmagic'))) { @@ -1631,7 +1624,7 @@ function identity_selector() { intval(get_account_id()) ); if (count($r) > 1) { - //$account = get_app()->get_account(); + //$account = App::get_account(); $o = replace_macros(get_markup_template('channel_id_select.tpl'), array( '$channels' => $r, '$selected' => local_channel() @@ -1649,7 +1642,7 @@ function is_public_profile() { return false; if(intval(get_config('system','block_public'))) return false; - $channel = get_app()->get_channel(); + $channel = App::get_channel(); if($channel && $channel['channel_r_profile'] == PERMS_PUBLIC) return true; @@ -1855,7 +1848,7 @@ function get_zcard($channel,$observer_hash = '',$args = array()) { // $translate = intval(($scale / 1.0) * 100); - $channel['channel_addr'] = $channel['channel_address'] . '@' . get_app()->get_hostname(); + $channel['channel_addr'] = $channel['channel_address'] . '@' . App::get_hostname(); $zcard = array('chan' => $channel); $r = q("select height, width, resource_id, scale, type from photo where uid = %d and scale = %d and photo_usage = %d", diff --git a/include/import.php b/include/import.php index b7ec1c565..9a57012b2 100644 --- a/include/import.php +++ b/include/import.php @@ -636,6 +636,7 @@ function sync_events($channel,$events) { function import_menus($channel,$menus) { + if($channel && $menus) { foreach($menus as $menu) { $m = array(); @@ -681,6 +682,8 @@ function import_menus($channel,$menus) { } } } + + } diff --git a/include/items.php b/include/items.php index 879f8ea12..07cf2e0e8 100755 --- a/include/items.php +++ b/include/items.php @@ -274,7 +274,7 @@ function can_comment_on_post($observer_xchan, $item) { return true; if(strstr($item['comment_policy'],'network:') && strstr($item['comment_policy'],'diaspora')) return true; - if(strstr($item['comment_policy'],'site:') && strstr($item['comment_policy'],get_app()->get_hostname())) + if(strstr($item['comment_policy'],'site:') && strstr($item['comment_policy'],App::get_hostname())) return true; return false; @@ -413,8 +413,8 @@ function post_activity_item($arr) { if(! array_key_exists('item_thread_top',$arr) && (! $is_comment)) $arr['item_thread_top'] = 1; - $channel = get_app()->get_channel(); - $observer = get_app()->get_observer(); + $channel = App::get_channel(); + $observer = App::get_observer(); $arr['aid'] = ((x($arr,'aid')) ? $arr['aid'] : $channel['channel_account_id']); $arr['uid'] = ((x($arr,'uid')) ? $arr['uid'] : $channel['channel_id']); @@ -602,7 +602,7 @@ function get_feed_for($channel, $observer_hash, $params) { 'order' => 'post', 'top' => $params['top'], 'cat' => $params['cat'] - ), $channel, $observer_hash, CLIENT_MODE_NORMAL, get_app()->module); + ), $channel, $observer_hash, CLIENT_MODE_NORMAL, App::$module); $feed_template = get_markup_template('atom_feed.tpl'); @@ -1362,7 +1362,7 @@ function map_scope($scope, $strip = false) { case PERMS_AUTHED: return 'authenticated'; case PERMS_SITE: - return 'site: ' . get_app()->get_hostname(); + return 'site: ' . App::get_hostname(); case PERMS_PENDING: return 'any connections'; case PERMS_CONTACTS: @@ -2265,7 +2265,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { $arr['body'] = trim(z_input_filter($arr['uid'],$arr['body'],$arr['mimetype'])); if(local_channel() && (! $arr['sig'])) { - $channel = get_app()->get_channel(); + $channel = App::get_channel(); if($channel['channel_hash'] === $arr['author_xchan']) { $arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey'])); $arr['item_verified'] = 1; @@ -2661,7 +2661,7 @@ function item_store_update($arr,$allow_exec = false, $deliver = true) { $arr['body'] = trim(z_input_filter($arr['uid'],$arr['body'],$arr['mimetype'])); if(local_channel() && (! $arr['sig'])) { - $channel = get_app()->get_channel(); + $channel = App::get_channel(); if($channel['channel_hash'] === $arr['author_xchan']) { $arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey'])); $arr['item_verified'] = 1; @@ -2887,7 +2887,7 @@ function store_diaspora_comment_sig($datarray, $channel, $parent_item, $post_id, logger('storing diaspora comment signature',LOGGER_DEBUG); - $diaspora_handle = $channel['channel_address'] . '@' . get_app()->get_hostname(); + $diaspora_handle = $channel['channel_address'] . '@' . App::get_hostname(); $signed_text = $datarray['mid'] . ';' . $parent_item['mid'] . ';' . $signed_body . ';' . $diaspora_handle; @@ -2966,7 +2966,7 @@ function send_status_notifications($post_id,$item) { if($unfollowed) return; - $link = get_app()->get_baseurl() . '/display/' . $item['mid']; + $link = z_root() . '/display/' . $item['mid']; $y = q("select id from notify where link = '%s' and uid = %d limit 1", dbesc($link), @@ -3848,8 +3848,8 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { $datarray = get_atom_elements($feed,$item,$author); if($contact['xchan_network'] === 'rss') { - $res['public_policy'] = 'specific'; - $res['comment_policy'] = 'none'; + $datarray['public_policy'] = 'specific'; + $datarray['comment_policy'] = 'none'; } if((! x($author,'author_name')) || ($author['author_is_feed'])) @@ -3911,8 +3911,8 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { $datarray = get_atom_elements($feed,$item,$author); if($contact['xchan_network'] === 'rss') { - $res['public_policy'] = 'specific'; - $res['comment_policy'] = 'none'; + $datarray['public_policy'] = 'specific'; + $datarray['comment_policy'] = 'none'; } @@ -3932,6 +3932,16 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { $datarray['author_xchan'] = ''; + if(activity_match($datarray['verb'],ACTIVITY_FOLLOW) && $datarray['obj_type'] === ACTIVITY_OBJ_PERSON) { + $cb = array('item' => $datarray,'channel' => $importer, 'xchan' => null, 'author' => $author, 'caught' => false); + call_hooks('follow_from_feed',$cb); + if($cb['caught']) { + if($cb['return_code']) + http_status_exit($cb['return_code']); + continue; + } + } + if($author['author_link'] != $contact['xchan_url']) { $x = import_author_unknown(array('name' => $author['author_name'],'url' => $author['author_link'],'photo' => array('src' => $author['author_photo']))); if($x) @@ -4284,10 +4294,9 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { } function fix_private_photos($s, $uid, $item = null, $cid = 0) { - $a = get_app(); logger('fix_private_photos', LOGGER_DEBUG); - $site = substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')); + $site = substr(z_root(),strpos(z_root(),'://')); $orig_body = $s; $new_body = ''; @@ -4567,8 +4576,6 @@ function drop_items($items) { function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = false) { - $a = get_app(); - // locate item to be deleted $r = q("SELECT * FROM item WHERE id = %d LIMIT 1", @@ -4579,7 +4586,7 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal if(! $interactive) return 0; notice( t('Item not found.') . EOL); - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(z_root() . '/' . $_SESSION['return_url']); } $item = $r[0]; @@ -4602,7 +4609,7 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal $ok_to_delete = true; // author deletion - $observer = $a->get_observer(); + $observer = App::get_observer(); if($observer && $observer['xchan_hash'] && ($observer['xchan_hash'] === $item['author_xchan'])) $ok_to_delete = true; @@ -4652,13 +4659,13 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal if((intval($item['item_wall']) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1)) proc_run('php','include/notifier.php','drop',$notify_id); - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(z_root() . '/' . $_SESSION['return_url']); } else { if(! $interactive) return 0; notice( t('Permission denied.') . EOL); - goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); + goaway(z_root() . '/' . $_SESSION['return_url']); } } @@ -5067,8 +5074,6 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $result = array('success' => false); - $a = get_app(); - $sql_extra = ''; $sql_nets = ''; $sql_options = ''; @@ -5191,8 +5196,8 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $pager_sql = ''; } else { $itemspage = (($channel) ? get_pconfig($uid,'system','itemspage') : 20); - $a->set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); - $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(get_app()->pager['itemspage']), intval(get_app()->pager['start'])); + App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); + $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); } if (isset($arr['start']) && isset($arr['records'])) @@ -5462,7 +5467,7 @@ function set_linkified_perms($linkified, &$str_contact_allow, &$str_group_allow, * @return boolean */ function comment_local_origin($item) { - if(stripos($item['mid'], get_app()->get_hostname()) && ($item['parent'] != $item['id'])) + if(stripos($item['mid'], App::get_hostname()) && ($item['parent'] != $item['id'])) return true; return false; diff --git a/include/language.php b/include/language.php index 121816ae6..1a012cb84 100644 --- a/include/language.php +++ b/include/language.php @@ -83,38 +83,38 @@ function get_best_language() { return $arr['preferred']; $a = get_app(); - return ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en'); + return ((isset(App::$config['system']['language'])) ? App::$config['system']['language'] : 'en'); } function push_lang($language) { global $a; - $a->langsave = $a->language; + App::$langsave = App::$language; - if($language === $a->language) + if($language === App::$language) return; - if(isset($a->strings) && count($a->strings)) { - $a->stringsave = $a->strings; + if(isset(App::$strings) && count(App::$strings)) { + App::$stringsave = App::$strings; } - $a->strings = array(); + App::$strings = array(); load_translation_table($language); - $a->language = $language; + App::$language = $language; } function pop_lang() { global $a; - if($a->language === $a->langsave) + if(App::$language === App::$langsave) return; - if(isset($a->stringsave)) - $a->strings = $a->stringsave; + if(isset(App::$stringsave)) + App::$strings = App::$stringsave; else - $a->strings = array(); + App::$strings = array(); - $a->language = $a->langsave; + App::$language = App::$langsave; } /** @@ -126,7 +126,7 @@ function pop_lang() { function load_translation_table($lang, $install = false) { global $a; - $a->strings = array(); + App::$strings = array(); if(file_exists("view/$lang/hstrings.php")) { include("view/$lang/hstrings.php"); @@ -173,8 +173,8 @@ function t($s, $ctx = '') { global $a; $cs = $ctx ? '__ctx:' . $ctx . '__ ' . $s : $s; - if (x($a->strings, $cs)) { - $t = $a->strings[$cs]; + if (x(App::$strings, $cs)) { + $t = App::$strings[$cs]; return ((is_array($t)) ? translate_projectname($t[0]) : translate_projectname($t)); } @@ -208,9 +208,9 @@ function tt($singular, $plural, $count, $ctx = ''){ $a = get_app(); $cs = $ctx ? "__ctx:" . $ctx . "__ " . $singular : $singular; - if (x($a->strings,$cs)) { - $t = $a->strings[$cs]; - $f = 'string_plural_select_' . str_replace('-', '_', $a->language); + if (x(App::$strings,$cs)) { + $t = App::$strings[$cs]; + $f = 'string_plural_select_' . str_replace('-', '_', App::$language); if (! function_exists($f)) $f = 'string_plural_select_default'; diff --git a/include/menu.php b/include/menu.php index d90cefddb..e8f1d8eb8 100644 --- a/include/menu.php +++ b/include/menu.php @@ -35,11 +35,11 @@ function menu_element($menu) { $arr['edited'] = $menu['menu']['menu_edited']; $arr['baseurl'] = z_root(); - if($menu['menu_flags']) { + if($menu['menu']['menu_flags']) { $arr['flags'] = array(); - if($menu['menu_flags'] & MENU_BOOKMARK) + if($menu['menu']['menu_flags'] & MENU_BOOKMARK) $arr['flags'][] = 'bookmark'; - if($menu['menu_flags'] & MENU_SYSTEM) + if($menu['menu']['menu_flags'] & MENU_SYSTEM) $arr['flags'][] = 'system'; } if($menu['items']) { @@ -72,7 +72,7 @@ function menu_render($menu, $class='', $edit = false, $var = array()) { if(! $menu) return ''; - $channel_id = ((is_array(get_app()->profile)) ? get_app()->profile['profile_uid'] : 0); + $channel_id = ((is_array(App::$profile)) ? App::$profile['profile_uid'] : 0); if ((! $channel_id) && (local_channel())) $channel_id = local_channel(); @@ -296,7 +296,7 @@ function menu_add_item($menu_id, $uid, $arr) { $mitem_flags = intval($arr['mitem_flags']); if(local_channel() == $uid) { - $channel = get_app()->get_channel(); + $channel = App::get_channel(); } $acl = new Zotlabs\Access\AccessList($channel); @@ -337,7 +337,7 @@ function menu_edit_item($menu_id, $uid, $arr) { if(local_channel() == $uid) { - $channel = get_app()->get_channel(); + $channel = App::get_channel(); } $acl = new Zotlabs\Access\AccessList($channel); diff --git a/include/message.php b/include/message.php index f24bb6e4b..a7883d50e 100644 --- a/include/message.php +++ b/include/message.php @@ -38,7 +38,7 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto=' $channel = $r[0]; } else { - $channel = get_app()->get_channel(); + $channel = App::get_channel(); } if(! $channel) { @@ -75,7 +75,7 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto=' if($recip) $recip_handle = $recip[0]['xchan_addr']; - $sender_handle = $channel['channel_address'] . '@' . get_app()->get_hostname(); + $sender_handle = $channel['channel_address'] . '@' . App::get_hostname(); $handles = $recip_handle . ';' . $sender_handle; @@ -124,7 +124,7 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto=' $dups = false; $hash = random_string(); - $mid = $hash . '@' . get_app()->get_hostname(); + $mid = $hash . '@' . App::get_hostname(); $r = q("SELECT id FROM mail WHERE mid = '%s' LIMIT 1", dbesc($mid)); @@ -169,7 +169,7 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto=' $r = attach_by_hash_nodata($hash,$rev); if($r['success']) { $attachments[] = array( - 'href' => $a->get_baseurl() . '/attach/' . $r['data']['hash'], + 'href' => z_root() . '/attach/' . $r['data']['hash'], 'length' => $r['data']['filesize'], 'type' => $r['data']['filetype'], 'title' => urlencode($r['data']['filename']), @@ -225,7 +225,7 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto=' if(count($images)) { foreach($images as $image) { - if(! stristr($image,$a->get_baseurl() . '/photo/')) + if(! stristr($image,z_root() . '/photo/')) continue; $image_uri = substr($image,strrpos($image,'/') + 1); $image_uri = substr($image_uri,0, strpos($image_uri,'-')); diff --git a/include/nav.php b/include/nav.php index d449718b8..1c40e0adb 100644 --- a/include/nav.php +++ b/include/nav.php @@ -8,11 +8,11 @@ function nav(&$a) { * */ - if(!(x($a->page,'nav'))) - $a->page['nav'] = ''; + if(!(x(App::$page,'nav'))) + App::$page['nav'] = ''; $base = z_root(); - $a->page['htmlhead'] .= <<< EOT + App::$page['htmlhead'] .= <<< EOT <script>$(document).ready(function() { $("#nav-search-text").search_autocomplete('$base/acl'); @@ -24,8 +24,8 @@ EOT; if(local_channel()) { - $channel = $a->get_channel(); - $observer = $a->get_observer(); + $channel = App::get_channel(); + $observer = App::get_observer(); $prof = q("select id from profile where uid = %d and is_default = 1", intval($channel['channel_id']) ); @@ -35,12 +35,12 @@ EOT; ); } elseif(remote_channel()) - $observer = $a->get_observer(); + $observer = App::get_observer(); $myident = (($channel) ? $channel['xchan_addr'] : ''); - $sitelocation = (($myident) ? $myident : $a->get_hostname()); + $sitelocation = (($myident) ? $myident : App::get_hostname()); @@ -55,8 +55,8 @@ EOT; if($banner === false) $banner = get_config('system','sitename'); - $a->page['header'] .= replace_macros(get_markup_template('hdr.tpl'), array( - '$baseurl' => $a->get_baseurl(), + App::$page['header'] .= replace_macros(get_markup_template('hdr.tpl'), array( + '$baseurl' => z_root(), '$sitelocation' => $sitelocation, '$banner' => $banner )); @@ -92,10 +92,8 @@ EOT; $nav['usermenu'][] = Array('photos/' . $channel['channel_address'], t('Photos'), "", t('Your photos'),'photos_nav_btn'); $nav['usermenu'][] = Array('cloud/' . $channel['channel_address'],t('Files'),"",t('Your files'),'cloud_nav_btn'); - require_once('include/chat.php'); - $has_chats = chatroom_list_count(local_channel()); if(! UNO) - $nav['usermenu'][] = Array('chat/' . $channel['channel_address'] . (($has_chats) ? '' : '/new'), t('Chat'),"",t('Your chatrooms'),'chat_nav_btn'); + $nav['usermenu'][] = Array('chat/' . $channel['channel_address'], t('Chat'),"",t('Your chatrooms'),'chat_nav_btn'); require_once('include/menu.php'); @@ -138,18 +136,18 @@ EOT; $homelink = get_my_url(); if(! $homelink) { - $observer = $a->get_observer(); + $observer = App::get_observer(); $homelink = (($observer) ? $observer['xchan_url'] : ''); } - if(($a->module != 'home') && (! (local_channel()))) + if((App::$module != 'home') && (! (local_channel()))) $nav['home'] = array($homelink, t('Home'), "", t('Home Page'),'home_nav_btn'); - if(($a->config['system']['register_policy'] == REGISTER_OPEN) && (! local_channel()) && (! remote_channel())) + if((App::$config['system']['register_policy'] == REGISTER_OPEN) && (! local_channel()) && (! remote_channel())) $nav['register'] = array('register',t('Register'), "", t('Create an account'),'register_nav_btn'); - $help_url = z_root() . '/help?f=&cmd=' . $a->cmd; + $help_url = z_root() . '/help?f=&cmd=' . App::$cmd; if(! get_config('system','hide_help')) { require_once('mod/help.php'); @@ -242,25 +240,25 @@ EOT; // turned off until somebody discovers this and figures out a good location for it. $powered_by = ''; -// $powered_by = '<strong>red<img class="smiley" src="' . $a->get_baseurl() . '/images/rm-16.png" alt="r#" />matrix</strong>'; +// $powered_by = '<strong>red<img class="smiley" src="' . z_root() . '/images/rm-16.png" alt="r#" />matrix</strong>'; $tpl = get_markup_template('nav.tpl'); - $a->page['nav'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + App::$page['nav'] .= replace_macros($tpl, array( + '$baseurl' => z_root(), '$sitelocation' => $sitelocation, '$nav' => $x['nav'], '$banner' => $banner, '$emptynotifications' => t('Loading...'), '$userinfo' => $x['usermenu'], '$localuser' => local_channel(), - '$sel' => $a->nav_sel, + '$sel' => App::$nav_sel, '$powered_by' => $powered_by, '$help' => t('@name, #tag, ?doc, content'), '$pleasewait' => t('Please wait...') )); - call_hooks('page_header', $a->page['nav']); + call_hooks('page_header', App::$page['nav']); } /* @@ -269,7 +267,7 @@ $powered_by = ''; */ function nav_set_selected($item){ $a = get_app(); - $a->nav_sel = array( + App::$nav_sel = array( 'community' => null, 'network' => null, 'home' => null, @@ -283,5 +281,5 @@ function nav_set_selected($item){ 'manage' => null, 'register' => null, ); - $a->nav_sel[$item] = 'active'; + App::$nav_sel[$item] = 'active'; } diff --git a/include/network.php b/include/network.php index e7d341321..ac14548a5 100644 --- a/include/network.php +++ b/include/network.php @@ -602,7 +602,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false) continue; } - $hostname = str_replace('www.','',substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3)); + $hostname = str_replace('www.','',substr(z_root(),strpos(z_root(),'://')+3)); if(stristr($mtch[3],$hostname)) continue; @@ -1144,21 +1144,23 @@ function discover_by_webbie($webbie) { $avatar = ''; $pubkey = ''; - if(array_key_exists('address',$x)) - $address = $x['address']; - if(array_key_exists('location',$x)) - $location = $x['location']; - if(array_key_exists('nickname',$x)) - $nickname = $x['nickname']; + if(is_array($x)) { + if(array_key_exists('address',$x)) + $address = $x['address']; + if(array_key_exists('location',$x)) + $location = $x['location']; + if(array_key_exists('nickname',$x)) + $nickname = $x['nickname']; + } if(! $x) $probe_old = true; if($probe_old) { - $x = old_webfinger($webbie); - if($x) { + $y = old_webfinger($webbie); + if($y) { logger('old_webfinger: ' . print_r($x,true)); - foreach($x as $link) { + foreach($y as $link) { if($link['@attributes']['rel'] === NAMESPACE_DFRN) $dfrn = unamp($link['@attributes']['href']); if($link['@attributes']['rel'] === 'salmon') @@ -1854,7 +1856,7 @@ function format_and_send_email($sender,$xchan,$item) { $sender_name = t('Administrator'); - $hostname = get_app()->get_hostname(); + $hostname = App::get_hostname(); if(strpos($hostname,':')) $hostname = substr($hostname,0,strpos($hostname,':')); $sender_email = 'noreply' . '@' . $hostname; @@ -1928,11 +1930,11 @@ function get_site_info() { $admin = array(); foreach($r as $rr) { if($rr['channel_pageflags'] & PAGE_HUBADMIN) - $admin[] = array( 'name' => $rr['channel_name'], 'address' => $rr['channel_address'] . '@' . get_app()->get_hostname(), 'channel' => z_root() . '/channel/' . $rr['channel_address']); + $admin[] = array( 'name' => $rr['channel_name'], 'address' => $rr['channel_address'] . '@' . App::get_hostname(), 'channel' => z_root() . '/channel/' . $rr['channel_address']); } if(! $admin) { foreach($r as $rr) { - $admin[] = array( 'name' => $rr['channel_name'], 'address' => $rr['channel_address'] . '@' . get_app()->get_hostname(), 'channel' => z_root() . '/channel/' . $rr['channel_address']); + $admin[] = array( 'name' => $rr['channel_name'], 'address' => $rr['channel_address'] . '@' . App::get_hostname(), 'channel' => z_root() . '/channel/' . $rr['channel_address']); } } } @@ -1947,7 +1949,7 @@ function get_site_info() { $service_class = false; $visible_plugins = array(); - if(is_array($a->plugins) && count($a->plugins)) { + if(is_array(App::$plugins) && count(App::$plugins)) { $r = q("select * from addon where hidden = 0"); if(count($r)) foreach($r as $rr) @@ -1987,8 +1989,8 @@ function get_site_info() { load_config('feature_lock'); $locked_features = array(); - if(is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) { - foreach($a->config['feature_lock'] as $k => $v) { + if(is_array(App::$config['feature_lock']) && count(App::$config['feature_lock'])) { + foreach(App::$config['feature_lock'] as $k => $v) { if($k === 'config_loaded') continue; $locked_features[$k] = intval($v); diff --git a/include/oauth.php b/include/oauth.php index f3d144158..ec41a5dd2 100644 --- a/include/oauth.php +++ b/include/oauth.php @@ -27,7 +27,7 @@ class ZotOAuth1DataStore extends OAuth1DataStore { ); if($r) { - get_app()->set_oauth_key($consumer_key); + App::set_oauth_key($consumer_key); return new OAuth1Consumer($r[0]['client_id'],$r[0]['pw'],$r[0]['redirect_uri']); } return null; diff --git a/include/oembed.php b/include/oembed.php index fb7a30e65..3994af0fb 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -85,7 +85,7 @@ function oembed_fetch_url($embedurl){ // logger('fetch: ' . $embedurl); - $txt = Cache::get($a->videowidth . $embedurl); + $txt = Cache::get(App::$videowidth . $embedurl); if(strstr($txt,'youtu') && strstr(z_root(),'https:')) { $txt = str_replace('http:','https:',$txt); @@ -124,7 +124,7 @@ function oembed_fetch_url($embedurl){ $entries = $xpath->query("//link[@type='application/json+oembed']"); foreach($entries as $e){ $href = $e->getAttributeNode("href")->nodeValue; - $x = z_fetch_url($href . '&maxwidth=' . $a->videowidth); + $x = z_fetch_url($href . '&maxwidth=' . App::$videowidth); $txt = $x['body']; break; } @@ -133,7 +133,7 @@ function oembed_fetch_url($embedurl){ $entries = $xpath->query("//link[@type='text/json+oembed']"); foreach($entries as $e){ $href = $e->getAttributeNode("href")->nodeValue; - $x = z_fetch_url($href . '&maxwidth=' . $a->videowidth); + $x = z_fetch_url($href . '&maxwidth=' . App::$videowidth); $txt = $x['body']; break; } @@ -142,7 +142,7 @@ function oembed_fetch_url($embedurl){ } if ($txt==false || $txt=="") { - $x = array('url' => $embedurl,'videowidth' => $a->videowidth); + $x = array('url' => $embedurl,'videowidth' => App::$videowidth); call_hooks('oembed_probe',$x); if(array_key_exists('embed',$x)) $txt = $x['embed']; @@ -154,7 +154,7 @@ function oembed_fetch_url($embedurl){ //save in cache if(! get_config('system','oembed_cache_disable')) - Cache::set($a->videowidth . $embedurl,$txt); + Cache::set(App::$videowidth . $embedurl,$txt); } @@ -195,7 +195,7 @@ function oembed_format_object($j){ } $ret.=replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => z_root(), '$embedurl'=>$embedurl, '$escapedhtml'=>base64_encode($jhtml), '$tw'=>$tw, diff --git a/include/permissions.php b/include/permissions.php index 8f593640c..19242d29f 100644 --- a/include/permissions.php +++ b/include/permissions.php @@ -63,7 +63,7 @@ function get_perms() { */ function get_all_perms($uid, $observer_xchan, $internal_use = true) { - $api = get_app()->get_oauth_key(); + $api = App::get_oauth_key(); if($api) return get_all_api_perms($uid,$api); @@ -270,7 +270,7 @@ function get_all_perms($uid, $observer_xchan, $internal_use = true) { */ function perm_is_allowed($uid, $observer_xchan, $permission) { - $api = get_app()->get_oauth_key(); + $api = App::get_oauth_key(); if($api) return api_perm_is_allowed($uid,$api,$permission); diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index dce92d8da..3bea54fd4 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -679,9 +679,9 @@ function import_xchan_photo($photo,$xchan,$thing = false) { if($r === false) $photo_failure = true; - $photo = $a->get_baseurl() . '/photo/' . $hash . '-4'; - $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5'; - $micro = $a->get_baseurl() . '/photo/' . $hash . '-6'; + $photo = z_root() . '/photo/' . $hash . '-4'; + $thumb = z_root() . '/photo/' . $hash . '-5'; + $micro = z_root() . '/photo/' . $hash . '-6'; } else { logger('import_xchan_photo: invalid image from ' . $photo); @@ -689,9 +689,9 @@ function import_xchan_photo($photo,$xchan,$thing = false) { } } if($photo_failure) { - $photo = $a->get_baseurl() . '/' . get_default_profile_photo(); - $thumb = $a->get_baseurl() . '/' . get_default_profile_photo(80); - $micro = $a->get_baseurl() . '/' . get_default_profile_photo(48); + $photo = z_root() . '/' . get_default_profile_photo(); + $thumb = z_root() . '/' . get_default_profile_photo(80); + $micro = z_root() . '/' . get_default_profile_photo(48); $type = 'image/png'; } diff --git a/include/photos.php b/include/photos.php index 5dd5f3c62..5838c013f 100644 --- a/include/photos.php +++ b/include/photos.php @@ -490,12 +490,12 @@ function photos_album_widget($channelx,$observer,$albums = null) { $o = ''; // If we weren't passed an album list, see if the photos module - // dropped one for us to find in $a->data['albums']. + // dropped one for us to find in App::$data['albums']. // If all else fails, load it. if(! $albums) { - if(array_key_exists('albums', get_app()->data)) - $albums = get_app()->data['albums']; + if(array_key_exists('albums', App::$data)) + $albums = App::$data['albums']; else $albums = photos_albums_list($channelx,$observer); } diff --git a/include/plugin.php b/include/plugin.php index bd844442f..8dceb8fb1 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -219,7 +219,7 @@ function unregister_hook($hook, $file, $function) { // -// It might not be obvious but themes can manually add hooks to the $a->hooks +// It might not be obvious but themes can manually add hooks to the App::$hooks // array in their theme_init() and use this to customise the app behaviour. // UPDATE: use insert_hook($hookname,$function_name) to do this // @@ -227,19 +227,19 @@ function unregister_hook($hook, $file, $function) { function load_hooks() { $a = get_app(); -// if(! is_array($a->hooks)) - $a->hooks = array(); +// if(! is_array(App::$hooks)) + App::$hooks = array(); $r = q("SELECT * FROM hook WHERE true ORDER BY priority DESC"); if($r) { foreach($r as $rr) { - if(! array_key_exists($rr['hook'],$a->hooks)) - $a->hooks[$rr['hook']] = array(); + if(! array_key_exists($rr['hook'],App::$hooks)) + App::$hooks[$rr['hook']] = array(); - $a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']); + App::$hooks[$rr['hook']][] = array($rr['file'],$rr['function']); } } -//logger('hooks: ' . print_r($a->hooks,true)); +//logger('hooks: ' . print_r(App::$hooks,true)); } /** @@ -261,13 +261,13 @@ function load_hooks() { */ function insert_hook($hook, $fn) { $a = get_app(); - if(! is_array($a->hooks)) - $a->hooks = array(); + if(! is_array(App::$hooks)) + App::$hooks = array(); - if(! array_key_exists($hook, $a->hooks)) - $a->hooks[$hook] = array(); + if(! array_key_exists($hook, App::$hooks)) + App::$hooks[$hook] = array(); - $a->hooks[$hook][] = array('', $fn); + App::$hooks[$hook][] = array('', $fn); } /** @@ -282,8 +282,8 @@ function insert_hook($hook, $fn) { function call_hooks($name, &$data = null) { $a = get_app(); - if((is_array($a->hooks)) && (array_key_exists($name, $a->hooks))) { - foreach($a->hooks[$name] as $hook) { + if((is_array(App::$hooks)) && (array_key_exists($name, App::$hooks))) { + foreach(App::$hooks[$name] as $hook) { if($hook[0]) @include_once($hook[0]); @@ -392,7 +392,7 @@ function check_plugin_versions($info) { $test = trim($test); if(! $test) continue; - if(! in_array($test,get_app()->plugins)) + if(! in_array($test,App::$plugins)) $found = false; } } @@ -495,10 +495,10 @@ function get_theme_screenshot($theme) { $exts = array('.png', '.jpg'); foreach($exts as $ext) { if(file_exists('view/theme/' . $theme . '/img/screenshot' . $ext)) - return($a->get_baseurl() . '/view/theme/' . $theme . '/img/screenshot' . $ext); + return(z_root() . '/view/theme/' . $theme . '/img/screenshot' . $ext); } - return($a->get_baseurl() . '/images/blank.png'); + return(z_root() . '/images/blank.png'); } /** @@ -508,19 +508,19 @@ function get_theme_screenshot($theme) { * @param string $media change media attribute (default to 'screen') */ function head_add_css($src, $media = 'screen') { - get_app()->css_sources[] = array($src, $media); + App::$css_sources[] = array($src, $media); } function head_remove_css($src, $media = 'screen') { $a = get_app(); - $index = array_search(array($src, $media), $a->css_sources); + $index = array_search(array($src, $media), App::$css_sources); if ($index !== false) - unset($a->css_sources[$index]); + unset(App::$css_sources[$index]); } function head_get_css() { $str = ''; - $sources = get_app()->css_sources; + $sources = App::$css_sources; if (count($sources)) { foreach ($sources as $source) $str .= format_css_if_exists($source); @@ -560,7 +560,7 @@ function script_path() { // Some proxy setups may require using http_host - if(intval(get_app()->config['system']['script_path_use_http_host'])) + if(intval(App::$config['system']['script_path_use_http_host'])) $server_var = 'HTTP_HOST'; else $server_var = 'SERVER_NAME'; @@ -576,19 +576,19 @@ function script_path() { } function head_add_js($src) { - get_app()->js_sources[] = $src; + App::$js_sources[] = $src; } function head_remove_js($src) { $a = get_app(); - $index = array_search($src, $a->js_sources); + $index = array_search($src, App::$js_sources); if($index !== false) - unset($a->js_sources[$index]); + unset(App::$js_sources[$index]); } function head_get_js() { $str = ''; - $sources = get_app()->js_sources; + $sources = App::$js_sources; if(count($sources)) foreach($sources as $source) { if($source === 'main.js') @@ -624,7 +624,7 @@ function theme_include($file, $root = '') { if($root !== '' && $root[strlen($root)-1] !== '/') $root = $root . '/'; - $theme_info = $a->theme_info; + $theme_info = App::$theme_info; if(array_key_exists('extends',$theme_info)) $parent = $theme_info['extends']; @@ -656,7 +656,7 @@ function theme_include($file, $root = '') { function get_intltext_template($s, $root = '') { $a = get_app(); - $t = $a->template_engine(); + $t = App::template_engine(); $template = $t->get_intltext_template($s, $root); return $template; @@ -665,7 +665,7 @@ function get_intltext_template($s, $root = '') { function get_markup_template($s, $root = '') { $a = get_app(); - $t = $a->template_engine(); + $t = App::template_engine(); $template = $t->get_markup_template($s, $root); return $template; } diff --git a/include/security.php b/include/security.php index f3cf2d1b6..38045c8a9 100644 --- a/include/security.php +++ b/include/security.php @@ -14,21 +14,19 @@ */ function authenticate_success($user_record, $login_initial = false, $interactive = false, $return = false, $update_lastlog = false) { - $a = get_app(); - $_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; $lastlog_updated = false; if(x($user_record, 'account_id')) { - $a->account = $user_record; + App::$account = $user_record; $_SESSION['account_id'] = $user_record['account_id']; $_SESSION['authenticated'] = 1; $uid_to_load = (((x($_SESSION,'uid')) && (intval($_SESSION['uid']))) ? intval($_SESSION['uid']) - : intval($a->account['account_default_channel']) + : intval(App::$account['account_default_channel']) ); if($uid_to_load) { @@ -40,9 +38,9 @@ function authenticate_success($user_record, $login_initial = false, $interactive dbesc(datetime_convert()), intval($_SESSION['account_id']) ); - $a->account['account_lastlog'] = datetime_convert(); + App::$account['account_lastlog'] = datetime_convert(); $lastlog_updated = true; - call_hooks('logged_in', $a->account); + call_hooks('logged_in', App::$account); } } @@ -59,7 +57,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive return; } - if(($a->module !== 'home') && x($_SESSION,'login_return_url') && strlen($_SESSION['login_return_url'])) { + if((App::$module !== 'home') && x($_SESSION,'login_return_url') && strlen($_SESSION['login_return_url'])) { $return_url = $_SESSION['login_return_url']; // don't let members get redirected to a raw ajax page update - this can happen @@ -68,14 +66,14 @@ function authenticate_success($user_record, $login_initial = false, $interactive $return_url = ''; unset($_SESSION['login_return_url']); - goaway($a->get_baseurl() . '/' . $return_url); + goaway(z_root() . '/' . $return_url); } /* This account has never created a channel. Send them to new_channel by default */ - if($a->module === 'login') { + if(App::$module === 'login') { $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0 ", - intval($a->account['account_id']) + intval(App::$account['account_id']) ); if(($r) && (! $r[0]['total'])) goaway(z_root() . '/new_channel'); @@ -116,7 +114,7 @@ function change_channel($change_channel) { if($r) { $hash = $r[0]['channel_hash']; $_SESSION['uid'] = intval($r[0]['channel_id']); - get_app()->set_channel($r[0]); + App::set_channel($r[0]); $_SESSION['theme'] = $r[0]['channel_theme']; $_SESSION['mobile_theme'] = get_pconfig(local_channel(),'system', 'mobile_theme'); date_default_timezone_set($r[0]['channel_timezone']); @@ -127,10 +125,10 @@ function change_channel($change_channel) { ); if($x) { $_SESSION['my_url'] = $x[0]['xchan_url']; - $_SESSION['my_address'] = $r[0]['channel_address'] . '@' . substr(get_app()->get_baseurl(), strpos(get_app()->get_baseurl(), '://') + 3); + $_SESSION['my_address'] = $r[0]['channel_address'] . '@' . substr(z_root(), strpos(z_root(), '://') + 3); - get_app()->set_observer($x[0]); - get_app()->set_perms(get_all_perms(local_channel(), $hash)); + App::set_observer($x[0]); + App::set_perms(get_all_perms(local_channel(), $hash)); } if(! is_dir('store/' . $r[0]['channel_address'])) @os_mkdir('store/' . $r[0]['channel_address'], STORAGE_DEFAULT_PERMISSIONS,true); @@ -293,7 +291,7 @@ function scopes_sql($uid,$observer) { if(! is_foreigner($observer)) $str .= " or public_policy = 'network: red' "; if(local_channel()) - $str .= " or public_policy = 'site: " . get_app()->get_hostname() . "' "; + $str .= " or public_policy = 'site: " . App::get_hostname() . "' "; $ab = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1", dbesc($observer), @@ -320,7 +318,7 @@ function scopes_sql($uid,$observer) { */ function public_permissions_sql($observer_hash) { - //$observer = get_app()->get_observer(); + //$observer = App::get_observer(); $groups = init_groups_visitor($observer_hash); $gs = '<<>>'; // should be impossible to match @@ -360,10 +358,9 @@ function public_permissions_sql($observer_hash) { * so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types). */ function get_form_security_token($typename = '') { - $a = get_app(); $timestamp = time(); - $sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $timestamp . $typename); + $sec_hash = hash('whirlpool', App::$observer['xchan_guid'] . ((local_channel()) ? App::$channel['channel_prvkey'] : '') . session_id() . $timestamp . $typename); return $timestamp . '.' . $sec_hash; } @@ -374,12 +371,10 @@ function check_form_security_token($typename = '', $formname = 'form_security_to $max_livetime = 10800; // 3 hours - $a = get_app(); - $x = explode('.', $hash); if (time() > (IntVal($x[0]) + $max_livetime)) return false; - $sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $x[0] . $typename); + $sec_hash = hash('whirlpool', App::$observer['xchan_guid'] . ((local_channel()) ? App::$channel['channel_prvkey'] : '') . session_id() . $x[0] . $typename); return ($sec_hash == $x[1]); } @@ -389,17 +384,15 @@ function check_form_security_std_err_msg() { } function check_form_security_token_redirectOnErr($err_redirect, $typename = '', $formname = 'form_security_token') { if (!check_form_security_token($typename, $formname)) { - $a = get_app(); - logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename); + logger('check_form_security_token failed: user ' . App::$observer['xchan_name'] . ' - form element ' . $typename); logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); notice( check_form_security_std_err_msg() ); - goaway($a->get_baseurl() . $err_redirect ); + goaway(z_root() . $err_redirect ); } } function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') { if (!check_form_security_token($typename, $formname)) { - $a = get_app(); - logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename); + logger('check_form_security_token failed: user ' . App::$observer['xchan_name'] . ' - form element ' . $typename); logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); header('HTTP/1.1 403 Forbidden'); killme(); diff --git a/include/session.php b/include/session.php index 6060e4712..71bfdc12a 100644 --- a/include/session.php +++ b/include/session.php @@ -156,12 +156,12 @@ session_set_save_handler( // Force cookies to be secure (https only) if this site is SSL enabled. Must be done before session_start(). - if(intval(get_app()->config['system']['ssl_cookie_protection'])) { + if(intval(App::$config['system']['ssl_cookie_protection'])) { $arr = session_get_cookie_params(); session_set_cookie_params( ((isset($arr['lifetime'])) ? $arr['lifetime'] : 0), ((isset($arr['path'])) ? $arr['path'] : '/'), - ((isset($arr['domain'])) ? $arr['domain'] : get_app()->get_hostname()), + ((isset($arr['domain'])) ? $arr['domain'] : App::get_hostname()), ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false), ((isset($arr['httponly'])) ? $arr['httponly'] : true)); }
\ No newline at end of file diff --git a/include/smarty.php b/include/smarty.php index 99f143db1..3812c6021 100755 --- a/include/smarty.php +++ b/include/smarty.php @@ -16,19 +16,19 @@ class FriendicaSmarty extends Smarty { // setTemplateDir can be set to an array, which Smarty will parse in order. // The order is thus very important here $template_dirs = array('theme' => "view/theme/$theme/tpl/"); - if( x($a->theme_info,"extends") ) - $template_dirs = $template_dirs + array('extends' => "view/theme/".$a->theme_info["extends"]."/tpl/"); + if( x(App::$theme_info,"extends") ) + $template_dirs = $template_dirs + array('extends' => "view/theme/".App::$theme_info["extends"]."/tpl/"); $template_dirs = $template_dirs + array('base' => 'view/tpl/'); $this->setTemplateDir($template_dirs); - $basecompiledir = $a->config['system']['smarty3_folder']; + $basecompiledir = App::$config['system']['smarty3_folder']; $this->setCompileDir($basecompiledir.'/compiled/'); $this->setConfigDir($basecompiledir.'/config/'); $this->setCacheDir($basecompiledir.'/cache/'); - $this->left_delimiter = $a->get_template_ldelim('smarty3'); - $this->right_delimiter = $a->get_template_rdelim('smarty3'); + $this->left_delimiter = App::get_template_ldelim('smarty3'); + $this->right_delimiter = App::get_template_rdelim('smarty3'); // Don't report errors so verbosely $this->error_reporting = E_ALL & ~E_NOTICE; @@ -53,7 +53,7 @@ class FriendicaSmartyEngine implements ITemplateEngine { // Cannot use get_config() here because it is called during installation when there is no DB. // FIXME: this may leak private information such as system pathnames. - $basecompiledir = ((array_key_exists('smarty3_folder',$a->config['system'])) ? $a->config['system']['smarty3_folder'] : ''); + $basecompiledir = ((array_key_exists('smarty3_folder',App::$config['system'])) ? App::$config['system']['smarty3_folder'] : ''); if (!$basecompiledir) $basecompiledir = dirname(__dir__) . "/" . TEMPLATE_BUILD_PATH; if (!is_dir($basecompiledir)) { echo "<b>ERROR:</b> folder <tt>$basecompiledir</tt> does not exist."; killme(); @@ -61,7 +61,7 @@ class FriendicaSmartyEngine implements ITemplateEngine { if(!is_writable($basecompiledir)){ echo "<b>ERROR:</b> folder <tt>$basecompiledir</tt> must be writable by webserver."; killme(); } - $a->config['system']['smarty3_folder'] = $basecompiledir; + App::$config['system']['smarty3_folder'] = $basecompiledir; } // ITemplateEngine interface @@ -94,8 +94,8 @@ class FriendicaSmartyEngine implements ITemplateEngine { public function get_intltext_template($file, $root='') { $a = get_app(); - if(file_exists("view/{$a->language}/$file")) - $template_file = "view/{$a->language}/$file"; + if(file_exists("view/{App::$language}/$file")) + $template_file = "view/{App::$language}/$file"; elseif(file_exists("view/en/$file")) $template_file = "view/en/$file"; else diff --git a/include/socgraph.php b/include/socgraph.php index e44a8ea9a..1b1bccf20 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -409,7 +409,7 @@ function poco($a,$extended = false) { http_status_exit(401); } - $observer = $a->get_observer(); + $observer = App::get_observer(); if(argc() > 1) { $user = notags(trim(argv(1))); diff --git a/include/taxonomy.php b/include/taxonomy.php index 5ef106938..71ed6e91d 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -299,7 +299,7 @@ function dir_tagblock($link,$r) { if(! $r) - $r = get_app()->data['directory_keywords']; + $r = App::$data['directory_keywords']; if($r) { $o = '<div class="dirtagblock widget"><h3>' . t('Keywords') . '</h3><div class="tags" align="center">'; diff --git a/include/text.php b/include/text.php index 621f4cf93..a1a1cfb1c 100644 --- a/include/text.php +++ b/include/text.php @@ -27,7 +27,7 @@ function replace_macros($s, $r) { $arr = array('template' => $s, 'params' => $r); call_hooks('replace_macros', $arr); - $t = $a->template_engine(); + $t = App::template_engine(); $output = $t->replace_macros($arr['template'],$arr['params']); return $output; @@ -99,7 +99,7 @@ function z_input_filter($channel_id,$s,$type = 'text/bbcode') { return escape_tags($s); $a = get_app(); - if($a->is_sys) { + if(App::$is_sys) { return $s; } @@ -368,34 +368,34 @@ function hex2bin($s) { // Automatic pagination. // To use, get the count of total items. -// Then call $a->set_pager_total($number_items); -// Optionally call $a->set_pager_itemspage($n) to the number of items to display on each page +// Then call App::set_pager_total($number_items); +// Optionally call App::set_pager_itemspage($n) to the number of items to display on each page // Then call paginate($a) after the end of the display loop to insert the pager block on the page // (assuming there are enough items to paginate). -// When using with SQL, the setting LIMIT %d, %d => $a->pager['start'],$a->pager['itemspage'] +// When using with SQL, the setting LIMIT %d, %d => App::$pager['start'],App::$pager['itemspage'] // will limit the results to the correct items for the current page. // The actual page handling is then accomplished at the application layer. function paginate(&$a) { $o = ''; - $stripped = preg_replace('/(&page=[0-9]*)/','',$a->query_string); + $stripped = preg_replace('/(&page=[0-9]*)/','',App::$query_string); // $stripped = preg_replace('/&zid=(.*?)([\?&]|$)/ism','',$stripped); $stripped = str_replace('q=','',$stripped); $stripped = trim($stripped,'/'); - $pagenum = $a->pager['page']; - $url = $a->get_baseurl() . '/' . $stripped; + $pagenum = App::$pager['page']; + $url = z_root() . '/' . $stripped; - if($a->pager['total'] > $a->pager['itemspage']) { + if(App::$pager['total'] > App::$pager['itemspage']) { $o .= '<div class="pager">'; - if($a->pager['page'] != 1) - $o .= '<span class="pager_prev">'."<a href=\"$url".'&page='.($a->pager['page'] - 1).'">' . t('prev') . '</a></span> '; + if(App::$pager['page'] != 1) + $o .= '<span class="pager_prev">'."<a href=\"$url".'&page='.(App::$pager['page'] - 1).'">' . t('prev') . '</a></span> '; $o .= "<span class=\"pager_first\"><a href=\"$url"."&page=1\">" . t('first') . "</a></span> "; - $numpages = $a->pager['total'] / $a->pager['itemspage']; + $numpages = App::$pager['total'] / App::$pager['itemspage']; $numstart = 1; $numstop = $numpages; @@ -406,15 +406,15 @@ function paginate(&$a) { } for($i = $numstart; $i <= $numstop; $i++){ - if($i == $a->pager['page']) + if($i == App::$pager['page']) $o .= '<span class="pager_current">'.(($i < 10) ? ' '.$i : $i); else $o .= "<span class=\"pager_n\"><a href=\"$url"."&page=$i\">".(($i < 10) ? ' '.$i : $i)."</a>"; $o .= '</span> '; } - if(($a->pager['total'] % $a->pager['itemspage']) != 0) { - if($i == $a->pager['page']) + if((App::$pager['total'] % App::$pager['itemspage']) != 0) { + if($i == App::$pager['page']) $o .= '<span class="pager_current">'.(($i < 10) ? ' '.$i : $i); else $o .= "<span class=\"pager_n\"><a href=\"$url"."&page=$i\">".(($i < 10) ? ' '.$i : $i)."</a>"; @@ -424,8 +424,8 @@ function paginate(&$a) { $lastpage = (($numpages > intval($numpages)) ? intval($numpages)+1 : $numpages); $o .= "<span class=\"pager_last\"><a href=\"$url"."&page=$lastpage\">" . t('last') . "</a></span> "; - if(($a->pager['total'] - ($a->pager['itemspage'] * $a->pager['page'])) > 0) - $o .= '<span class="pager_next">'."<a href=\"$url"."&page=".($a->pager['page'] + 1).'">' . t('next') . '</a></span>'; + if((App::$pager['total'] - (App::$pager['itemspage'] * App::$pager['page'])) > 0) + $o .= '<span class="pager_next">'."<a href=\"$url"."&page=".(App::$pager['page'] + 1).'">' . t('next') . '</a></span>'; $o .= '</div>'."\r\n"; } return $o; @@ -439,20 +439,20 @@ function alt_pager(&$a, $i, $more = '', $less = '') { if(! $less) $less = t('newer'); - $stripped = preg_replace('/(&page=[0-9]*)/','',$a->query_string); + $stripped = preg_replace('/(&page=[0-9]*)/','',App::$query_string); $stripped = str_replace('q=','',$stripped); $stripped = trim($stripped,'/'); - //$pagenum = $a->pager['page']; - $url = $a->get_baseurl() . '/' . $stripped; + //$pagenum = App::$pager['page']; + $url = z_root() . '/' . $stripped; return replace_macros(get_markup_template('alt_pager.tpl'), array( - '$has_less' => (($a->pager['page'] > 1) ? true : false), - '$has_more' => (($i > 0 && $i >= $a->pager['itemspage']) ? true : false), + '$has_less' => ((App::$pager['page'] > 1) ? true : false), + '$has_more' => (($i > 0 && $i >= App::$pager['itemspage']) ? true : false), '$less' => $less, '$more' => $more, '$url' => $url, - '$prevpage' => $a->pager['page'] - 1, - '$nextpage' => $a->pager['page'] + 1, + '$prevpage' => App::$pager['page'] - 1, + '$nextpage' => App::$pager['page'] + 1, )); } @@ -470,7 +470,7 @@ function item_message_id() { do { $dups = false; $hash = random_string(); - $mid = $hash . '@' . get_app()->get_hostname(); + $mid = $hash . '@' . App::get_hostname(); $r = q("SELECT id FROM item WHERE mid = '%s' LIMIT 1", dbesc($mid)); @@ -544,7 +544,7 @@ function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { global $a; global $db; - if(($a->module == 'install') || (! ($db && $db->connected))) + if((App::$module == 'install') || (! ($db && $db->connected))) return; $debugging = get_config('system', 'debugging'); @@ -569,6 +569,25 @@ function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { @file_put_contents($pluginfo['filename'], $pluginfo['message'], FILE_APPEND); } +// like logger() but with a function backtrace to pinpoint certain classes +// of problems which show up deep in the calling stack + + +function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { + + logger($msg, $level, $priority); + if(version_compare(PHP_VERSION, '5.4.0') >= 0) { + $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + if($stack) { + for($x = 1; $x < count($stack); $x ++) { + logger('stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()',$level, $priority); + } + } + } +} + + + function log_priority_str($priority) { $parr = array( LOG_EMERG => 'LOG_EMERG', @@ -606,7 +625,7 @@ function dlogger($msg, $level = 0) { global $a; global $db; - if(($a->module == 'install') || (! ($db && $db->connected))) + if((App::$module == 'install') || (! ($db && $db->connected))) return; $debugging = get_config('system','debugging'); @@ -766,20 +785,20 @@ function contact_block() { $o = ''; $a = get_app(); - if(! $a->profile['uid']) + if(! App::$profile['uid']) return; - if(! perm_is_allowed($a->profile['uid'],get_observer_hash(),'view_contacts')) + if(! perm_is_allowed(App::$profile['uid'],get_observer_hash(),'view_contacts')) return; - $shown = get_pconfig($a->profile['uid'],'system','display_friend_count'); + $shown = get_pconfig(App::$profile['uid'],'system','display_friend_count'); if($shown === false) $shown = 25; if($shown == 0) return; - $is_owner = ((local_channel() && local_channel() == $a->profile['uid']) ? true : false); + $is_owner = ((local_channel() && local_channel() == App::$profile['uid']) ? true : false); $sql_extra = ''; $abook_flags = " and abook_pending = 0 and abook_self = 0 "; @@ -789,12 +808,12 @@ function contact_block() { $sql_extra = " and xchan_hidden = 0 "; } - if((! is_array($a->profile)) || ($a->profile['hide_friends'])) + if((! is_array(App::$profile)) || (App::$profile['hide_friends'])) return $o; $r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d $abook_flags and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra", - intval($a->profile['uid']) + intval(App::$profile['uid']) ); if(count($r)) { $total = intval($r[0]['total']); @@ -807,7 +826,7 @@ function contact_block() { $randfunc = db_getfunc('RAND'); $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d $abook_flags and abook_archived = 0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ORDER BY $randfunc LIMIT %d", - intval($a->profile['uid']), + intval(App::$profile['uid']), intval($shown) ); @@ -824,7 +843,7 @@ function contact_block() { $tpl = get_markup_template('contact_block.tpl'); $o = replace_macros($tpl, array( '$contacts' => $contacts, - '$nickname' => $a->profile['channel_address'], + '$nickname' => App::$profile['channel_address'], '$viewconnections' => (($total > $shown) ? sprintf(t('View all %s connections'),$total) : ''), '$micropro' => $micropro, )); @@ -881,7 +900,7 @@ function search($s,$id='search-box',$url='/search',$save = false) { return replace_macros(get_markup_template('searchbox.tpl'),array( '$s' => $s, '$id' => $id, - '$action_url' => $a->get_baseurl((stristr($url,'network')) ? true : false) . $url, + '$action_url' => z_root() . $url, '$search_label' => t('Search'), '$save_label' => t('Save'), '$savedsearch' => feature_enabled(local_channel(),'savedsearch') @@ -1062,41 +1081,41 @@ function list_smilies() { ); $icons = array( - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-heart.gif" alt="<3" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="</3" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-brokenheart.gif" alt="<\\3" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-smile.gif" alt=":-)" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-wink.gif" alt=";-)" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-frown.gif" alt=":-(" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-P" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-p" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-\"" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-\"" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-kiss.gif" alt=":-X" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-laughing.gif" alt=":-D" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-surprised.gif" alt=":-O" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-thumbsup.gif" alt="\\o/" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="o.O" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="O.o" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="o_O" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="O_o" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-cry.gif" alt=":\'(" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-embarassed.gif" alt=":-[" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-cool.gif" alt="8-)" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/beer_mug.gif" alt=":beer" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/beer_mug.gif" alt=":homebrew" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/coffee.gif" alt=":coffee" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-facepalm.gif" alt=":facepalm" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/like.gif" alt=":like" />', - '<img class="smiley" src="' . $a->get_baseurl() . '/images/dislike.gif" alt=":dislike" />', - '<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . $a->get_baseurl() . '/images/rm-32.png" alt="' . urlencode('red#matrix') . '" />matrix</strong></a>', - '<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . $a->get_baseurl() . '/images/rm-32.png" alt="' . urlencode('red#') . '" />matrix</strong></a>', - '<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . $a->get_baseurl() . '/images/rm-32.png" alt="r#" />matrix</strong></a>' + '<img class="smiley" src="' . z_root() . '/images/smiley-heart.gif" alt="<3" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-brokenheart.gif" alt="</3" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-brokenheart.gif" alt="<\\3" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-smile.gif" alt=":-)" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-wink.gif" alt=";-)" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-frown.gif" alt=":-(" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-tongue-out.gif" alt=":-P" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-tongue-out.gif" alt=":-p" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-kiss.gif" alt=":-\"" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-kiss.gif" alt=":-\"" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-kiss.gif" alt=":-x" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-kiss.gif" alt=":-X" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-laughing.gif" alt=":-D" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt="8-|" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt="8-O" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt=":-O" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-thumbsup.gif" alt="\\o/" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="o.O" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="O.o" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="o_O" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="O_o" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-cry.gif" alt=":\'(" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-foot-in-mouth.gif" alt=":-!" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-undecided.gif" alt=":-/" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-embarassed.gif" alt=":-[" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-cool.gif" alt="8-)" />', + '<img class="smiley" src="' . z_root() . '/images/beer_mug.gif" alt=":beer" />', + '<img class="smiley" src="' . z_root() . '/images/beer_mug.gif" alt=":homebrew" />', + '<img class="smiley" src="' . z_root() . '/images/coffee.gif" alt=":coffee" />', + '<img class="smiley" src="' . z_root() . '/images/smiley-facepalm.gif" alt=":facepalm" />', + '<img class="smiley" src="' . z_root() . '/images/like.gif" alt=":like" />', + '<img class="smiley" src="' . z_root() . '/images/dislike.gif" alt=":dislike" />', + '<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . z_root() . '/images/rm-32.png" alt="' . urlencode('red#matrix') . '" />matrix</strong></a>', + '<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . z_root() . '/images/rm-32.png" alt="' . urlencode('red#') . '" />matrix</strong></a>', + '<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . z_root() . '/images/rm-32.png" alt="r#" />matrix</strong></a>' ); @@ -1173,7 +1192,7 @@ function preg_heart($x) { $t = ''; for($cnt = 0; $cnt < strlen($x[1]); $cnt ++) - $t .= '<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-heart.gif" alt="<3" />'; + $t .= '<img class="smiley" src="' . z_root() . '/images/smiley-heart.gif" alt="<3" />'; $r = str_replace($x[0],$t,$x[0]); @@ -1701,12 +1720,12 @@ function feed_hublinks() { function feed_salmonlinks($nick) { $a = get_app(); - $salmon = '<link rel="salmon" href="' . xmlify($a->get_baseurl() . '/salmon/' . $nick) . '" />' . "\n" ; + $salmon = '<link rel="salmon" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ; // old style links that status.net still needed as of 12/2010 - $salmon .= ' <link rel="http://salmon-protocol.org/ns/salmon-replies" href="' . xmlify($a->get_baseurl() . '/salmon/' . $nick) . '" />' . "\n" ; - $salmon .= ' <link rel="http://salmon-protocol.org/ns/salmon-mention" href="' . xmlify($a->get_baseurl() . '/salmon/' . $nick) . '" />' . "\n" ; + $salmon .= ' <link rel="http://salmon-protocol.org/ns/salmon-replies" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ; + $salmon .= ' <link rel="http://salmon-protocol.org/ns/salmon-mention" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ; return $salmon; } @@ -1768,7 +1787,7 @@ function mimetype_select($channel_id, $current = 'text/bbcode') { ); $a = get_app(); - if($a->is_sys) { + if(App::$is_sys) { $x[] = 'application/x-php'; } else { @@ -1819,7 +1838,7 @@ function lang_selector() { } $ll = substr($l,5); $ll = substr($ll,0,strrpos($ll,'/')); - $selected = (($ll === $a->language && (x($_SESSION, 'language'))) ? $ll : $selected); + $selected = (($ll === App::$language && (x($_SESSION, 'language'))) ? $ll : $selected); $lang_options[$ll] = get_language_name($ll, $ll) . " ($ll)"; } } @@ -2241,10 +2260,10 @@ function json_decode_plus($s) { */ function design_tools() { - $channel = get_app()->get_channel(); + $channel = App::get_channel(); $sys = false; - if(get_app()->is_sys && is_site_admin()) { + if(App::$is_sys && is_site_admin()) { require_once('include/identity.php'); $channel = get_sys_channel(); $sys = true; @@ -2354,8 +2373,8 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d $basetag = str_replace('_',' ',substr($tag,1)); //create text for link - $url = $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag); - $newtag = '#[zrl=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/zrl]'; + $url = z_root() . '/search?tag=' . rawurlencode($basetag); + $newtag = '#[zrl=' . z_root() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/zrl]'; //replace tag by the link. Make sure to not replace something in the middle of a word // The '=' is needed to not replace color codes if the code is also used as a tag // Much better would be to somehow completely avoiding things in e.g. [color]-tags. @@ -2501,7 +2520,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d // $r is set if we found something - $channel = get_app()->get_channel(); + $channel = App::get_channel(); if($r) { $profile = $r[0]['xchan_url']; @@ -2531,7 +2550,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $d if($g && $exclusive) { $access_tag .= 'gid:' . $g[0]['hash']; } - $channel = get_app()->get_channel(); + $channel = App::get_channel(); if($channel) { $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . z_root() . '/channel/' . $channel['channel_address'] . ']' . $newname . '[/zrl]'; $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); @@ -2589,7 +2608,7 @@ function linkify_tags($a, &$body, $uid, $diaspora = false) { if($fullnametagged) continue; - $success = handle_tag($a, $body, $access_tag, $str_tags, ($uid) ? $uid : $a->profile_uid , $tag, $diaspora); + $success = handle_tag($a, $body, $access_tag, $str_tags, ($uid) ? $uid : App::$profile_uid , $tag, $diaspora); $results[] = array('success' => $success, 'access_tag' => $access_tag); if($success['replaced']) $tagged[] = $tag; } diff --git a/include/widgets.php b/include/widgets.php index deb514915..0116e5bd1 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -11,15 +11,15 @@ require_once('include/attach.php'); require_once('include/Contact.php'); function widget_profile($args) { - $a = get_app(); + $block = (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false); - return profile_sidebar($a->profile, $block, true); + return profile_sidebar(App::$profile, $block, true); } function widget_zcard($args) { - $a = get_app(); + $block = (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false); - $channel = channelx_by_n($a->profile_uid); + $channel = channelx_by_n(App::$profile_uid); return get_zcard($channel,get_observer_hash(),array('width' => 875)); } @@ -33,8 +33,8 @@ function widget_tagcloud($args) { $o = ''; //$tab = 0; - $a = get_app(); - $uid = $a->profile_uid; + + $uid = App::$profile_uid; $count = ((x($args,'count')) ? intval($args['count']) : 24); $flags = 0; $type = TERM_CATEGORY; @@ -85,7 +85,7 @@ function widget_collections($args) { $each = 'group'; $edit = false; $current = 0; - $abook_id = get_app()->poi['abook_xchan']; + $abook_id = App::$poi['abook_xchan']; $wmode = 1; break; default: @@ -164,8 +164,7 @@ function widget_follow($args) { if(! local_channel()) return ''; - $a = get_app(); - $uid =$a->channel['channel_id']; + $uid = App::$channel['channel_id']; $r = q("select count(*) as total from abook where abook_channel = %d and abook_self = 0 ", intval($uid) ); @@ -210,8 +209,6 @@ function widget_savedsearch($arr) { if((! local_channel()) || (! feature_enabled(local_channel(),'savedsearch'))) return ''; - $a = get_app(); - $search = ((x($_GET,'search')) ? $_GET['search'] : ''); if(x($_GET,'searchsave') && $search) { @@ -238,7 +235,7 @@ function widget_savedsearch($arr) { $search = ''; } - $srchurl = $a->query_string; + $srchurl = App::$query_string; $srchurl = rtrim(preg_replace('/searchsave\=[^\&].*?(\&|$)/is','',$srchurl),'&'); $hasq = ((strpos($srchurl,'?') !== false) ? true : false); @@ -295,7 +292,6 @@ function widget_filer($arr) { if(! local_channel()) return ''; - $a = get_app(); $selected = ((x($_REQUEST,'file')) ? $_REQUEST['file'] : ''); @@ -316,20 +312,19 @@ function widget_filer($arr) { '$sel_all' => (($selected == '') ? 'selected' : ''), '$all' => t('Everything'), '$terms' => $terms, - '$base' => z_root() . '/' . $a->cmd + '$base' => z_root() . '/' . App::$cmd )); } function widget_archive($arr) { $o = ''; - $a = get_app(); - if(! $a->profile_uid) { + if(! App::$profile_uid) { return ''; } - $uid = $a->profile_uid; + $uid = App::$profile_uid; if(! feature_enabled($uid,'archives')) return ''; @@ -345,7 +340,7 @@ function widget_archive($arr) { if(! $visible_years) $visible_years = 5; - $url = z_root() . '/' . $a->cmd; + $url = z_root() . '/' . App::$cmd; $ret = list_post_dates($uid,$wall,$mindate); @@ -370,34 +365,34 @@ function widget_archive($arr) { function widget_fullprofile($arr) { - $a = get_app(); - if(! $a->profile['profile_uid']) + + if(! App::$profile['profile_uid']) return; $block = (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false); - return profile_sidebar($a->profile, $block); + return profile_sidebar(App::$profile, $block); } function widget_shortprofile($arr) { - $a = get_app(); - if(! $a->profile['profile_uid']) + + if(! App::$profile['profile_uid']) return; $block = (((get_config('system', 'block_public')) && (! local_channel()) && (! remote_channel())) ? true : false); - return profile_sidebar($a->profile, $block, true, true); + return profile_sidebar(App::$profile, $block, true, true); } function widget_categories($arr) { - $a = get_app(); - if($a->profile['profile_uid'] && (! perm_is_allowed($a->profile['profile_uid'],get_observer_hash(),'view_stream'))) + + if(App::$profile['profile_uid'] && (! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'view_stream'))) return ''; $cat = ((x($_REQUEST,'cat')) ? htmlspecialchars($_REQUEST['cat'],ENT_COMPAT,'UTF-8') : ''); - $srchurl = $a->query_string; + $srchurl = App::$query_string; $srchurl = rtrim(preg_replace('/cat\=[^\&].*?(\&|$)/is','',$srchurl),'&'); $srchurl = str_replace(array('?f=','&f='),array('',''),$srchurl); @@ -406,31 +401,31 @@ function widget_categories($arr) { } function widget_tagcloud_wall($arr) { - $a = get_app(); - if((! $a->profile['profile_uid']) || (! $a->profile['channel_hash'])) + + if((! App::$profile['profile_uid']) || (! App::$profile['channel_hash'])) return ''; - if(! perm_is_allowed($a->profile['profile_uid'], get_observer_hash(), 'view_stream')) + if(! perm_is_allowed(App::$profile['profile_uid'], get_observer_hash(), 'view_stream')) return ''; $limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 50); - if(feature_enabled($a->profile['profile_uid'], 'tagadelic')) - return wtagblock($a->profile['profile_uid'], $limit, '', $a->profile['channel_hash'], 'wall'); + if(feature_enabled(App::$profile['profile_uid'], 'tagadelic')) + return wtagblock(App::$profile['profile_uid'], $limit, '', App::$profile['channel_hash'], 'wall'); return ''; } function widget_catcloud_wall($arr) { - $a = get_app(); - if((! $a->profile['profile_uid']) || (! $a->profile['channel_hash'])) + + if((! App::$profile['profile_uid']) || (! App::$profile['channel_hash'])) return ''; - if(! perm_is_allowed($a->profile['profile_uid'], get_observer_hash(), 'view_stream')) + if(! perm_is_allowed(App::$profile['profile_uid'], get_observer_hash(), 'view_stream')) return ''; $limit = ((array_key_exists('limit',$arr)) ? intval($arr['limit']) : 50); - return catblock($a->profile['profile_uid'], $limit, '', $a->profile['channel_hash'], 'wall'); + return catblock(App::$profile['profile_uid'], $limit, '', App::$profile['channel_hash'], 'wall'); } @@ -486,8 +481,8 @@ function widget_settings_menu($arr) { if(! local_channel()) return; - $a = get_app(); - $channel = $a->get_channel(); + + $channel = App::get_channel(); $abook_self_id = 0; @@ -501,16 +496,22 @@ function widget_settings_menu($arr) { if($abk) $abook_self_id = $abk[0]['abook_id']; + $hublocs = q("select count(*) as total from hubloc where hubloc_hash = '%s'", + dbesc($channel['channel_hash']) + ); + + $hublocs = (($hublocs[0]['total'] > 1) ? true : false); + $tabs = array( array( 'label' => t('Account settings'), - 'url' => $a->get_baseurl(true).'/settings/account', + 'url' => z_root().'/settings/account', 'selected' => ((argv(1) === 'account') ? 'active' : ''), ), array( 'label' => t('Channel settings'), - 'url' => $a->get_baseurl(true).'/settings/channel', + 'url' => z_root().'/settings/channel', 'selected' => ((argv(1) === 'channel') ? 'active' : ''), ), @@ -519,42 +520,50 @@ function widget_settings_menu($arr) { if(get_features()) { $tabs[] = array( 'label' => t('Additional features'), - 'url' => $a->get_baseurl(true).'/settings/features', + 'url' => z_root().'/settings/features', 'selected' => ((argv(1) === 'features') ? 'active' : ''), ); } $tabs[] = array( 'label' => t('Feature/Addon settings'), - 'url' => $a->get_baseurl(true).'/settings/featured', + 'url' => z_root().'/settings/featured', 'selected' => ((argv(1) === 'featured') ? 'active' : ''), ); $tabs[] = array( 'label' => t('Display settings'), - 'url' => $a->get_baseurl(true).'/settings/display', + 'url' => z_root().'/settings/display', 'selected' => ((argv(1) === 'display') ? 'active' : ''), - ); - - $tabs[] = array( - 'label' => t('Connected apps'), - 'url' => $a->get_baseurl(true) . '/settings/oauth', - 'selected' => ((argv(1) === 'oauth') ? 'active' : ''), ); + if($hublocs) { + $tabs[] = array( + 'label' => t('Manage locations'), + 'url' => z_root() . '/locs', + 'selected' => ((argv(1) === 'locs') ? 'active' : ''), + ); + } + // IF can go away when UNO export and import is fully functional if(! UNO) { $tabs[] = array( 'label' => t('Export channel'), - 'url' => $a->get_baseurl(true) . '/uexport', + 'url' => z_root() . '/uexport', 'selected' => '' ); } + $tabs[] = array( + 'label' => t('Connected apps'), + 'url' => z_root() . '/settings/oauth', + 'selected' => ((argv(1) === 'oauth') ? 'active' : ''), + ); + if($role === false || $role === 'custom') { $tabs[] = array( 'label' => t('Connection Default Permissions'), - 'url' => $a->get_baseurl(true) . '/connedit/' . $abook_self_id, + 'url' => z_root() . '/connedit/' . $abook_self_id, 'selected' => '' ); } @@ -562,7 +571,7 @@ function widget_settings_menu($arr) { if(feature_enabled(local_channel(),'premium_channel')) { $tabs[] = array( 'label' => t('Premium Channel Settings'), - 'url' => $a->get_baseurl(true) . '/connect/' . $channel['channel_address'], + 'url' => z_root() . '/connect/' . $channel['channel_address'], 'selected' => '' ); } @@ -570,7 +579,7 @@ function widget_settings_menu($arr) { if(feature_enabled(local_channel(),'channel_sources')) { $tabs[] = array( 'label' => t('Channel Sources'), - 'url' => $a->get_baseurl(true) . '/sources', + 'url' => z_root() . '/sources', 'selected' => '' ); } @@ -588,28 +597,27 @@ function widget_mailmenu($arr) { if (! local_channel()) return; - $a = get_app(); return replace_macros(get_markup_template('message_side.tpl'), array( '$title' => t('Private Mail Menu'), '$combined'=>array( 'label' => t('Combined View'), - 'url' => $a->get_baseurl(true) . '/mail/combined', + 'url' => z_root() . '/mail/combined', 'sel' => (argv(1) == 'combined'), ), '$inbox'=>array( 'label' => t('Inbox'), - 'url' => $a->get_baseurl(true) . '/mail/inbox', + 'url' => z_root() . '/mail/inbox', 'sel' => (argv(1) == 'inbox'), ), '$outbox'=>array( 'label' => t('Outbox'), - 'url' => $a->get_baseurl(true) . '/mail/outbox', + 'url' => z_root() . '/mail/outbox', 'sel' => (argv(1) == 'outbox'), ), '$new'=>array( 'label' => t('New Message'), - 'url' => $a->get_baseurl(true) . '/mail/new', + 'url' => z_root() . '/mail/new', 'sel'=> (argv(1) == 'new'), ) )); @@ -620,8 +628,6 @@ function widget_conversations($arr) { if (! local_channel()) return; - $a = get_app(); - if(argc() > 1) { switch(argv(1)) { @@ -646,7 +652,7 @@ function widget_conversations($arr) { require_once('include/message.php'); // private_messages_list() can do other more complicated stuff, for now keep it simple - $r = private_messages_list(local_channel(), $mailbox, $a->pager['start'], $a->pager['itemspage']); + $r = private_messages_list(local_channel(), $mailbox, App::$pager['start'], App::$pager['itemspage']); if(! $r) { info( t('No messages.') . EOL); @@ -721,8 +727,8 @@ function widget_design_tools($arr) { // mod menu doesn't load a profile. For any modules which load a profile, check it. // otherwise local_channel() is sufficient for permissions. - if($a->profile['profile_uid']) - if(($a->profile['profile_uid'] != local_channel()) && (! $a->is_sys)) + if(App::$profile['profile_uid']) + if((App::$profile['profile_uid'] != local_channel()) && (! App::$is_sys)) return ''; if(! local_channel()) @@ -738,22 +744,21 @@ function widget_findpeople($arr) { function widget_photo_albums($arr) { - $a = get_app(); - if(! $a->profile['profile_uid']) + if(! App::$profile['profile_uid']) return ''; - $channelx = channelx_by_n($a->profile['profile_uid']); - if((! $channelx) || (! perm_is_allowed($a->profile['profile_uid'], get_observer_hash(), 'view_storage'))) + $channelx = channelx_by_n(App::$profile['profile_uid']); + if((! $channelx) || (! perm_is_allowed(App::$profile['profile_uid'], get_observer_hash(), 'view_storage'))) return ''; require_once('include/photos.php'); - return photos_album_widget($channelx, $a->get_observer()); + return photos_album_widget($channelx, App::get_observer()); } function widget_vcard($arr) { require_once ('include/Contact.php'); - return vcard_from_xchan('', get_app()->get_observer()); + return vcard_from_xchan('', App::get_observer()); } @@ -771,24 +776,35 @@ function widget_dirtags($arr) { } function widget_menu_preview($arr) { - if(! get_app()->data['menu_item']) + if(! App::$data['menu_item']) return; require_once('include/menu.php'); - return menu_render(get_app()->data['menu_item']); + return menu_render(App::$data['menu_item']); } function widget_chatroom_list($arr) { - $a = get_app(); require_once("include/chat.php"); - $r = chatroom_list($a->profile['profile_uid']); - return replace_macros(get_markup_template('chatroomlist.tpl'), array( - '$header' => t('Chat Rooms'), - '$baseurl' => z_root(), - '$nickname' => $a->profile['channel_address'], - '$items' => $r, + $r = chatroom_list(App::$profile['profile_uid']); + + if($r) { + return replace_macros(get_markup_template('chatroomlist.tpl'), array( + '$header' => t('Chatrooms'), + '$baseurl' => z_root(), + '$nickname' => App::$profile['channel_address'], + '$items' => $r, + '$overview' => t('Overview') + )); + } +} + +function widget_chatroom_members() { + $o = replace_macros(get_markup_template('chatroom_members.tpl'), array( + '$header' => t('Chat Members') )); + + return $o; } function widget_bookmarkedchats($arr) { @@ -835,7 +851,7 @@ function widget_item($arr) { if(array_key_exists('channel_id',$arr) && intval($arr['channel_id'])) $channel_id = intval($arr['channel_id']); if(! $channel_id) - $channel_id = get_app()->profile_uid; + $channel_id = App::$profile_uid; if(! $channel_id) return ''; @@ -981,17 +997,15 @@ function widget_cover_photo($arr) { require_once('include/identity.php'); $o = ''; - - $a = get_app(); - if($a->module == 'channel' && $_REQUEST['mid']) + if(App::$module == 'channel' && $_REQUEST['mid']) return ''; $channel_id = 0; if(array_key_exists('channel_id', $arr) && intval($arr['channel_id'])) $channel_id = intval($arr['channel_id']); if(! $channel_id) - $channel_id = $a->profile_uid; + $channel_id = App::$profile_uid; if(! $channel_id) return ''; @@ -1047,13 +1061,13 @@ function widget_photo_rand($arr) { if(array_key_exists('channel_id', $arr) && intval($arr['channel_id'])) $channel_id = intval($arr['channel_id']); if(! $channel_id) - $channel_id = get_app()->profile_uid; + $channel_id = App::$profile_uid; if(! $channel_id) return ''; $scale = ((array_key_exists('scale',$arr)) ? intval($arr['scale']) : 0); - $ret = photos_list_photos(array('channel_id' => $channel_id),get_app()->get_observer(),$album); + $ret = photos_list_photos(array('channel_id' => $channel_id),App::get_observer(),$album); $filtered = array(); if($ret['success'] && $ret['photos']) @@ -1097,7 +1111,7 @@ function widget_random_block($arr) { if(array_key_exists('channel_id',$arr) && intval($arr['channel_id'])) $channel_id = intval($arr['channel_id']); if(! $channel_id) - $channel_id = get_app()->profile_uid; + $channel_id = App::$profile_uid; if(! $channel_id) return ''; @@ -1133,7 +1147,7 @@ function widget_random_block($arr) { function widget_rating($arr) { - $a = get_app(); + $poco_rating = get_config('system','poco_rating_enable'); if((! $poco_rating) && ($poco_rating !== false)) { @@ -1143,7 +1157,7 @@ function widget_rating($arr) { if($arr['target']) $hash = $arr['target']; else - $hash = $a->poi['xchan_hash']; + $hash = App::$poi['xchan_hash']; if(! $hash) return; @@ -1152,7 +1166,7 @@ function widget_rating($arr) { $remote = false; if(remote_channel() && ! local_channel()) { - $ob = $a->get_observer(); + $ob = App::get_observer(); if($ob && $ob['xchan_url']) { $p = parse_url($ob['xchan_url']); if($p) { @@ -1166,7 +1180,7 @@ function widget_rating($arr) { $self = false; if(local_channel()) { - $channel = $a->get_channel(); + $channel = App::get_channel(); if($hash == $channel['channel_hash']) $self = true; @@ -1195,7 +1209,7 @@ function widget_rating($arr) { // used by site ratings pages to provide a return link function widget_pubsites($arr) { - if(get_app()->poi) + if(App::$poi) return; return '<div class="widget"><ul class="nav nav-pills"><li><a href="pubsites">' . t('Public Hubs') . '</a></li></ul></div>'; } @@ -1203,8 +1217,6 @@ function widget_pubsites($arr) { function widget_forums($arr) { - $a = get_app(); - if(! local_channel()) return ''; @@ -1306,8 +1318,6 @@ function widget_admin($arr) { return login(false); } - - $a = get_app(); $o = ''; // array( url, name, extra css classes ) @@ -1336,7 +1346,7 @@ function widget_admin($arr) { $plugin = $h['name']; $plugins[] = array(z_root() . '/admin/plugins/' . $plugin, $plugin, 'plugin'); // temp plugins with admin - $a->plugins_admin[] = $plugin; + App::$plugins_admin[] = $plugin; } } @@ -1364,7 +1374,7 @@ function widget_admin($arr) { function widget_album($args) { - $owner_uid = get_app()->profile_uid; + $owner_uid = App::$profile_uid; $sql_extra = permissions_sql($owner_uid); @@ -1423,7 +1433,7 @@ function widget_album($args) { $imgalt_e = $rr['filename']; $desc_e = $rr['description']; - $imagelink = (z_root() . '/photos/' . get_app()->profile['channel_address'] . '/image/' . $rr['resource_id']); + $imagelink = (z_root() . '/photos/' . App::$profile['channel_address'] . '/image/' . $rr['resource_id']); $photos[] = array( @@ -1449,7 +1459,7 @@ function widget_album($args) { '$album_id' => rand(), '$album_edit' => array(t('Edit Album'), $album_edit), '$can_post' => false, - '$upload' => array(t('Upload'), z_root() . '/photos/' . get_app()->profile['channel_address'] . '/upload/' . bin2hex($album)), + '$upload' => array(t('Upload'), z_root() . '/photos/' . App::$profile['channel_address'] . '/upload/' . bin2hex($album)), '$order' => false, '$upload_form' => $upload_form, '$usage' => $usage_message diff --git a/include/zot.php b/include/zot.php index d8cae3954..fa3563085 100644 --- a/include/zot.php +++ b/include/zot.php @@ -181,7 +181,7 @@ function zot_finger($webbie, $channel = null, $autofallback = true) { if (strpos($webbie,'@') === false) { $address = $webbie; - $host = get_app()->get_hostname(); + $host = App::get_hostname(); } else { $address = substr($webbie,0,strpos($webbie,'@')); $host = substr($webbie,strpos($webbie,'@')+1); @@ -941,7 +941,7 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) { } if(($changed) || ($ud_flags == UPDATE_FLAGS_FORCED)) { - $guid = random_string() . '@' . get_app()->get_hostname(); + $guid = random_string() . '@' . App::get_hostname(); update_modtime($xchan_hash,$guid,$address,$ud_flags); logger('import_xchan: changed: ' . $what,LOGGER_DEBUG); } @@ -1527,7 +1527,7 @@ function allowed_public_recips($msg) { return $recips; if(strpos($scope,'site:') === 0) { - if(($scope === 'site: ' . get_app()->get_hostname()) && ($msg['notify']['sender']['url'] === z_root())) + if(($scope === 'site: ' . App::get_hostname()) && ($msg['notify']['sender']['url'] === z_root())) return $recips; else return array(); @@ -1606,7 +1606,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ } $channel = $r[0]; - $DR->addto_recipient($channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>'); + $DR->addto_recipient($channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . App::get_hostname() . '>'); /* blacklisted channels get a permission denied, no special message to tip them off */ @@ -2085,7 +2085,7 @@ function process_mail_delivery($sender, $arr, $deliveries) { } $channel = $r[0]; - $DR->addto_recipient($channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>'); + $DR->addto_recipient($channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . App::get_hostname() . '>'); /* blacklisted channels get a permission denied, no special message to tip them off */ @@ -2227,7 +2227,7 @@ function process_location_delivery($sender,$arr,$deliveries) { $x = sync_locations($sender,$arr,true); logger('process_location_delivery: results: ' . print_r($x,true), LOGGER_DEBUG); if($x['changed']) { - $guid = random_string() . '@' . get_app()->get_hostname(); + $guid = random_string() . '@' . App::get_hostname(); update_modtime($sender['hash'],$sender['guid'],$arr['locations'][0]['address'],UPDATE_FLAGS_UPDATED); } } @@ -2690,7 +2690,7 @@ function import_directory_profile($hash, $profile, $addr, $ud_flags = UPDATE_FLA call_hooks('import_directory_profile', $d); if (($d['update']) && (! $suppress_update)) - update_modtime($arr['xprof_hash'],random_string() . '@' . get_app()->get_hostname(), $addr, $ud_flags); + update_modtime($arr['xprof_hash'],random_string() . '@' . App::get_hostname(), $addr, $ud_flags); return $d['update']; } @@ -2969,7 +2969,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) { $synchubs = array(); foreach($h as $x) { - if($x['hubloc_host'] == $a->get_hostname()) + if($x['hubloc_host'] == App::get_hostname()) continue; $synchubs[] = $x; @@ -2991,8 +2991,8 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) { $info['type'] = 'channel_sync'; $info['encoding'] = 'red'; // note: not zot, this packet is very red specific - if(array_key_exists($uid,$a->config) && array_key_exists('transient',$a->config[$uid])) { - $settings = $a->config[$uid]['transient']; + if(array_key_exists($uid,App::$config) && array_key_exists('transient',App::$config[$uid])) { + $settings = App::$config[$uid]['transient']; if($settings) { $info['config'] = $settings; } @@ -3490,7 +3490,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(array_key_exists('item',$arr) && is_array($arr['item'][0])) { $DR = new Zotlabs\Zot\DReport(z_root(),$d['hash'],$d['hash'],$arr['item'][0]['message_id'],'channel sync processed'); - $DR->addto_recipient($channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>'); + $DR->addto_recipient($channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . App::get_hostname() . '>'); } else $DR = new Zotlabs\Zot\DReport(z_root(),$d['hash'],$d['hash'],'sync packet','channel sync delivered'); @@ -3918,7 +3918,7 @@ function zotinfo($arr) { $a = get_app(); $visible_plugins = array(); - if(is_array($a->plugins) && count($a->plugins)) { + if(is_array(App::$plugins) && count(App::$plugins)) { $r = q("select * from addon where hidden = 0"); if($r) foreach($r as $rr) @@ -3983,11 +3983,11 @@ function check_zotinfo($channel,$locations,&$ret) { dbesc($channel['channel_guid']), dbesc($channel['channel_guid_sig']), dbesc($channel['channel_hash']), - dbesc($channel['channel_address'] . '@' . get_app()->get_hostname()), + dbesc($channel['channel_address'] . '@' . App::get_hostname()), intval(1), dbesc(z_root()), dbesc(base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey']))), - dbesc(get_app()->get_hostname()), + dbesc(App::get_hostname()), dbesc(z_root() . '/post'), dbesc(get_config('system','pubkey')), dbesc('zot') |