From 4555c4bf6af6283ce16147e079c722186fa39f00 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Mon, 28 Mar 2011 16:24:33 +1100 Subject: [PATCH] more error handling (specifically SQL errors) in install.php --- install.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/install.php b/install.php index de318c3a..7d90b523 100644 --- a/install.php +++ b/install.php @@ -310,8 +310,10 @@ preg_match_all("/((SET|CREATE|INSERT).+)\n\n/msU", $sql, $queries); $queries = $queries[1]; + $sql_errors = ''; foreach($queries as &$query) { - query($query) or error(db_error()); + if(!query($query)) + $sql_errors .= '
  • ' . db_error() . '
  • '; } $boards = listBoards(); @@ -322,13 +324,26 @@ 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.

    '; + 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'] = '

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

    '; + $page['body'] .= '

    Delete install.php!

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

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