diff -r 299a90e28abc -r 87e08a6e4fec install.php --- a/install.php Thu Jan 03 18:39:19 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2470 +0,0 @@ -The Enano installer has found a Enano installation in this directory. You MUST delete config.php if you want to re-install Enano.

If you wish to upgrade an older Enano installation to this version, please use the upgrade script.

'); - exit; -} - -define('IN_ENANO_INSTALL', 'true'); - -define('ENANO_VERSION', '1.1.1'); -define('ENANO_CODE_NAME', 'Germination'); -// In beta versions, define ENANO_BETA_VERSION here - -// This is required to make installation work right -define("ENANO_ALLOW_LOAD_NOLANG", 1); - -if(!defined('scriptPath')) { - $sp = dirname($_SERVER['REQUEST_URI']); - if($sp == '/' || $sp == '\\') $sp = ''; - define('scriptPath', $sp); -} - -if(!defined('contentPath')) { - $sp = dirname($_SERVER['REQUEST_URI']); - if($sp == '/' || $sp == '\\') $sp = ''; - define('contentPath', $sp); -} -global $_starttime, $this_page, $sideinfo; -$_starttime = microtime(true); - -global $db; - -// Determine directory (special case for development servers) -if ( strpos(__FILE__, '/repo/') && file_exists('.enanodev') ) -{ - $filename = str_replace('/repo/', '/', __FILE__); -} -else -{ - $filename = __FILE__; -} - -define('ENANO_ROOT', dirname($filename)); - -function is_page($p) -{ - return true; -} - -function microtime_float() -{ - list($usec, $sec) = explode(" ", microtime()); - return ((float)$usec + (float)$sec); -} - -require('includes/wikiformat.php'); -require('includes/constants.php'); -require('includes/rijndael.php'); -require('includes/functions.php'); -require('includes/dbal.php'); -require('includes/lang.php'); -require('includes/json.php'); - -// Initialize language support -$lang = new Language('eng'); -$lang->load_file('./language/english/install.json'); - -strip_magic_quotes_gpc(); - -// -// INSTALLER LIBRARY -// - -$neutral_color = 'C'; - -function run_installer_stage($stage_id, $stage_name, $function, $failure_explanation, $allow_skip = true) -{ - static $resumed = false; - static $resume_stack = array(); - - if ( empty($resume_stack) && isset($_POST['resume_stack']) && preg_match('/[a-z_]+((\|[a-z_]+)+)/', $_POST['resume_stack']) ) - { - $resume_stack = explode('|', $_POST['resume_stack']); - } - - $already_run = false; - if ( in_array($stage_id, $resume_stack) ) - { - $already_run = true; - } - - if ( !$resumed ) - { - if ( !isset($_GET['stage']) ) - $resumed = true; - if ( isset($_GET['stage']) && $_GET['stage'] == $stage_id ) - { - $resumed = true; - } - } - if ( !$resumed && $allow_skip ) - { - echo_stage_success($stage_id, $stage_name); - return false; - } - if ( !function_exists($function) ) - die('libenanoinstall: CRITICAL: function "' . $function . '" for ' . $stage_id . ' doesn\'t exist'); - $result = @call_user_func($function, false, $already_run); - if ( $result ) - { - echo_stage_success($stage_id, $stage_name); - $resume_stack[] = $stage_id; - return true; - } - else - { - echo_stage_failure($stage_id, $stage_name, $failure_explanation, $resume_stack); - return false; - } -} - -function start_install_table() -{ - echo '' . "\n"; - ob_start(); -} - -function close_install_table() -{ - echo '
' . "\n\n"; - ob_end_flush(); -} - -function echo_stage_success($stage_id, $stage_name) -{ - global $neutral_color; - $neutral_color = ( $neutral_color == 'A' ) ? 'C' : 'A'; - echo '' . htmlspecialchars($stage_name) . 'Done' . "\n"; - ob_flush(); -} - -function echo_stage_failure($stage_id, $stage_name, $failure_explanation, $resume_stack) -{ - global $neutral_color; - global $lang; - - $neutral_color = ( $neutral_color == 'A' ) ? 'C' : 'A'; - echo '' . htmlspecialchars($stage_name) . 'Failed' . "\n"; - ob_flush(); - close_install_table(); - $post_data = ''; - $mysql_error = mysql_error(); - foreach ( $_POST as $key => $value ) - { - // FIXME: These should really also be sanitized for double quotes - $value = htmlspecialchars($value); - $key = htmlspecialchars($key); - $post_data .= " \n"; - } - echo '
- ' . $post_data . ' - -

' . $lang->get('meta_msg_err_stagefailed_title') . '

-

' . $failure_explanation . '

- ' . ( !empty($mysql_error) ? "

" . $lang->get('meta_msg_err_stagefailed_mysqlerror') . " $mysql_error

" : '' ) . ' -

' . $lang->get('meta_msg_err_stagefailed_body') . '

-

-
'; - global $template, $template_bak; - if ( is_object($template_bak) ) - $template_bak->footer(); - else - $template->footer(); - exit; -} - -// -// INSTALLER STAGES -// - -function stg_mysql_connect($act_get = false) -{ - global $db; - $db = new mysql(); - - static $conn = false; - if ( $act_get ) - return $conn; - - $db_user =& $_POST['db_user']; - $db_pass =& $_POST['db_pass']; - $db_name =& $_POST['db_name']; - - if ( !preg_match('/^[a-z0-9_-]+$/', $db_name) ) - { - $db_name = htmlspecialchars($db_name); - die("

SECURITY: malformed database name \"$db_name\"

"); - } - - // First, try to connect using the normal credentials - $conn = @mysql_connect($_POST['db_host'], $_POST['db_user'], $_POST['db_pass']); - if ( !$conn ) - { - // Connection failed. Do we have the root username and password? - if ( !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) ) - { - $conn_root = @mysql_connect($_POST['db_host'], $_POST['db_root_user'], $_POST['db_root_pass']); - if ( !$conn_root ) - { - // Couldn't connect using either set of credentials. Bail out. - return false; - } - unset($db_user, $db_pass); - $db_user = mysql_real_escape_string($_POST['db_user']); - $db_pass = mysql_real_escape_string($_POST['db_pass']); - // Create the user account - $q = @mysql_query("GRANT ALL PRIVILEGES ON test.* TO '{$db_user}'@'localhost' IDENTIFIED BY '$db_pass' WITH GRANT OPTION;", $conn_root); - if ( !$q ) - { - return false; - } - // Revoke privileges from test, we don't need them - $q = @mysql_query("REVOKE ALL PRIVILEGES ON test.* FROM '{$db_user}'@'localhost';", $conn_root); - if ( !$q ) - { - return false; - } - if ( $_POST['db_host'] != 'localhost' && $_POST['db_host'] != '127.0.0.1' && $_POST['db_host'] != '::1' ) - { - // If not connecting to a server running on localhost, allow from any host - // this is safer than trying to detect the hostname of the webserver, but less secure - $q = @mysql_query("GRANT ALL PRIVILEGES ON test.* TO '{$db_user}'@'%' IDENTIFIED BY '$db_pass' WITH GRANT OPTION;", $conn_root); - if ( !$q ) - { - return false; - } - // Revoke privileges from test, we don't need them - $q = @mysql_query("REVOKE ALL PRIVILEGES ON test.* FROM '{$db_user}'@'%';", $conn_root); - if ( !$q ) - { - return false; - } - } - mysql_close($conn_root); - $conn = @mysql_connect($_POST['db_host'], $_POST['db_user'], $_POST['db_pass']); - if ( !$conn ) - { - // This should honestly never happen. - return false; - } - } - } - $q = @mysql_query("USE `$db_name`;", $conn); - if ( !$q ) - { - // access denied to the database; try the whole root schenanegan again - if ( !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) ) - { - $conn_root = @mysql_connect($_POST['db_host'], $_POST['db_root_user'], $_POST['db_root_pass']); - if ( !$conn_root ) - { - // Couldn't connect as root; bail out - return false; - } - // create the database, if it doesn't exist - $q = @mysql_query("CREATE DATABASE IF NOT EXISTS `$db_name`;", $conn_root); - if ( !$q ) - { - // this really should never fail, so don't give any tolerance to it - return false; - } - unset($db_user, $db_pass); - $db_user = mysql_real_escape_string($_POST['db_user']); - $db_pass = mysql_real_escape_string($_POST['db_pass']); - // we're in with root rights; grant access to the database - $q = @mysql_query("GRANT ALL PRIVILEGES ON `$db_name`.* TO '{$db_user}'@'localhost';", $conn_root); - if ( !$q ) - { - return false; - } - if ( $_POST['db_host'] != 'localhost' && $_POST['db_host'] != '127.0.0.1' && $_POST['db_host'] != '::1' ) - { - $q = @mysql_query("GRANT ALL PRIVILEGES ON `$db_name`.* TO '{$db_user}'@'%';", $conn_root); - if ( !$q ) - { - return false; - } - } - mysql_close($conn_root); - // grant tables have hopefully been flushed, kill and reconnect our regular user connection - mysql_close($conn); - $conn = @mysql_connect($_POST['db_host'], $_POST['db_user'], $_POST['db_pass']); - if ( !$conn ) - { - return false; - } - } - else - { - return false; - } - // try again - $q = @mysql_query("USE `$db_name`;", $conn); - if ( !$q ) - { - // really failed this time; bail out - return false; - } - } - // initialize DBAL - $db->connect(true, $_POST['db_host'], $db_user, $db_pass, $db_name); - // connected and database exists - return true; -} - -function stg_pgsql_connect($act_get = false) -{ - global $db; - $db = new postgresql(); - - static $conn = false; - if ( $act_get ) - return $conn; - - $db_user =& $_POST['db_user']; - $db_pass =& $_POST['db_pass']; - $db_name =& $_POST['db_name']; - - if ( !preg_match('/^[a-z0-9_-]+$/', $db_name) ) - { - $db_name = htmlspecialchars($db_name); - die("

SECURITY: malformed database name \"$db_name\"

"); - } - - // First, try to connect using the normal credentials - $conn = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_user']} password={$_POST['db_pass']}"); - if ( !$conn ) - { - // Connection failed. Do we have the root username and password? - if ( !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) ) - { - $conn_root = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_root_user']} password={$_POST['db_root_pass']}"); - if ( !$conn_root ) - { - // Couldn't connect using either set of credentials. Bail out. - return false; - } - unset($db_user, $db_pass); - $db_user = pg_escape_string($_POST['db_user']); - $db_pass = pg_escape_string($_POST['db_pass']); - // Create the user account - $q = @pg_query("CREATE ROLE '$db_user' WITH NOSUPERUSER UNENCRYPTED PASSWORD '$db_pass';", $conn_root); - if ( !$q ) - { - return false; - } - pg_close($conn_root); - $conn = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_user']} password={$_POST['db_pass']}"); - if ( !$conn ) - { - // This should honestly never happen. - return false; - } - } - } - if ( !$q ) - { - // access denied to the database; try the whole root schenanegan again - if ( !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) ) - { - $conn_root = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_root_user']} password={$_POST['db_root_pass']}"); - if ( !$conn_root ) - { - // Couldn't connect as root; bail out - return false; - } - unset($db_user, $db_pass); - $db_user = pg_escape_string($_POST['db_user']); - $db_pass = pg_escape_string($_POST['db_pass']); - // create the database, if it doesn't exist - $q = @mysql_query("CREATE DATABASE $db_name WITH OWNER $db_user;", $conn_root); - if ( !$q ) - { - // this really should never fail, so don't give any tolerance to it - return false; - } - // Setting the owner to $db_user should grant all the rights we need - pg_close($conn_root); - // grant tables have hopefully been flushed, kill and reconnect our regular user connection - pg_close($conn); - $conn = @pg_connect("host={$_POST['db_host']} port=5432 user={$_POST['db_user']} password={$_POST['db_pass']}"); - if ( !$conn ) - { - return false; - } - } - else - { - return false; - } - // try again - $q = @mysql_query("USE `$db_name`;", $conn); - if ( !$q ) - { - // really failed this time; bail out - return false; - } - } - // initialize DBAL - $db->connect(true, $_POST['db_host'], $db_user, $db_pass, $db_name); - // connected and database exists - return true; -} - -function stg_drop_tables() -{ - global $db; - // Our list of tables included in Enano - $tables = Array( 'categories', 'comments', 'config', 'logs', 'page_text', 'session_keys', 'pages', 'users', 'users_extra', 'themes', 'buddies', 'banlist', 'files', 'privmsgs', 'sidebar', 'hits', 'search_index', 'groups', 'group_members', 'acl', 'tags', 'page_groups', 'page_group_members' ); - - // Drop each table individually; if it fails, it probably means we're trying to drop a - // table that didn't exist in the Enano version we're deleting the database for. - foreach ( $tables as $table ) - { - // Remember that table_prefix is sanitized. - $table = "{$_POST['table_prefix']}$table"; - $db->sql_query("DROP TABLE $table;", $conn); - } - return true; -} - -function stg_decrypt_admin_pass($act_get = false) -{ - static $decrypted_pass = false; - if ( $act_get ) - return $decrypted_pass; - - $aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE); - - if ( !empty($_POST['crypt_data']) ) - { - require('config.new.php'); - if ( !isset($cryptkey) ) - { - return false; - } - define('_INSTRESUME_AES_KEYBACKUP', $key); - $key = hexdecode($cryptkey); - - $decrypted_pass = $aes->decrypt($_POST['crypt_data'], $key, ENC_HEX); - - } - else - { - $decrypted_pass = $_POST['admin_pass']; - } - if ( empty($decrypted_pass) ) - return false; - return true; -} - -function stg_generate_aes_key($act_get = false) -{ - static $key = false; - if ( $act_get ) - return $key; - - $aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE); - $key = $aes->gen_readymade_key(); - return true; -} - -function stg_parse_schema($act_get = false) -{ - static $schema; - if ( $act_get ) - return $schema; - - global $db; - - $admin_pass = stg_decrypt_admin_pass(true); - $key = stg_generate_aes_key(true); - $aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE); - $key = $aes->hextostring($key); - $admin_pass = $aes->encrypt($admin_pass, $key, ENC_HEX); - - $cacheonoff = is_writable(ENANO_ROOT.'/cache/') ? '1' : '0'; - - $admin_user = $_POST['admin_user']; - $admin_user = str_replace('_', ' ', $admin_user); - $admin_user = $db->escape($admin_user); - - switch ( $_POST['db_driver'] ) - { - case 'mysql': - $schema_file = 'schema.sql'; - break; - case 'postgresql': - $schema_file = 'schema-pg.sql'; - break; - } - - if ( !isset($schema_file) ) - die('insanity'); - - $schema = file_get_contents($schema_file); - $schema = str_replace('{{SITE_NAME}}', $db->escape($_POST['sitename'] ), $schema); - $schema = str_replace('{{SITE_DESC}}', $db->escape($_POST['sitedesc'] ), $schema); - $schema = str_replace('{{COPYRIGHT}}', $db->escape($_POST['copyright'] ), $schema); - $schema = str_replace('{{ADMIN_USER}}', $admin_user , $schema); - $schema = str_replace('{{ADMIN_PASS}}', $db->escape($admin_pass ), $schema); - $schema = str_replace('{{ADMIN_EMAIL}}', $db->escape($_POST['admin_email']), $schema); - $schema = str_replace('{{ENABLE_CACHE}}', $db->escape($cacheonoff ), $schema); - $schema = str_replace('{{REAL_NAME}}', '', $schema); - $schema = str_replace('{{TABLE_PREFIX}}', $_POST['table_prefix'], $schema); - $schema = str_replace('{{VERSION}}', ENANO_VERSION, $schema); - $schema = str_replace('{{ADMIN_EMBED_PHP}}', $_POST['admin_embed_php'], $schema); - // Not anymore!! :-D - // $schema = str_replace('{{BETA_VERSION}}', ENANO_BETA_VERSION, $schema); - - if(isset($_POST['wiki_mode'])) - { - $schema = str_replace('{{WIKI_MODE}}', '1', $schema); - } - else - { - $schema = str_replace('{{WIKI_MODE}}', '0', $schema); - } - - // Build an array of queries - $schema = explode("\n", $schema); - - foreach ( $schema as $i => $sql ) - { - $query =& $schema[$i]; - $t = trim($query); - if ( empty($t) || preg_match('/^(\#|--)/i', $t) ) - { - unset($schema[$i]); - unset($query); - } - } - - $schema = array_values($schema); - $schema = implode("\n", $schema); - $schema = explode(";\n", $schema); - - foreach ( $schema as $i => $sql ) - { - $query =& $schema[$i]; - if ( substr($query, ( strlen($query) - 1 ), 1 ) != ';' ) - { - $query .= ';'; - } - } - - return true; -} - -function stg_install($_unused, $already_run) -{ - // This one's pretty easy. - $conn = stg_mysql_connect(true); - if ( !is_resource($conn) ) - return false; - $schema = stg_parse_schema(true); - if ( !is_array($schema) ) - return false; - - // If we're resuming installation, the encryption key was regenerated. - // This means we'll have to update the encrypted password in the database. - if ( $already_run ) - { - $admin_pass = stg_decrypt_admin_pass(true); - $key = stg_generate_aes_key(true); - $aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE); - $key = $aes->hextostring($key); - $admin_pass = $aes->encrypt($admin_pass, $key, ENC_HEX); - $admin_user = mysql_real_escape_string($_POST['admin_user']); - $admin_user = str_replace('_', ' ', $admin_user); - - $q = @mysql_query("UPDATE {$_POST['table_prefix']}users SET password='$admin_pass' WHERE username='$admin_user';"); - if ( !$q ) - { - echo '

MySQL return: ' . mysql_error() . '

'; - return false; - } - - return true; - } - - // OK, do the loop, baby!!! - foreach($schema as $q) - { - $r = mysql_query($q, $conn); - if ( !$r ) - { - echo '

MySQL return: ' . mysql_error() . '

'; - return false; - } - } - - return true; -} - -function stg_write_config() -{ - $privkey = stg_generate_aes_key(true); - - switch($_POST['urlscheme']) - { - case "ugly": - default: - $cp = scriptPath.'/index.php?title='; - break; - case "short": - $cp = scriptPath.'/index.php/'; - break; - case "tiny": - $cp = scriptPath.'/'; - break; - } - - if ( $_POST['urlscheme'] == 'tiny' ) - { - $contents = '# Begin Enano rules -RewriteEngine on -RewriteCond %{REQUEST_FILENAME} !-d -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^(.+) '.scriptPath.'/index.php?title=$1 [L,QSA] -RewriteRule \.(php|html|gif|jpg|png|css|js)$ - [L] -# End Enano rules -'; - if ( file_exists('./.htaccess') ) - $ht = fopen(ENANO_ROOT.'/.htaccess', 'a+'); - else - $ht = fopen(ENANO_ROOT.'/.htaccess.new', 'w'); - if ( !$ht ) - return false; - fwrite($ht, $contents); - fclose($ht); - } - - $config_file = ''; - - $cf_handle = fopen(ENANO_ROOT.'/config.new.php', 'w'); - if ( !$cf_handle ) - return false; - fwrite($cf_handle, $config_file); - - fclose($cf_handle); - - return true; -} - -function _stg_rename_config_revert() -{ - if ( file_exists('./config.php') ) - { - @rename('./config.php', './config.new.php'); - } - - $handle = @fopen('./config.php.new', 'w'); - if ( !$handle ) - return false; - $contents = ''; - fwrite($handle, $contents); - fclose($handle); - return true; -} - -function stg_build_index() -{ - global $db, $session, $paths, $template, $plugins; // Common objects; - if ( $paths->rebuild_search_index() ) - return true; - return false; -} - -function stg_rename_config() -{ - if ( !@rename('./config.new.php', './config.php') ) - { - echo '

Can\'t rename config.php

'; - _stg_rename_config_revert(); - return false; - } - - if ( $_POST['urlscheme'] == 'tiny' && !file_exists('./.htaccess') ) - { - if ( !@rename('./.htaccess.new', './.htaccess') ) - { - echo '

Can\'t rename .htaccess

'; - _stg_rename_config_revert(); - return false; - } - } - return true; -} - -function stg_start_api_success() -{ - return true; -} - -function stg_start_api_failure() -{ - return false; -} - -function stg_import_language() -{ - global $db, $session, $paths, $template, $plugins; // Common objects - - $lang_file = ENANO_ROOT . "/language/english/enano.json"; - install_language("eng", "English", "English", $lang_file); - - return true; -} - -function stg_init_logs() -{ - global $db, $session, $paths, $template, $plugins; // Common objects - - $q = $db->sql_query('INSERT INTO ' . table_prefix . 'logs(log_type,action,time_id,date_string,author,page_text,edit_summary) VALUES(\'security\', \'install_enano\', ' . time() . ', \'' . enano_date('d M Y h:i a') . '\', \'' . mysql_real_escape_string($_POST['admin_user']) . '\', \'' . mysql_real_escape_string(ENANO_VERSION) . '\', \'' . mysql_real_escape_string($_SERVER['REMOTE_ADDR']) . '\');'); - if ( !$q ) - { - echo '

MySQL return: ' . mysql_error() . '

'; - return false; - } - - if ( !$session->get_permissions('clear_logs') ) - { - echo '

$session: denied clear_logs

'; - return false; - } - - PageUtils::flushlogs('Main_Page', 'Article'); - - return true; -} - -//die('Key size: ' . AES_BITS . '
Block size: ' . AES_BLOCKSIZE); - -if(!function_exists('wikiFormat')) -{ - function wikiFormat($message, $filter_links = true) - { - $wiki = & Text_Wiki::singleton('Mediawiki'); - $wiki->setRenderConf('Xhtml', 'code', 'css_filename', 'codefilename'); - $wiki->setRenderConf('Xhtml', 'wikilink', 'view_url', contentPath); - $result = $wiki->transform($message, 'Xhtml'); - - // HTML fixes - $result = preg_replace('#([\s]*?)<\/tr>#is', '', $result); - $result = preg_replace('#

([\s]*?)<\/p>#is', '', $result); - $result = preg_replace('#
([\s]*?)$descTest passed"; - } elseif(!$val && $warn) { - if($cv) $color='FFFFCC'; else $color='FFFFAA'; - echo "$desc
$extended_descTest passed with warning"; - $warned = true; - } else { - if($cv) $color='FFCCCC'; else $color='FFAAAA'; - echo "$desc
$extended_descTest failed"; - $failed = true; - } -} -function is_apache() { $r = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? true : false; return $r; } - -function show_license($fb = false) -{ - global $lang; - ?> -

- -

get('license_info_unstable_title'); ?>

-

get('license_info_unstable_body'); ?>

- -

get('license_section_gpl_heading'); ?>

- lang_code != 'eng' ): ?> -

get('license_gpl_blurb_inenglish'); ?>

- - - Because I could never find the Create a Page button in PHP-Nuke.

'; - echo '

' . str_replace('http://enanocms.org/', 'http://www.2robots.com/2003/10/15/web-portals-suck/', $template->fading_button) . '

'; - echo '

It\'s not a portal, my friends.

'; - } - ?> -
- get('pophelp_admin_embed_php_title'); - $content = $lang->get('pophelp_admin_embed_php_body'); - break; - case 'url_schemes': - $title = $lang->get('pophelp_url_schemes_title'); - $content = $lang->get('pophelp_url_schemes_body'); - break; - default: - $title = 'Invalid topic'; - $content = 'Invalid help topic.'; - break; - } - $close_window = $lang->get('pophelp_btn_close_window'); - echo << - - - Enano installation quick help • {$title} - - - - -

{$title}

- {$content} -

- {$close_window} -

- - -EOF; - exit; - break; - case 'langjs': - header('Content-type: text/javascript'); - $lang_js = enano_json_encode($lang->strings); - // use EEOF here because jEdit misinterprets "typ'eof'" - echo <<load_theme('stpatty', 'shamrock', false); - -$modestrings = Array( - 'welcome' => $lang->get('welcome_modetitle'), - 'license' => $lang->get('license_modetitle'), - 'sysreqs' => $lang->get('sysreqs_modetitle'), - 'database' => $lang->get('database_modetitle'), - 'database_mysql'=> $lang->get('database_mysql_modetitle'), - 'database_pgsql'=> $lang->get('database_pgsql_modetitle'), - 'website' => $lang->get('website_modetitle'), - 'login' => $lang->get('login_modetitle'), - 'confirm' => $lang->get('confirm_modetitle'), - 'install' => $lang->get('install_modetitle'), - 'finish' => $lang->get('finish_modetitle'), - '_hiddenstages' => '...', // all stages below this line are hidden - 'showlicense' => $lang->get('license_modetitle') - ); - -$sideinfo = ''; -$vars = $template->extract_vars('elements.tpl'); -$p = $template->makeParserText($vars['sidebar_button']); -$hidden = false; -foreach ( $modestrings as $id => $str ) -{ - if ( $_GET['mode'] == $id ) - { - $flags = 'style="font-weight: bold; text-decoration: underline;"'; - $this_page = $str; - } - else - { - $flags = ''; - } - if ( $id == '_hiddenstages' ) - $hidden = true; - if ( !$hidden ) - { - $p->assign_vars(Array( - 'HREF' => '#', - 'FLAGS' => $flags . ' onclick="return false;"', - 'TEXT' => $str - )); - $sideinfo .= $p->run(); - } -} - -$template->init_vars(); - -if(isset($_GET['mode']) && $_GET['mode'] == 'css') -{ - header('Content-type: text/css'); - echo $template->get_css(); - exit; -} - -if ( defined('ENANO_IS_STABLE') ) - $branch = 'stable'; -else if ( defined('ENANO_IS_UNSTABLE') ) - $branch = 'unstable'; -else -{ - $version = explode('.', ENANO_VERSION); - if ( !isset($version[1]) ) - // unknown branch, really - $branch = 'unstable'; - else - { - $version[1] = intval($version[1]); - if ( $version[1] % 2 == 1 ) - $branch = 'unstable'; - else - $branch = 'stable'; - } -} - -$template->header(); - -switch($_GET['mode']) -{ - default: - case 'welcome': - ?> -
- [ Enano CMS Project logo ] -

get('welcome_heading'); ?>

-

- get("welcome_branch_$branch"); - - $v_string = sprintf('%s %s – %s', $lang->get('welcome_version'), ENANO_VERSION, $branch_l); - echo $v_string; - ?> -

- '; - echo $lang->get('welcome_aka', array( - 'codename' => strtolower(ENANO_CODE_NAME) - )); - echo '

'; - } - ?> -
- -
-
- -

get('license_heading'); ?>

-

get('license_blurb_thankyou'); ?>

-

get('license_blurb_pleaseread'); ?>

- - - -

get('sysreqs_heading'); ?>

-

get('sysreqs_blurb'); ?>

- - get('sysreqs_req_php'), $lang->get('sysreqs_req_desc_php') ); - run_test('return version_compare(\'5.2.0\', PHP_VERSION, \'<\');', $lang->get('sysreqs_req_php5'), $lang->get('sysreqs_req_desc_php5'), true); - run_test('return function_exists(\'mysql_connect\');', $lang->get('sysreqs_req_mysql'), $lang->get('sysreqs_req_desc_mysql') ); - run_test('return function_exists(\'pg_connect\');', 'PostgreSQL extension for PHP', 'It seems that your PHP installation does not have the PostgreSQL extension enabled. Because of this, you won\'t be able to use the PostgreSQL database driver. This is OK in the majority of cases. If you want to use PostgreSQL support, you\'ll need to either compile the PHP extension for Postgres or install the extension with your distribution\'s package manager. Windows administrators will need enable php_pgsql.dll in their php.ini.', true); - run_test('return @ini_get(\'file_uploads\');', $lang->get('sysreqs_req_uploads'), $lang->get('sysreqs_req_desc_uploads') ); - run_test('return is_apache();', $lang->get('sysreqs_req_apache'), $lang->get('sysreqs_req_desc_apache'), true); - run_test('return is_writable(ENANO_ROOT.\'/config.new.php\');', $lang->get('sysreqs_req_config'), $lang->get('sysreqs_req_desc_config') ); - run_test('return file_exists(\'/usr/bin/convert\');', $lang->get('sysreqs_req_magick'), $lang->get('sysreqs_req_desc_magick'), true); - run_test('return is_writable(ENANO_ROOT.\'/cache/\');', $lang->get('sysreqs_req_cachewriteable'), $lang->get('sysreqs_req_desc_cachewriteable'), true); - run_test('return is_writable(ENANO_ROOT.\'/files/\');', $lang->get('sysreqs_req_fileswriteable'), $lang->get('sysreqs_req_desc_fileswriteable'), true); - if ( !function_exists('mysql_connect') && !function_exists('pg_connect') ) - { - run_test('return false;', 'No database drivers are available.', 'You need to have at least one database driver working to install Enano. See the warnings on MySQL and PostgreSQL above for more information on installing these database drivers.', false); - } - echo '
'; - if(!$failed) - { - ?> - - - '; - run_test('return false;', $lang->get('sysreqs_summary_fail_title'), $lang->get('sysreqs_summary_fail_body')); - echo '
'; - } - } - ?> - Choose a database driver'; - echo '

The next step is to choose the database driver that Enano will use. In most cases this is MySQL, but there are certain - advantages to PostgreSQL, which is made available only experimentally.

'; - if ( @file_exists('/etc/enano-is-virt-appliance') ) - { - echo '

You\'re using the Enano virtual appliance.
Unless you configured the appliance manually, PostgreSQL support is not available. In 99% of cases you\'ll want to click MySQL below.

'; - } - - $mysql_disable_reason = ''; - $pgsql_disable_reason = ''; - $mysql_disable = ''; - $pgsql_disable = ''; - if ( !function_exists('mysql_connect') ) - { - $mysql_disable = ' disabled="disabled"'; - $mysql_disable_reason = 'You don\'t have the MySQL PHP extension installed.'; - } - if ( !function_exists('pg_connect') ) - { - $pgsql_disable = ' disabled="disabled"'; - $pgsql_disable_reason = 'You don\'t have the PostgreSQL PHP extensnion installed.'; - } - if ( function_exists('pg_connect') && version_compare(PHP_VERSION, '5.0.0', '<') ) - { - $pgsql_disable = ' disabled="disabled"'; - $pgsql_disable_reason = 'You need to have at least PHP 5 to use the PostgreSQL database driver.'; - } - - echo '
'; - ?> - - - - > - MySQL
- Click this button to use MySQL as the database backend for your site. Most web hosts support MySQL, and if you have - administrative access to your MySQL server, you can create a new database and user during this installation process if you - haven't done so already. -
$mysql_disable_reason"; - } - ?> - -
- - - > - PostgreSQL
- Click this button to use PostgreSQL as the database backend for your site. While not as widely supported, PostgreSQL has more - liberal licensing conditions and when properly configured is faster than MySQL. Some plugins may not work with the PostgreSQL - driver. -
$pgsql_disable_reason"; - } - ?> - -
-
- /> -
- /> -
- '; - break; - case "database_mysql": - ?> - -

get('database_blurb_needdb'); ?>

-

get('database_blurb_howtomysql'); ?>

- - ' . $lang->get('database_vm_login_info', array( 'host' => 'localhost', 'user' => 'enano', 'pass' => 'clurichaun', 'name' => 'enano_www1' )) . ' -

'; - } - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

get('database_table_title'); ?>

-
- get('database_field_hostname_title'); ?> -
get('database_field_hostname_body'); ?> -
-
- - - Good/bad icon -
- get('database_field_dbname_title'); ?>
- get('database_field_dbname_body'); ?>
- -
- - - Good/bad icon -
- get('database_field_dbauth_title'); ?>
- get('database_field_dbauth_body'); ?>
- -
- - - Good/bad icon -
- -
-

get('database_heading_optionalinfo'); ?>

-
- get('database_field_tableprefix_title'); ?>
- get('database_field_tableprefix_body'); ?> -
- - - Good/bad icon -
- get('database_field_rootauth_title'); ?>
- get('database_field_rootauth_body'); ?>
- -
- - - Good/bad icon -
- -
- get('database_field_mysqlversion_title'); ?> - - get('database_field_mysqlversion_blurb_willbechecked'); ?> - - Good/bad icon -
- get('database_field_droptables_title'); ?>
- get('database_field_droptables_body'); ?> -
- -
- -
- - - -

get('database_blurb_needdb'); ?>

-

get('database_blurb_howtomysql'); ?>

- - ' . $lang->get('database_vm_login_info', array( 'host' => 'localhost', 'user' => 'enano', 'pass' => 'clurichaun', 'name' => 'enano_www1' )) . ' -

'; - } - ?> - - - - - - - - - - - - - - - -

Database information

Database hostname
This is the hostname (or sometimes the IP address) of your Postgres server. In many cases, this is "localhost".
Good/bad icon
Database name
The name of the actual database. If you don't already have a database, you can create one here, if you have the username and password of a PostgreSQL superuser.
Good/bad icon
Database login
These fields should be the username and password for a role that has permission to create and alter tables, select data, insert data, update data, and delete data. You may or may not choose to allow dropping tables.
Good/bad icon

Optional information

Table prefix
The value that you enter here will be added to the beginning of the name of each Enano table. You may use lowercase letters (a-z), numbers (0-9), and underscores (_).
Good/bad icon
Database administrative login
If the Postgres database or role that you entered above does not exist yet, you can create them here, assuming that you have the login information for a PostgreSQL superuser. Leave these fields blank unless you need to use them.
Good/bad icon
PostgreSQL versionPostgreSQL version information will
be checked when you click "Test
Connection". You need to have at
least PostgreSQL 8.2.0 to install Enano.
Good/bad icon
Delete existing tables?
If this option is checked, all the tables that will be used by Enano will be dropped (deleted) before the schema is executed. Do NOT use this option unless specifically instructed to.
- -
- restart the installation.'; - $template->footer(); - exit; - } - unset($_POST['_cont']); - ?> - -
- '."\n"; - } - ?> -

get('website_header_blurb'); ?>

- - - - - - - - - - - - - - - - - - - - - - - - - -
- get('website_field_name_title'); ?>
- get('website_field_name_body'); ?> -
- - - Good/bad icon -
- get('website_field_desc_title'); ?>
- get('website_field_desc_body'); ?> -
- - - Good/bad icon -
- get('website_field_copyright_title'); ?>
- get('website_field_copyright_body'); ?> -
- - - Good/bad icon -
- get('website_field_wikimode_title'); ?>
- get('website_field_wikimode_body'); ?> -
- - -   -
- get('website_field_urlscheme_title'); ?>
- get('website_field_urlscheme_body'); ?> -
- name="urlscheme" value="ugly" id="ugly" />
- name="urlscheme" value="short" id="short" />
-
- get('website_field_urlscheme_helplink'); ?> -
- -
- restart the installation.'; - $template->footer(); - exit; - } - unset($_POST['_cont']); - require('config.new.php'); - $aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE); - if ( isset($crypto_key) ) - { - $cryptkey = $crypto_key; - } - if(!isset($cryptkey) || ( isset($cryptkey) && strlen($cryptkey) != AES_BITS / 4) ) - { - $cryptkey = $aes->gen_readymade_key(); - $handle = @fopen(ENANO_ROOT.'/config.new.php', 'w'); - if(!$handle) - { - echo '

ERROR: Despite my repeated attempts to verify that the configuration file can be written, I was indeed prevented from opening it for writing. Maybe you\'re still on crack Windows?

'; - $template->footer(); - exit; - } - fwrite($handle, ''); - fclose($handle); - } - // Sorry for the ugly hack, but this f***s up jEdit badly. - echo ' - - '; - ?> -
- '."\n"; - } - ?> -

get('login_header_blurb'); ?>

- - - - - - - - - - - - - - - - - - - - - - - - - - -
get('login_field_username_title'); ?>
get('login_field_username_body'); ?>
Good/bad icon
get('login_field_password_title'); ?>Good/bad icon
get('login_field_password_confirm'); ?>
get('login_field_email_title'); ?>Good/bad icon
- get('login_field_allowphp_title'); ?>
- - - get('login_field_allowphp_body', - array( - 'important_notes' => '' . $lang->get('login_field_allowphp_isi') . '' - ) - ); - ?> - - -
-    - -
get('login_aes_blurb'); ?>
- -
- - - -
- - restart the installation.'; - $template->footer(); - exit; - } - unset($_POST['_cont']); - ?> -
- '."\n"; - } - ?> -

get('confirm_header_blurb_title'); ?>

-

get('confirm_header_blurb_body'); ?>

-
    -
  • get('confirm_lbl_db_host'); ?>
  • -
  • get('confirm_lbl_db_name'); ?>
  • -
  • get('confirm_lbl_db_user'); ?>
  • -
  • get('confirm_lbl_db_pass'); ?>
  • -
  • get('confirm_lbl_sitename'); ?>
  • -
  • get('confirm_lbl_sitedesc'); ?>
  • -
  • get('confirm_lbl_adminuser'); ?>
  • -
  • get('confirm_lbl_aesbits'); ?> get('confirm_lbl_aes_strength', array( 'aes_bits' => AES_BITS )); ?>
    get('confirm_lbl_aes_change'); ?>
  • -
- -
- restart the installation.'; - $template->footer(); - exit; - } - if ( !in_array($_POST['db_driver'], array('mysql', 'postgresql')) ) - { - echo 'Invalid database driver.'; - $template->footer(); - exit; - } - switch($_POST['urlscheme']) - { - case "ugly": - default: - $cp = scriptPath.'/index.php?title='; - break; - case "short": - $cp = scriptPath.'/index.php/'; - break; - case "tiny": - $cp = scriptPath.'/'; - break; - } - function err($t) { global $template; echo $t; $template->footer(); exit; } - - // $stages = array('connect', 'decrypt', 'genkey', 'parse', 'sql', 'writeconfig', 'renameconfig', 'startapi', 'initlogs'); - - if ( !preg_match('/^[a-z0-9_-]*$/', $_POST['table_prefix']) ) - err('Hacking attempt was detected in table_prefix.'); - - start_install_table(); - - // Are we just trying to auto-rename the config files? If so, skip everything else - if ( !isset($_GET['stage']) || ( isset($_GET['stage']) && $_GET['stage'] != 'renameconfig' ) ) - { - // The stages connect, decrypt, genkey, and parse are preprocessing and don't do any actual data modification. - // Thus, they need to be run on each retry, e.g. never skipped. - run_installer_stage('connect', $lang->get('install_stg_connect_title'), 'stg_mysql_connect', $lang->get('install_stg_connect_body'), false); - if ( isset($_POST['drop_tables']) ) - { - // Are we supposed to drop any existing tables? If so, do it now - run_installer_stage('drop', $lang->get('install_stg_drop_title'), 'stg_drop_tables', 'This step never returns failure'); - } - run_installer_stage('decrypt', $lang->get('install_stg_decrypt_title'), 'stg_decrypt_admin_pass', $lang->get('install_stg_decrypt_body'), false); - run_installer_stage('genkey', $lang->get('install_stg_genkey_title', array( 'aes_bits' => AES_BITS )), 'stg_generate_aes_key', $lang->get('install_stg_genkey_body'), false); - run_installer_stage('parse', $lang->get('install_stg_parse_title'), 'stg_parse_schema', $lang->get('install_stg_parse_body'), false); - run_installer_stage('sql', $lang->get('install_stg_sql_title'), 'stg_install', $lang->get('install_stg_sql_body'), false); - run_installer_stage('writeconfig', $lang->get('install_stg_writeconfig_title'), 'stg_write_config', $lang->get('install_stg_writeconfig_body')); - - // Mainstream installation complete - Enano should be usable now - // The stage of starting the API is special because it has to be called out of function context. - // To alleviate this, we have two functions, one that returns success and one that returns failure - // If the Enano API load is successful, the success function is called to report the action to the user - // If unsuccessful, the failure report is sent - - $template_bak = $template; - - $_GET['title'] = 'Main_Page'; - require('includes/common.php'); - - if ( is_object($db) && is_object($session) ) - { - run_installer_stage('startapi', $lang->get('install_stg_startapi_title'), 'stg_start_api_success', '...', false); - } - else - { - run_installer_stage('startapi', $lang->get('install_stg_startapi_title'), 'stg_start_api_failure', $lang->get('install_stg_startapi_body'), false); - } - - // We need to be logged in (with admin rights) before logs can be flushed - $admin_password = stg_decrypt_admin_pass(true); - $session->login_without_crypto($_POST['admin_user'], $admin_password, false); - - // Now that login cookies are set, initialize the session manager and ACLs - $session->start(); - $paths->init(); - - run_installer_stage('importlang', $lang->get('install_stg_importlang_title'), 'stg_import_language', $lang->get('install_stg_importlang_body')); - run_installer_stage('initlogs', $lang->get('install_stg_initlogs_title'), 'stg_init_logs', $lang->get('install_stg_initlogs_body')); - - run_installer_stage('buildindex', $lang->get('install_stg_buildindex_title'), 'stg_build_index', $lang->get('install_stg_buildindex_body')); - - /* - * HACKERS: - * If you're making a custom distribution of Enano, put all your custom plugin-related code here. - * You have access to the full Enano API as well as being logged in with complete admin rights. - * Don't do anything horrendously fancy here, unless you add a new stage (or more than one) and - * have the progress printed out properly. - */ - - } // check for stage == renameconfig - else - { - // If we did skip the main installer routine, set $template_bak to make the reversal later work properly - $template_bak = $template; - } - - // Final step is to rename the config file - // In early revisions of 1.0.2, this step was performed prior to the initialization of the Enano API. It was decided to move - // this stage to the end because it will fail more often than any other stage, thus making alternate routes imperative. If this - // stage fails, then no big deal, we'll just have the user rename the files manually and then let them see the pretty success message. - run_installer_stage('renameconfig', $lang->get('install_stg_rename_title'), 'stg_rename_config', $lang->get('install_stg_rename_body')); - - close_install_table(); - - unset($template); - $template =& $template_bak; - - echo '

' . $lang->get('install_msg_complete_title') . '

'; - echo '

' . $lang->get('install_msg_complete_body', array('finish_link' => 'install.php?mode=finish')) . '

'; - - // echo ''; - - break; - case "finish": - echo '

' . $lang->get('finish_msg_congratulations') . '

- ' . $lang->get('finish_body') . ' -

' . $lang->get('finish_link_mainpage', array('mainpage_link' => 'index.php')) . '

'; - break; - // this stage is never shown during the installation, but is provided for legal purposes - case "showlicense": - show_license(true); - break; -} -$template->footer(); - -?>