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