diff options
Diffstat (limited to 'boot.php')
-rwxr-xr-x | boot.php | 491 |
1 files changed, 188 insertions, 303 deletions
@@ -5,14 +5,13 @@ */ /** - * Hubzilla. * - * Hubzilla is an open source decentralised communications + * This is an open source decentralised communications * platform combined with a decentralised identity/authentication framework * wrapped in an extensible content management system, providing website designers * the ability to embed fully decentralised communications and social tools * into many traditional website designs (blogs, forums, small business - * websites, charitable organisations, etc.). Hubzilla also provides DNS mobility + * websites, charitable organisations, etc.). Also provided is DNS mobility * and internet scale privacy/access control. * * This allows any individual website to participate in a matrix of linked @@ -47,13 +46,13 @@ require_once('include/account.php'); require_once('include/zid.php'); require_once('include/xchan.php'); require_once('include/hubloc.php'); - +require_once('include/attach.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); -define ( 'STD_VERSION', '2.1' ); -define ( 'ZOT_REVISION', '1.2' ); +define ( 'STD_VERSION', '2.7.5' ); +define ( 'ZOT_REVISION', '1.3' ); -define ( 'DB_UPDATE_VERSION', 1188 ); +define ( 'DB_UPDATE_VERSION', 1196 ); define ( 'PROJECT_BASE', __DIR__ ); @@ -65,7 +64,7 @@ define ( 'PROJECT_BASE', __DIR__ ); * This can be used in HTML and JavaScript where needed a line break. */ define ( 'EOL', '<br>' . "\r\n" ); -define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); +define ( 'ATOM_TIME', 'Y-m-d\\TH:i:s\\Z' ); // aka ISO 8601 "Zulu" define ( 'TEMPLATE_BUILD_PATH', 'store/[data]/smarty3' ); define ( 'DIRECTORY_MODE_NORMAL', 0x0000); // A directory client @@ -79,14 +78,12 @@ define ( 'DIRECTORY_MODE_STANDALONE', 0x0100); // A detached (off the grid) hub // point to go out and find the rest of the world. define ( 'DIRECTORY_REALM', 'RED_GLOBAL'); -define ( 'DIRECTORY_FALLBACK_MASTER', 'https://hub.pixelbits.de'); +define ( 'DIRECTORY_FALLBACK_MASTER', 'https://gravizot.de'); -$DIRECTORY_FALLBACK_SERVERS = array( - 'https://hubzilla.site', +$DIRECTORY_FALLBACK_SERVERS = array( 'https://hubzilla.zottel.net', - 'https://hub.pixelbits.de', 'https://my.federated.social', - 'https://hubzilla.nl', + //'https://hubzilla.nl', 'https://gravizot.de' ); @@ -127,7 +124,9 @@ define ( 'LANGUAGE_DETECT_MIN_CONFIDENCE', 0.01 ); * either more or less restrictive. */ -define ( 'STORAGE_DEFAULT_PERMISSIONS', 0770 ); +if(! defined('STORAGE_DEFAULT_PERMISSIONS')) { + define ( 'STORAGE_DEFAULT_PERMISSIONS', 0770 ); +} /** @@ -150,12 +149,6 @@ define ( 'MAX_IMAGE_LENGTH', -1 ); /** - * Not yet used - */ - -define ( 'DEFAULT_DB_ENGINE', 'MyISAM' ); - -/** * log levels */ @@ -167,14 +160,6 @@ define ( 'LOGGER_ALL', 4 ); /** - * Server roles - */ - -define ( 'SERVER_ROLE_BASIC', 0x0001 ); -define ( 'SERVER_ROLE_STANDARD', 0x0002 ); -define ( 'SERVER_ROLE_PRO', 0x0004 ); - -/** * registration policies */ @@ -193,15 +178,6 @@ define ( 'ACCESS_FREE', 2 ); define ( 'ACCESS_TIERED', 3 ); /** - * relationship types - */ - -define ( 'CONTACT_IS_FOLLOWER', 1); -define ( 'CONTACT_IS_SHARING', 2); -define ( 'CONTACT_IS_FRIEND', 3); - - -/** * DB update return values */ @@ -229,7 +205,7 @@ define ( 'PAGE_PREMIUM', 0x0010 ); define ( 'PAGE_ADULT', 0x0020 ); define ( 'PAGE_CENSORED', 0x0040 ); // Site admin has blocked this channel from appearing in casual search results and site feeds define ( 'PAGE_SYSTEM', 0x1000 ); -define ( 'PAGE_HUBADMIN', 0x2000 ); // set this to indicate a preferred admin channel rather than the +define ( 'PAGE_HUBADMIN', 0x2000 ); // set this to indicate a preferred admin channel rather than the // default channel of any accounts with the admin role. define ( 'PAGE_REMOVED', 0x8000 ); @@ -280,6 +256,7 @@ define ( 'NETWORK_OSTATUS', 'stat'); // status.net, identi.ca, GNU-s define ( 'NETWORK_GNUSOCIAL', 'gnusoc'); // status.net, identi.ca, GNU-social, other OStatus implementations define ( 'NETWORK_FEED', 'rss'); // RSS/Atom feeds with no known "post/notify" protocol define ( 'NETWORK_DIASPORA', 'diaspora'); // Diaspora +define ( 'NETWORK_ACTIVITYPUB', 'activitypub'); define ( 'NETWORK_MAIL', 'mail'); // IMAP/POP define ( 'NETWORK_MAIL2', 'mai2'); // extended IMAP/POP define ( 'NETWORK_FACEBOOK', 'face'); // Facebook API @@ -426,6 +403,8 @@ define ( 'VNOTIFY_INFO', 0x0080 ); define ( 'VNOTIFY_ALERT', 0x0100 ); define ( 'VNOTIFY_INTRO', 0x0200 ); define ( 'VNOTIFY_REGISTER', 0x0400 ); +define ( 'VNOTIFY_FILES', 0x0800 ); +define ( 'VNOTIFY_PUBS', 0x1000 ); @@ -444,6 +423,7 @@ define ( 'TERM_THING', 7 ); define ( 'TERM_BOOKMARK', 8 ); define ( 'TERM_HIERARCHY', 9 ); define ( 'TERM_COMMUNITYTAG', 10 ); +define ( 'TERM_FORUM', 11 ); define ( 'TERM_OBJ_POST', 1 ); define ( 'TERM_OBJ_PHOTO', 2 ); @@ -475,10 +455,23 @@ define ( 'NAMESPACE_STATUSNET', 'http://status.net/schema/api/1/' ); define ( 'NAMESPACE_ATOM1', 'http://www.w3.org/2005/Atom' ); define ( 'NAMESPACE_YMEDIA', 'http://search.yahoo.com/mrss/' ); +// We should be using versioned jsonld contexts so that signatures will be slightly more reliable. +// Why signatures are unreliable by design is a problem nobody seems to care about +// "because it's a proposed W3C standard". . + +// Anyway, if you use versioned contexts, communication with Mastodon fails. Have not yet investigated +// the reason for the dependency but for the current time, use the standard non-versioned context. +//define ( 'ACTIVITYSTREAMS_JSONLD_REV', 'https://www.w3.org/ns/activitystreams-history/v1.8.jsonld' ); + +define ( 'ACTIVITYSTREAMS_JSONLD_REV', 'https://www.w3.org/ns/activitystreams' ); + +define ( 'ZOT_APSCHEMA_REV', '/apschema/v1.2' ); /** * activity stream defines */ +define ( 'ACTIVITY_PUBLIC_INBOX', 'https://www.w3.org/ns/activitystreams#Public' ); + define ( 'ACTIVITY_REACT', NAMESPACE_ZOT . '/activity/react' ); define ( 'ACTIVITY_LIKE', NAMESPACE_ACTIVITY_SCHEMA . 'like' ); define ( 'ACTIVITY_DISLIKE', NAMESPACE_ZOT . '/activity/dislike' ); @@ -501,8 +494,10 @@ define ( 'ACTIVITY_JOIN', NAMESPACE_ACTIVITY_SCHEMA . 'join' ); define ( 'ACTIVITY_POST', NAMESPACE_ACTIVITY_SCHEMA . 'post' ); define ( 'ACTIVITY_UPDATE', NAMESPACE_ACTIVITY_SCHEMA . 'update' ); define ( 'ACTIVITY_TAG', NAMESPACE_ACTIVITY_SCHEMA . 'tag' ); +define ( 'ACTIVITY_SHARE', NAMESPACE_ACTIVITY_SCHEMA . 'share' ); define ( 'ACTIVITY_FAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'favorite' ); define ( 'ACTIVITY_CREATE', NAMESPACE_ACTIVITY_SCHEMA . 'create' ); +define ( 'ACTIVITY_DELETE', NAMESPACE_ACTIVITY_SCHEMA . 'delete' ); define ( 'ACTIVITY_WIN', NAMESPACE_ACTIVITY_SCHEMA . 'win' ); define ( 'ACTIVITY_LOSE', NAMESPACE_ACTIVITY_SCHEMA . 'lose' ); define ( 'ACTIVITY_TIE', NAMESPACE_ACTIVITY_SCHEMA . 'tie' ); @@ -512,6 +507,7 @@ define ( 'ACTIVITY_POKE', NAMESPACE_ZOT . '/activity/poke' ); define ( 'ACTIVITY_MOOD', NAMESPACE_ZOT . '/activity/mood' ); define ( 'ACTIVITY_OBJ_COMMENT', NAMESPACE_ACTIVITY_SCHEMA . 'comment' ); +define ( 'ACTIVITY_OBJ_ACTIVITY',NAMESPACE_ACTIVITY_SCHEMA . 'activity' ); define ( 'ACTIVITY_OBJ_NOTE', NAMESPACE_ACTIVITY_SCHEMA . 'note' ); define ( 'ACTIVITY_OBJ_PERSON', NAMESPACE_ACTIVITY_SCHEMA . 'person' ); define ( 'ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo' ); @@ -526,14 +522,7 @@ define ( 'ACTIVITY_OBJ_PROFILE', NAMESPACE_ZOT . '/activity/profile' ); define ( 'ACTIVITY_OBJ_THING', NAMESPACE_ZOT . '/activity/thing' ); define ( 'ACTIVITY_OBJ_LOCATION',NAMESPACE_ZOT . '/activity/location' ); define ( 'ACTIVITY_OBJ_FILE', NAMESPACE_ZOT . '/activity/file' ); - -/** - * item weight for query ordering - */ - -define ( 'GRAVITY_PARENT', 0); -define ( 'GRAVITY_LIKE', 3); -define ( 'GRAVITY_COMMENT', 6); +define ( 'ACTIVITY_OBJ_CARD', NAMESPACE_ZOT . '/activity/card' ); /** * Account Flags @@ -550,7 +539,6 @@ define ( 'ACCOUNT_PENDING', 0x0010 ); * Account roles */ -define ( 'ACCOUNT_ROLE_ALLOWCODE', 0x0001 ); define ( 'ACCOUNT_ROLE_SYSTEM', 0x0002 ); define ( 'ACCOUNT_ROLE_DEVELOPER', 0x0004 ); define ( 'ACCOUNT_ROLE_ADMIN', 0x1000 ); @@ -560,19 +548,21 @@ define ( 'ACCOUNT_ROLE_ADMIN', 0x1000 ); */ define ( 'ITEM_VISIBLE', 0x0000); -//define ( 'ITEM_HIDDEN', 0x0001); +define ( 'ITEM_HIDDEN', 0x0001); define ( 'ITEM_BLOCKED', 0x0002); define ( 'ITEM_MODERATED', 0x0004); define ( 'ITEM_SPAM', 0x0008); -//define ( 'ITEM_DELETED', 0x0010); +define ( 'ITEM_DELETED', 0x0010); define ( 'ITEM_UNPUBLISHED', 0x0020); -//define ( 'ITEM_WEBPAGE', 0x0040); // is a static web page, not a conversational item +define ( 'ITEM_WEBPAGE', 0x0040); // is a static web page, not a conversational item define ( 'ITEM_DELAYED_PUBLISH', 0x0080); define ( 'ITEM_BUILDBLOCK', 0x0100); // Named thusly to make sure nobody confuses this with ITEM_BLOCKED -//define ( 'ITEM_PDL', 0x0200); // Page Description Language - e.g. Comanche +define ( 'ITEM_PDL', 0x0200); // Page Description Language - e.g. Comanche define ( 'ITEM_BUG', 0x0400); // Is a bug, can be used by the internal bug tracker define ( 'ITEM_PENDING_REMOVE', 0x0800); // deleted, notification period has lapsed define ( 'ITEM_DOC', 0x1000); // hubzilla only, define here so that item import does the right thing +define ( 'ITEM_CARD', 0x2000); + define ( 'ITEM_TYPE_POST', 0 ); define ( 'ITEM_TYPE_BLOCK', 1 ); @@ -580,6 +570,7 @@ define ( 'ITEM_TYPE_PDL', 2 ); define ( 'ITEM_TYPE_WEBPAGE', 3 ); define ( 'ITEM_TYPE_BUG', 4 ); define ( 'ITEM_TYPE_DOC', 5 ); +define ( 'ITEM_TYPE_CARD', 6 ); define ( 'ITEM_IS_STICKY', 1000 ); @@ -621,15 +612,7 @@ function sys_boot() { $a->convert(); - if(defined('UNO')) { - if(UNO) - App::$config['system']['server_role'] = 'basic'; - else - App::$config['system']['server_role'] = 'standard'; - } - - if(! (array_key_exists('server_role',App::$config['system']) && App::$config['system']['server_role'])) - App::$config['system']['server_role'] = 'standard'; + App::$config['system']['server_role'] = 'pro'; App::$timezone = ((App::$config['system']['timezone']) ? App::$config['system']['timezone'] : 'UTC'); date_default_timezone_set(App::$timezone); @@ -640,12 +623,10 @@ function sys_boot() { } if(! defined('DEFAULT_NOTIFY_ICON')) { - define( 'DEFAULT_NOTIFY_ICON', '/images/hz-white-32.png' ); + define( 'DEFAULT_NOTIFY_ICON', '/images/hz-white-64.png' ); } - if(! defined('CRYPTO_ALGORITHM')) { - define( 'CRYPTO_ALGORITHM', 'aes256cbc' ); - } + App::head_set_icon(DEFAULT_PLATFORM_ICON); /* * Try to open the database; @@ -728,6 +709,7 @@ function startup() { * which is now static (although currently constructed at startup). We are only converting * 'system' config settings. */ + class miniApp { public $config = array('system' => array()); @@ -756,7 +738,6 @@ class miniApp { class App { public static $install = false; // true if we are installing the software - public static $role = 0; // server role (constant, not the string) public static $account = null; // account record of the logged-in account public static $channel = null; // channel record of the current channel of the logged-in account public static $observer = null; // xchan record of the page observer @@ -810,6 +791,10 @@ class App { public static $is_tablet = false; public static $comanche; + + public static $channel_links; + + public static $category; // Allow themes to control internal parameters @@ -937,11 +922,19 @@ class App { * * There will always be one argument. If provided a naked domain * URL, self::$argv[0] is set to "home". + * + * If $argv[0] has a period in it, for example foo.json; rewrite + * to module = 'foo' and set $_REQUEST['module_format'] = 'json'; */ self::$argv = explode('/', self::$cmd); self::$argc = count(self::$argv); if ((array_key_exists('0', self::$argv)) && strlen(self::$argv[0])) { + if(strpos(self::$argv[0],'.')) { + $_REQUEST['module_format'] = substr(self::$argv[0],strpos(self::$argv[0],'.')+1); + self::$argv[0] = substr(self::$argv[0],0,strpos(self::$argv[0],'.')); + } + self::$module = str_replace(".", "_", self::$argv[0]); self::$module = str_replace("-", "_", self::$module); if(strpos(self::$module,'_') === 0) @@ -952,6 +945,7 @@ class App { self::$module = 'home'; } + /* * See if there is any page number information, and initialise * pagination @@ -972,8 +966,6 @@ class App { self::$is_mobile = $mobile_detect->isMobile(); self::$is_tablet = $mobile_detect->isTablet(); - self::head_set_icon(DEFAULT_PLATFORM_ICON); - /* * register template engines */ @@ -1031,36 +1023,10 @@ class App { } } - public static function get_role() { - if(! self::$role) - return self::set_role(); - return self::$role; - } - - public static function set_role() { - $role_str = \Zotlabs\Lib\System::get_server_role(); - switch($role_str) { - case 'basic': - $role = SERVER_ROLE_BASIC; - break; - case 'pro': - $role = SERVER_ROLE_PRO; - break; - case 'standard': - default: - $role = SERVER_ROLE_STANDARD; - break; - } - self::$role = $role; - return $role; - } - - public static function get_scheme() { return self::$scheme; } - public static function get_hostname() { return self::$hostname; } @@ -1077,6 +1043,19 @@ class App { return self::$path; } + public static function get_channel_links() { + $s = ''; + $x = self::$channel_links; + if($x && is_array($x) && count($x)) { + foreach($x as $y) { + if($s) { + $s .= ','; + } + $s .= '<' . $y['url'] . '>; rel="' . $y['rel'] . '"; type="' . $y['type'] . '"'; + } + } + return $s; + } public static function set_account($acct) { self::$account = $acct; } @@ -1174,24 +1153,25 @@ class App { * since the code added by the modules frequently depends on it * being first */ - $tpl = get_markup_template('head.tpl'); - self::$page['htmlhead'] = replace_macros($tpl, array( - '$preload_images' => $preload_images, - '$user_scalable' => $user_scalable, - '$query' => urlencode(self::$query_string), - '$baseurl' => self::get_baseurl(), - '$local_channel' => local_channel(), - '$metas' => self::$meta->get(), - '$plugins' => $x['header'], - '$update_interval' => $interval, - 'osearch' => sprintf( t('Search %1$s (%2$s)','opensearch'), Zotlabs\Lib\System::get_site_name(), t('$Projectname','opensearch')), - '$head_css' => head_get_css(), - '$head_js' => head_get_js(), - '$linkrel' => head_get_links(), - '$js_strings' => js_strings(), - '$zid' => get_my_address(), - '$channel_id' => self::$profile['uid'], - )) . self::$page['htmlhead']; + + self::$page['htmlhead'] = replace_macros(get_markup_template('head.tpl'), + [ + '$preload_images' => $preload_images, + '$user_scalable' => $user_scalable, + '$query' => urlencode(self::$query_string), + '$baseurl' => self::get_baseurl(), + '$local_channel' => local_channel(), + '$metas' => self::$meta->get(), + '$plugins' => $x['header'], + '$update_interval' => $interval, + '$head_css' => head_get_css(), + '$head_js' => head_get_js(), + '$linkrel' => head_get_links(), + '$js_strings' => js_strings(), + '$zid' => get_my_address(), + '$channel_id' => self::$profile['uid'] + ] + ) . self::$page['htmlhead']; // always put main.js at the end self::$page['htmlhead'] .= head_get_main_js(); @@ -1204,11 +1184,13 @@ class App { * @param string $name */ public static function register_template_engine($class, $name = '') { - if ($name === ""){ - $v = get_class_vars( $class ); - if(x($v, "name")) $name = $v['name']; + if(! $name) { + $v = get_class_vars($class); + if(x($v, "name")) { + $name = $v['name']; + } } - if ($name === ""){ + if (! $name) { echo "template engine <tt>$class</tt> cannot be registered without a name.\n"; killme(); } @@ -1224,19 +1206,21 @@ class App { * @return object Template Engine instance */ public static function template_engine($name = ''){ - if ($name !== "") { + if($name !== '') { $template_engine = $name; - } else { + } + else { $template_engine = 'smarty3'; - if (x(self::$theme, 'template_engine')) { + if(x(self::$theme, 'template_engine')) { $template_engine = self::$theme['template_engine']; } } - if (isset(self::$template_engines[$template_engine])){ + if(isset(self::$template_engines[$template_engine])){ if(isset(self::$template_engine_instance[$template_engine])){ return self::$template_engine_instance[$template_engine]; - } else { + } + else { $class = self::$template_engines[$template_engine]; $obj = new $class; self::$template_engine_instance[$template_engine] = $obj; @@ -1244,7 +1228,8 @@ class App { } } - echo "template engine <tt>$template_engine</tt> is not registered!\n"; killme(); + echo "template engine <tt>$template_engine</tt> is not registered!\n"; + killme(); } /** @@ -1283,18 +1268,6 @@ class App { /** - * @brief Retrieve the App structure. - * - * Useful in functions which require it but don't get it passed to them - * - * @return App - */ -function get_app() { - return $a; -} - - -/** * @brief Multi-purpose function to check variable state. * * Usage: x($var) or $x($array, 'key') @@ -1382,9 +1355,27 @@ function os_mkdir($path, $mode = 0777, $recursive = false) { $oldumask = @umask(0); $result = @mkdir($path, $mode, $recursive); @umask($oldumask); - return $result; + return $result; +} + + +// recursively delete a directory +function rrmdir($path) { + if(is_dir($path) === true) { + $files = array_diff(scandir($path), array('.', '..')); + foreach($files as $file) { + rrmdir(realpath($path) . '/' . $file); + } + return rmdir($path); + } + elseif(is_file($path) === true) { + return unlink($path); + } + + return false; } + /** * @brief Function to check if request was an AJAX (xmlhttprequest) request. * @@ -1399,11 +1390,7 @@ function is_ajax() { // base url for use in cmdline programs which don't have // $_SERVER variables, and synchronising the state of installed plugins. -function check_config(&$a) { - - $build = get_config('system','db_version'); - if(! intval($build)) - $build = set_config('system','db_version',DB_UPDATE_VERSION); +function check_config() { $saved = get_config('system','urlverify'); if(! $saved) @@ -1441,88 +1428,8 @@ function check_config(&$a) { if (! $syschan_exists) create_sys_channel(); - if($build != DB_UPDATE_VERSION) { - $stored = intval($build); - if(! $stored) { - logger('Critical: check_config unable to determine database schema version'); - return; - } - $current = intval(DB_UPDATE_VERSION); - if(($stored < $current) && file_exists('install/update.php')) { - - load_config('database'); - - // We're reporting a different version than what is currently installed. - // Run any existing update scripts to bring the database up to current. - require_once('install/update.php'); - - // make sure that boot.php and update.php are the same release, we might be - // updating right this very second and the correct version of the update.php - // file may not be here yet. This can happen on a very busy site. - - if(DB_UPDATE_VERSION == UPDATE_VERSION) { - for($x = $stored; $x < $current; $x ++) { - if(function_exists('update_r' . $x)) { - // There could be a lot of processes running or about to run. - // We want exactly one process to run the update command. - // So store the fact that we're taking responsibility - // after first checking to see if somebody else already has. - - // If the update fails or times-out completely you may need to - // delete the config entry to try again. - - if(get_config('database','update_r' . $x)) - break; - set_config('database','update_r' . $x, '1'); - // call the specific update - - $func = 'update_r' . $x; - $retval = $func(); - if($retval) { - - // Prevent sending hundreds of thousands of emails by creating - // a lockfile. - - $lockfile = 'store/[data]/mailsent'; - - if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400))) - return; - @unlink($lockfile); - //send the administrator an e-mail - file_put_contents($lockfile, $x); - - $r = q("select account_language from account where account_email = '%s' limit 1", - dbesc(App::$config['system']['admin_email']) - ); - push_lang(($r) ? $r[0]['account_language'] : 'en'); - - - $email_tpl = get_intltext_template("update_fail_eml.tpl"); - $email_msg = replace_macros($email_tpl, array( - '$sitename' => App::$config['system']['sitename'], - '$siteurl' => z_root(), - '$update' => $x, - '$error' => sprintf( t('Update %s failed. See error logs.'), $x) - )); - - $subject = email_header_encode(sprintf(t('Update Error at %s'), z_root())); - - mail(App::$config['system']['admin_email'], $subject, $email_msg, - 'From: Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" - . 'Content-type: text/plain; charset=UTF-8' . "\n" - . 'Content-transfer-encoding: 8bit' ); - //try the logger - logger('CRITICAL: Update Failed: ' . $x); - pop_lang(); - } - else - set_config('database','update_r' . $x, 'success'); - } - } - set_config('system','db_version', DB_UPDATE_VERSION); - } - } - } + $x = new \Zotlabs\Lib\DB_Upgrade(DB_UPDATE_VERSION); + /** * @@ -1730,6 +1637,7 @@ function login($register = false, $form_id = 'main-login', $hiddens=false, $logi '$login_page' => $login_page, '$logout' => t('Logout'), '$login' => t('Login'), + '$remote_login' => t('Remote Authentication'), '$form_id' => $form_id, '$lname' => array('username', t('Login/Email') , '', ''), '$lpassword' => array('password', t('Password'), '', ''), @@ -1798,8 +1706,8 @@ function get_account_id() { * @return int|bool channel_id or false */ function local_channel() { - if(session_id() - && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated'] + if(session_id() + && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated'] && array_key_exists('uid',$_SESSION) && intval($_SESSION['uid'])) return intval($_SESSION['uid']); @@ -1807,18 +1715,6 @@ function local_channel() { } /** - * local_user() got deprecated and replaced by local_channel(). - * - * @deprecated since v2.1, use local_channel() - * @see local_channel() - */ -function local_user() { - logger('local_user() is DEPRECATED, use local_channel()'); - return local_channel(); -} - - -/** * @brief Returns a xchan_hash (visitor_id) of remote authenticated visitor * or false. * @@ -1831,8 +1727,8 @@ function local_user() { * @return string|bool visitor_id or false */ function remote_channel() { - if(session_id() - && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated'] + if(session_id() + && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated'] && array_key_exists('visitor_id',$_SESSION) && $_SESSION['visitor_id']) return $_SESSION['visitor_id']; @@ -1840,18 +1736,6 @@ function remote_channel() { } /** - * remote_user() got deprecated and replaced by remote_channel(). - * - * @deprecated since v2.1, use remote_channel() - * @see remote_channel() - */ -function remote_user() { - logger('remote_user() is DEPRECATED, use remote_channel()'); - return remote_channel(); -} - - -/** * Contents of $s are displayed prominently on the page the next time * a page is loaded. Usually used for errors or alerts. * @@ -1863,8 +1747,8 @@ function notice($s) { if(! x($_SESSION, 'sysmsg')) $_SESSION['sysmsg'] = array(); - // ignore duplicated error messages which haven't yet been displayed - // - typically seen as multiple 'permission denied' messages + // ignore duplicated error messages which haven't yet been displayed + // - typically seen as multiple 'permission denied' messages // as a result of auto-reloading a protected page with &JS=1 if(in_array($s,$_SESSION['sysmsg'])) @@ -1886,7 +1770,7 @@ function notice($s) { function info($s) { if(! session_id()) return; - if(! x($_SESSION, 'sysmsg_info')) + if(! x($_SESSION, 'sysmsg_info')) $_SESSION['sysmsg_info'] = array(); if(App::$interactive) $_SESSION['sysmsg_info'][] = $s; @@ -1962,7 +1846,7 @@ function proc_run(){ proc_close(proc_open($cmd, array(), $foo)); } else { - if(get_config('system','use_proc_open')) + if(get_config('system','use_proc_open')) proc_close(proc_open($cmdline ." &", array(), $foo)); else exec($cmdline . ' > /dev/null &'); @@ -1975,8 +1859,8 @@ function proc_run(){ * @return bool true if we run on M$ Windows * * It's possible you might be able to run on WAMP or XAMPP, and this - * has been accomplished, but is not officially supported. Good luck. - * + * has been accomplished, but is not officially supported. Good luck. + * */ function is_windows() { return ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false); @@ -2143,7 +2027,7 @@ function curPageURL() { * * @return mixed */ -function get_custom_nav(&$a, $navname) { +function get_custom_nav($navname) { if (! $navname) return App::$page['nav']; // load custom nav menu by name here @@ -2155,9 +2039,8 @@ function get_custom_nav(&$a, $navname) { * If there is no parsed Comanche template already load a module's pdl file * and parse it with Comanche. * - * @param App &$a global application object */ -function load_pdl(&$a) { +function load_pdl() { App::$comanche = new Zotlabs\Render\Comanche(); @@ -2184,7 +2067,7 @@ function load_pdl(&$a) { } -function exec_pdl(&$a) { +function exec_pdl() { if(App::$pdl) { App::$comanche->parse(App::$pdl,1); } @@ -2196,11 +2079,10 @@ function exec_pdl(&$a) { * * Build the page - now that we have all the components * - * @param App &$a global application object */ -function construct_page(&$a) { +function construct_page() { - exec_pdl($a); + exec_pdl(); $comanche = ((count(App::$layout)) ? true : false); @@ -2216,7 +2098,7 @@ function construct_page(&$a) { if ($comanche) { if (App::$layout['nav']) { - App::$page['nav'] = get_custom_nav($a, App::$layout['nav']); + App::$page['nav'] = get_custom_nav(App::$layout['nav']); } } @@ -2226,7 +2108,7 @@ function construct_page(&$a) { // Zotlabs\Render\Theme::debug(); if (($p = theme_include($current_theme[0] . '.js')) != '') - head_add_js($p); + head_add_js('/' . $p); if (($p = theme_include('mod_' . App::$module . '.php')) != '') require_once($p); @@ -2238,10 +2120,13 @@ function construct_page(&$a) { else head_add_css(((x(App::$page, 'template')) ? App::$page['template'] : 'default' ) . '.css'); - head_add_css('mod_' . App::$module . '.css'); + if (($p = theme_include('mod_' . App::$module . '.css')) != '') + head_add_css('mod_' . App::$module . '.css'); + head_add_css(Zotlabs\Render\Theme::url($installing)); - head_add_js('mod_' . App::$module . '.js'); + if (($p = theme_include('mod_' . App::$module . '.js')) != '') + head_add_js('mod_' . App::$module . '.js'); App::build_pagehead(); @@ -2324,7 +2209,7 @@ function construct_page(&$a) { if(App::$config['system']['x_security_headers']) { header("X-Frame-Options: SAMEORIGIN"); header("X-Xss-Protection: 1; mode=block;"); - header("X-Content-Type-Options: nosniff"); + header("X-Content-Type-Options: nosniff"); } if(App::$config['system']['public_key_pins']) { @@ -2337,7 +2222,7 @@ function construct_page(&$a) { } /** - * @brief Returns Hubzilla's root directory. + * @brief Returns appplication root directory. * * @return string */ @@ -2353,7 +2238,7 @@ function appdirpath() { function head_set_icon($icon) { App::$data['pageicon'] = $icon; -// logger('head_set_icon: ' . $icon); + } /** @@ -2429,37 +2314,38 @@ function z_get_temp_dir() { function z_check_cert() { if(strpos(z_root(),'https://') !== false) { - $x = z_fetch_url(z_root() . '/siteinfo/json'); + $x = z_fetch_url(z_root() . '/siteinfo.json'); if(! $x['success']) { $recurse = 0; - $y = z_fetch_url(z_root() . '/siteinfo/json',false,$recurse,array('novalidate' => true)); + $y = z_fetch_url(z_root() . '/siteinfo.json',false,$recurse,array('novalidate' => true)); if($y['success']) cert_bad_email(); } } -} +} /** * @brief Send email to admin if server has an invalid certificate. * - * If a Hubzilla hub is available over https it must have a publicly valid - * certificate. + * If a hub is available over https it must have a publicly valid certificate. */ -function cert_bad_email() { - $email_tpl = get_intltext_template("cert_bad_eml.tpl"); - $email_msg = replace_macros($email_tpl, array( - '$sitename' => App::$config['system']['sitename'], - '$siteurl' => z_root(), - '$error' => t('Website SSL certificate is not valid. Please correct.') - )); +function cert_bad_email() { + return z_mail( + [ + 'toEmail' => \App::$config['system']['admin_email'], + 'messageSubject' => sprintf(t('[$Projectname] Website SSL error for %s'), App::get_hostname()), + 'textVersion' => replace_macros(get_intltext_template('cert_bad_eml.tpl'), + [ + '$sitename' => App::$config['system']['sitename'], + '$siteurl' => z_root(), + '$error' => t('Website SSL certificate is not valid. Please correct.') + ] + ) + ] + ); - $subject = email_header_encode(sprintf(t('[hubzilla] Website SSL error for %s'), App::get_hostname())); - mail(App::$config['system']['admin_email'], $subject, $email_msg, - 'From: Administrator' . '@' . App::get_hostname() . "\n" - . 'Content-type: text/plain; charset=UTF-8' . "\n" - . 'Content-transfer-encoding: 8bit' ); } @@ -2545,7 +2431,7 @@ function check_for_new_perms() { function check_cron_broken() { $d = get_config('system','lastcron'); - + if((! $d) || ($d < datetime_convert('UTC','UTC','now - 4 hours'))) { Zotlabs\Daemon\Master::Summon(array('Cron')); set_config('system','lastcron',datetime_convert()); @@ -2570,29 +2456,28 @@ function check_cron_broken() { return; } - $email_tpl = get_intltext_template("cron_bad_eml.tpl"); - $email_msg = replace_macros($email_tpl, array( - '$sitename' => App::$config['system']['sitename'], - '$siteurl' => z_root(), - '$error' => t('Cron/Scheduled tasks not running.'), - '$lastdate' => (($d)? $d : t('never')) - )); - - $subject = email_header_encode(sprintf(t('[hubzilla] Cron tasks not running on %s'), App::get_hostname())); - mail(App::$config['system']['admin_email'], $subject, $email_msg, - 'From: Administrator' . '@' . App::get_hostname() . "\n" - . 'Content-type: text/plain; charset=UTF-8' . "\n" - . 'Content-transfer-encoding: 8bit' ); - return; + return z_mail( + [ + 'toEmail' => \App::$config['system']['admin_email'], + 'messageSubject' => sprintf(t('[$Projectname] Cron tasks not running on %s'), App::get_hostname()), + 'textVersion' => replace_macros(get_intltext_template('cron_bad_eml.tpl'), + [ + '$sitename' => App::$config['system']['sitename'], + '$siteurl' => z_root(), + '$error' => t('Cron/Scheduled tasks not running.'), + '$lastdate' => (($d)? $d : t('never')) + ] + ) + ] + ); } function observer_prohibited($allow_account = false) { - if($allow_account) + if($allow_account) return (((get_config('system','block_public')) && (! get_account_id()) && (! remote_channel())) ? true : false ); return (((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) ? true : false ); } - |