mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-08 13:46:09 +00:00
Full Refactor Admin Panel & Logs
Full Refactor Admin Panel & Logs (now you can see detailed logs in admin panel)
This commit is contained in:
@@ -1,52 +1,72 @@
|
||||
<?php
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename givePlus.php ##
|
||||
## Type BACKEND ##
|
||||
## Developed by: aggenkeech ##
|
||||
## License: TravianZ Project ##
|
||||
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ##
|
||||
## ##
|
||||
#################################################################################
|
||||
if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.php");
|
||||
|
||||
function mysqli_result($res, $row, $field=0) {
|
||||
$res->data_seek($row);
|
||||
$datarow = $res->fetch_array();
|
||||
return $datarow[$field];
|
||||
if (!isset($_SESSION)) {
|
||||
session_start();
|
||||
}
|
||||
if (empty($_SESSION['access']) || $_SESSION['access'] < 9) {
|
||||
die("Access Denied: You are not Admin!");
|
||||
}
|
||||
|
||||
// go max 5 levels up - we don't have folders that go deeper than that
|
||||
include_once("../../config.php");
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Autoloader path
|
||||
// ---------------------------------------------------------------------------
|
||||
$autoprefix = '';
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$autoprefix = str_repeat('../', $i);
|
||||
if (file_exists($autoprefix.'autoloader.php')) {
|
||||
// we have our path, let's leave
|
||||
if (file_exists($autoprefix . 'autoloader.php')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
include_once($autoprefix."GameEngine/Database.php");
|
||||
include_once($autoprefix . "GameEngine/Database.php");
|
||||
|
||||
$sql = "SELECT id FROM ".TB_PREFIX."users ORDER BY ID DESC LIMIT 1";
|
||||
$loops = mysqli_result(mysqli_query($GLOBALS["link"], $sql), 0);
|
||||
|
||||
$plusdur = $_POST['plus'] * 86400;
|
||||
|
||||
for($i = 0; $i < $loops + 1; $i++)
|
||||
{
|
||||
$query = "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$i."";
|
||||
$result = mysqli_query($GLOBALS["link"], $query);
|
||||
while($row = mysqli_fetch_assoc($result))
|
||||
{
|
||||
if($row['plus'] < time()) { $plusbefore = time(); $addplus = $plusbefore + $plusdur; } elseif($row['plus'] > time()) { $plusbefore = $row['plus']; $addplus = $plusbefore + $plusdur; }
|
||||
mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET
|
||||
plus = '".$addplus."'
|
||||
WHERE id = '".$row['id']."'");
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// Input
|
||||
// ---------------------------------------------------------------------------
|
||||
$days = (int)($_POST['plus'] ?? 0);
|
||||
if ($days <= 0) {
|
||||
header("Location: ../../../Admin/admin.php?p=givePlus&e=0");
|
||||
exit;
|
||||
}
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=givePlus&g");
|
||||
$plusdur = $days * 86400;
|
||||
$time = time();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Update în masă – fără loop
|
||||
// ---------------------------------------------------------------------------
|
||||
// Dacă plus < now, pornește de acum, altfel adaugă la timpul existent
|
||||
$database->query(
|
||||
"UPDATE " . TB_PREFIX . "users
|
||||
SET plus = IF(plus < $time, $time + $plusdur, plus + $plusdur)
|
||||
WHERE id > 3"
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Log admin
|
||||
// ---------------------------------------------------------------------------
|
||||
$adminId = (int)$_SESSION['id'];
|
||||
$logText = "Gave $days days Plus to all players";
|
||||
$logEsc = $database->escape($logText);
|
||||
|
||||
$database->query(
|
||||
"INSERT INTO " . TB_PREFIX . "admin_log (`id`, `user`, `log`, `time`) " .
|
||||
"VALUES (0, '$adminId', '$logEsc', $time)"
|
||||
);
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=givePlus&g=1");
|
||||
exit;
|
||||
?>
|
||||
Reference in New Issue
Block a user