bug fix in read.php, bump version in footer, NEW: bulk delete
This commit is contained in:
@@ -6,6 +6,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$db = getDbInstance();
|
$db = getDbInstance();
|
||||||
$json = json_decode(file_get_contents('php://input'), true);
|
$json = json_decode(file_get_contents('php://input'), true);
|
||||||
|
|
||||||
|
if($json["action"] == "download") {
|
||||||
$params = $json['params'];
|
$params = $json['params'];
|
||||||
$files = [];
|
$files = [];
|
||||||
|
|
||||||
@@ -52,6 +53,49 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
'status' => 200
|
'status' => 200
|
||||||
]);
|
]);
|
||||||
exit();
|
exit();
|
||||||
|
} else if($json["action"] == "delete") {
|
||||||
|
$params = $json['params'];
|
||||||
|
$files = [];
|
||||||
|
|
||||||
|
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([
|
||||||
|
'data' => 'No qrcodes were selected.',
|
||||||
|
'status' => 400
|
||||||
|
]);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($type == "dynamic")
|
||||||
|
$instance = new DynamicQrcode();
|
||||||
|
else if($type == "static")
|
||||||
|
$instance = new StaticQrcode();
|
||||||
|
else
|
||||||
|
die("Type not allowed");
|
||||||
|
|
||||||
|
foreach ($params as $param) {
|
||||||
|
$a = 0;
|
||||||
|
$instance->deleteQrcode($param, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode([
|
||||||
|
'action' => "delete",
|
||||||
|
'data' => "Qrcode deleted",
|
||||||
|
'status' => 200
|
||||||
|
]);
|
||||||
|
exit();
|
||||||
|
|
||||||
|
} else
|
||||||
|
exit("Action not allowed");
|
||||||
} else {
|
} else {
|
||||||
exit('Direct access to this script not allowed.');
|
exit('Direct access to this script not allowed.');
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+5
-1
@@ -459,7 +459,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
action: 'download',
|
action: $('select[name=action]').val(),
|
||||||
params: params,
|
params: params,
|
||||||
type: $('input[name=type]').val()
|
type: $('input[name=type]').val()
|
||||||
}
|
}
|
||||||
@@ -472,8 +472,12 @@
|
|||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
|
if(data["action"] === "download") {
|
||||||
window.location.href = res.data;
|
window.location.href = res.data;
|
||||||
$('#err-msg').css('display', 'none');
|
$('#err-msg').css('display', 'none');
|
||||||
|
} else if(data["action"] === "delete") {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.status == 400) {
|
if (res.status == 400) {
|
||||||
|
|||||||
@@ -3,8 +3,20 @@
|
|||||||
<div id="err-msg"></div>
|
<div id="err-msg"></div>
|
||||||
<div class="bulk-action-wrapper">
|
<div class="bulk-action-wrapper">
|
||||||
<form id="bulk-action" action="bulk_action.php" method="POST">
|
<form id="bulk-action" action="bulk_action.php" method="POST">
|
||||||
<button type="submit" class="btn btn-primary">Download selected</button>
|
<div class="col-sm-12 mb-2" style="margin-left: 10px">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-5 col-md-2">
|
||||||
|
<div class="input-group">
|
||||||
|
<select name="action" class="form-control">
|
||||||
|
<option value="download" selected >Download</option>
|
||||||
|
<option value="delete">Delete</option>
|
||||||
|
</select>
|
||||||
<input type="hidden" name="type" value="dynamic">
|
<input type="hidden" name="type" value="dynamic">
|
||||||
|
<button type="submit" class="btn btn-primary">Apply</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,8 +3,20 @@
|
|||||||
<div id="err-msg"></div>
|
<div id="err-msg"></div>
|
||||||
<div class="bulk-action-wrapper">
|
<div class="bulk-action-wrapper">
|
||||||
<form id="bulk-action" action="bulk_action.php" method="POST">
|
<form id="bulk-action" action="bulk_action.php" method="POST">
|
||||||
<button type="submit" class="btn btn-primary">Download selected</button>
|
<div class="col-sm-12 mb-2" style="margin-left: 10px">
|
||||||
<input type="hidden" name="type" value="dynamic">
|
<div class="row">
|
||||||
|
<div class="col-5 col-md-2">
|
||||||
|
<div class="input-group">
|
||||||
|
<select name="action" class="form-control">
|
||||||
|
<option value="download" selected >Download</option>
|
||||||
|
<option value="delete">Delete</option>
|
||||||
|
</select>
|
||||||
|
<input type="hidden" name="type" value="static">
|
||||||
|
<button type="submit" class="btn btn-primary">Apply</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,10 +6,9 @@
|
|||||||
|
|
||||||
<!-- Main Footer -->
|
<!-- Main Footer -->
|
||||||
<footer class="main-footer text-sm">
|
<footer class="main-footer text-sm">
|
||||||
<strong>Copyright © <?php echo date("Y");?> <a href="#">PHP Qrcode Generator</a> - </strong>
|
<strong><a href="https://github.com/giandonatoinverso/PHP-Dynamic-Qr-code" target="_blank">PHP Qrcode Generator</a> by </strong> Giandonato Inverso
|
||||||
All rights reserved by Giandonato Inverso.
|
|
||||||
<div class="float-right d-none d-sm-inline-block">
|
<div class="float-right d-none d-sm-inline-block">
|
||||||
<b>Version</b> 2.2.1
|
<b>Version</b> 2.2.4
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
@@ -23,7 +22,7 @@
|
|||||||
<!-- AdminLTE App -->
|
<!-- AdminLTE App -->
|
||||||
<script src="dist/js/adminlte.js"></script>
|
<script src="dist/js/adminlte.js"></script>
|
||||||
<!-- AdminLTE Custom-->
|
<!-- AdminLTE Custom-->
|
||||||
<script src="dist/js/custom.js"></script>
|
<script src="dist/js/custom.js?nocache=<?php print rand();?>"></script>
|
||||||
<!-- Color picker -->
|
<!-- Color picker -->
|
||||||
<script src="plugins/bootstrap-colorpicker/js/bootstrap-colorpicker.min.js"></script>
|
<script src="plugins/bootstrap-colorpicker/js/bootstrap-colorpicker.min.js"></script>
|
||||||
<!-- date-range-picker -->
|
<!-- date-range-picker -->
|
||||||
|
|||||||
@@ -89,9 +89,9 @@ class DynamicQrcode {
|
|||||||
* Delete qr code
|
* Delete qr code
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function deleteQrcode($id) {
|
public function deleteQrcode($id, $async = false) {
|
||||||
if($_SESSION['type'] === "super") {
|
if($_SESSION['type'] === "super") {
|
||||||
$this->qrcode_instance->deleteQrcode($id);
|
$this->qrcode_instance->deleteQrcode($id, $async);
|
||||||
} else if ($_SESSION['type'] === "admin") {
|
} else if ($_SESSION['type'] === "admin") {
|
||||||
$qrcode = $this->getQrcode($id);
|
$qrcode = $this->getQrcode($id);
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ class DynamicQrcode {
|
|||||||
$user = $users->getUser($_SESSION['user_id']);
|
$user = $users->getUser($_SESSION['user_id']);
|
||||||
|
|
||||||
if($user["id"] === $qrcode["id_owner"])
|
if($user["id"] === $qrcode["id_owner"])
|
||||||
$this->qrcode_instance->deleteQrcode($id);
|
$this->qrcode_instance->deleteQrcode($id, $async);
|
||||||
else
|
else
|
||||||
$this->failure("You cannot delete this qrcode because it's of another user");
|
$this->failure("You cannot delete this qrcode because it's of another user");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class Qrcode {
|
|||||||
* Delete qr code
|
* Delete qr code
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function deleteQrcode($id) {
|
public function deleteQrcode($id, $async = false) {
|
||||||
$db = getDbInstance();
|
$db = getDbInstance();
|
||||||
|
|
||||||
$qrcode = $this->getQrcode($id);
|
$qrcode = $this->getQrcode($id);
|
||||||
@@ -171,6 +171,7 @@ class Qrcode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($status)
|
if ($status)
|
||||||
|
if (!$async)
|
||||||
$this->info('Qr code deleted successfully!');
|
$this->info('Qr code deleted successfully!');
|
||||||
else
|
else
|
||||||
$this->failure('Unable to delete qr code');
|
$this->failure('Unable to delete qr code');
|
||||||
|
|||||||
@@ -390,9 +390,9 @@ class StaticQrcode {
|
|||||||
* Delete qr code
|
* Delete qr code
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function deleteQrcode($id) {
|
public function deleteQrcode($id, $async = false) {
|
||||||
if($_SESSION['type'] === "super") {
|
if($_SESSION['type'] === "super") {
|
||||||
$this->qrcode_instance->deleteQrcode($id);
|
$this->qrcode_instance->deleteQrcode($id, $async);
|
||||||
} else if ($_SESSION['type'] === "admin") {
|
} else if ($_SESSION['type'] === "admin") {
|
||||||
$qrcode = $this->getQrcode($id);
|
$qrcode = $this->getQrcode($id);
|
||||||
|
|
||||||
@@ -404,7 +404,7 @@ class StaticQrcode {
|
|||||||
$user = $users->getUser($_SESSION['user_id']);
|
$user = $users->getUser($_SESSION['user_id']);
|
||||||
|
|
||||||
if($user["id"] === $qrcode["id_owner"])
|
if($user["id"] === $qrcode["id_owner"])
|
||||||
$this->qrcode_instance->deleteQrcode($id);
|
$this->qrcode_instance->deleteQrcode($id, $async);
|
||||||
else
|
else
|
||||||
$this->failure("You cannot delete this qrcode because it's of another user");
|
$this->failure("You cannot delete this qrcode because it's of another user");
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ $data = array (
|
|||||||
'scan' => $db->inc(1)
|
'scan' => $db->inc(1)
|
||||||
);
|
);
|
||||||
$db->where("identifier", $_GET['id']);
|
$db->where("identifier", $_GET['id']);
|
||||||
$db->update (DATABASE_PREFIX.'dynamic_qrcodes', $data);
|
$db->update ('dynamic_qrcodes', $data);
|
||||||
|
|
||||||
if($qrcode['state'] == 'enable'){
|
if($qrcode['state'] == 'enable'){
|
||||||
echo '<meta http-equiv="refresh" content="0; URL='.$qrcode['link'].'" />';
|
echo '<meta http-equiv="refresh" content="0; URL='.$qrcode['link'].'" />';
|
||||||
|
|||||||
Reference in New Issue
Block a user