refactoring of table database, added script for upgrading to versions >= 2.0, added multi-user support
Signed-off-by: giandonato.inverso@edempg.it <giandonato.inverso@studenti.unimi.it>
This commit is contained in:
committed by
giandonato.inverso@edempg.it
parent
cdab7df35d
commit
575a6b3caa
@@ -86,7 +86,7 @@
|
||||
<div class="col-6 col-md-1">
|
||||
<label for="format">Format *</label>
|
||||
<select name="format" class="form-control" required="required">
|
||||
<option value="png" selected >PNG</option>
|
||||
<option value="png" selected>PNG</option>
|
||||
<option value="gif">GIF</option>
|
||||
<option value="jpeg">JPEG</option>
|
||||
<option value="jpg">JPG</option>
|
||||
@@ -96,4 +96,29 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($_SESSION['type'] === 'super') { ?>
|
||||
<div class="col-sm-12 mb-2">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="form-group">
|
||||
<label for="id_owner">Owner *</label>
|
||||
<select name="id_owner" class="form-control">
|
||||
<option value="" selected>All</option>
|
||||
<?php
|
||||
|
||||
require_once BASE_PATH . '/lib/Users/Users.php';
|
||||
$users_instance = new Users();
|
||||
$users = $users_instance->getAllUsers();
|
||||
|
||||
foreach ($users as $user) {
|
||||
?>
|
||||
<option value="<?php echo $user["id"];?>"><?php echo $user["username"];?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</fieldset>
|
||||
|
||||
@@ -34,6 +34,32 @@
|
||||
<input type="radio" name="state" value="disable" <?php echo ($edit && $dynamic_qrcode['state'] =='disable')? "checked": "" ; ?> required="required" id="disable"/> Disable</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($_SESSION['type'] === 'super') { ?>
|
||||
<div class="col-sm-4">
|
||||
<div class="form-group">
|
||||
<label for="id_owner">Owner *</label>
|
||||
<select name="id_owner" class="form-control" required="required">
|
||||
<?php
|
||||
require_once BASE_PATH . '/lib/Users/Users.php';
|
||||
$users_instance = new Users();
|
||||
|
||||
if(isset($dynamic_qrcode['id_owner'])) {
|
||||
$owner = $users_instance->getUser($dynamic_qrcode['id_owner']);
|
||||
echo "<option selected value=\"" . $owner["id"] . "\">" . $owner["username"] . "</option>";
|
||||
}
|
||||
|
||||
$users = $users_instance->getAllUsers();
|
||||
foreach ($users as $user) {
|
||||
?>
|
||||
<option value="<?php echo $user["id"];?>"><?php echo $user["username"];?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<input type="hidden" name="id" value="<?php echo $dynamic_qrcode['id'];?>"/>
|
||||
<input type="hidden" name="edit" value="true"/>
|
||||
<input type="hidden" name="old_filename" value="<?php echo $dynamic_qrcode['filename'];?>"/>
|
||||
|
||||
@@ -7,6 +7,32 @@
|
||||
<input type="text" name="filename" value="<?php echo htmlspecialchars($edit ? $static_qrcode['filename'] : '', ENT_QUOTES, 'UTF-8'); ?>" placeholder="Filename" class="form-control" required="required" id = "filename">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($_SESSION['type'] === 'super') { ?>
|
||||
<div class="col-sm-4">
|
||||
<div class="form-group">
|
||||
<label for="id_owner">Owner *</label>
|
||||
<select name="id_owner" class="form-control" required="required">
|
||||
<?php
|
||||
require_once BASE_PATH . '/lib/Users/Users.php';
|
||||
$users_instance = new Users();
|
||||
|
||||
if(isset($static_qrcode['id_owner'])) {
|
||||
$owner = $users_instance->getUser($static_qrcode['id_owner']);
|
||||
echo "<option selected value=\"" . $owner["id"] . "\">" . $owner["username"] . "</option>";
|
||||
echo "<option value=\"\">All</option>";
|
||||
}
|
||||
|
||||
$users = $users_instance->getAllUsers();
|
||||
foreach ($users as $user) {
|
||||
?>
|
||||
<option value="<?php echo $user["id"];?>"><?php echo $user["username"];?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<input type="hidden" name="id" value="<?php echo $static_qrcode['id'];?>"/>
|
||||
<input type="hidden" name="edit" value="true"/>
|
||||
<input type="hidden" name="old_filename" value="<?php echo $static_qrcode['filename'];?>"/>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<span class="input-group-text"><i class="fa fa-user"></i></span>
|
||||
</div>
|
||||
|
||||
<input type="text" name="user_name" placeholder="Username" class="form-control" required="required" value="<?php echo ($edit) ? $user['user_name'] : ''; ?>" autocomplete="off">
|
||||
<input type="text" name="username" placeholder="Username" class="form-control" required="required" value="<?php echo ($edit) ? $user['username'] : ''; ?>" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -31,12 +31,12 @@
|
||||
<div class="form-group">
|
||||
<div class="radio">
|
||||
<label class="radio">
|
||||
<input type="radio" name="admin_type" value="super" required="required" <?php echo ($edit && $user['admin_type'] =='super') ? "checked": "" ; ?>/> Super admin</label>
|
||||
<input type="radio" name="type" value="super" required="required" <?php echo ($edit && $user['type'] =='super') ? "checked": "" ; ?>/> Super admin</label>
|
||||
</div>
|
||||
|
||||
<div class="radio">
|
||||
<label class="radio">
|
||||
<input type="radio" name="admin_type" value="admin" required="required" <?php echo ($edit && $user['admin_type'] =='admin') ? "checked": "" ; ?>/> Admin</label>
|
||||
<input type="radio" name="type" value="admin" required="required" <?php echo ($edit && $user['type'] =='admin') ? "checked": "" ; ?>/> Admin</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -80,4 +80,29 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($_SESSION['type'] === 'super') { ?>
|
||||
<div class="col-sm-12 mb-2">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="form-group">
|
||||
<label for="id_owner">Owner *</label>
|
||||
<select name="id_owner" class="form-control">
|
||||
<option value="" selected>All</option>
|
||||
<?php
|
||||
|
||||
require_once BASE_PATH . '/lib/Users/Users.php';
|
||||
$users_instance = new Users();
|
||||
$users = $users_instance->getAllUsers();
|
||||
|
||||
foreach ($users as $user) {
|
||||
?>
|
||||
<option value="<?php echo $user["id"];?>"><?php echo $user["username"];?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<br>
|
||||
@@ -16,6 +16,7 @@
|
||||
<tr>
|
||||
<th><input type="checkbox" name="bulk-select" value="1"></th>
|
||||
<th>ID</th>
|
||||
<th>Owner</th>
|
||||
<th>Filename</th>
|
||||
<th>Unique redirect identifier</th>
|
||||
<th>URL</th>
|
||||
@@ -30,6 +31,21 @@
|
||||
<tr>
|
||||
<td><input type="checkbox" name="action[]" value="<?=$row['id']?>" onchange="updateBulkActionVisibility()"></td>
|
||||
<td><?php echo $row['id']; ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if(!isset($row['id_owner']))
|
||||
echo "";
|
||||
else {
|
||||
require_once BASE_PATH . '/lib/Users/Users.php';
|
||||
$users = new Users();
|
||||
$user = $users->getUser($row['id_owner']);
|
||||
if($user !== NULL)
|
||||
echo $user["username"];
|
||||
else
|
||||
echo "";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo htmlspecialchars($row['filename']); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['identifier']); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['link']); ?></td>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<tr>
|
||||
<th><input type="checkbox" name="bulk-select" value="1"></th>
|
||||
<th>ID</th>
|
||||
<th>Owner</th>
|
||||
<th>Filename</th>
|
||||
<th>Type</th>
|
||||
<th>Content</th>
|
||||
@@ -28,6 +29,21 @@
|
||||
<tr>
|
||||
<td><input type="checkbox" name="action[]" value="<?=$row['id']?>" onchange="updateBulkActionVisibility()"></td>
|
||||
<td><?php echo $row['id']; ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if(!isset($row['id_owner']))
|
||||
echo "";
|
||||
else {
|
||||
require_once BASE_PATH . '/lib/Users/Users.php';
|
||||
$users = new Users();
|
||||
$user = $users->getUser($row['id_owner']);
|
||||
if($user !== NULL)
|
||||
echo $user["username"];
|
||||
else
|
||||
echo "";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo htmlspecialchars($row['filename']); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['type']); ?></td>
|
||||
<td><?php echo $row['content']; ?></td>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<tr>
|
||||
<th width="5%">ID</th>
|
||||
<th width="45%">Username</th>
|
||||
<th width="40%">Admin type</th>
|
||||
<th width="40%">Type</th>
|
||||
<th width="10%">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -15,11 +15,11 @@
|
||||
<?php foreach ($rows as $row): ?>
|
||||
<tr>
|
||||
<td><?php echo $row['id']; ?></td>
|
||||
<td><?php echo htmlspecialchars($row['user_name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['admin_type']); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['username']); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['type']); ?></td>
|
||||
<td>
|
||||
<!-- EDIT -->
|
||||
<a href="admin_user.php?edit=true&id=<?php echo $row['id']; ?>" class="btn btn-primary"><i class="fas fa-edit"></i></a>
|
||||
<a href="user.php?edit=true&id=<?php echo $row['id']; ?>" class="btn btn-primary"><i class="fas fa-edit"></i></a>
|
||||
|
||||
<!-- DELETE -->
|
||||
<a
|
||||
@@ -36,7 +36,7 @@
|
||||
</div><!-- /.Card body -->
|
||||
|
||||
<div class="card-footer clearfix">
|
||||
<?php echo paginationLinks($page, $total_pages, 'admin_users.php'); ?>
|
||||
<?php echo paginationLinks($page, $total_pages, 'users.php'); ?>
|
||||
</div><!-- /.Card footer -->
|
||||
|
||||
</div><!-- /.Card -->
|
||||
@@ -46,7 +46,7 @@
|
||||
<!-- Delete Confirmation Modal -->
|
||||
<div class="modal fade" id="delete-modal" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<form action="admin_user.php" method="POST">
|
||||
<form action="user.php" method="POST">
|
||||
<!-- Modal content -->
|
||||
|
||||
<div class="modal-content">
|
||||
|
||||
Reference in New Issue
Block a user