diff options
Diffstat (limited to 'boot.php')
-rwxr-xr-x | boot.php | 172 |
1 files changed, 37 insertions, 135 deletions
@@ -49,7 +49,7 @@ require_once('include/hubloc.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); -define ( 'STD_VERSION', '2.3.2' ); +define ( 'STD_VERSION', '2.3.3' ); define ( 'ZOT_REVISION', '1.2' ); define ( 'DB_UPDATE_VERSION', 1188 ); @@ -1260,18 +1260,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') @@ -1394,11 +1382,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) @@ -1436,88 +1420,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); + /** * @@ -2114,7 +2018,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 @@ -2126,9 +2030,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(); @@ -2155,7 +2058,7 @@ function load_pdl(&$a) { } -function exec_pdl(&$a) { +function exec_pdl() { if(App::$pdl) { App::$comanche->parse(App::$pdl,1); } @@ -2167,11 +2070,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); @@ -2187,7 +2089,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']); } } @@ -2421,19 +2323,19 @@ function z_check_cert() { */ 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('[$Projectname] 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' ); + 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.') + ] + ) + ] + ); } @@ -2544,20 +2446,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')) + ] + ) + ] + ); } |