diff options
author | Mario Vavti <mario@mariovavti.com> | 2017-05-31 09:56:35 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2017-05-31 09:56:35 +0200 |
commit | 47d55694a4c84b6c12c0db61a69bcac8b671b20e (patch) | |
tree | b15e96f4ea67e2214a66a9d28dafaf53d25b98ec /boot.php | |
parent | 087f9784e3c5a860ed2b86e7f9e8e9f312038546 (diff) | |
parent | f0e615dee529e031663576286345141ad2996974 (diff) | |
download | volse-hubzilla-47d55694a4c84b6c12c0db61a69bcac8b671b20e.tar.gz volse-hubzilla-47d55694a4c84b6c12c0db61a69bcac8b671b20e.tar.bz2 volse-hubzilla-47d55694a4c84b6c12c0db61a69bcac8b671b20e.zip |
Merge branch '2.4RC'2.4
Diffstat (limited to 'boot.php')
-rwxr-xr-x | boot.php | 275 |
1 files changed, 74 insertions, 201 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,14 @@ 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.2' ); +define ( 'STD_VERSION', '2.4' ); define ( 'ZOT_REVISION', '1.2' ); -define ( 'DB_UPDATE_VERSION', 1188 ); +define ( 'DB_UPDATE_VERSION', 1191 ); define ( 'PROJECT_BASE', __DIR__ ); @@ -126,7 +126,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 ); +} /** @@ -149,12 +151,6 @@ define ( 'MAX_IMAGE_LENGTH', -1 ); /** - * Not yet used - */ - -define ( 'DEFAULT_DB_ENGINE', 'MyISAM' ); - -/** * log levels */ @@ -192,15 +188,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 */ @@ -500,6 +487,7 @@ 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_WIN', NAMESPACE_ACTIVITY_SCHEMA . 'win' ); @@ -527,14 +515,6 @@ 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); - -/** * Account Flags */ @@ -549,7 +529,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 ); @@ -559,16 +538,16 @@ 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 @@ -642,9 +621,6 @@ function sys_boot() { define( 'DEFAULT_NOTIFY_ICON', '/images/hz-white-32.png' ); } - if(! defined('CRYPTO_ALGORITHM')) { - define( 'CRYPTO_ALGORITHM', 'aes256cbc' ); - } /* * Try to open the database; @@ -727,6 +703,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()); @@ -1282,18 +1259,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') @@ -1384,6 +1349,24 @@ function os_mkdir($path, $mode = 0777, $recursive = false) { 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. * @@ -1398,11 +1381,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) @@ -1440,88 +1419,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); + /** * @@ -1806,18 +1705,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. * @@ -1839,18 +1726,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. * @@ -2142,7 +2017,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 @@ -2154,9 +2029,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(); @@ -2183,7 +2057,7 @@ function load_pdl(&$a) { } -function exec_pdl(&$a) { +function exec_pdl() { if(App::$pdl) { App::$comanche->parse(App::$pdl,1); } @@ -2195,11 +2069,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); @@ -2215,7 +2088,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']); } } @@ -2339,7 +2212,7 @@ function construct_page(&$a) { } /** - * @brief Returns Hubzilla's root directory. + * @brief Returns appplication root directory. * * @return string */ @@ -2355,7 +2228,7 @@ function appdirpath() { function head_set_icon($icon) { App::$data['pageicon'] = $icon; -// logger('head_set_icon: ' . $icon); + } /** @@ -2431,10 +2304,10 @@ 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(); } @@ -2445,23 +2318,23 @@ function z_check_cert() { /** * @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.') - )); - - $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' ); +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.') + ] + ) + ] + ); } @@ -2572,20 +2445,20 @@ 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')) + ] + ) + ] + ); } |