From 0360176490ed348ebd866566fc5a57147e75bb96 Mon Sep 17 00:00:00 2001 From: Giandonato Inverso <70962472+giandonatoinverso@users.noreply.github.com> Date: Tue, 17 Oct 2023 00:41:15 +0200 Subject: [PATCH] bug fix --- src/bulk_action.php | 4 ++-- src/config/config.php | 8 +++++++- src/dist/js/custom.js | 2 +- src/forms/form_dynamic_add.php | 2 ++ src/forms/form_dynamic_edit.php | 2 ++ src/forms/form_static_edit.php | 2 ++ src/forms/qrcode_options.php | 2 ++ src/includes/footer.php | 2 +- src/index.php | 10 +++++----- src/login.php | 1 + 10 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/bulk_action.php b/src/bulk_action.php index d0956c0..e59d302 100644 --- a/src/bulk_action.php +++ b/src/bulk_action.php @@ -30,7 +30,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { foreach ($params as $param) { $row = $db->where('id', $param); $row = $db->getOne("{$type}_qrcodes"); - $files[] = SAVED_QRCODE_FOLDER . $row['qrcode']; + @$files[] = SAVED_QRCODE_FOLDER . $row['qrcode']; } $zip = new ZipArchive(); @@ -41,7 +41,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $zip->open($relative_dir, ZipArchive::CREATE); foreach ($files as $file) { - $download_file = file_get_contents($file, true); + $download_file = @file_get_contents($file, true); $zip->addFromString(basename($file), $download_file); } diff --git a/src/config/config.php b/src/config/config.php index e1dd79e..e3633e7 100755 --- a/src/config/config.php +++ b/src/config/config.php @@ -6,6 +6,12 @@ error_reporting(E_ALL); ini_set('display_errors', 'On'); define('BASE_PATH', dirname(dirname(__FILE__))); define('CURRENT_PAGE', basename($_SERVER['REQUEST_URI'])); +define('SCRIPT_NAME', ltrim(dirname($_SERVER['SCRIPT_NAME']), '/')); + +if(SCRIPT_NAME === "") + define('SCRIPT_FOLDER', ""); +else + define('SCRIPT_FOLDER', "/" . SCRIPT_NAME); require_once BASE_PATH . '/lib/MysqliDb/MysqliDb.php'; require_once BASE_PATH . '/helpers/helpers.php'; @@ -14,7 +20,7 @@ require_once BASE_PATH . '/helpers/helpers.php'; //You can change the folder where the qr code will be saved define('SAVED_QRCODE_FOLDER', './saved_qrcode/'); define('SAVED_QRCODE_DIRECTORY', BASE_PATH.'/saved_qrcode/'); -define('SAVED_QRCODE_URL', base_url().'/saved_qrcode/'); +define('SAVED_QRCODE_URL', base_url(). SCRIPT_FOLDER .'/saved_qrcode/'); //You can change the page name for the redirect and the search parameter (the default is "id") define('READ_PATH', base_url().'/read.php?id='); diff --git a/src/dist/js/custom.js b/src/dist/js/custom.js index 19a57e1..256bbc2 100644 --- a/src/dist/js/custom.js +++ b/src/dist/js/custom.js @@ -459,7 +459,7 @@ } $.ajax({ - url: window.location.origin + '/bulk_action.php', + url: './bulk_action.php', method: "POST", data: JSON.stringify(data), dataType: "json", diff --git a/src/forms/form_dynamic_add.php b/src/forms/form_dynamic_add.php index e2723ec..6a40776 100644 --- a/src/forms/form_dynamic_add.php +++ b/src/forms/form_dynamic_add.php @@ -120,5 +120,7 @@ + + "/> diff --git a/src/forms/form_dynamic_edit.php b/src/forms/form_dynamic_edit.php index 868ceb3..b61b52e 100644 --- a/src/forms/form_dynamic_edit.php +++ b/src/forms/form_dynamic_edit.php @@ -58,6 +58,8 @@ + + "/> diff --git a/src/forms/form_static_edit.php b/src/forms/form_static_edit.php index 498ed53..9732d3e 100644 --- a/src/forms/form_static_edit.php +++ b/src/forms/form_static_edit.php @@ -31,6 +31,8 @@ + + "/> diff --git a/src/forms/qrcode_options.php b/src/forms/qrcode_options.php index 3594a36..d918862 100644 --- a/src/forms/qrcode_options.php +++ b/src/forms/qrcode_options.php @@ -104,5 +104,7 @@ + + "/>
\ No newline at end of file diff --git a/src/includes/footer.php b/src/includes/footer.php index ec78f93..9aa7a36 100644 --- a/src/includes/footer.php +++ b/src/includes/footer.php @@ -9,7 +9,7 @@ Copyright © PHP Qrcode Generator - All rights reserved by Giandonato Inverso.
- Version 2.2.0 + Version 2.2.1
diff --git a/src/index.php b/src/index.php index e1f35c3..5e7bc19 100644 --- a/src/index.php +++ b/src/index.php @@ -6,14 +6,14 @@ require_once 'includes/auth_validate.php'; $db = getDbInstance(); //Get Dynamic qr code rows -if($_SESSION['type'] !== 'super') { +if($_SESSION['type'] !== 'super') { $db->where("id_owner", $_SESSION['user_id']); $db->orWhere ("id_owner", NULL, 'IS'); } $numQrcode_dynamic = $db->getValue("dynamic_qrcodes", "count(*)"); //Get Static qr code rows -if($_SESSION['type'] !== 'super') { +if($_SESSION['type'] !== 'super') { $db->where("id_owner", $_SESSION['user_id']); $db->orWhere ("id_owner", NULL, 'IS'); } @@ -22,7 +22,7 @@ $numQrcode_static = $db->getValue("static_qrcodes", "count(*)"); $total = $numQrcode_dynamic + $numQrcode_static; //Get Total scan -if($_SESSION['type'] !== 'super') { +if($_SESSION['type'] !== 'super') { $db->where("id_owner", $_SESSION['user_id']); $db->orWhere ("id_owner", NULL, 'IS'); } @@ -32,8 +32,8 @@ $numScan = $db->getOne(DATABASE_PREFIX."dynamic_qrcodes", "sum(scan) as numScan" //I initialize the variables that will contain the daily values to 0 otherwise in the foreach loop they will be reset every time //Get the number of DYNAMIC qr code created in 7 days and total scan -if($_SESSION['type'] !== 'super') - $createdQrcode_dynamic = $db->query("select `created_at`, `scan` from " . DATABASE_PREFIX . "dynamic_qrcodes where `created_at` > curdate()-7 AND (`id_owner`=" . $_SESSION['user_id'] . " OR `id_owner` IS NULL);"); +if($_SESSION['type'] !== 'super') + $createdQrcode_dynamic = $db->query("select `created_at`, `scan` from " . DATABASE_PREFIX . "dynamic_qrcodes where `created_at` > curdate()-7 AND (`id_owner`= " . $_SESSION['user_id'] . " OR `id_owner` IS NULL);"); else $createdQrcode_dynamic = $db->query("select `created_at`, `scan` from ".DATABASE_PREFIX."dynamic_qrcodes where `created_at` > curdate()-7;"); diff --git a/src/login.php b/src/login.php index ed92009..7c6c46d 100644 --- a/src/login.php +++ b/src/login.php @@ -34,6 +34,7 @@ if (isset($_COOKIE['series_id']) && isset($_COOKIE['remember_token'])) } $_SESSION['user_logged_in'] = TRUE; + $_SESSION['user_id'] = $row['id']; $_SESSION['type'] = $row['type']; header('Location: index.php'); exit;