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.