diff --git a/install.php b/install.php index 052f7db4..b6b66c47 100644 --- a/install.php +++ b/install.php @@ -1,10 +1,6 @@ ' . $driver_txt . ''; + $page['body'] .= ''; } $page['body'] .= ' + + + @@ -240,5 +239,86 @@ echo Element('page.html', $page); + } elseif($step == 3) { + $instance_config = +' $value) { + if(is_array($value)) { + $instance_config .= "\n"; + create_config_from_array($instance_config, $value, $prefix . '[\'' . addslashes($name) . '\']'); + $instance_config .= "\n"; + } else { + $instance_config .= ' $config' . $prefix . '[\'' . addslashes($name) . '\'] = '; + + if(is_numeric($value)) + $instance_config .= $value; + else + $instance_config .= "'" . addslashes($value) . "'"; + + $instance_config .= ";\n"; + } + } + } + + create_config_from_array($instance_config, $_POST); + + $instance_config .= '?>'; + + if(@file_put_contents('inc/instance-config.php', $instance_config)) { + header('Location: ?step=4', true, $config['redirect_http']); + } else { + $page['title'] = 'Manual installation required'; + $page['body'] = ' +
I couldn\'t write to inc/instance-config.php with the new configuration, probably due to a permissions error.
+Please complete the installation manually by copying and pasting the following code into the contents of inc/instance-config.php:
+ ++ Once complete, click here to complete installation. +
+ '; + echo Element('page.html', $page); + } + } elseif($step == 4) { + // SQL installation + + sql_open(); + + $sql = @file_get_contents('install.sql') or error("Couldn't load install.sql."); + + // This code is probably horrible, but what I'm trying + // to do is find all of the SQL queires and put them + // in an array. + preg_match_all("/((SET|CREATE|INSERT).+)\n\n/msU", $sql, $queries); + $queries = $queries[1]; + + foreach($queries as &$query) { + query($query) or error(db_error()); + } + + $boards = listBoards(); + foreach($boards as &$_board) { + setupBoard($_board); + buildIndex(); + } + + sql_close(); + + touch($config['has_installed'], 0777); + + $page['title'] = 'Installation complete'; + $page['body'] = 'Thank you for using Tinyboard. Please remember to report any bugs you discover.
'; + echo Element('page.html', $page); } ?> \ No newline at end of file