$config, 'title' => 'Install', 'body' => '' ); if(file_exists($config['has_installed'])) { $page['title'] = 'Pre-installation test'; $page['body'] = '

It appears that Tinyboard is already installed! Delete ' . $config['has_installed'] . ' to reinstall.

'; die(Element('page.html', $page)); } if($step == 0) { // Agreeement $page['body'] = '

I have read and understood the agreement. Proceed to installation.

'; echo Element('page.html', $page); } elseif($step == 1) { $page['title'] = 'Pre-installation test'; $page['body'] = ''; function rheader($item) { global $page, $config; $page['body'] .= ''; } function row($item, $result) { global $page, $config; $page['body'] .= ''; } // Required extensions rheader('PHP extensions'); row('PDO', extension_loaded('pdo')); row('GD', extension_loaded('gd')); // GD tests rheader('GD tests'); row('JPEG', function_exists('imagecreatefromjpeg')); row('PNG', function_exists('imagecreatefrompng')); row('GIF', function_exists('imagecreatefromgif')); row('BMP', function_exists('imagecreatefrombmp')); // Database drivers $drivers = PDO::getAvailableDrivers(); rheader('PDO drivers (currently installed drivers)'); foreach($drivers as &$driver) { row($driver, true); } // Permissions rheader('File permissions'); row('root directory (' . getcwd() . ')', is_writable('.')); $page['body'] .= '
' . $item . '
' . $item . '

Continue.

'; echo Element('page.html', $page); } elseif($step == 2) { // Basic config $page['title'] = 'Configuration'; function create_salt() { return substr(base64_encode(sha1(rand())), 0, rand(25, 31)); } $page['body'] = '
Database
Cookies
Flood control
Images
Display
Directories
Miscellaneous

'; 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 buildJavascript(); 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]; $sql_errors = ''; foreach($queries as &$query) { if(!query($query)) $sql_errors .= '
  • ' . db_error() . '
  • '; } $boards = listBoards(); foreach($boards as &$_board) { setupBoard($_board); buildIndex(); } sql_close(); $page['title'] = 'Installation complete'; $page['body'] = '

    Thank you for using Tinyboard. Please remember to report any bugs you discover.

    '; if(!empty($sql_errors)) { $page['body'] .= '

    SQL errors

    SQL errors were encountered when trying to install the database. This may be the result of using a database which is already occupied with a Tinyboard installation; if so, you can probably ignore this.

    The errors encountered were:

    Ignore errors and complete installation.

    '; } else { touch($config['has_installed'], 0777); if(!@unlink(__FILE__)) { $page['body'] .= '

    Delete install.php!

    I couldn\'t remove install.php. You will have to remove it manually.

    '; } } echo Element('page.html', $page); } elseif($step == 5) { $page['title'] = 'Installation complete'; $page['body'] = '

    Thank you for using Tinyboard. Please remember to report any bugs you discover.

    '; touch($config['has_installed'], 0777); if(!@unlink(__FILE__)) { $page['body'] .= '

    Delete install.php!

    I couldn\'t remove install.php. You will have to remove it manually.

    '; } echo Element('page.html', $page); } ?>