Got the installer working. Fixed a few bugs including a nasty-to-debug issue where the lang_id was being hardcoded during installation, resulting in strings being inserted with the wrong lang_id causing an infinfinite loop with fetch() throwing a "no strings" error and using template (which calls fetch()) to complain
--- a/includes/dbal.php Wed Jul 09 18:38:44 2008 -0400
+++ b/includes/dbal.php Wed Jul 09 20:53:47 2008 -0400
@@ -271,7 +271,7 @@
}
}
- $r = mysql_query($q, $this->_conn);
+ $r = pg_query($q, $this->_conn);
if ( $log_query )
$this->query_times[$q] = microtime_float() - $time_start;
@@ -326,7 +326,7 @@
$q = str_replace(array("\\\"", "\\'"), '', $q);
// make sure quotes match
- foreach ( array('"', "'") as $quote )
+ foreach ( array("'", '"') as $quote )
{
if ( get_char_count($q, $quote) % 2 == 1 )
{
@@ -1003,29 +1003,7 @@
function sql_unbuffered_query($q)
{
- $this->enable_errorhandler();
-
- $this->num_queries++;
- $this->query_backtrace[] = '(UNBUFFERED) ' . $q;
- $this->latest_query = $q;
- // First make sure we have a connection
- if ( !$this->_conn )
- {
- $this->_die('A database connection has not yet been established.');
- }
- // Does this query look malicious?
- if ( !$this->check_query($q) )
- {
- $this->report_query($q);
- grinding_halt('SQL Injection attempt', '<p>Enano has caught and prevented an SQL injection attempt. Your IP address has been recorded and the administrator has been notified.</p><p>Query was:</p><pre>'.htmlspecialchars($q).'</pre>');
- }
-
- $time_start = microtime_float();
- $r = pg_query($q);
- $this->query_times[$q] = microtime_float() - $time_start;
- $this->latest_result = $r;
- $this->disable_errorhandler();
- return $r;
+ return $this->sql_query($q);
}
/**
@@ -1043,7 +1021,7 @@
$q = str_replace(array("\\\"", "\\'"), '', $q);
// make sure quotes match
- foreach ( array('"', "'") as $quote )
+ foreach ( array("'", '"') as $quote )
{
if ( get_char_count($q, $quote) % 2 == 1 )
{
--- a/includes/lang.php Wed Jul 09 18:38:44 2008 -0400
+++ b/includes/lang.php Wed Jul 09 20:53:47 2008 -0400
@@ -76,9 +76,11 @@
{
global $db, $session, $paths, $template, $plugins; // Common objects
- if ( defined('IN_ENANO_INSTALL') )
+ if ( defined('IN_ENANO_INSTALL') && !defined('ENANO_CONFIG_FETCHED') )
{
- // special case for the Enano installer: it will load its own strings from a JSON file and just use this API for fetching and templatizing them.
+ // special case for the Enano installer: it will load its own strings from a JSON file and just use this API for fetching
+ // and templatizing them.
+ // 1.1.4 fix: this was still being called after main API startup from installer payload
$this->lang_id = 1;
$this->lang_code = $lang;
return true;
@@ -96,7 +98,7 @@
$db->_die('lang.php - attempting to pass invalid value to constructor');
}
- $lang_default = ( $x = getConfig('default_language') ) ? intval($x) : '\'def\'';
+ $lang_default = ( $x = getConfig('default_language') ) ? intval($x) : '0';
$q = $db->sql_query("SELECT lang_id, lang_code, last_changed, ( lang_id = $lang_default ) AS is_default FROM " . table_prefix . "language WHERE $sql_col OR lang_id = $lang_default ORDER BY is_default ASC LIMIT 1;");
@@ -606,6 +608,8 @@
function get_uncensored($string_id, $substitutions = false)
{
+ global $db, $session, $paths, $template, $plugins; // Common objects
+
// Extract the category and string ID
$category = substr($string_id, 0, ( strpos($string_id, '_') ));
$string_name = substr($string_id, ( strpos($string_id, '_') + 1 ));
@@ -619,7 +623,7 @@
{
// Ehh, the string wasn't found. Rerun fetch() and try again.
// Or if it's the installer, no use in refetching, so just fail.
- if ( defined('IN_ENANO_INSTALL') )
+ if ( defined('IN_ENANO_INSTALL') || ( defined('ENANO_INSTALLED') && !@$db->_conn ) )
{
return $string_id;
}
--- a/includes/paths.php Wed Jul 09 18:38:44 2008 -0400
+++ b/includes/paths.php Wed Jul 09 20:53:47 2008 -0400
@@ -801,6 +801,7 @@
function rebuild_search_index($verbose = false, $debug = false)
{
global $db, $session, $paths, $template, $plugins; // Common objects
+ require_once(ENANO_ROOT . '/includes/search.php');
@set_time_limit(0);
--- a/install/includes/payload.php Wed Jul 09 18:38:44 2008 -0400
+++ b/install/includes/payload.php Wed Jul 09 20:53:47 2008 -0400
@@ -48,7 +48,7 @@
if ( $db->numrows() < 1 )
return false;
list($aes_key) = $db->fetchrow_num();
- $aes_key = $aes->hextostring($aes_key);
+ $aes_key = hexdecode($aes_key);
$pass = $aes->decrypt($_POST['crypt_data'], $aes_key, ENC_HEX);
if ( !$pass )
@@ -98,7 +98,7 @@
$aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE);
$site_key = stg_make_private_key();
- $site_key = $aes->hextostring($site_key);
+ $site_key = hexdecode($site_key);
$admin_pass_clean = stg_password_decode();
$admin_pass = $aes->encrypt($admin_pass_clean, $site_key, ENC_HEX);
@@ -318,6 +318,7 @@
return false;
$lang_local = new Language($lang_id);
+
$lang_local->import( ENANO_ROOT . "/language/{$lang_info['dir']}/user.json" );
$lang_local->import( ENANO_ROOT . "/language/{$lang_info['dir']}/tools.json" );
$lang_local->import( ENANO_ROOT . "/language/{$lang_info['dir']}/admin.json" );
--- a/install/includes/stages/install.php Wed Jul 09 18:38:44 2008 -0400
+++ b/install/includes/stages/install.php Wed Jul 09 20:53:47 2008 -0400
@@ -105,6 +105,7 @@
}
// Import languages
+error_reporting(E_ALL | E_STRICT);
run_installer_stage('importlang', $lang->get('install_stg_importlang_title'), 'stg_language_setup', $lang->get('install_stg_importlang_body'));
// Init logs