diff --git a/config.php.template b/config.php.template
index d523af9..72c8874 100644
--- a/config.php.template
+++ b/config.php.template
@@ -11,7 +11,7 @@ define("INSTALL_OVERRIDE", false);
$mysqli = new mysqli("##server##","##user##","##password##","##database##");
if ($mysqli->connect_errno) {
- printf("Connect failed: %s\n", $mysqli->connect_error);
+ printf("Connection failed: %s\n", $mysqli->connect_error);
exit();
}
diff --git a/install.php b/install.php
index 1c01e6f..0ac4bbd 100644
--- a/install.php
+++ b/install.php
@@ -5,44 +5,83 @@ define("NAME", 'Status page'); //Website name
render_header("Install");?>
Installation
connect_errno) {
+ $message = "Connection failed: %s\n", $mysqli->connect_error;
+ }
+}
+
+if (filter_var($_POST['url'], FILTER_VALIDATE_URL) === false)
+{
+ $message = "Please set valid url!"
+}
+
+//Ostatnà má checky existence ve funkci pro pridani
+if (0 == strlen(trim($_POST['servername'])) || 0 == strlen(trim($_POST['url'])) || 0 == strlen(trim($_POST['mailer']))
+ || 0 == strlen(trim($_POST['mailer_email'])) || 0 == strlen(trim($_POST['server'])) || 0 == strlen(trim($_POST['database']))
+ || 0 == strlen(trim($_POST['dbuser'])) || 0 == strlen(trim($_POST['dbpassword'])))
+{
+ $message = "Please enter all data!";
+}
+
+if(isset($_POST['server']) && !isset($message))
{
define("INSTALL_OVERRIDE", true);
- error_reporting(E_ALL);
- require("classes/constellation.php");
- $config = file_get_contents("config.php.template");
- $config = str_replace("##name##", $_POST['servername'], $config);
- $config = str_replace("##url##", $_POST['url'], $config);
- $config = str_replace("##mailer##", $_POST['mailer'], $config);
- $config = str_replace("##mailer_email##", $_POST['mailer_email'], $config);
- $config = str_replace("##server##", $_POST['server'], $config);
- $config = str_replace("##database##", $_POST['database'], $config);
- $config = str_replace("##user##", $_POST['dbuser'], $config);
- $config = str_replace("##password##", $_POST['dbpassword'], $config);
- $config = str_replace("##name##", $_POST['servername'], $config);
- file_put_contents("config.php", $config);
- require("config.php");
+
+ //No need to include config, as we have connection from testing it... :)
+ //There may be better way to do this...
$sql = file_get_contents("install.sql");
$array = explode(";", $sql);
- //TODO: Checkovat pls
+
foreach ($array as $value) {
- $mysqli->query($value);
+ $q_res = $mysqli->query($value);
+ if ($q_res === false)
+ {
+ $message = "Error while creating database. Please check permission for your account or MYSQL version.
Error: ".$mysqli->error;
+ break;
+ }
}
- User::add();
- if (isset($message))
+ if (!isset($message))
{
- echo "$message
";
- render_footer();
- die;
+ require("classes/constellation.php");
+
+ User::add();
}
- unlink("config.php.temlpate");
- unlink("install.sql");
- unlink(__FILE__);
+ if (!isset($message))
+ {
+ //Create config
+ $config = file_get_contents("config.php.template");
+ $config = str_replace("##name##", $_POST['servername'], $config);
+ $config = str_replace("##url##", $_POST['url'], $config);
+ $config = str_replace("##mailer##", $_POST['mailer'], $config);
+ $config = str_replace("##mailer_email##", $_POST['mailer_email'], $config);
+ $config = str_replace("##server##", $_POST['server'], $config);
+ $config = str_replace("##database##", $_POST['database'], $config);
+ $config = str_replace("##user##", $_POST['dbuser'], $config);
+ $config = str_replace("##password##", $_POST['dbpassword'], $config);
+ $config = str_replace("##name##", $_POST['servername'], $config);
+ file_put_contents("config.php", $config);
- header("Location: /");
-}else{
+ unlink("config.php.temlpate");
+ unlink("install.sql");
+ unlink(__FILE__);
+
+ header("Location: /");
+ }
+}
+
+if (isset($message))
+{
+?>
+
+