Example #1
0
                        if ($database->getErrorNum()) {
                            $errors[$database->getQuery()] = $database->getErrorMsg();
                        }
                    }
                }
                $database->setQuery("DROP TABLE IF EXISTS `{$table}`");
                $database->query();
                if ($database->getErrorNum()) {
                    $errors[$database->getQuery()] = $database->getErrorMsg();
                }
            }
        }
    }
    populate_db($DBname, $DBPrefix, 'dbsetup.sql');
    if ($DBSample) {
        populate_db($DBname, $DBPrefix, 'sample_data.sql');
    }
    if ($CEMDB) {
        // Removed for now - database is too large to import here
        // it must be done manually from the command line
        // populate_db($DBname,$DBPrefix,'cemdb.sql');
    }
    $DBcreated = 1;
}
function db_err($step, $alert)
{
    global $DBhostname, $DBuserName, $DBpassword, $DBDel, $DBname, $DBPort;
    echo "<form name=\"{$step}\" method=\"post\" action=\"install1.php\">\n\t<input type=\"hidden\" name=\"DBhostname\" value=\"{$DBhostname}\">\n\t<input type=\"hidden\" name=\"DBuserName\" value=\"{$DBuserName}\">\n\t<input type=\"hidden\" name=\"DBpassword\" value=\"{$DBpassword}\">\n\t<input type=\"hidden\" name=\"DBDel\" value=\"{$DBDel}\">\n\t<input type=\"hidden\" name=\"DBname\" value=\"{$DBname}\">\n\t</form>\n";
    //echo "<script>alert(\"$alert\"); document.$step.submit();</script>";
    echo "<script>alert(\"{$alert}\"); window.history.go(-1);</script>";
    //this wasn't working
Example #2
0
if (isset($_POST["idb"])) {
   require_once(CONF_DB); 
   if (!$connect_id = @mysql_connect(HOST,USER,PASS)) 
      $errors[] = "Tidak Bisa Terkoneksi ke Database"; 
   if (!$errors)
      if (!mysql_select_db(DB, $connect_id))
           $errors[] = "Tidak Dapat Menemukan Database $db";
   if ($errors) {
      $dbhost = $host;
	  $dbuser = $user;
	  $dbpass = $pass; 
	  $dbname = $db; 
   }
   if (!$errors) {
    populate_db($connect_id,'db_sistem.sql');
    if (!$errors) $step=2;

   }	     	    
} 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Install Database</title>
<style type="text/css">
<!--
body {
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
function step2($file = "")
{
    global $_CONFIG, $filepath;
    $DBcreated = $_REQUEST[DBcreated];
    if ($DBcreated == 'on') {
        $DBhostname = $_REQUEST['mysql_server'];
        $DBuserName = $_REQUEST['mysql_username'];
        $DBpassword = $_REQUEST['mysql_pass'];
        $DBname = $_REQUEST['mysql_db'];
        $_CONFIG['mysqli'] = new mysqli($DBhostname, $DBuserName, $DBpassword, $DBname);
        /* check connection */
        if ($_CONFIG['mysqli']->connect_errno) {
            printf("Connect failed: %s\n", $_CONFIG['mysqli']->connect_error);
            exit;
        }
        $_CONFIG['mysqli']->query("SET sql_mode='';");
        $_CONFIG['mysqli']->query("SET foreign_key_checks = 0;");
        if ($_REQUEST['charset_of_file'] != "") {
            $_CONFIG['mysqli']->query("SET NAMES " . $_REQUEST['charset_of_file'] . "");
        } else {
            $_CONFIG['mysqli']->query("SET NAMES utf8;");
        }
    }
    if ($_REQUEST['do_database'] != 1) {
        ############ DATABASE ONLY RESTRICTION##################################################
        ########################### START FTP MODE #################################
        if ($_REQUEST[transfer_mode] == 2) {
            $_CONFIG[output_path] = $_CONFIG[output_path] . "/archive_tmp/";
            @mkdir($_CONFIG[output_path]);
            // set up basic connection
            $conn_id = @ftp_connect($_REQUEST[ftp_server], $_REQUEST[ftp_port]) or die("<span class='error'>Could not connect to {$_REQUEST['ftp_server']} on port {$_REQUEST['ftp_port']}! Ftp connection has failed!</span>");
            // login with username and password
            $login_result = @ftp_login($conn_id, $_REQUEST[ftp_user], $_REQUEST[ftp_pass]) or die("<span class='error'>Could not login to ftp server for user {$_REQUEST['ftp_user']} and provided pass! Ftp connection has failed!</span>");
            // check connection
            if (!$conn_id || !$login_result) {
                echo "<b  style='color:red'>FTP connection has failed!</b>";
                echo "<b  style='color:red'>Attempted to connect to " . $_REQUEST[ftp_server] . ":" . $_REQUEST[ftp_port] . " for user " . $_REQUEST[ftp_user] . "</b>";
                return;
            } else {
                echo "<br />Connected to {$_REQUEST['ftp_server']}, for user {$_REQUEST['ftp_user']}, starting transfer...<br />";
            }
            $ftp_dir_original = ftp_pwd($conn_id);
            @ftp_mkdir($conn_id, $_REQUEST[ftp_path]);
            // try to change the directory to somedir
            if (@ftp_chdir($conn_id, $_REQUEST[ftp_path])) {
                echo "Current directory is now: <b>" . ftp_pwd($conn_id) . "</b>\n";
            } else {
                echo "<b  style='color:red'>Couldn't change directory to <b>{$_REQUEST['ftp_path']}</b>, please verify that the ftp location exists or use the \"Install files directly\" option!</b><br />\n";
                return;
            }
            @ftp_chdir($conn_id, $ftp_dir_original);
        }
        ########################## END FTP MODE ######################################
        ##### START extract ######
        if ($_REQUEST['refresh'] < 1) {
            $ext = substr($file, strlen($file) - 4, strlen($file));
            if ($_REQUEST['file_utilities'] != '1') {
                $tar_object = new Archive_Tar($file);
                if ($_REQUEST['manual_ftp']) {
                    $tar_object->_openRead();
                    fseek($tar_object->_file, $_CONFIG['seek']);
                    $seek = $tar_object->_extractList($_CONFIG['output_path'], $return, "partial", "", "", $_CONFIG['filesLimit']);
                    $seek = $seek - 512;
                    //reverse 512 bytes
                    if ($seek > 0) {
                        $backupSize = filesize($file);
                        $rurl = rurl($seek, $backupSize);
                        $percent = sprintf("%.2f", $seek * 100 / $backupSize);
                        echo "<h3>Processing files - " . $percent . "%</h3>";
                        echo "<script> document.location='" . $rurl . "'</script>";
                        return;
                    }
                    $_REQUEST['fpos'] = 0;
                    $_REQUEST['chunk'] = 0;
                } else {
                    $tar_object->extract($_CONFIG['output_path']);
                    #$tar_object->extractList("backups/perm.txt", $_CONFIG['output_path']);
                }
            } else {
                if ($ext == '.tgz') {
                    $compress = 'z';
                } else {
                    $compress = '';
                }
                shell_exec("tar -x" . $compress . "pf {$file} -C {$_CONFIG['output_path']}");
            }
        }
        ##### END extract ######
        $new_arr = array();
        #@chmod($_CONFIG[output_path], 0777);
        $tran_file = $_CONFIG[output_path] . "/transfer.txt";
        if ($_REQUEST[transfer_mode] == 2) {
            # initialise list arrays, directories and files separately and array counters for them
            $excludedFolders = array();
            $d_arr = array();
            $d = 0;
            $ds_arr = array();
            $f_arr = array();
            $f = 0;
            $s_arr = array();
            $s = 0;
            $d_arr[$d] = $_CONFIG[output_path];
            if ($_REQUEST['refresh'] < 1) {
                # obtain the list of files by recursing the mambo file store
                recurseFiles($d_arr, $ds_arr, $f_arr, $s_arr, $d, $f, $s, $excludedFolders, '', $_CONFIG[output_path]);
                recurseFiles($d_arr, $ds_arr, $f_arr, $s_arr, $d, $f, $s, $d_arr, '', $_CONFIG[output_path]);
                sort($d_arr);
                sort($f_arr);
                $new_arr = array_merge($d_arr, $f_arr);
                if ($_REQUEST[transfer_mode] == 2) {
                    if ($fp = fopen($tran_file, "w")) {
                        foreach ($new_arr as $file) {
                            fwrite($fp, $file . "\n");
                        }
                        fclose($fp);
                    } else {
                        echo "Unable to write to directory " . $_CONFIG[output_path] . "! Please check that this directory is writeable!";
                        return;
                    }
                } else {
                }
            } else {
                $content = "";
                $new_arr = file($tran_file);
            }
            if (sizeof($new_arr) != 0) {
                $percn = sprintf("%.2f", $_REQUEST[next] * 100 / sizeof($new_arr));
            }
            if ($percn > sizeof($new_arr)) {
                $percn = sizeof($new_arr);
            }
        }
        if ($_REQUEST['refresh'] == 1) {
            echo "<h3>Transfering {$percn}% of " . sizeof($new_arr) . " files through ftp</h3>";
            echo "<textarea cols=70 rows=30 name='ftp_list'></textarea>";
        } elseif ($_REQUEST['refresh'] == 2) {
            echo "Files transfer finished!";
        }
        $i = (int) $_REQUEST[next];
        $j = 0;
        ### MOVING THE FILES THROUGH FTP
        #foreach($new_arr as $key=>$file)
        for ($key = $i; $key <= sizeof($new_arr); $key++) {
            $file = str_replace(array("\r", "\n"), array("", ""), $new_arr[$key]);
            if ($_REQUEST['manual_ftp'] == 1) {
                if ($j == 100) {
                    #echo "Transfering files from line: ". (int)$_REQUEST[next];
                    $qstr = explode("&refresh=1&next=", $_SERVER['QUERY_STRING']);
                    $rurl = "XCloner.php?" . $qstr[0] . "&refresh=1&next=" . ($_REQUEST[next] + 100);
                    ftp_close($conn_id);
                    echo "<script> document.location='" . $rurl . "'</script>";
                    exit;
                }
            }
            $j++;
            $sfile = str_replace($_CONFIG[output_path], "", $file);
            $fsource = $_CONFIG[output_path] . "/" . $sfile;
            if ($sfile != "" && $sfile != "/") {
                if ($_REQUEST[transfer_mode] == 2) {
                    $upload = 1;
                    $ftarget = $_REQUEST[ftp_path] . "/" . $sfile;
                    if (is_dir($fsource)) {
                        $upload1 = @ftp_mkdir($conn_id, $ftarget);
                    } else {
                        $upload = ftp_put($conn_id, $ftarget, $fsource, FTP_BINARY);
                    }
                    #echo "$i <br >";
                    if (!$upload) {
                        echo "<br /><font color=red>Transfer fail for {$fsource} to {$ftarget}</font> <br />File already exists and/or doesn't have writing permissions!<br/>";
                    } else {
                        if ($_REQUEST['manual_ftp'] == 1) {
                            $ftarget .= '\\n';
                            echo "<script>document.form.ftp_list.value = document.form.ftp_list.value + '" . $ftarget . "'; </script>";
                            #echo "$ftarget <br />\n";
                        }
                    }
                }
            }
        }
        if ($_REQUEST['refresh'] == 1) {
            $qstr = explode("&refresh=1&next=", $_SERVER['QUERY_STRING']);
            $rurl = "XCloner.php?" . $qstr[0] . "&refresh=2&next=" . ($_REQUEST[next] + 102);
            echo "<script> document.location='" . $rurl . "'</script>";
            exit;
        }
        ############### RESTORING HTACCESS AND CONFIGURATION PERM#####################################
        if ($_REQUEST[transfer_mode] == 2) {
            $cmd = "CHMOD 0777 " . $_REQUEST[ftp_path] . "/" . "wp-config.php";
            @ftp_site($conn_id, $cmd);
        } else {
            @chmod($_REQUEST[output_path] . "/" . "wp-config.php", 0777);
        }
        #### CUSTOM PERMISSIONS #####
        if ($_REQUEST['preserve_perm']) {
            $perm_data = "";
            $perm_file = $_CONFIG[output_path] . "/administrator/backups/perm.txt";
            $per = 1;
            @chmod($perm_file, 0777);
            $fp = @fopen($perm_file, 'r');
            if ($fp) {
                while (!feof($fp)) {
                    $perm_data .= fread($fp, 1024);
                }
                fclose($fp);
            } else {
                echo "Could not set permissions! Permissions file {$perm_file} not found!<br />";
                $per = 0;
            }
            $data = explode("\n", $perm_data);
            foreach ($data as $value) {
                $dir = explode("|", $value);
                if ($dir[1] == "") {
                    $dir[1] = '0755';
                }
                if (strstr($dir[0], "wp-config.php")) {
                    $dir[1] = '0777';
                }
                if ($_REQUEST[transfer_mode] == 2) {
                    $cmd = "CHMOD " . $dir[1] . " " . $_REQUEST[ftp_path] . "/" . $dir[0];
                    @ftp_site($conn_id, $cmd);
                } else {
                    @chmod($_CONFIG[output_path] . "/" . $dir[0], octdec($dir[1]));
                }
            }
            if ($per) {
                echo "<h2>Permissions restored to their initial value...</h2>";
            }
        }
        #### END CUSTOM PERMISSIONS #####
        $_CONFIG[output_path] = str_replace("/archive_tmp/", "", $_CONFIG[output_path]);
        if ($_REQUEST[transfer_mode] == 2) {
            // close the FTP stream
            @ftp_close($conn_id);
            recursive_remove_directory($_CONFIG[output_path] . "/archive_tmp/");
            @unlink($_CONFIG[output_path] . "/archive_tmp/");
            echo "<h2>Files succesfully copied to " . $_REQUEST[ftp_path] . " on {$_REQUEST['ftp_server']} using FTP</h2>";
        } else {
            echo "<h2>Files succesfully copied to " . $_CONFIG[output_path] . "</h2>";
        }
        ######### END DATABASE ONLY RESTRICT #########################################
    }
    ##### RESTORE CONFIGURATION #####
    $update_config = 1;
    if ($_REQUEST['files_skip'] and isset($_REQUEST['fpos'])) {
        $update_config = 0;
    }
    if ($_REQUEST['do_database'] != 1 || $_REQUEST['files_skip'] == 1) {
        $config_file = $_CONFIG[output_path] . "/wp-config.php";
        @chmod($config_file, 0777);
        @unlink($_CONFIG[output_path] . "/administrator/backups/perm.txt");
        if ($_CONFIG['sql_usefile'] == "database-sql.sql" and $update_config) {
            if (write_config($config_file)) {
                echo "<H2>Configuration updated!</H2>";
            } else {
                echo "<span class='error'>Unable to write to configuration file {$config_file}... Aborting...</span>";
                return;
            }
        }
    }
    ############ ATTEMPT DATABASE INSERT #####################################
    if ($DBcreated != 'on') {
        echo "<h2>Database import skipped!</h2>";
        echo "<a href='" . $_CONFIG[output_url] . "'><b>All should be done! Click here to continue...</b></a><br />";
        return;
    }
    if ($DBcreated == 'on' && $_REQUEST['do_database'] == 1) {
        $sqlfile = $_CONFIG[output_path] . "/administrator/backups/" . $_CONFIG['sql_usefile'];
        if (!file_exists($sqlfile)) {
            echo "<span class='error'>Unable to read the database backup file {$sqlfile} , database was not imported!</span>";
        } else {
            if ($_REQUEST['manual_sql']) {
                $errors = populate_db_manual($db, $sqlfile);
            } else {
                $errors = populate_db($db, $sqlfile);
            }
            if (sizeof($errors) > 0) {
                echo "There were some errors while importing the database:<br />";
                echo "<textarea cols=60 rows=30>" . implode("\n", $errors) . "</textarea>";
                exit;
            } else {
                @unlink($_CONFIG[output_path] . "/administrator/backups/" . $_CONFIG['sql_usefile']);
            }
            echo "<h2>Database populated...</h2>";
        }
    }
    ###################################################################################
    if ($_REQUEST['do_database'] != 1) {
        $vars = "";
        foreach ($_REQUEST as $key => $value) {
            $vars .= $key . '=' . @urlencode($value) . '&';
        }
        #$href = "XCloner.php?".$vars."do_database=1";
        $href = rurl() . "&do_database=1";
        echo "<br /><a href='{$href}'>Please click here to continue with database import...</a>";
        return;
    } else {
        echo "<br /><a href='" . $_CONFIG[output_url] . "'><b>All should be done! Click here to continue...<br /></a><br />";
        return;
    }
}
Example #4
0
         die(_ERRORCONNECT . ": <font color='#FF0000'>" . mysql_error() . "</font>");
     }
     $sql = "CREATE DATABASE " . $_POST['dbname'] . "";
     if (mysql_query($sql, $link)) {
         echo "<p>" . _INSTALLPASSO3 . "</p><br/>";
         echo _OKCREATE . ": " . $_POST['dbname'] . "\n";
     } else {
         echo _ERRORCREATE . ": <font color='#FF0000'>" . mysql_error() . "</font>\n";
     }
     echo "\r\n        <form action=\"install.php?passo=3\" method=\"post\">\r\n        <p>\r\n        <input type=\"hidden\" name=\"dbname\" value=\"" . $_POST['dbname'] . "\" id=\"\"/><br/>\r\n        <input type=\"hidden\" name=\"host\" value=\"" . $_POST['host'] . "\" id=\"\"/><br/>\r\n        <input type=\"hidden\" name=\"username\" value=\"" . $_POST['username'] . "\" id=\"\"/><br/>\r\n        <input type=\"hidden\" name=\"password\" value=\"" . $_POST['password'] . "\" id=\"\"/><br/>\r\n        <input type=\"submit\" class=\"button\" name=\"envia\" value=" . _INSTALLNEXTSTEP . " />\r\n        </p></form>\r\n        ";
     break;
 case '3':
     echo '<div id="wrapper"><img src="imagens/install/install.jpg" alt="Instalation Image" width="100" height="100" /><h1>' . _INSTALLING . ' nBlog v' . _VERSAO . '</h1>';
     include PATH . 'includes/install/install_functions.php';
     echo _INSTALLPASSO4;
     populate_db($_POST['dbname'], 'nblog.sql', $_POST['host'], $_POST['username'], $_POST['password']);
     echo "\r\n        <form action=\"install.php?passo=4\" method=\"post\">\r\n        <p>\r\n        <input type=\"hidden\" name=\"dbname\" value=\"" . $_POST['dbname'] . "\" id=\"\"/><br/>\r\n        <input type=\"hidden\" name=\"host\" value=\"" . $_POST['host'] . "\" id=\"\"/><br/>\r\n        <input type=\"hidden\" name=\"username\" value=\"" . $_POST['username'] . "\" id=\"\"/><br/>\r\n        <input type=\"hidden\" name=\"password\" value=\"" . $_POST['password'] . "\" id=\"\"/><br/>\r\n        <input type=\"submit\" class=\"button\" name=\"envia\" value=" . _INSTALLNEXTSTEP . " />\r\n        </p></form>\r\n        ";
     break;
 case '4':
     if (file_exists('includes/varsdb.php')) {
         $canWrite = is_writable('includes/varsdb.php');
     } else {
         $canWrite = is_writable('..');
     }
     $config = "<?\n";
     $config .= "if(!defined('IN_BLOG'))\n";
     $config .= "{\n";
     $config .= "\texit;\n";
     $config .= "}\n";
     $config .= "\$sqlconfig = array();\n";
     $config .= "\$sqlconfig['username'] = '******'username']}';\n";
Example #5
0
<?php

include 'lib/fortissimo.php';
$ft->title('Fortissimo Setup');
if ($ft->config('setup_done')) {
    return $ft->errorpage('Sorry, you have already completed the setup process.');
}
# STEP 1: let's create the tables that we need...
include 'lib/db_utils.php';
setup_db();
populate_db();
# okay, make sure they gave us all the inputs
$user = trim($_POST['admin_name']);
$pw1 = trim($_POST['admin_pw1']);
$pw2 = trim($_POST['admin_pw2']);
$ft->assign('admin_name', $user);
if (!$user || !$pw1 || !$pw2) {
    $ft->assign('error1', 'You must fill in all fields in this section.');
    return $ft->makepage('setup');
}
if ($pw1 != $pw2) {
    $ft->assign('error1', 'The chosen passwords do not match.');
    return $ft->makepage('setup');
}
if (strlen($pw1) < 6) {
    $ft->assign('error1', 'Your password must be at least 6 characters long.');
    return $ft->makepage('setup');
}
# setup this account
$id = get_pilot_id($user);
$ft->dbh->_do_query('UPDATE tbl:pilots SET password = ?, roles = 1 WHERE pilotid = ?', array($pw1, $id));
Example #6
0
                            $errors[$database->getQuery()] = $database->getErrorMsg();
                        }
                    }
                    $query = "DROP TABLE IF EXISTS `{$table}`";
                    $database->setQuery($query);
                    $database->query();
                    if ($database->getErrorNum()) {
                        $errors[$database->getQuery()] = $database->getErrorMsg();
                    }
                }
            }
        }
    }
    populate_db($database, 'joomla.sql');
    if ($DBSample) {
        populate_db($database, 'sample_data.sql');
    }
    $DBcreated = 1;
}
function db_err($step, $alert)
{
    global $DBhostname, $DBuserName, $DBpassword, $DBDel, $DBname;
    echo "<form name=\"{$step}\" method=\"post\" action=\"install1.php\">\r\n\t<input type=\"hidden\" name=\"DBhostname\" value=\"{$DBhostname}\">\r\n\t<input type=\"hidden\" name=\"DBuserName\" value=\"{$DBuserName}\">\r\n\t<input type=\"hidden\" name=\"DBpassword\" value=\"{$DBpassword}\">\r\n\t<input type=\"hidden\" name=\"DBDel\" value=\"{$DBDel}\">\r\n\t<input type=\"hidden\" name=\"DBname\" value=\"{$DBname}\">\r\n\t</form>\n";
    //echo "<script>alert(\"$alert\"); window.history.go(-1);</script>";
    echo "<script>alert(\"{$alert}\"); document.location.href='install1.php';</script>";
    exit;
}
/**
 * @param object
 * @param string File name
 */
Example #7
0
    $database = new database($DBhostname, $DBuserName, $DBpassword, $DBname);
    // delete existing mos table if exists
    $query = "SHOW TABLES FROM `{$DBname}`";
    $database->setQuery($query);
    $errors = array();
    if ($tables = $database->loadResultArray()) {
        foreach ($tables as $table) {
            $query = "DROP TABLE IF EXISTS `{$table}`";
            $database->setQuery($query);
            $database->query();
            if ($database->getErrorNum()) {
                $errors[$database->getQuery()] = $database->getErrorMsg();
            }
        }
    }
    populate_db($database, 'nuke.sql');
    $DBcreated = 1;
}
function db_err($step, $alert)
{
    global $DBhostname, $DBuserName, $DBpassword, $DBname;
    echo "<form name=\"{$step}\" method=\"post\" action=\"install1.php\">\n\t<input type=\"hidden\" name=\"DBhostname\" value=\"{$DBhostname}\">\n\t<input type=\"hidden\" name=\"DBuserName\" value=\"{$DBuserName}\">\n\t<input type=\"hidden\" name=\"DBpassword\" value=\"{$DBpassword}\">\n\t<input type=\"hidden\" name=\"DBname\" value=\"{$DBname}\">\n\t</form>\n";
    //echo "<script>alert(\"$alert\"); window.history.go(-1);</script>";
    echo "<script>alert(\"{$alert}\"); document.location.href='install1.php';</script>";
    exit;
}
/**
 * @param object
 * @param string File name
 */
function populate_db(&$database, $sqlfile = 'nuke.sql')
Example #8
0
if (!$database->_resource) {
    db_err('stepBack2', 'Le mot de passe et le nom d\'utilisateur sont incorrects.');
}
$configArray['DBhostname'] = $DBhostname;
$configArray['DBuserName'] = $DBuserName;
$configArray['DBpassword'] = $DBpassword;
$configArray['DBname'] = $DBname;
$sql = "CREATE DATABASE `{$DBname}`";
$database->setQuery($sql);
$database->query();
$test = $database->getErrorNum();
if ($test != 0 && $test != 1007) {
    db_err('stepBack', 'Erreur de base de données : ' . $database->getErrorMsg());
}
$database = new database($DBhostname, $DBuserName, $DBpassword, $DBname, $DBPrefix);
populate_db($database);
function db_err($step, $alert)
{
    global $DBhostname, $DBuserName, $DBpassword, $DBDel, $DBname;
    echo "<form name=\"{$step}\" method=\"post\" action=\"install1.php\">\n\t<input type=\"hidden\" name=\"DBhostname\" value=\"{$DBhostname}\">\n\t<input type=\"hidden\" name=\"DBuserName\" value=\"{$DBuserName}\">\n\t<input type=\"hidden\" name=\"DBpassword\" value=\"{$DBpassword}\">\n\t</form>\n";
    echo "<script type=\"text/javascript\">alert(\"{$alert}\"); document.location.href='install1.php';</script>";
    exit;
}
function populate_db(&$database, $sqlfile = 'creermonjeu.sql')
{
    global $errors;
    $mqr = @get_magic_quotes_runtime();
    @set_magic_quotes_runtime(0);
    $query = fread(fopen('sql/' . $sqlfile, 'r'), filesize('sql/' . $sqlfile));
    @set_magic_quotes_runtime($mqr);
    $pieces = split_sql($query);