new installation process via script, elimination of data entry form for installation
Signed-off-by: giandonato.inverso@edempg.it <Zannabianca20>
This commit is contained in:
committed by
giandonato.inverso@edempg.it
parent
4dd7f9ab25
commit
c3e04a4357
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
//Note: This file should be included first in every php page.
|
|
||||||
error_reporting(E_ALL);
|
|
||||||
ini_set('display_errors', 'On');
|
|
||||||
define('BASE_PATH', dirname(dirname(__FILE__)));
|
|
||||||
define('APP_FOLDER', 'simpleadmin');
|
|
||||||
define('CURRENT_PAGE', basename($_SERVER['REQUEST_URI']));
|
|
||||||
|
|
||||||
/* PATH OF SAVED QR CODES */
|
|
||||||
define('PATH', './saved_qrcode/'); //You can change the folder where the qr code will be saved
|
|
||||||
define('DIRECTORY', BASE_PATH.'/saved_qrcode/');
|
|
||||||
|
|
||||||
//You can change the page name for the redirect and the search parameter (the default is "id")
|
|
||||||
define('READ_PATH', $_SERVER['HTTP_HOST'].'/read.php?id=');
|
|
||||||
|
|
||||||
require_once BASE_PATH . '/lib/MysqliDb/MysqliDb.php';
|
|
||||||
require_once BASE_PATH . '/helpers/helpers.php';
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| DATABASE CONFIGURATION
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
define('DB_HOST', "%HOSTNAME%");
|
|
||||||
define('DB_USER', "%USERNAME%");
|
|
||||||
define('DB_PASSWORD', "%PASSWORD%");
|
|
||||||
define('DB_NAME', "%DATABASE%");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get instance of DB object
|
|
||||||
*/
|
|
||||||
function getDbInstance() {
|
|
||||||
return new MysqliDb(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
|
|
||||||
}
|
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
<?php
|
|
||||||
error_reporting(0);
|
|
||||||
|
|
||||||
if (isset($_POST["btn_install"])) {
|
|
||||||
|
|
||||||
$db_host = $_POST['db_host'];
|
|
||||||
$db_name = $_POST['db_name'];
|
|
||||||
$db_user = $_POST['db_user'];
|
|
||||||
$db_password = $_POST['db_password'];
|
|
||||||
|
|
||||||
// Load the classes and create the new objects
|
|
||||||
require_once('includes/core_class.php');
|
|
||||||
require_once('includes/database_class.php');
|
|
||||||
|
|
||||||
$core = new Core();
|
|
||||||
$database = new Database();
|
|
||||||
|
|
||||||
// Validate the post data
|
|
||||||
if ($core->validate_post($_POST) == true) {
|
|
||||||
// First create the database, then create tables, then write config file
|
|
||||||
if ($database->create_database($_POST) == false) {
|
|
||||||
$message = $core->show_message('error', "The database could not be created, please check your database credentials!");
|
|
||||||
} else if ($database->create_tables($_POST) == false) {
|
|
||||||
$message = $core->show_message('error', "The database tables could not be created, please check your database credentials!");
|
|
||||||
} else if ($core->write_config($_POST) == false) {
|
|
||||||
$message = $core->show_message('error', "The database configuration file could not be written, please chmod application/config/database.php file to 777");
|
|
||||||
}
|
|
||||||
|
|
||||||
// If no errors, redirect to index
|
|
||||||
if (!isset($message)) {
|
|
||||||
header("Refresh: 10; finish.php");
|
|
||||||
$installing = 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$message = $core->show_message('error', 'Not all fields have been filled in correctly. The host, username, password, and database name are required.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>PHP Dynamic Qr code - Installer</title>
|
|
||||||
<!-- Bootstrap CSS -->
|
|
||||||
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Poppins:400,500,700" rel="stylesheet">
|
|
||||||
<!-- Font-awesome CSS -->
|
|
||||||
<link href="assets/css/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
|
|
||||||
<link rel="stylesheet" href="assets/css/style.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-8 col-sm-12 col-md-offset-2">
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12 logo-cnt">
|
|
||||||
<img src="assets/img/DynamicQRCode_BlackWhite.png">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
|
|
||||||
<div class="install-box">
|
|
||||||
<div class="steps">
|
|
||||||
<div class="step-progress">
|
|
||||||
<div class="step-progress-line" data-now-value="72" data-number-of-steps="5" style="width: 72%;"></div>
|
|
||||||
</div>
|
|
||||||
<div class="step">
|
|
||||||
<div class="step-icon"><i class="fa fa-code"></i></div>
|
|
||||||
<p>Start</p>
|
|
||||||
</div>
|
|
||||||
<div class="step">
|
|
||||||
<div class="step-icon"><i class="fa fa-folder-open"></i></div>
|
|
||||||
<p>Folder Permissions</p>
|
|
||||||
</div>
|
|
||||||
<div class="step active">
|
|
||||||
<div class="step-icon"><i class="fa fa-database"></i></div>
|
|
||||||
<p>Database</p>
|
|
||||||
</div>
|
|
||||||
<div class="step">
|
|
||||||
<div class="step-icon"><i class="fa fa-user"></i></div>
|
|
||||||
<p>Finish</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="messages">
|
|
||||||
<?php if (isset($message)) { ?>
|
|
||||||
<div class="alert alert-danger">
|
|
||||||
<strong><?php echo $message; ?></strong>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
<?php if (isset($installing)) { ?>
|
|
||||||
<div class="alert alert-success">
|
|
||||||
<strong>The database is being created. Please wait!</strong>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
</div>
|
|
||||||
<?php if (isset($installing)) { ?>
|
|
||||||
<div class="col-sm-12">
|
|
||||||
<div class="row">
|
|
||||||
<div class="spinner">
|
|
||||||
<div class="rect1"></div>
|
|
||||||
<div class="rect2"></div>
|
|
||||||
<div class="rect3"></div>
|
|
||||||
<div class="rect4"></div>
|
|
||||||
<div class="rect5"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
<div class="step-contents">
|
|
||||||
<div class="tab-1">
|
|
||||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
|
|
||||||
<div class="tab-content">
|
|
||||||
<div class="tab_1">
|
|
||||||
<h1 class="step-title">Database</h1>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="email">Host</label>
|
|
||||||
<input type="text" class="form-control form-input" name="db_host" placeholder="Host"
|
|
||||||
value="<?php echo isset($db_host) ? @$db_host : 'localhost'; ?>" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="email">Database Name</label>
|
|
||||||
<input type="text" class="form-control form-input" name="db_name" placeholder="Database Name"
|
|
||||||
value="<?php echo @$db_name; ?>" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="email">Username</label>
|
|
||||||
<input type="text" class="form-control form-input" name="db_user" placeholder="Username"
|
|
||||||
value="<?php echo @$db_user; ?>" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="email">Password</label>
|
|
||||||
<input type="text" class="form-control form-input" name="db_password" placeholder="Password"
|
|
||||||
value="<?php echo @$db_password; ?>">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="buttons">
|
|
||||||
<a href="folder-permissions.php" class="btn btn-success btn-custom pull-left">Prev</a>
|
|
||||||
<button type="submit" name="btn_install" class="btn btn-success btn-custom pull-right">Finish</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
+13
-50
@@ -1,12 +1,3 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
if (!file_exists('../config/config.php')) {
|
|
||||||
header("Location: index.php");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
@@ -14,7 +5,7 @@ if (!file_exists('../config/config.php')) {
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>PHP Dynamic Qr code - Installer</title>
|
<title>PHP Dynamic Qr code - Setup</title>
|
||||||
<!-- Bootstrap CSS -->
|
<!-- Bootstrap CSS -->
|
||||||
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
|
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
|
||||||
<link href="https://fonts.googleapis.com/css?family=Poppins:400,500,700" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css?family=Poppins:400,500,700" rel="stylesheet">
|
||||||
@@ -36,52 +27,25 @@ if (!file_exists('../config/config.php')) {
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
|
|
||||||
<div class="install-box">
|
<div class="install-box">
|
||||||
|
|
||||||
|
|
||||||
<div class="steps">
|
|
||||||
<div class="step-progress">
|
|
||||||
<div class="step-progress-line" data-now-value="100" data-number-of-steps="5" style="width: 100%;"></div>
|
|
||||||
</div>
|
|
||||||
<div class="step">
|
|
||||||
<div class="step-icon"><i class="fa fa-code"></i></div>
|
|
||||||
<p>Start</p>
|
|
||||||
</div>
|
|
||||||
<div class="step">
|
|
||||||
<div class="step-icon"><i class="fa fa-folder-open"></i></div>
|
|
||||||
<p>Folder Permissions</p>
|
|
||||||
</div>
|
|
||||||
<div class="step">
|
|
||||||
<div class="step-icon"><i class="fa fa-database"></i></div>
|
|
||||||
<p>Database</p>
|
|
||||||
</div>
|
|
||||||
<div class="step active">
|
|
||||||
<div class="step-icon"><i class="fa fa-user"></i></div>
|
|
||||||
<p>Finish</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="step-contents">
|
<div class="step-contents">
|
||||||
<div class="tab-1">
|
<div class="tab-1">
|
||||||
<h1 class="step-title">Finish</h1>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
<p style="font-size: 18px">
|
||||||
<p style="font-size: 18px"><strong>The installation was successful.</strong><br> Keep the documentation handy and log in to the control panel by entering the default credentials:<br><br>
|
<strong>The installation was successful.</strong>
|
||||||
|
<br>
|
||||||
|
Keep the documentation handy and log in to the control panel by entering the default credentials:
|
||||||
|
<br><br>
|
||||||
|
<b>superadmin</b><br>
|
||||||
|
<b>superadmin</b><br><br>
|
||||||
|
We recommend that you create a new superadmin user and to delete the default one mentioned above.<br><br>
|
||||||
|
|
||||||
<b>superadmin</b><br>
|
<b>N.B.</b> Remember to delete the "install" folder otherwise you could accidentally start the installation procedure again, deleting all the saves in the database</p>
|
||||||
<b>superadmin</b><br><br>
|
|
||||||
|
|
||||||
We recommend that you create a new superadmin user and to delete the default one mentioned above.<br><br>
|
|
||||||
|
|
||||||
<b>N.B.</b> Remember to delete the "install" folder otherwise you could accidentally start the installation procedure again, deleting all the saves in the database</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="buttons">
|
|
||||||
|
|
||||||
<a href="../login.php" class="btn btn-success btn-custom pull-right">Log in</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="buttons">
|
||||||
|
<a href="../login.php" class="btn btn-success btn-custom pull-right">Log in</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -91,6 +55,5 @@ We recommend that you create a new superadmin user and to delete the default one
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>PHP Dynamic Qr code - Installer</title>
|
|
||||||
<!-- Bootstrap CSS -->
|
|
||||||
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Poppins:400,500,700" rel="stylesheet">
|
|
||||||
<!-- Font-awesome CSS -->
|
|
||||||
<link href="assets/css/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
|
|
||||||
<link rel="stylesheet" href="assets/css/style.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-8 col-sm-12 col-md-offset-2">
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12 logo-cnt">
|
|
||||||
<img src="assets/img/DynamicQRCode_BlackWhite.png">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
|
|
||||||
<div class="install-box">
|
|
||||||
|
|
||||||
|
|
||||||
<div class="steps">
|
|
||||||
<div class="step-progress">
|
|
||||||
<div class="step-progress-line" data-now-value="50" data-number-of-steps="5" style="width: 50%;"></div>
|
|
||||||
</div>
|
|
||||||
<div class="step">
|
|
||||||
<div class="step-icon"><i class="fa fa-code"></i></div>
|
|
||||||
<p>Start</p>
|
|
||||||
</div>
|
|
||||||
<div class="step active">
|
|
||||||
<div class="step-icon"><i class="fa fa-folder-open"></i></div>
|
|
||||||
<p>Folder Permissions</p>
|
|
||||||
</div>
|
|
||||||
<div class="step">
|
|
||||||
<div class="step-icon"><i class="fa fa-database"></i></div>
|
|
||||||
<p>Database</p>
|
|
||||||
</div>
|
|
||||||
<div class="step">
|
|
||||||
<div class="step-icon"><i class="fa fa-user"></i></i></div>
|
|
||||||
<p>Finish</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="step-contents">
|
|
||||||
<div class="tab-1">
|
|
||||||
<h1 class="step-title">Folder Permissions</h1>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<p><i class="fa fa-folder-open"></i> /config</p>
|
|
||||||
<p><i class="fa fa-folder-open"></i> /saved_qrcode</p>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6 text-right">
|
|
||||||
<p><?php if (is_writable('../config')) { ?><i class="fa fa-check color-success"></i><?php } else { ?><i class="fa fa-close color-danger"></i><?php } ?></p>
|
|
||||||
<p><?php if (is_writable('../saved_qrcode')) { ?><i class="fa fa-check color-success"></i><?php } else { ?><i class="fa fa-close color-danger"></i><?php } ?></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="buttons">
|
|
||||||
<a href="index.php" class="btn btn-success btn-custom pull-left">Prev</a>
|
|
||||||
|
|
||||||
<a href="database.php" class="btn btn-success btn-custom pull-right">Next</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
/**
|
|
||||||
* PHP Dynamic Qr code
|
|
||||||
*
|
|
||||||
* @author Giandonato Inverso <info@giandonatoinverso.it>
|
|
||||||
* @copyright Copyright (c) 2020-2021
|
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
|
||||||
* @link https://github.com/giandonatoinverso/PHP-Dynamic-Qr-code
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
<?php
|
|
||||||
|
|
||||||
class Core {
|
|
||||||
|
|
||||||
// Function to validate the post data
|
|
||||||
function validate_post($data)
|
|
||||||
{
|
|
||||||
/* Validating the hostname, the database name and the username. The password is optional. */
|
|
||||||
return !empty($data['db_host']) && !empty($data['db_user']) && !empty($data['db_name']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to show an error
|
|
||||||
function show_message($type,$message) {
|
|
||||||
return $message;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to write the config file
|
|
||||||
function write_config($data) {
|
|
||||||
|
|
||||||
// Config path
|
|
||||||
$template_path = 'config/database.php';
|
|
||||||
$output_path = '../config/config.php';
|
|
||||||
|
|
||||||
// Open the file
|
|
||||||
$database_file = file_get_contents($template_path);
|
|
||||||
|
|
||||||
$new = str_replace("%HOSTNAME%",$data['db_host'],$database_file);
|
|
||||||
$new = str_replace("%USERNAME%",$data['db_user'],$new);
|
|
||||||
$new = str_replace("%PASSWORD%",$data['db_password'],$new);
|
|
||||||
$new = str_replace("%DATABASE%",$data['db_name'],$new);
|
|
||||||
|
|
||||||
// Write the new database.php file
|
|
||||||
$handle = fopen($output_path,'w+');
|
|
||||||
|
|
||||||
// Chmod the file, in case the user forgot
|
|
||||||
@chmod($output_path,0777);
|
|
||||||
|
|
||||||
// Verify file permissions
|
|
||||||
if(is_writable($output_path)) {
|
|
||||||
|
|
||||||
// Write the file
|
|
||||||
if(fwrite($handle,$new)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +1,28 @@
|
|||||||
/**
|
|
||||||
* PHP Dynamic Qr code
|
|
||||||
*
|
|
||||||
* @author Giandonato Inverso <info@giandonatoinverso.it>
|
|
||||||
* @copyright Copyright (c) 2020-2021
|
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
|
||||||
* @link https://github.com/giandonatoinverso/PHP-Dynamic-Qr-code
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* PHP Dynamic Qr code
|
||||||
|
*
|
||||||
|
* @author Giandonato Inverso <info@giandonatoinverso.it>
|
||||||
|
* @copyright Copyright (c) 2020-2021
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://github.com/giandonatoinverso/PHP-Dynamic-Qr-code
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
class Database {
|
class Database {
|
||||||
|
|
||||||
// Function to the database and tables and fill them with the default data
|
// Function to the database and tables and fill them with the default data
|
||||||
function create_database($data)
|
function create_database($db_host, $db_user, $db_password, $db_name, $db_port)
|
||||||
{
|
{
|
||||||
// Connect to the database
|
// Connect to the database
|
||||||
$mysqli = new mysqli($data['db_host'],$data['db_user'],$data['db_password'],'');
|
$mysqli = new mysqli($db_host,$db_user,$db_password,'', $db_port);
|
||||||
|
|
||||||
// Check for errors
|
// Check for errors
|
||||||
if(mysqli_connect_errno())
|
if(mysqli_connect_errno())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create the prepared statement
|
// Create the prepared statement
|
||||||
$mysqli->query("CREATE DATABASE IF NOT EXISTS ".$data['db_name']);
|
$mysqli->query("CREATE DATABASE IF NOT EXISTS ".$db_name);
|
||||||
|
|
||||||
// Close the connection
|
// Close the connection
|
||||||
$mysqli->close();
|
$mysqli->close();
|
||||||
@@ -31,10 +31,10 @@ class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Function to create the tables and fill them with the default data
|
// Function to create the tables and fill them with the default data
|
||||||
function create_tables($data)
|
function create_tables($db_host, $db_user, $db_password, $db_name, $db_port)
|
||||||
{
|
{
|
||||||
// Connect to the database
|
// Connect to the database
|
||||||
$mysqli = new mysqli($data['db_host'],$data['db_user'],$data['db_password'],$data['db_name']);
|
$mysqli = new mysqli($db_host,$db_user,$db_password,$db_name, $db_port);
|
||||||
|
|
||||||
// Check for errors
|
// Check for errors
|
||||||
if(mysqli_connect_errno())
|
if(mysqli_connect_errno())
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>PHP Dynamic Qr code - Installer</title>
|
|
||||||
<!-- Bootstrap CSS -->
|
|
||||||
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Poppins:400,500,700" rel="stylesheet">
|
|
||||||
<!-- Font-awesome CSS -->
|
|
||||||
<link href="assets/css/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
|
|
||||||
<link rel="stylesheet" href="assets/css/style.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-8 col-sm-12 col-md-offset-2">
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12 logo-cnt">
|
|
||||||
<!--<h1>PHP Dynamic Qr code Generator</h1>-->
|
|
||||||
<img src="assets/img/DynamicQRCode_BlackWhite.png">
|
|
||||||
<!--<p>Welcome to the Installer</p>-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
|
|
||||||
<div class="install-box">
|
|
||||||
|
|
||||||
|
|
||||||
<div class="steps">
|
|
||||||
<div class="step-progress">
|
|
||||||
<div class="step-progress-line" data-now-value="28" data-number-of-steps="5" style="width: 28%;"></div>
|
|
||||||
</div>
|
|
||||||
<div class="step active">
|
|
||||||
<div class="step-icon"><i class="fa fa-code"></i></div>
|
|
||||||
<p>Start</p>
|
|
||||||
</div>
|
|
||||||
<div class="step">
|
|
||||||
<div class="step-icon"><i class="fa fa-folder-open"></i></div>
|
|
||||||
<p>Folder Permissions</p>
|
|
||||||
</div>
|
|
||||||
<div class="step">
|
|
||||||
<div class="step-icon"><i class="fa fa-database"></i></div>
|
|
||||||
<p>Database</p>
|
|
||||||
</div>
|
|
||||||
<div class="step">
|
|
||||||
<div class="step-icon"><i class="fa fa-user"></i></div>
|
|
||||||
<p>Finish</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="step-contents">
|
|
||||||
<div class="tab-1">
|
|
||||||
<h1 class="step-title">System Requirements</h1>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-11">
|
|
||||||
<p>
|
|
||||||
<span class="req-span"><i class="fa fa-circle"></i> PHP Version:</span>
|
|
||||||
<?php if (phpversion() >= 5.6): ?>
|
|
||||||
<strong class="color-success"><?php echo phpversion(); ?></strong>
|
|
||||||
<?php else: ?>
|
|
||||||
<strong class="color-danger"><?php echo phpversion(); ?> <small>(Your PHP version must be 5.6 or greater)</small>
|
|
||||||
</strong>
|
|
||||||
<?php endif; ?>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<span class="req-span"><i class="fa fa-circle"></i> cURL PHP Extension:</span>
|
|
||||||
<?php if (extension_loaded('curl')): ?>
|
|
||||||
<strong class="color-success">Enabled</strong>
|
|
||||||
<?php else: ?>
|
|
||||||
<strong class="color-danger">Disabled <small>(You should enable "cURL" in your server)</small>
|
|
||||||
</strong>
|
|
||||||
<?php endif; ?>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-1 text-right">
|
|
||||||
<p>
|
|
||||||
<?php if (phpversion() >= 5.6): ?>
|
|
||||||
<i class="fa fa-check color-success"></i>
|
|
||||||
<?php else: ?>
|
|
||||||
<i class="fa fa-times color-danger"></i>
|
|
||||||
<?php endif; ?>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<?php if (extension_loaded('curl')): ?>
|
|
||||||
<i class="fa fa-check color-success"></i>
|
|
||||||
<?php else: ?>
|
|
||||||
<i class="fa fa-times color-danger"></i>
|
|
||||||
<?php endif; ?>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="buttons">
|
|
||||||
|
|
||||||
<a href="folder-permissions.php" class="btn btn-success btn-custom pull-right">Next</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHP Dynamic Qr code
|
||||||
|
*
|
||||||
|
* @author Giandonato Inverso <info@giandonatoinverso.it>
|
||||||
|
* @copyright Copyright (c) 2020-2021
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://github.com/giandonatoinverso/PHP-Dynamic-Qr-code
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once ('../config/environment.php');
|
||||||
|
require_once('includes/database_class.php');
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| CHECK REQUIREMENTS
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!(phpversion() >= 5.6)) {
|
||||||
|
echo "Installation failed. A php version> = 5.6 is required";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extension_loaded('curl')) {
|
||||||
|
echo "Installation failed. The curl extension is required";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| CHECK FOLDER PERMISSION
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!is_writable('../saved_qrcode')) {
|
||||||
|
echo "Installation failed. The folder where you save the qrcodes must have write permissions";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| DATABASE CREATION
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
$database = new Database();
|
||||||
|
|
||||||
|
if (!$database->create_database(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT)) {
|
||||||
|
echo "The database could not be created, please check your database credentials!";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
else if (!$database->create_tables(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT)) {
|
||||||
|
echo "The database tables could not be created, please check your database credentials!";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no errors, redirect to index
|
||||||
|
header("Refresh: 1; finish.php");
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user