# HG changeset patch # User Dan # Date 1200617354 18000 # Node ID 8978cb3541caa7cc6563304863ee2144e09db64c # Parent fdaf9070566c78d38a6aef41eace6e07cbab9e83 Initlogs stage of installer now working diff -r fdaf9070566c -r 8978cb3541ca includes/common.php --- a/includes/common.php Thu Jan 17 02:03:33 2008 -0500 +++ b/includes/common.php Thu Jan 17 19:49:14 2008 -0500 @@ -282,7 +282,11 @@ table_prefix.'acl', table_prefix.'page_groups', table_prefix.'page_group_members', - table_prefix.'tags' + table_prefix.'tags', + table_prefix.'language', + table_prefix.'language_strings', + table_prefix.'lockout', + table_prefix.'search_index' ); // Load plugin manager diff -r fdaf9070566c -r 8978cb3541ca includes/pageutils.php --- a/includes/pageutils.php Thu Jan 17 02:03:33 2008 -0500 +++ b/includes/pageutils.php Thu Jan 17 19:49:14 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 = '
Notice:
The page you are viewing was archived on ' . $r['date_string'] . '.
View current version | Restore this version

'.RenderMan::render($r['page_text']); + $message = '
Notice:
The page you are viewing was archived on ' . enano_date('d M Y h:i a', intval($r['time_id'])) . '.
View current version | Restore this version

'.RenderMan::render($r['page_text']); if( !$paths->pages[$page]['special'] ) { @@ -618,7 +618,7 @@ if($ticker < $numrows) echo ''."\n"; else echo ''; // Date and time - echo '' . $r['date_string'] . ''."\n"; + echo '' . enano_date('d M Y h:i a', intval($r['time_id'])) . ''."\n"; // User if ( $session->get_permissions('mod_misc') && is_valid_ip($r['author']) ) @@ -694,7 +694,7 @@ echo ''; // Date and time - echo '' . $r['date_string'] . ''; + echo '' . enano_date('d M Y h:i a', intval($r['time_id'])) . ''; // User echo 'pages[$paths->nslist[$rb['namespace']].$rb['page_id']]['name'].'" has been rolled back to the state it was in on ' . $rb['date_string'] . '.'; + return 'The page "' . $paths->pages[$paths->nslist[$rb['namespace']].$rb['page_id']]['name'].'" has been rolled back to the state it was in on ' . enano_date('d M Y h:i a', intval($rb['time_id'])) . '.'; } break; case "rename": @@ -825,7 +825,7 @@ } else { - return 'The page "' . $paths->pages[$paths->nslist[$rb['namespace']].$rb['page_id']]['name'].'" has been rolled back to the name it had ("' . $rb['edit_summary'] . '") before ' . $rb['date_string'] . '.'; + return 'The page "' . $paths->pages[$paths->nslist[$rb['namespace']].$rb['page_id']]['name'].'" has been rolled back to the name it had ("' . $rb['edit_summary'] . '") before ' . enano_date('d M Y h:i a', intval($rb['time_id'])) . '.'; } break; case "prot": @@ -835,7 +835,7 @@ if ( !$e ) return "An error occurred during the rollback operation.\nMySQL said: ".$db->get_error()."\n\nSQL backtrace:\n".$db->sql_backtrace(); else - return 'The page "' . $paths->pages[$paths->nslist[$rb['namespace']].$rb['page_id']]['name'].'" has been unprotected according to the log created at ' . $rb['date_string'] . '.'; + return 'The page "' . $paths->pages[$paths->nslist[$rb['namespace']].$rb['page_id']]['name'].'" has been unprotected according to the log created at ' . enano_date('d M Y h:i a', intval($rb['time_id'])) . '.'; break; case "semiprot": if ( !$perms->get_permissions('protect') ) @@ -844,7 +844,7 @@ if ( !$e ) return "An error occurred during the rollback operation.\nMySQL said: ".$db->get_error()."\n\nSQL backtrace:\n".$db->sql_backtrace(); else - return 'The page "' . $paths->pages[$paths->nslist[$rb['namespace']].$rb['page_id']]['name'].'" has been unprotected according to the log created at ' . $rb['date_string'] . '.'; + return 'The page "' . $paths->pages[$paths->nslist[$rb['namespace']].$rb['page_id']]['name'].'" has been unprotected according to the log created at ' . enano_date('d M Y h:i a', intval($rb['time_id'])) . '.'; break; case "unprot": if ( !$perms->get_permissions('protect') ) @@ -853,7 +853,7 @@ if ( !$e ) return "An error occurred during the rollback operation.\nMySQL said: ".$db->get_error()."\n\nSQL backtrace:\n".$db->sql_backtrace(); else - return 'The page "' . $paths->pages[$paths->nslist[$rb['namespace']].$rb['page_id']]['name'].'" has been protected according to the log created at ' . $rb['date_string'] . '.'; + return 'The page "' . $paths->pages[$paths->nslist[$rb['namespace']].$rb['page_id']]['name'].'" has been protected according to the log created at ' . enano_date('d M Y h:i a', intval($rb['time_id'])) . '.'; break; case "delete": if ( !$perms->get_permissions('history_rollback_extra') ) @@ -865,7 +865,7 @@ $e = $db->sql_query('SELECT page_text,char_tag FROM ' . table_prefix.'logs WHERE page_id=\'' . $rb['page_id'] . '\' AND namespace=\'' . $rb['namespace'] . '\' AND log_type=\'page\' AND action=\'edit\' ORDER BY time_id DESC;'); if(!$e) return("An error occurred during the rollback operation.\nMySQL said: ".$db->get_error()."\n\nSQL backtrace:\n".$db->sql_backtrace()); $r = $db->fetchrow(); $e = $db->sql_query('INSERT INTO ' . table_prefix.'page_text(page_id,namespace,page_text,char_tag) VALUES(\'' . $rb['page_id'] . '\',\'' . $rb['namespace'] . '\',\'' . $db->escape($r['page_text']) . '\',\'' . $r['char_tag'] . '\')'); if(!$e) return("An error occurred during the rollback operation.\nMySQL said: ".$db->get_error()."\n\nSQL backtrace:\n".$db->sql_backtrace()); - return 'The page "' . $name . '" has been undeleted according to the log created at ' . $rb['date_string'] . '.'; + return 'The page "' . $name . '" has been undeleted according to the log created at ' . enano_date('d M Y h:i a', intval($rb['time_id'])) . '.'; break; case "reupload": if ( !$session->get_permissions('history_rollback_extra') ) @@ -1453,7 +1453,7 @@ // This is a special exception for the Enano installer, which doesn't init languages yet. $lang = new Language('eng'); } - if(!$session->get_permissions('clear_logs')) + if(!$session->get_permissions('clear_logs') && !defined('IN_ENANO_INSTALL')) { return $lang->get('etc_access_denied'); } diff -r fdaf9070566c -r 8978cb3541ca includes/paths.php --- a/includes/paths.php Thu Jan 17 02:03:33 2008 -0500 +++ b/includes/paths.php Thu Jan 17 19:49:14 2008 -0500 @@ -145,7 +145,7 @@ } $db->free_result(); - if ( defined('ENANO_INTERFACE_INDEX') || defined('ENANO_INTERFACE_AJAX') || defined('IN_ENANO_INSTALL') || defined('IN_ENANO_UPGRADE') ) + if ( defined('ENANO_INTERFACE_INDEX') || defined('ENANO_INTERFACE_AJAX') || defined('IN_ENANO_UPGRADE') ) { if( isset($_GET['title']) ) { diff -r fdaf9070566c -r 8978cb3541ca install/includes/payload.php --- a/install/includes/payload.php Thu Jan 17 02:03:33 2008 -0500 +++ b/install/includes/payload.php Thu Jan 17 19:49:14 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 '
Error: could not locate wikitext for main page (' . $wkt . ')
'; + return false; + } + $wkt = @file_get_contents($wkt); + if ( empty($wkt) ) + return false; + + $wkt = $db->escape($wkt); + $vars = array( 'TABLE_PREFIX' => $_POST['table_prefix'], 'SITE_NAME' => $db->escape($_POST['site_name']), @@ -128,7 +140,8 @@ 'ADMIN_EMAIL' => $db->escape($_POST['email']), 'REAL_NAME' => '', // This has always been stubbed. 'ADMIN_EMBED_PHP' => strval(AUTH_DISALLOW), - 'UNIX_TIME' => strval(time()) + 'UNIX_TIME' => strval(time()), + 'MAIN_PAGE_CONTENT' => $wkt ); $sql_parser->assign_vars($vars); @@ -279,7 +292,7 @@ RewriteCond %{REQUEST_FILENAME} !-d # Main rule - short and sweet -RewriteRule (.*) index.php?title=\$1 +RewriteRule (.*) index.php?title=\$1 [L,QSA] EOF; fwrite($hh, $hhc); @@ -310,3 +323,19 @@ return true; } + +function stg_init_logs() +{ + global $db, $session, $paths, $template, $plugins; // Common objects + global $installer_version; + + $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') . '\', \'' . $db->escape($_POST['admin_user']) . '\', \'' . $db->escape(enano_version()) . '\', \'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\');'); + if ( !$q ) + { + echo '

MySQL return: ' . $db->sql_error() . '

'; + return false; + } + + return true; +} + diff -r fdaf9070566c -r 8978cb3541ca install/includes/stages/install.php --- a/install/includes/stages/install.php Thu Jan 17 02:03:33 2008 -0500 +++ b/install/includes/stages/install.php Thu Jan 17 19:49:14 2008 -0500 @@ -107,6 +107,9 @@ // 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(); $db->close(); diff -r fdaf9070566c -r 8978cb3541ca install/schemas/mysql_stage2.sql --- a/install/schemas/mysql_stage2.sql Thu Jan 17 02:03:33 2008 -0500 +++ b/install/schemas/mysql_stage2.sql Thu Jan 17 19:49:14 2008 -0500 @@ -306,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, '');