# HG changeset patch # User Dan # Date 1200630695 18000 # Node ID 2398420f48e7a186eda84fa546ac7b91cabccb1c # Parent dd7cbc97f681e1f7646d6a0acf0eab60fd55cadd# Parent 9d7225c0db6d964b38b00c41e62135ec4397eb43 Dropping changes from revision 350 (dd7cbc97f681) diff -r dd7cbc97f681 -r 2398420f48e7 includes/common.php --- a/includes/common.php Thu Jan 17 09:39:56 2008 -0500 +++ b/includes/common.php Thu Jan 17 23:31:35 2008 -0500 @@ -259,35 +259,6 @@ setConfig('default_language', $row['lang_id']); } -// Our list of tables included in Enano -$system_table_list = Array( - table_prefix.'categories', - table_prefix.'comments', - table_prefix.'config', - table_prefix.'logs', - table_prefix.'page_text', - table_prefix.'session_keys', - table_prefix.'pages', - table_prefix.'users', - table_prefix.'users_extra', - table_prefix.'themes', - table_prefix.'buddies', - table_prefix.'banlist', - table_prefix.'files', - table_prefix.'privmsgs', - table_prefix.'sidebar', - table_prefix.'hits', - table_prefix.'groups', - table_prefix.'group_members', - table_prefix.'acl', - table_prefix.'page_groups', - table_prefix.'page_group_members', - table_prefix.'tags', - table_prefix.'language', - table_prefix.'language_strings', - table_prefix.'lockout' - ); - // Load plugin manager $plugins = new pluginLoader(); diff -r dd7cbc97f681 -r 2398420f48e7 includes/constants.php --- a/includes/constants.php Thu Jan 17 09:39:56 2008 -0500 +++ b/includes/constants.php Thu Jan 17 23:31:35 2008 -0500 @@ -141,6 +141,44 @@ // significantly increase encryption strength either. define('AES_BLOCKSIZE', 128); +// Our list of tables included in Enano +$system_table_list = Array( + 'categories', + 'comments', + 'config', + 'logs', + 'page_text', + 'session_keys', + 'pages', + 'users', + 'users_extra', + 'themes', + 'buddies', + 'banlist', + 'files', + 'privmsgs', + 'sidebar', + 'hits', + 'groups', + 'group_members', + 'acl', + 'page_groups', + 'page_group_members', + 'tags', + 'language', + 'language_strings', + 'lockout', + 'search_index' + ); + +if ( defined('table_prefix') ) +{ + foreach ( $system_table_list as $i => $_ ) + { + $system_table_list[$i] = table_prefix . $system_table_list[$i]; + } +} + /* * MIMETYPES * diff -r dd7cbc97f681 -r 2398420f48e7 includes/dbal.php --- a/includes/dbal.php Thu Jan 17 09:39:56 2008 -0500 +++ b/includes/dbal.php Thu Jan 17 23:31:35 2008 -0500 @@ -199,7 +199,11 @@ $q = $this->sql_query('USE `'.$dbname.'`;'); if ( !$q ) + { + if ( $manual_credentials ) + return false; $this->_die('The database could not be selected.'); + } // We're in! $this->disable_errorhandler(); diff -r dd7cbc97f681 -r 2398420f48e7 includes/pageutils.php --- a/includes/pageutils.php Thu Jan 17 09:39:56 2008 -0500 +++ b/includes/pageutils.php Thu Jan 17 23:31:35 2008 -0500 @@ -211,7 +211,7 @@ if ($db->numrows() > 0 ) { $r = $db->fetchrow(); - echo '
This page also appears to have some log entries in the database - it seems that it was deleted on ' . $r['date_string'] . '. You can probably roll back the deletion.
'; + echo 'This page also appears to have some log entries in the database - it seems that it was deleted on ' . enano_date('d M Y h:i a', intval($r['time_id'])) . '. You can probably roll back the deletion.
'; } $db->free_result(); } @@ -258,7 +258,7 @@ } $r = $db->fetchrow(); $db->free_result(); - $message = '$e"; + return false; + } + + $vars = array( + 'TABLE_PREFIX' => $_POST['table_prefix'], + 'SITE_NAME' => $db->escape($_POST['site_name']), + 'SITE_DESC' => $db->escape($_POST['site_desc']), + 'COPYRIGHT' => $db->escape($_POST['copyright']), + // FIXME: update form + 'WIKI_MODE' => ( isset($_POST['wiki_mode']) ? '1' : '0' ), + 'ENABLE_CACHE' => ( is_writable( ENANO_ROOT . '/cache/' ) ? '1' : '0' ), + 'VERSION' => $installer_version['version'], + 'ADMIN_USER' => $db->escape($_POST['username']), + 'ADMIN_PASS' => $admin_pass, + 'ADMIN_EMAIL' => $db->escape($_POST['email']), + 'REAL_NAME' => '', // This has always been stubbed. + 'ADMIN_EMBED_PHP' => strval(AUTH_DISALLOW), + 'UNIX_TIME' => strval(time()) + ); + + $sql_parser->assign_vars($vars); + return $sql_parser->parse(); +} + +function stg_deliver_payload() +{ + global $db; + $schema = stg_load_schema(); + foreach ( $schema as $sql ) + { + if ( !$db->sql_query($sql) ) + { + echo $db->get_error(); + return false; + } + } + return true; +} + +function stg_write_config() +{ + global $dbhost, $dbuser, $dbpasswd, $dbname, $dbdriver; + $db_data = array( + 'host' => str_replace("'", "\\'", $dbhost), + 'user' => str_replace("'", "\\'", $dbuser), + 'pass' => str_replace("'", "\\'", $dbpasswd), + 'name' => str_replace("'", "\\'", $dbname), + 'tp' => table_prefix, + 'drv' => $dbdriver + ); + + // Retrieves the existing key + $site_key = stg_make_private_key(); + + // Determine contentPath + switch ( @$_POST['url_scheme'] ) + { + case 'standard': + default: + $sp_append = 'index.php?title='; + break; + case 'shortened': + $sp_append = 'index.php/'; + break; + case 'rewrite': + $sp_append = '/'; + break; + } + + $scriptpath = scriptPath; + $contentpath = $scriptpath . $sp_append; + + $config_file = <<
' . $failure_explanation . '
'; + else + echo ''; global $ui; $ui->show_footer(); exit; diff -r dd7cbc97f681 -r 2398420f48e7 install/includes/payload.php --- a/install/includes/payload.php Thu Jan 17 09:39:56 2008 -0500 +++ b/install/includes/payload.php Thu Jan 17 23:31:35 2008 -0500 @@ -89,7 +89,7 @@ function stg_load_schema() { - global $db, $dbdriver, $installer_version; + global $db, $dbdriver, $installer_version, $lang_id, $languages; static $sql_parser = false; if ( is_object($sql_parser) ) @@ -114,6 +114,18 @@ return false; } + $wkt = ENANO_ROOT . "/language/{$languages[$lang_id]['dir']}/install/mainpage-default.wkt"; + if ( !file_exists( $wkt ) ) + { + echo 'MySQL return: ' . $db->sql_error() . '
'; + return false; + } + + return true; +} + +function stg_aes_cleanup() +{ + global $db, $session, $paths, $template, $plugins; // Common objects + $q = $db->sql_query('DELETE FROM ' . table_prefix . 'config WHERE config_name = \'install_aes_key\' OR config_name = \'site_aes_key\';'); + if ( !$q ) + $db->_die(); + 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(ENANO_ROOT . '/config.new.php', ENANO_ROOT . '/config.php') ) + { + echo 'Can\'t rename config.php
'; + _stg_rename_config_revert(); + return false; + } + + if ( filesize(ENANO_ROOT . '/.htaccess.new') > 1 ) + { + // rename/possibly concatenate .htaccess.new + $htaccess_base = ''; + if ( file_exists(ENANO_ROOT . '/.htaccess') ) + $htaccess_base .= @file_get_contents(ENANO_ROOT . '/.htaccess'); + if ( strlen($htaccess_base) > 0 && !preg_match("/\n$/", $htaccess_base) ) + $htaccess_base .= "\n\n"; + $htaccess_base .= @file_get_contents(ENANO_ROOT . '/.htaccess.new'); + if ( file_exists(ENANO_ROOT . '/.htaccess') ) + { + $hh = @fopen(ENANO_ROOT . '/.htaccess', 'w'); + if ( !$hh ) + return false; + fwrite($hh, $htaccess_base); + fclose($hh); + @unlink(ENANO_ROOT . '/.htaccess.new'); + return true; + } + else + { + return @rename(ENANO_ROOT . '/.htaccess.new', ENANO_ROOT . '/.htaccess'); + } + } + else + { + @unlink(ENANO_ROOT . '/.htaccess.new'); + } + return true; +} + diff -r dd7cbc97f681 -r 2398420f48e7 install/includes/stages/database_post.php --- a/install/includes/stages/database_post.php Thu Jan 17 09:39:56 2008 -0500 +++ b/install/includes/stages/database_post.php Thu Jan 17 23:31:35 2008 -0500 @@ -26,14 +26,68 @@ $db_pass =& $_POST['db_pass']; $db_name =& $_POST['db_name']; $db_prefix =& $_POST['table_prefix']; +$db_root_user =& $_POST['db_root_user']; +$db_root_pass =& $_POST['db_root_pass']; + +if ( !preg_match('/^[a-z0-9_]*$/', $db_prefix) ) +{ + $ui->show_header(); + echo 'That table prefix isn\'t going to work.
'; + return true; +} $result = $dbal->connect(true, $db_host, $db_user, $db_pass, $db_name); +// If connection failed, we have the root login, AND we're on MySQL, try to force our way in +if ( !$result && !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) && $driver == 'mysql' ) +{ + // Allow a jump / breakout + switch ( 'foo' ) { case 'foo': + + // Try to connect to the DB as root + $result_root = $dbal->connect(true, $db_host, $db_root_user, $db_root_pass, 'mysql'); + if ( !$result_root ) + break; + + $q = $dbal->sql_query('CREATE DATABASE IF NOT EXISTS `' . $dbal->escape($db_name) . '`;'); + if ( !$q ) + break; + + if ( $db_host == 'localhost' || $db_host == '127.0.0.1' ) + { + $q = $dbal->sql_query('GRANT ALL PRIVILEGES ON `' . $dbal->escape($db_name) . '`.* TO \'' . $dbal->escape($db_user) . '\'@\'localhost\'' . "\n" . + ' IDENTIFIED BY \'' . $dbal->escape($db_pass) . '\' WITH GRANT OPTION'); + } + else + { + $q = $dbal->sql_query('GRANT ALL PRIVILEGES ON `' . $dbal->escape($db_name) . '`.* TO \'' . $dbal->escape($db_user) . '\'@\'%\'' . "\n" . + ' IDENTIFIED BY \'' . $dbal->escape($db_pass) . '\' WITH GRANT OPTION'); + } + + if ( !$q ) + break; + + $dbal->close(); + $result = $dbal->connect(true, $db_host, $db_user, $db_pass, $db_name); + + break; + } +} + $ui->show_header(); if ( $result ) { - // We're good, write out a config file + // We're good, do table drop if requested + if ( isset($_POST['drop_tables']) ) + { + global $system_table_list; + foreach ( $system_table_list as $table ) + { + $dbal->sql_query("DROP TABLE {$db_prefix}$table"); + } + } + // Write out a config file $ch = @fopen( ENANO_ROOT . '/config.new.php', 'w' ); if ( !$ch ) { diff -r dd7cbc97f681 -r 2398420f48e7 install/includes/stages/finish.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/includes/stages/finish.php Thu Jan 17 23:31:35 2008 -0500 @@ -0,0 +1,76 @@ +show_header(); + echo 'ERROR: That database driver is not supported.
'; + return true; +} + +$db = new $dbdriver(); +$db->connect(); + +$ui->show_header(); +flush(); + +?> +Enano is cleaning up and performing some final installation tasks. Please wait...
+ +get('install_stg_buildindex_title'), 'stg_build_index', $lang->get('install_stg_buildindex_body')); +run_installer_stage('renameconfig', $lang->get('install_stg_rename_title'), 'stg_rename_config', $lang->get('install_stg_rename_body', array('mainpage_link' => scriptPath . '/index.php'))); + +close_install_table(); + +?> +Enano has finished setting up on your server. Now you can go to your new + website and start creating content!
+get('finish_body'); + echo '' . $lang->get('finish_link_mainpage', array('mainpage_link' => scriptPath . '/index.php')) . '
'; +?> +close(); + diff -r dd7cbc97f681 -r 2398420f48e7 install/includes/stages/install.php --- a/install/includes/stages/install.php Thu Jan 17 09:39:56 2008 -0500 +++ b/install/includes/stages/install.php Thu Jan 17 23:31:35 2008 -0500 @@ -107,7 +107,19 @@ // Import languages run_installer_stage('importlang', $lang->get('install_stg_importlang_title'), 'stg_language_setup', $lang->get('install_stg_importlang_body')); +// Init logs +run_installer_stage('initlogs', $lang->get('install_stg_initlogs_title'), 'stg_init_logs', $lang->get('install_stg_initlogs_body')); + close_install_table(); +?> + +close(); diff -r dd7cbc97f681 -r 2398420f48e7 install/install.php --- a/install/install.php Thu Jan 17 09:39:56 2008 -0500 +++ b/install/install.php Thu Jan 17 23:31:35 2008 -0500 @@ -19,6 +19,7 @@ define('ENANO_DANGEROUS', 1); require_once('includes/common.php'); +@ini_set('display_errors', 'on'); $stages = array('language', 'license', 'sysreqs', 'database', 'website', 'login', 'confirm', 'install', 'finish'); $stage_ids = array(); @@ -268,6 +269,9 @@ case 'install': require( ENANO_ROOT . '/install/includes/stages/install.php' ); break; + case 'finish': + require( ENANO_ROOT . '/install/includes/stages/finish.php' ); + break; } $ui->show_footer(); diff -r dd7cbc97f681 -r 2398420f48e7 install/schemas/mysql_stage2.sql --- a/install/schemas/mysql_stage2.sql Thu Jan 17 09:39:56 2008 -0500 +++ b/install/schemas/mysql_stage2.sql Thu Jan 17 23:31:35 2008 -0500 @@ -181,6 +181,12 @@ PRIMARY KEY ( hit_id ) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +CREATE TABLE {{TABLE_PREFIX}}search_index( + word varchar(64) NOT NULL, + page_names text, + PRIMARY KEY ( word ) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + CREATE TABLE {{TABLE_PREFIX}}groups( group_id mediumint(5) UNSIGNED NOT NULL auto_increment, group_name varchar(64), @@ -300,7 +306,10 @@ ('powered_btn', '1'); INSERT INTO {{TABLE_PREFIX}}page_text(page_id, namespace, page_text, char_tag) VALUES - ('Main_Page', 'Article', '=== Enano has been successfully installed and is working. ===\n\nIf you can see this message, it means that you\'ve finished the Enano setup process and are ready to start building your website. Congratulations!\n\nTo edit this front page, click the Log In button to the left, enter the credentials you provided during the installation, and click the Edit This Page button that appears on the blue toolbar just above this text. You can also [http://docs.enanocms.org/Help:2.4 learn more] about editing pages.\n\nTo create more pages, use the Create a Page button to the left. If you enabled wiki mode, you don\'t have to log in first, however your IP address will be shown in the page history.\n\nVisit the [http://docs.enanocms.org/Help:Contents Enano documentation project website] to learn more about administering your site effectively and keeping things secure.\n\n\'\'\'NOTE:\'\'\' You have just installed an unstable version of Enano. This release is completely unsupported and may contain security issues or serious usability bugs. You should not use this release on a production website. The Enano team will not provide any type of support at all for this experimental release.', ''); + ('Main_Page', 'Article', '{{MAIN_PAGE_CONTENT}}', ''); + +INSERT INTO {{TABLE_PREFIX}}logs(time_id, date_string, log_type, action, page_id, namespace, author, page_text) VALUES + ({{UNIX_TIME}}, 'DEPRECATED', 'page', 'edit', 'Main_Page', 'Article', '{{ADMIN_USER}}', '{{MAIN_PAGE_CONTENT}}'); INSERT INTO {{TABLE_PREFIX}}pages(page_order, name, urlname, namespace, special, visible, comments_on, protected, delvotes, delvote_ips) VALUES (NULL, 'Main Page', 'Main_Page', 'Article', 0, 1, 1, 1, 0, ''); diff -r dd7cbc97f681 -r 2398420f48e7 install/schemas/postgresql_stage2.sql --- a/install/schemas/postgresql_stage2.sql Thu Jan 17 09:39:56 2008 -0500 +++ b/install/schemas/postgresql_stage2.sql Thu Jan 17 23:31:35 2008 -0500 @@ -177,6 +177,12 @@ PRIMARY KEY ( hit_id ) ); +CREATE TABLE {{TABLE_PREFIX}}search_index( + word varchar(64) NOT NULL, + page_names text, + PRIMARY KEY ( word ) +); + CREATE TABLE {{TABLE_PREFIX}}groups( group_id SERIAL, group_name varchar(64), diff -r dd7cbc97f681 -r 2398420f48e7 language/english/install.json --- a/language/english/install.json Thu Jan 17 09:39:56 2008 -0500 +++ b/language/english/install.json Thu Jan 17 23:31:35 2008 -0500 @@ -273,7 +273,13 @@ stg_writeconfig_title: 'Write configuration files', stg_writeconfig_body: 'Enano was unable to write the configuration file with your site\'s database credentials. This is almost always because your configuration file does not have the correct permissions. On Windows servers, you may see this message even if the check on the System Requirements page passed. Temporarily running IIS as the Administrator user may help.', stg_rename_title: 'Rename configuration files', - stg_rename_body: 'Enano couldn\'t rename the configuration files to their correct production names. Please CHMOD the folder where your Enano files are to 777 and click the retry button below, or perform the following rename operations and then finish the installation.You have finished installing Enano on this server.
-Click the link below to see the main page for your website. Where to go from here: