diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index ebfa217..a9c1932 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -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 diff --git a/documentation/index.html b/documentation/index.html index 635ea65..b8eb1d2 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -67,7 +67,7 @@
@@ -86,18 +86,12 @@

Installation

Follow these steps to install the script:

    -
  1. Extract the zip archive to your server
  2. -
  3. Open the /install/ folder in the browser
  4. -

    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.

    - -
  5. Check folder permissions
  6. -

    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.

    - -
  7. Enter your database credentials. Click next.
  8. -

    - +
  9. Clone the project from github
  10. +
  11. Edit the yaml file for docker or manually enter the credentials you want in the /config/environment.php file
  12. +
  13. Launch the setup file in your browser /install/setup.php
  14. +

    The script checks the requirements, write permissions on the generated folders and creates a database with sample data

  15. Finish
  16. -

    The installation is finished and you can access the control panel.

    +

    If all went well you will see a summary screen with a login button. Alternatively, you will get an error message

diff --git a/qrcode/install/config/database.php b/qrcode/config/config.php old mode 100644 new mode 100755 similarity index 67% rename from qrcode/install/config/database.php rename to qrcode/config/config.php index 2c48784..cea86f7 --- a/qrcode/install/config/database.php +++ b/qrcode/config/config.php @@ -1,5 +1,7 @@ DATABASE_HOST, + 'username' => DATABASE_USER, + 'password' => DATABASE_PASSWORD, + 'db'=> DATABASE_NAME, + 'port' => DATABASE_PORT, + 'prefix' => DATABASE_PREFIX, + 'charset' => DATABASE_CHARSET)); } diff --git a/qrcode/config/environment.php b/qrcode/config/environment.php new file mode 100644 index 0000000..4dcf888 --- /dev/null +++ b/qrcode/config/environment.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/qrcode/install/database.php b/qrcode/install/database.php deleted file mode 100644 index 63012e3..0000000 --- a/qrcode/install/database.php +++ /dev/null @@ -1,163 +0,0 @@ -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.'); - } -} - -?> - - - - - - - - - PHP Dynamic Qr code - Installer - - - - - - - - - -
-
-
- -
-
- -
-
- -
-
- -
-
-
-
-
-
-
-

Start

-
-
-
-

Folder Permissions

-
-
-
-

Database

-
-
-
-

Finish

-
-
- -
- -
- -
- - -
- The database is being created. Please wait! -
- -
- -
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-

Database

-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
- Prev - -
-
-
-
-
-
-
-
-
-
- - - diff --git a/qrcode/install/finish.php b/qrcode/install/finish.php index 2abb5e7..da5ddd8 100644 --- a/qrcode/install/finish.php +++ b/qrcode/install/finish.php @@ -1,12 +1,3 @@ - - @@ -14,7 +5,7 @@ if (!file_exists('../config/config.php')) { - PHP Dynamic Qr code - Installer + PHP Dynamic Qr code - Setup @@ -36,52 +27,25 @@ if (!file_exists('../config/config.php')) {
-
- - -
-
-
-
-
-
-

Start

-
-
-
-

Folder Permissions

-
-
-
-

Database

-
-
-
-

Finish

-
-
-
-

Finish

- -

The installation was successful.
Keep the documentation handy and log in to the control panel by entering the default credentials:

+

+ The installation was successful. +
+ Keep the documentation handy and log in to the control panel by entering the default credentials: +

+ superadmin
+ superadmin

+ We recommend that you create a new superadmin user and to delete the default one mentioned above.

-superadmin
-superadmin

- -We recommend that you create a new superadmin user and to delete the default one mentioned above.

- -N.B. Remember to delete the "install" folder otherwise you could accidentally start the installation procedure again, deleting all the saves in the database

-
- -
- - Log in + N.B. Remember to delete the "install" folder otherwise you could accidentally start the installation procedure again, deleting all the saves in the database

+
+ Log in +
@@ -91,6 +55,5 @@ We recommend that you create a new superadmin user and to delete the default one
- diff --git a/qrcode/install/folder-permissions.php b/qrcode/install/folder-permissions.php deleted file mode 100644 index 2c743d6..0000000 --- a/qrcode/install/folder-permissions.php +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - PHP Dynamic Qr code - Installer - - - - - - - - - -
-
-
- -
-
- -
-
- -
-
- -
- - -
-
-
-
-
-
-

Start

-
-
-
-

Folder Permissions

-
-
-
-

Database

-
-
-
-

Finish

-
-
- -
-
-

Folder Permissions

-
-
-

/config

-

/saved_qrcode

-
-
-

-

-
-
-
- Prev - - Next -
-
-
- -
-
-
-
-
-
- - - - diff --git a/qrcode/install/includes/core_class.php b/qrcode/install/includes/core_class.php deleted file mode 100644 index 3716125..0000000 --- a/qrcode/install/includes/core_class.php +++ /dev/null @@ -1,61 +0,0 @@ -/** -* PHP Dynamic Qr code -* -* @author Giandonato Inverso -* @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 -*/ - -* @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 -*/ + * @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()) diff --git a/qrcode/install/index.php b/qrcode/install/index.php deleted file mode 100644 index 5c915ee..0000000 --- a/qrcode/install/index.php +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - PHP Dynamic Qr code - Installer - - - - - - - - - -
-
-
- -
-
- - - -
-
- -
-
- -
- - -
-
-
-
-
-
-

Start

-
-
-
-

Folder Permissions

-
-
-
-

Database

-
-
-
-

Finish

-
-
- -
-
-

System Requirements

-
-
-

-    PHP Version: - = 5.6): ?> - - -  (Your PHP version must be 5.6 or greater) - - -

-

-    cURL PHP Extension: - - Enabled - - Disabled (You should enable "cURL" in your server) - - -

- -
-
-

- = 5.6): ?> - - - - -

-

- - - - - -

- -
-
- -
- - Next -
- -
-
-
-
-
-
-
-
- - - - diff --git a/qrcode/install/setup.php b/qrcode/install/setup.php new file mode 100644 index 0000000..f16f6ee --- /dev/null +++ b/qrcode/install/setup.php @@ -0,0 +1,62 @@ + + * @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"); + +?> \ No newline at end of file