Merge remote-tracking branch 'origin/master'

# Conflicts:
#	docker/README.md
This commit is contained in:
nirpt
2022-08-28 13:22:12 +02:00
11 changed files with 147 additions and 531 deletions
+10 -7
View File
@@ -15,13 +15,16 @@ services:
ports:
- "8080:80"
user: "${PUID}:${PGID}"
#environment:
#ADMIN_USER: "superadmin" # not supported yet please see road map
#ADMIN_PASSWORD: "superadmin" # not supported yet please see road map
#DATABASE_HOST: "mariadb" # not supported yet please see road map
#DATABASE_NAME: "qrcode" # not supported yet please see road map
#DATABASE_USER: "qrcode" # not supported yet please see road map
#DATABASE_PASSWORD: "changeme" # not supported yet please see road map
environment:
ADMIN_USER: "superadmin"
ADMIN_PASSWORD: "superadmin"
DATABASE_HOST: "mariadb"
DATABASE_PORT: "3306"
DATABASE_NAME: "qrcode"
DATABASE_USER: "qrcode"
DATABASE_PASSWORD: "changeme"
DATABASE_PREFIX: ""
DATABASE_CHARSET: "utf8"
volumes:
- ./data/app/config:/var/www/html/config
- ./data/app/saved_qrcode:/var/www/html/saved_qrcode
+6 -12
View File
@@ -67,7 +67,7 @@
<div class="title" id="header">
<h1>PHP Dynamic Qr code - Generator of dynamic and static Qr code V1.0</h1>
<small> Documentation - Version 1.0 / Created: 24/08/2020 Last Update: </small>
<small> Documentation - Version 1.0 / Created: 24/08/2020 Last Update: 28/08/2022</small>
</div>
<div class="wrapper">
@@ -86,18 +86,12 @@
<h2> Installation</h2>
<p>Follow these steps to install the script:</p>
<ol><strong>
<li>Extract the zip archive to your server</li>
<li>Open the /install/ folder in the browser</li>
<p>Check system requirements. If one of these extensions is not enabled, you must enable it from your server settings. If all requirements are provided, click Next.</p>
<img src="assets/img/start.png" style="width: 75%; height: 75%">
<li>Check folder permissions</li>
<p>If a folder doesn't have read and write permissions you need to change the settings on your server. If all requirements are provided, click Next.</p>
<img src="assets/img/folder.png" style="width: 75%; height: 75%">
<li>Enter your database credentials. Click next.</li>
<p></p>
<img src="assets/img/database.png" style="width: 75%; height: 75%">
<li>Clone the project from github</li>
<li>Edit the yaml file for docker or manually enter the credentials you want in the /config/environment.php file</li>
<li>Launch the setup file in your browser /install/setup.php</li>
<p>The script checks the requirements, write permissions on the generated folders and creates a database with sample data</p>
<li>Finish</li>
<p>The installation is finished and you can access the control panel.</p>
<p>If all went well you will see a summary screen with a login button. Alternatively, you will get an error message</p>
</ol>
</div>
+10 -11
View File
@@ -1,5 +1,7 @@
<?php
require_once ('environment.php');
//Note: This file should be included first in every php page.
error_reporting(E_ALL);
ini_set('display_errors', 'On');
@@ -17,20 +19,17 @@ 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);
return new MysqliDb (Array (
'host' => DATABASE_HOST,
'username' => DATABASE_USER,
'password' => DATABASE_PASSWORD,
'db'=> DATABASE_NAME,
'port' => DATABASE_PORT,
'prefix' => DATABASE_PREFIX,
'charset' => DATABASE_CHARSET));
}
+32
View File
@@ -0,0 +1,32 @@
<?php
/*
|--------------------------------------------------------------------------
| DOCKER INSTALLATION
|--------------------------------------------------------------------------
*/
$docker_cid = getenv('DOCKER_CID');
if(is_string($docker_cid)) {
define('DATABASE_HOST', Getenv('DATABASE_HOST'));
define('DATABASE_PORT', filter_var(Getenv('DATABASE_PORT'), FILTER_VALIDATE_INT));
define('DATABASE_NAME', Getenv('DATABASE_NAME'));
define('DATABASE_USER', Getenv('DATABASE_USER'));
define('DATABASE_PASSWORD', Getenv('DATABASE_PASSWORD'));
define('DATABASE_PREFIX', Getenv('DATABASE_PREFIX'));
define('DATABASE_CHARSET', Getenv('DATABASE_CHARSET'));
} else {
define('DATABASE_HOST', "localhost");
define('DATABASE_PORT', "3306");
define('DATABASE_NAME', "qrcode");
define('DATABASE_USER', "root");
define('DATABASE_PASSWORD', "root");
define('DATABASE_PREFIX', "");
define('DATABASE_CHARSET', "utf8");
}
/*
|--------------------------------------------------------------------------
| INSTALLATION WITHOUT CONTAINER
|--------------------------------------------------------------------------
*/
?>
-163
View File
@@ -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
View File
@@ -1,12 +1,3 @@
<?php
if (!file_exists('../config/config.php')) {
header("Location: index.php");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
@@ -14,7 +5,7 @@ if (!file_exists('../config/config.php')) {
<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>
<title>PHP Dynamic Qr code - Setup</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">
@@ -36,52 +27,25 @@ if (!file_exists('../config/config.php')) {
<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="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="tab-1">
<h1 class="step-title">Finish</h1>
<div class="form-group">
<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>
<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>
<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>
<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>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>
<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>
</div>
@@ -91,6 +55,5 @@ We recommend that you create a new superadmin user and to delete the default one
</div>
</div>
</body>
</html>
-91
View File
@@ -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>
-61
View File
@@ -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;
}
}
}
+14 -14
View File
@@ -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 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 {
// 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
$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
if(mysqli_connect_errno())
return false;
// 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
$mysqli->close();
@@ -31,10 +31,10 @@ class Database {
}
// 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
$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
if(mysqli_connect_errno())
-122
View File
@@ -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>&nbsp;&nbsp;&nbsp;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(); ?>&nbsp;<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>&nbsp;&nbsp;&nbsp;cURL PHP Extension:</span>
<?php if (extension_loaded('curl')): ?>
<strong class="color-success">Enabled</strong>
<?php else: ?>
<strong class="color-danger">Disabled&nbsp;<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>
+62
View File
@@ -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");
?>