mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-06-14 06:03:12 +00:00
Added options to invite codes
fixed some bugs in sanity check
This commit is contained in:
parent
c9b81414b0
commit
2443f9b75a
7 changed files with 278 additions and 17 deletions
35
app/account/load.php
Normal file
35
app/account/load.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
include __DIR__ . "/../conn.php";
|
||||
include __DIR__ . "/../app.php";
|
||||
|
||||
use App\Account;
|
||||
use App\Diff;
|
||||
|
||||
$user_info = new Account();
|
||||
$diff = new Diff();
|
||||
|
||||
if (isset($_POST['log'])) {
|
||||
if ($user_info->is_admin($conn, $_SESSION['id'])) {
|
||||
?>
|
||||
<div class="log">
|
||||
<p>ID</p> <p>User IP</p> <p>Action</p> <p>Time</p>
|
||||
</div>
|
||||
<?php
|
||||
// Reading images from table
|
||||
$logs_request = mysqli_query($conn, "SELECT * FROM logs ORDER BY id DESC");
|
||||
|
||||
while ($log = mysqli_fetch_array($logs_request)) {
|
||||
?>
|
||||
<div class="log">
|
||||
<p><?php echo $log['id']; ?></p>
|
||||
<p><?php echo $log['ipaddress']; ?></p>
|
||||
<p><?php echo $log['action']; ?></p>
|
||||
<?php
|
||||
$log_time = new DateTime($log['time']);
|
||||
echo "<p>".$log_time->format('Y-m-d H:i:s T')." (".$diff->time($log['time']).")</p>";
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
61
app/account/token.php
Normal file
61
app/account/token.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
include __DIR__ . "/../conn.php";
|
||||
include __DIR__ . "/../app.php";
|
||||
|
||||
use App\Account;
|
||||
|
||||
$user_info = new Account();
|
||||
|
||||
if (isset($_POST['regenerate'])) {
|
||||
if ($user_info->is_admin($conn, $_SESSION['id'])) {
|
||||
// Prepare sql
|
||||
$sql = "UPDATE tokens SET used = True WHERE code = ?";
|
||||
$stmt = mysqli_prepare($conn, $sql);
|
||||
mysqli_stmt_bind_param($stmt, "s", $param_token);
|
||||
$param_token = $_POST['regenerate'];
|
||||
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
// Generate Token
|
||||
$token_array = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz';
|
||||
$new_token = substr(str_shuffle($token_array), 0, 15);
|
||||
|
||||
if (mysqli_query($conn, "INSERT INTO tokens (code, used) VALUES('$new_token', 0)")) {
|
||||
echo true;
|
||||
} else {
|
||||
echo false;
|
||||
}
|
||||
} else {
|
||||
echo false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['generate'])) {
|
||||
if ($user_info->is_admin($conn, $_SESSION['id'])) {
|
||||
// Generate Token
|
||||
$token_array = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz';
|
||||
$new_token = substr(str_shuffle($token_array), 0, 15);
|
||||
|
||||
if (mysqli_query($conn, "INSERT INTO tokens (code, used) VALUES('$new_token', 0)")) {
|
||||
echo true;
|
||||
} else {
|
||||
echo false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['delete'])) {
|
||||
if ($user_info->is_admin($conn, $_SESSION['id'])) {
|
||||
// Prepare sql
|
||||
$sql = "UPDATE tokens SET used = True WHERE id = ?";
|
||||
$stmt = mysqli_prepare($conn, $sql);
|
||||
mysqli_stmt_bind_param($stmt, "i", $param_token);
|
||||
$param_token = $_POST['delete'];
|
||||
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
echo true;
|
||||
} else {
|
||||
echo false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
session_start();
|
||||
|
||||
include dirname(__DIR__) . "/conn.php";
|
||||
include dirname(__DIR__) . "/../conn.php";
|
||||
|
||||
if (isset($_POST['fix'])) {
|
||||
$autofix_start = microtime(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue