Refactoring docker image building, NEW: added docker compose support

Signed-off-by: giandonato.inverso@edempg.it <giandonato.inverso@studenti.unimi.it>
This commit is contained in:
Giandonato Inverso
2023-10-16 19:49:29 +02:00
committed by giandonato.inverso@edempg.it
parent 5335b6fb7e
commit 68a2b9f7f3
19 changed files with 141 additions and 208 deletions
+25 -5
View File
@@ -5,10 +5,29 @@ require_once 'config/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$db = getDbInstance();
$json = json_decode(file_get_contents('php://input'), true);
$action = filter_var($json['action'], FILTER_SANITIZE_STRING);
if (isset($json['action'])) {
$action = filter_var($json['action'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
} else {
echo json_encode([
'data' => 'Missing action field in the request.',
'status' => 400
]);
exit();
}
$params = $json['params'];
$files = [];
$type = filter_var($json['type'], FILTER_SANITIZE_STRING);
if (isset($json['type'])) {
$type = filter_var($json['type'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
} else {
echo json_encode([
'data' => 'Type action field in the request.',
'status' => 400
]);
exit();
}
if (count($params) == 0) {
echo json_encode([
@@ -25,9 +44,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
$zip = new ZipArchive();
$relative_dir = SAVED_QRCODE_FOLDER. 'zip/qrcodes_'. $_SESSION['user_id'] .'.zip';
unlink($relative_dir);
$url_path = SAVED_QRCODE_URL . 'zip/qrcodes_'. $_SESSION['user_id'] .'.zip';
$uniqid = uniqid();
$relative_dir = SAVED_QRCODE_FOLDER. 'zip/qrcodes_'. $uniqid .'.zip';
@unlink($relative_dir);
$url_path = SAVED_QRCODE_URL . 'zip/qrcodes_'. $uniqid .'.zip';
$zip->open($relative_dir, ZipArchive::CREATE);
foreach ($files as $file) {
@@ -4,27 +4,22 @@
| DOCKER INSTALLATION
|--------------------------------------------------------------------------
*/
$docker_cid = getenv('DOCKER_CID');
if(is_string($docker_cid)) {
if(is_string(Getenv('TYPE')) && Getenv('TYPE') == "docker") {
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'));
// This must have a trailing underscore.
// Example: qr_
define('DATABASE_PREFIX', Getenv('DATABASE_PREFIX'));
define('DATABASE_PREFIX', Getenv('DATABASE_PREFIX')); // This must have a trailing underscore. Example: qr_
define('DATABASE_CHARSET', Getenv('DATABASE_CHARSET'));
} else {
define('DATABASE_HOST', "mariadb");
define('DATABASE_HOST', "localhost");
define('DATABASE_PORT', "3306");
define('DATABASE_NAME', "qrcode");
define('DATABASE_USER', "root");
define('DATABASE_PASSWORD', "root");
// This must have a trailing underscore.
// Example: qr_
define('DATABASE_PREFIX', "");
define('DATABASE_PREFIX', ""); // This must have a trailing underscore. Example: qr_
define('DATABASE_CHARSET', "utf8");
}
/*
+2 -2
View File
@@ -453,7 +453,7 @@
});
const data = {
action: $('select[name=bulk-action]').val(),
action: 'download',
params: params,
type: $('input[name=type]').val()
}
@@ -478,7 +478,7 @@
},
error: (err) => {
$('#err-msg').empty();
$('#err-msg').append('<i class="fas fa-exclamation-circle"></i> ' + res.data);
$('#err-msg').append('<i class="fas fa-exclamation-circle"></i> ' + err.responseText);
$('#err-msg').css('display', 'block');
console.log(err);
}
+1 -1
View File
@@ -9,7 +9,7 @@
<strong>Copyright &copy; <?php echo date("Y");?> <a href="#">PHP Qrcode Generator</a> - </strong>
All rights reserved by Giandonato Inverso.
<div class="float-right d-none d-sm-inline-block">
<b>Version</b> 2.1.0
<b>Version</b> 2.2.0
</div>
</footer>
</div>
+20 -20
View File
@@ -23,7 +23,7 @@ INSERT INTO `#prefix#users` (`id`, `username`, `password`, `series_id`, `remembe
CREATE TABLE IF NOT EXISTS `#prefix#dynamic_qrcodes` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`id_owner` int(25) NOT NULL AUTO_INCREMENT,
`id_owner` int(25) NULL DEFAULT NULL,
`filename` varchar(45) NOT NULL,
`format` varchar(45) DEFAULT NULL,
`identifier` longtext,
@@ -39,16 +39,16 @@ CREATE TABLE IF NOT EXISTS `#prefix#dynamic_qrcodes` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;
INSERT INTO `#prefix#dynamic_qrcodes` (`id`, `id_owner`, `filename`, `format`, `identifier`, `link`, `qrcode`, `scan`, `state`, `created_by`, `created_at`, `updated_by`, `updated_at`) VALUES
(1, 0, 'Facebook', 'png', 'rcCeC', 'https://facebook.com', 'Facebook.png', 0, 'enable', 0, '2020-09-01 15:35:13', 0, NULL),
(2, 0, 'Amazon', 'png', 'F7GOY6', 'https://amazon.com', 'Amazon.png', 0, 'enable', 0, '2020-09-01 15:40:34', 0, NULL),
(3, 0, 'Youtube', 'png', '8dK5Nd', 'https://youtube.com', 'Youtube.png', 0, 'enable', 0, '2020-09-01 15:41:43', 0, NULL),
(4, 0, 'Apple', 'jpg', '7zxTKn', 'https://apple.com', 'Apple.jpg', 0, 'enable', 0, '2020-09-01 15:44:20', 0, NULL),
(5, 0, 'Ebay', 'svg', 'a4F3kr', 'https://ebay.com', 'Ebay.svg', 0, 'enable', 0, '2020-09-01 15:44:46', 0, NULL),
(6, 0, 'Google', 'png', 'saJV1y', 'https://google.it', 'Google.png', 0, 'enable', 0, '2020-09-01 15:46:37', 0, NULL);
(1, 1, 'Facebook', 'png', 'rcCeC', 'https://facebook.com', 'Facebook.png', 0, 'enable', 0, '2020-09-01 15:35:13', 0, NULL),
(2, 1, 'Amazon', 'png', 'F7GOY6', 'https://amazon.com', 'Amazon.png', 0, 'enable', 0, '2020-09-01 15:40:34', 0, NULL),
(3, 1, 'Youtube', 'png', '8dK5Nd', 'https://youtube.com', 'Youtube.png', 0, 'enable', 0, '2020-09-01 15:41:43', 0, NULL),
(4, 1, 'Apple', 'jpg', '7zxTKn', 'https://apple.com', 'Apple.jpg', 0, 'enable', 0, '2020-09-01 15:44:20', 0, NULL),
(5, 1, 'Ebay', 'svg', 'a4F3kr', 'https://ebay.com', 'Ebay.svg', 0, 'enable', 0, '2020-09-01 15:44:46', 0, NULL),
(6, 1, 'Google', 'png', 'saJV1y', 'https://google.it', 'Google.png', 0, 'enable', 0, '2020-09-01 15:46:37', 0, NULL);
CREATE TABLE IF NOT EXISTS `#prefix#static_qrcodes` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`id_owner` int(25) NOT NULL AUTO_INCREMENT,
`id_owner` int(25) NULL DEFAULT NULL,
`filename` varchar(45) CHARACTER SET utf8 NOT NULL,
`format` varchar(45) DEFAULT NULL,
`type` varchar(45) CHARACTER SET utf8 DEFAULT NULL,
@@ -63,18 +63,18 @@ CREATE TABLE IF NOT EXISTS `#prefix#static_qrcodes` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
INSERT INTO `#prefix#static_qrcodes` (`id`, `id_owner`, `filename`, `format`, `type`, `content`, `qrcode`, `state`, `created_by`, `created_at`, `updated_by`, `updated_at`) VALUES
(1, 0, 'Text qr code', 'png', 'text', '<strong>Text:</strong> My first text', 'Text qr code.png', 'enable', 0, '2020-08-24 08:41:31', 0, NULL),
(2, 0, 'Email', 'jpg', 'email', '<strong>Email:</strong> assistance@domain.com<br><strong>Subject:</strong> Assistance request<br><strong>Message:</strong> Regarding my order N ° ... I require assistance', 'Email.jpg', 'enable', 0, '2020-08-24 08:44:13', 0, NULL),
(3, 0, 'Call me', 'png', 'phone', '<strong>Phone number:</strong> 12563776756', 'Call me.png', 'enable', 0, '2020-08-24 08:45:10', 0, NULL),
(4, 0, 'Send sms', 'png', 'sms', '<strong>Phone number:</strong> 12563776756<br><strong>Message:</strong> Test message', 'Send sms.png', 'enable', 0, '2020-08-24 08:46:52', 0, NULL),
(5, 0, 'wa.me', 'svg', 'whatsapp', '<strong>Phone number:</strong> 12563776756<br><strong>Message:</strong> Hey there! I am using WhatsApp', 'wa.me.svg', 'enable', 0, '2020-08-24 08:47:49', 0, NULL),
(6, 0, 'New York', 'png', 'location', '<strong>Latitude:</strong> 40.7127753<br><strong>Longitude:</strong> -74.0059728', 'New York.png', 'enable', 0, '2020-08-24 08:51:55', 0, NULL),
(7, 0, 'John Doe', 'png', 'vcard', '<div class="row"><div class="col-sm-4"><strong>Full name:</strong> John Doe<br><strong>Nickname:</strong> John<br><strong>Email:</strong> john@domain.com<br><strong>Website:</strong> https://johndoe.com</div><div class="col-sm-4"><strong>Company:</strong> Doe Inc.<br><strong>Role:</strong> CEO<br><strong>Categories:</strong> electronics, vcard<br><strong>Note:</strong> </div><div class="col-sm-4"><strong>Phone:</strong> 412-999-9988<br><strong>Home Phone:</strong> 412-999-5555<br><strong>Work phone:</strong> 412-444-2222<br><strong>Address:</strong> 123 Main Street&nbsp;Anywhere&nbsp;15523&nbsp;Arizona</div></div>', 'John Doe.png', 'enable', 0, '2020-08-24 08:55:59', 0, NULL),
(8, 0, 'Boat party', 'png', 'event', '<div class="row"><div class="col-sm-4"><strong>Title:</strong> Party with friends<br><strong>Start event:</strong> 2020-08-26 09:00 AM<br><strong>End event:</strong> 2020-08-26 03:00 PM<br></div><div class="col-sm-4"><strong>Location:</strong> New York<br><strong>Description:</strong> Happy Birthday Carl!<br><strong>URL:</strong> </div></div>', 'Boat party.png', 'enable', 0, '2020-08-24 08:58:20', 0, NULL),
(9, 0, 'Save me', 'svg', 'bookmark', '<strong>Title:</strong> Google search<br><strong>Url:</strong> https://google.it', 'Save me.svg', 'enable', 0, '2020-08-24 08:59:46', 0, NULL),
(10, 0, 'Free wifi', 'png', 'wifi', '<strong>Encryption:</strong> WPA<br><strong>SSID:</strong> TP-LINK-AB123<br><strong>Password:</strong> bBB8MR7TwbbUWMZT', 'Free wifi.png', 'enable', 0, '2020-08-24 09:02:35', 0, NULL),
(11, 0, 'Pay here', 'png', 'paypal', '<div class="row"><div class="col-sm-4"><strong>Payment type:</strong> _click<br><strong>Email:</strong> paypal@domain.com<br><strong>Item name:</strong> T-shirt<br><strong>Item id:</strong> 177</div><div class="col-sm-4"><strong>Amount:</strong> 15<br><strong>Currency:</strong> USD<br><strong>Shipping:</strong> 4<br><strong>Tax rate:</strong> </div></div>', 'Pay here.png', 'enable', 0, '2020-08-24 09:04:13', 0, NULL),
(12, 0, 'Send BTC ', 'jpg', 'bitcoin', '<strong>BTC address:</strong> 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa<br><strong>Amount:</strong> 1<br><strong>Label:</strong> <br><strong>Message:</strong> ', 'Send BTC .jpg', 'enable', 0, '2020-09-01 10:51:08', 0, NULL);
(1, 1, 'Text qr code', 'png', 'text', '<strong>Text:</strong> My first text', 'Text qr code.png', 'enable', 0, '2020-08-24 08:41:31', 0, NULL),
(2, 1, 'Email', 'jpg', 'email', '<strong>Email:</strong> assistance@domain.com<br><strong>Subject:</strong> Assistance request<br><strong>Message:</strong> Regarding my order N ° ... I require assistance', 'Email.jpg', 'enable', 0, '2020-08-24 08:44:13', 0, NULL),
(3, 1, 'Call me', 'png', 'phone', '<strong>Phone number:</strong> 12563776756', 'Call me.png', 'enable', 0, '2020-08-24 08:45:10', 0, NULL),
(4, 1, 'Send sms', 'png', 'sms', '<strong>Phone number:</strong> 12563776756<br><strong>Message:</strong> Test message', 'Send sms.png', 'enable', 0, '2020-08-24 08:46:52', 0, NULL),
(5, 1, 'wa.me', 'svg', 'whatsapp', '<strong>Phone number:</strong> 12563776756<br><strong>Message:</strong> Hey there! I am using WhatsApp', 'wa.me.svg', 'enable', 0, '2020-08-24 08:47:49', 0, NULL),
(6, 1, 'New York', 'png', 'location', '<strong>Latitude:</strong> 40.7127753<br><strong>Longitude:</strong> -74.0059728', 'New York.png', 'enable', 0, '2020-08-24 08:51:55', 0, NULL),
(7, 1, 'John Doe', 'png', 'vcard', '<div class="row"><div class="col-sm-4"><strong>Full name:</strong> John Doe<br><strong>Nickname:</strong> John<br><strong>Email:</strong> john@domain.com<br><strong>Website:</strong> https://johndoe.com</div><div class="col-sm-4"><strong>Company:</strong> Doe Inc.<br><strong>Role:</strong> CEO<br><strong>Categories:</strong> electronics, vcard<br><strong>Note:</strong> </div><div class="col-sm-4"><strong>Phone:</strong> 412-999-9988<br><strong>Home Phone:</strong> 412-999-5555<br><strong>Work phone:</strong> 412-444-2222<br><strong>Address:</strong> 123 Main Street&nbsp;Anywhere&nbsp;15523&nbsp;Arizona</div></div>', 'John Doe.png', 'enable', 0, '2020-08-24 08:55:59', 0, NULL),
(8, 1, 'Boat party', 'png', 'event', '<div class="row"><div class="col-sm-4"><strong>Title:</strong> Party with friends<br><strong>Start event:</strong> 2020-08-26 09:00 AM<br><strong>End event:</strong> 2020-08-26 03:00 PM<br></div><div class="col-sm-4"><strong>Location:</strong> New York<br><strong>Description:</strong> Happy Birthday Carl!<br><strong>URL:</strong> </div></div>', 'Boat party.png', 'enable', 0, '2020-08-24 08:58:20', 0, NULL),
(9, 1, 'Save me', 'svg', 'bookmark', '<strong>Title:</strong> Google search<br><strong>Url:</strong> https://google.it', 'Save me.svg', 'enable', 0, '2020-08-24 08:59:46', 0, NULL),
(10, 1, 'Free wifi', 'png', 'wifi', '<strong>Encryption:</strong> WPA<br><strong>SSID:</strong> TP-LINK-AB123<br><strong>Password:</strong> bBB8MR7TwbbUWMZT', 'Free wifi.png', 'enable', 0, '2020-08-24 09:02:35', 0, NULL),
(11, 1, 'Pay here', 'png', 'paypal', '<div class="row"><div class="col-sm-4"><strong>Payment type:</strong> _click<br><strong>Email:</strong> paypal@domain.com<br><strong>Item name:</strong> T-shirt<br><strong>Item id:</strong> 177</div><div class="col-sm-4"><strong>Amount:</strong> 15<br><strong>Currency:</strong> USD<br><strong>Shipping:</strong> 4<br><strong>Tax rate:</strong> </div></div>', 'Pay here.png', 'enable', 0, '2020-08-24 09:04:13', 0, NULL),
(12, 1, 'Send BTC', 'jpg', 'bitcoin', '<strong>BTC address:</strong> 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa<br><strong>Amount:</strong> 1<br><strong>Label:</strong> <br><strong>Message:</strong> ', 'Send BTC .jpg', 'enable', 0, '2020-09-01 10:51:08', 0, NULL);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+6 -9
View File
@@ -25,16 +25,13 @@ if (isset($_COOKIE['series_id']) && isset($_COOKIE['remember_token']))
// User found. verify remember token
if (password_verify($remember_token, $row['remember_token']))
{
// Verify if expiry time is modified.
$expires = strtotime($row['expires']);
$expires = strtotime($row['expires']);
if (strtotime(date()) > $expires)
{
// Remember Cookie has expired.
clearAuthCookie();
header('Location: login.php');
exit;
}
if (time() > $expires) {
clearAuthCookie();
header('Location: login.php');
exit;
}
$_SESSION['user_logged_in'] = TRUE;
$_SESSION['type'] = $row['type'];
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

+2 -2
View File
@@ -30,14 +30,14 @@ if ($conn->query($sql) === TRUE) {
echo "Error renaming column: " . $conn->error . "<br>";
}
$sql = "ALTER TABLE " . DATABASE_PREFIX . "dynamic_qrcodes" . " ADD `id_owner` INT(25) NULL AFTER `id`";
$sql = "ALTER TABLE " . DATABASE_PREFIX . "dynamic_qrcodes" . " ADD `id_owner` INT(25) NULL DEFAULT NULL AFTER `id`";
if ($conn->query($sql) === TRUE) {
echo "The id_owner column has been added to dynamic_qrcodes successfully.<br>";
} else {
echo "Error adding column: " . $conn->error . "<br>";
}
$sql = "ALTER TABLE " . DATABASE_PREFIX . "static_qrcodes" . " ADD `id_owner` INT(25) NULL AFTER `id`";
$sql = "ALTER TABLE " . DATABASE_PREFIX . "static_qrcodes" . " ADD `id_owner` INT(25) NULL DEFAULT NULL AFTER `id`";
if ($conn->query($sql) === TRUE) {
echo "The id_owner column has been added to static_qrcodes successfully.<br>";
} else {