2013-10-28 18:40:48 -07:00
|
|
|
<?php
|
|
|
|
|
2014-01-13 17:43:58 +00:00
|
|
|
// MYSQL Check - FIXME
|
|
|
|
// 1 UNKNOWN
|
2015-08-07 16:15:56 +00:00
|
|
|
include 'config.php';
|
2013-10-28 18:40:48 -07:00
|
|
|
|
2014-08-14 08:06:49 +10:00
|
|
|
if (!isset($sql_file)) {
|
2015-07-13 20:10:26 +02:00
|
|
|
$sql_file = 'build.sql';
|
2014-08-14 08:06:49 +10:00
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
|
|
|
|
$sql_fh = fopen($sql_file, 'r');
|
|
|
|
if ($sql_fh === false) {
|
|
|
|
echo 'ERROR: Cannot open SQL build script '.$sql_file."\n";
|
|
|
|
exit(1);
|
2014-08-14 08:06:49 +10:00
|
|
|
}
|
2015-09-01 22:42:02 +01:00
|
|
|
|
|
|
|
$database_link = mysqli_connect('p:'.$config['db_host'], $config['db_user'], $config['db_pass']);
|
2015-08-15 17:37:20 +00:00
|
|
|
if ($database_link === false) {
|
|
|
|
echo 'ERROR: Cannot connect to database: '.mysqli_error($database_link)."\n";
|
2015-07-13 20:10:26 +02:00
|
|
|
exit(1);
|
2014-08-14 08:06:49 +10:00
|
|
|
}
|
|
|
|
|
2015-08-15 17:37:20 +00:00
|
|
|
$select = mysqli_select_db($database_link, $config['db_name']);
|
2015-07-13 20:10:26 +02:00
|
|
|
if ($select === false) {
|
2015-08-15 17:37:20 +00:00
|
|
|
echo 'ERROR: Cannot select database: '.mysqli_error($database_link)."\n";
|
2015-07-13 20:10:26 +02:00
|
|
|
exit(1);
|
2015-05-18 20:12:52 +01:00
|
|
|
}
|
2013-10-28 18:40:48 -07:00
|
|
|
|
2015-09-01 22:42:02 +01:00
|
|
|
$limit = 0;
|
2015-07-13 20:10:26 +02:00
|
|
|
while (!feof($sql_fh)) {
|
|
|
|
$line = fgetss($sql_fh);
|
2015-09-01 22:42:02 +01:00
|
|
|
if (isset($_SESSION['stage']) ) {
|
|
|
|
$limit++;
|
|
|
|
if (isset($_SESSION['offset']) && $limit < $_REQUEST['offset']) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
elseif ( abs($limit-$_REQUEST['offset']) > 6) {
|
|
|
|
$_SESSION['offset'] = $limit;
|
|
|
|
echo '<b>Installing, please wait..</b><sub>'.date('r').'</sub><script>window.location.href = "install.php?offset='.$limit.'";</script>';
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
echo 'Step #'.$limit.' ...'.PHP_EOL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
if (!empty($line)) {
|
2015-08-15 17:37:20 +00:00
|
|
|
$creation = mysqli_query($database_link, $line);
|
2015-09-01 22:42:02 +01:00
|
|
|
if (!$creation && ($limit <= 100 || $limit > 391) ) {
|
2015-08-15 17:37:20 +00:00
|
|
|
echo 'WARNING: Cannot execute query ('.$line.'): '.mysqli_error($database_link)."\n";
|
2015-07-13 20:10:26 +02:00
|
|
|
}
|
2014-01-15 02:51:25 +00:00
|
|
|
}
|
2013-10-28 18:40:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fclose($sql_fh);
|
2015-09-01 23:31:41 +01:00
|
|
|
|
|
|
|
require 'includes/sql-schema/update.php';
|