From 9abd95fad3784a10fc48bc40f9b8a75d7d74edda Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 31 Mar 2016 16:06:03 -0700 Subject: static App --- include/Contact.php | 20 ++--- include/ConversationObject.php | 6 +- include/Import/import_diaspora.php | 2 +- include/ItemObject.php | 2 +- include/account.php | 8 +- include/acl_selectors.php | 12 +-- include/activities.php | 2 +- include/api.php | 62 +++++++-------- include/api_auth.php | 4 +- include/apps.php | 10 +-- include/attach.php | 4 +- include/auth.php | 16 ++-- include/bbcode.php | 22 +++--- include/cli_startup.php | 6 +- include/comanche.php | 28 +++---- include/config.php | 146 +++++++++++++++++------------------ include/contact_widgets.php | 8 +- include/conversation.php | 64 +++++++-------- include/datetime.php | 2 +- include/dir_fns.php | 6 +- include/enotify.php | 8 +- include/event.php | 4 +- include/identity.php | 154 ++++++++++++++++++------------------- include/items.php | 24 +++--- include/language.php | 36 ++++----- include/menu.php | 6 +- include/message.php | 6 +- include/nav.php | 34 ++++---- include/network.php | 12 +-- include/oauth.php | 2 +- include/oembed.php | 10 +-- include/permissions.php | 4 +- include/photos.php | 6 +- include/plugin.php | 54 ++++++------- include/security.php | 32 ++++---- include/session.php | 4 +- include/smarty.php | 18 ++--- include/socgraph.php | 2 +- include/taxonomy.php | 2 +- include/text.php | 80 +++++++++---------- include/widgets.php | 100 ++++++++++++------------ include/zot.php | 28 +++---- 42 files changed, 528 insertions(+), 528 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 727d4b062..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, @@ -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']) ); } } 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 623bf0676..9d5acd95f 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -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 .= "\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 .= "\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 .= "\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 73fd58d4d..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 = 'not implemented'; switch($type){ case "xml": @@ -171,7 +171,7 @@ require_once('include/api_auth.php'); $arr['$user'] = $user_info; $arr['$rss'] = array( 'alternate' => $user_info['url'], - 'self' => z_root(). "/". $a->query_string, + 'self' => z_root(). "/". App::$query_string, 'base' => z_root(), 'updated' => api_date(null), 'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME), @@ -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)){ @@ -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,7 +1272,7 @@ 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['title'] = App::$config['sitename']." Home Timeline"; $as['link']['url'] = z_root()."/".$user_info["screen_name"]."/all"; return($as); break; @@ -1333,7 +1333,7 @@ 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['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 = z_root() . '/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,7 +1561,7 @@ require_once('include/api_auth.php'); break; case "as": $as = api_format_as($a, $ret, $user_info); - $as["title"] = $a->config['sitename']." Mentions"; + $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,7 +1783,7 @@ 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['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"]; @@ -2088,7 +2088,7 @@ require_once('include/api_auth.php'); load_config('system'); $name = get_config('system','sitename'); - $server = $a->get_hostname(); + $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'); @@ -2270,7 +2270,7 @@ require_once('include/api_auth.php'); if ($page<0) $page=0; $start = $page*$count; - $channel = $a->get_channel(); + $channel = App::get_channel(); $profile_url = z_root() . '/channel/' . $channel['channel_address']; if ($box=="sentbox") { 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/bbcode.php b/include/bbcode.php index e243db699..c2ff5d7c8 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -37,7 +37,7 @@ function tryzrlvideo($match) { if($zrl) $link = zid($link); - return ''; + return ''; } // [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 ''; + return ''; } 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) { @@ -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", '', $Text); +// $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $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", '', $Text); +// $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $Text); // else // $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", "http://vimeo.com/$1", $Text); // } diff --git a/include/cli_startup.php b/include/cli_startup.php index 70ab1a24a..6aa652a8f 100644 --- a/include/cli_startup.php +++ b/include/cli_startup.php @@ -18,8 +18,8 @@ function cli_startup() { 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 +30,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 28a72f7ea..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] ); } @@ -303,22 +303,22 @@ function set_pconfig($uid, $family, $key, $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), @@ -343,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; @@ -360,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 @@ -375,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), @@ -391,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 @@ -403,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) @@ -414,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']; } } } @@ -428,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. * @@ -446,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] ); } @@ -484,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), @@ -508,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; @@ -518,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 @@ -533,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 66f84f066..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'] .= '