diff -r de56132c008d -r bdac73ed481e includes/common_cli.php --- a/includes/common_cli.php Sun Mar 28 21:49:26 2010 -0400 +++ b/includes/common_cli.php Sun Mar 28 23:10:46 2010 -0400 @@ -34,7 +34,7 @@ @include(ENANO_ROOT . $config_file); unset($dbuser, $dbpasswd); if ( !isset($dbdriver) ) - $dbdriver = 'mysql'; + $dbdriver = 'mysql'; $db = new $dbdriver(); $db->connect(); @@ -52,7 +52,7 @@ $e = $db->sql_query('SELECT config_name, config_value FROM '.table_prefix.'config;'); if ( !$e ) { - $db->_die('Some critical configuration information could not be selected.'); + $db->_die('Some critical configuration information could not be selected.'); } // Used in die_semicritical to figure out whether to call getConfig() or not define('ENANO_CONFIG_FETCHED', ''); @@ -61,7 +61,7 @@ $enano_config = Array(); while($r = $db->fetchrow()) { - $enano_config[$r['config_name']] = $r['config_value']; + $enano_config[$r['config_name']] = $r['config_value']; } $db->free_result(); @@ -71,12 +71,12 @@ // Now that we have the config, check the Enano version. if ( enano_version(false, true) != $version && !defined('IN_ENANO_UPGRADE') ) { - grinding_halt('Version mismatch', 'Trying to run Enano version '.$version.' on database version '.enano_version().', you might need to upgrade.'); + grinding_halt('Version mismatch', 'Trying to run Enano version '.$version.' on database version '.enano_version().', you might need to upgrade.'); } // Set our CDN path if ( !defined('cdnPath') ) - define('cdnPath', getConfig('cdn_path', scriptPath)); + define('cdnPath', getConfig('cdn_path', scriptPath)); // // Low level maintenance @@ -85,41 +85,41 @@ // If the AES key size has been changed, bail out and fast if ( !getConfig('aes_key_size') ) { - setConfig('aes_key_size', AES_BITS); + setConfig('aes_key_size', AES_BITS); } else if ( $ks = getConfig('aes_key_size') ) { - if ( intval($ks) != AES_BITS ) - { - grinding_halt('AES key size changed', 'Enano has detected that the AES key size in constants.php has been changed. This change cannot be performed after installation, otherwise the private key would have to be re-generated and all passwords would have to be re-encrypted.' . "\n\n" . 'Please change the key size back to ' . $ks . ' bits and rerun this script.'); - } + if ( intval($ks) != AES_BITS ) + { + grinding_halt('AES key size changed', 'Enano has detected that the AES key size in constants.php has been changed. This change cannot be performed after installation, otherwise the private key would have to be re-generated and all passwords would have to be re-encrypted.' . "\n\n" . 'Please change the key size back to ' . $ks . ' bits and rerun this script.'); + } } // Same for AES block size if ( !getConfig('aes_block_size') ) { - setConfig('aes_block_size', AES_BLOCKSIZE); + setConfig('aes_block_size', AES_BLOCKSIZE); } else if ( $ks = getConfig('aes_block_size') ) { - if ( intval($ks) != AES_BLOCKSIZE ) - { - grinding_halt('AES block size changed', "Enano has detected that the AES block size in constants.php has been changed. This change cannot be performed after installation, otherwise all passwords would have to be re-encrypted.\n\nPlease change the block size back to $ks bits and rerun this script."); - } + if ( intval($ks) != AES_BLOCKSIZE ) + { + grinding_halt('AES block size changed', "Enano has detected that the AES block size in constants.php has been changed. This change cannot be performed after installation, otherwise all passwords would have to be re-encrypted.\n\nPlease change the block size back to $ks bits and rerun this script."); + } } // Is there no default language? if ( getConfig('default_language') === false && !defined('IN_ENANO_MIGRATION') ) { - $q = $db->sql_query('SELECT lang_id FROM '.table_prefix.'language LIMIT 1;'); - if ( !$q ) - $db->_die('common.php - setting default language'); - if ( $db->numrows() < 1 && !defined('ENANO_ALLOW_LOAD_NOLANG') ) - { - grinding_halt('No languages', 'No languages are installed on the site, load from web interface for instructions on how to fix this.'); - } - $row = $db->fetchrow(); - setConfig('default_language', $row['lang_id']); + $q = $db->sql_query('SELECT lang_id FROM '.table_prefix.'language LIMIT 1;'); + if ( !$q ) + $db->_die('common.php - setting default language'); + if ( $db->numrows() < 1 && !defined('ENANO_ALLOW_LOAD_NOLANG') ) + { + grinding_halt('No languages', 'No languages are installed on the site, load from web interface for instructions on how to fix this.'); + } + $row = $db->fetchrow(); + setConfig('default_language', $row['lang_id']); } profiler_log('Ran checks'); @@ -144,11 +144,11 @@ // Load plugins from common because we can't give plugins full abilities in object context if ( !defined('ENANO_NO_PLUGINS') ) { - foreach ( $plugins->load_list as $f ) - { - if ( file_exists(ENANO_ROOT . '/plugins/' . $f) ) - include_once ENANO_ROOT . '/plugins/' . $f; - } + foreach ( $plugins->load_list as $f ) + { + if ( file_exists(ENANO_ROOT . '/plugins/' . $f) ) + include_once ENANO_ROOT . '/plugins/' . $f; + } } profiler_log('Loaded plugins'); @@ -170,87 +170,87 @@ // script though, because that will make the DBAL look in the wrong place for the config file. if ( !defined('IN_ENANO_INSTALL') ) { - // And here you have it, the de facto way to place a hook. Plugins can place hooks and hook - // into other plugins. You just never know. - $code = $plugins->setHook('base_classes_initted'); - foreach ( $code as $cmd ) - { - eval($cmd); - } - - profiler_log('Finished base_classes_initted hook'); - - // One quick security check... - if ( isset($_SERVER['REMOTE_ADDR']) ) - { - grinding_halt('REMOTE_ADDR detected', 'Detected a REMOTE_ADDR, this should not happen in CLI mode.'); - } - $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; + // And here you have it, the de facto way to place a hook. Plugins can place hooks and hook + // into other plugins. You just never know. + $code = $plugins->setHook('base_classes_initted'); + foreach ( $code as $cmd ) + { + eval($cmd); + } + + profiler_log('Finished base_classes_initted hook'); + + // One quick security check... + if ( isset($_SERVER['REMOTE_ADDR']) ) + { + grinding_halt('REMOTE_ADDR detected', 'Detected a REMOTE_ADDR, this should not happen in CLI mode.'); + } + $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; - // All checks passed! Start the main components up. - $session->start(); - - // This is where plugins will want to add pages from 1.1.x on out. You can still add - // pages at base_classes_initted but the titles won't be localized. This is because - // the session manager has to be started before localization will work in the user's - // preferred language. - $code = $plugins->setHook('session_started'); - foreach ( $code as $cmd ) - { - eval($cmd); - } - - profiler_log('Ran session_started hook'); - - $paths->init($paths->nslist['System'] . 'API'); - - // We're ready for whatever life throws us now. - define('ENANO_MAINSTREAM', ''); - - // If the site is disabled, bail out, unless we're trying to log in or administer the site - if(getConfig('site_disabled') == '1' && $session->user_level < USER_LEVEL_ADMIN) - { - if ( $paths->namespace == 'Admin' || ( $paths->namespace == 'Special' && ( $paths->page_id == 'CSS' || $paths->page_id == 'Administration' || $paths->page_id == 'Login' ) ) ) - { - // do nothing; allow execution to continue - } - else - { - if(!$n = getConfig('site_disabled_notice')) - { - $n = 'The administrator has disabled the site. Please check back later.'; - } - - $text = RenderMan::render($n) . ' -