mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-12 14:21:03 +00:00
chore: harden php8 compatibility, optimize installer/croppers, and refresh docs/admin ux
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#################################################################################
|
||||
|
||||
function get_map_tile_info($coord_x, $coord_y){ // todo mv to queries file
|
||||
$tbp = TB_PREFIX;
|
||||
$q = 'SELECT map_data.`id` AS village_id, map_data.`fieldtype`, map_data.`oasistype`, map_data.`occupied`, map_data.`image`, '.
|
||||
'oasis_data.`type`, '.
|
||||
'CASE '.
|
||||
@@ -21,10 +22,10 @@ function get_map_tile_info($coord_x, $coord_y){ // todo mv to queries file
|
||||
'ELSE village_data.`owner` '.
|
||||
'END AS owner_id, '.
|
||||
'u.`username` '.
|
||||
'FROM (SELECT * FROM `s1_wdata` WHERE `x` = '.$coord_x.' AND `y` = '.$coord_y.') AS map_data '.
|
||||
'LEFT JOIN `s1_odata` AS oasis_data ON map_data.`id` = oasis_data.`wref` '.
|
||||
'LEFT JOIN `s1_vdata` AS village_data ON village_data.`wref` = map_data.`id` '.
|
||||
'LEFT JOIN s1_users AS u ON u.`id` = COALESCE(oasis_data.`owner`, village_data.`owner`, 0);'; // todo check this db tables fields -- del doublings like oasistype = '2' and image = 'o2'
|
||||
'FROM (SELECT * FROM `'.$tbp.'wdata` WHERE `x` = '.$coord_x.' AND `y` = '.$coord_y.') AS map_data '.
|
||||
'LEFT JOIN `'.$tbp.'odata` AS oasis_data ON map_data.`id` = oasis_data.`wref` '.
|
||||
'LEFT JOIN `'.$tbp.'vdata` AS village_data ON village_data.`wref` = map_data.`id` '.
|
||||
'LEFT JOIN `'.$tbp.'users` AS u ON u.`id` = COALESCE(oasis_data.`owner`, village_data.`owner`, 0);'; // todo check this db tables fields -- del doublings like oasistype = '2' and image = 'o2'
|
||||
$result = mysqli_query($GLOBALS['link'], $q);
|
||||
return mysqli_fetch_assoc($result);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,11 @@ include_once("../GameEngine/Generator.php");
|
||||
include_once("../GameEngine/Technology.php");
|
||||
include_once("../GameEngine/Message.php");
|
||||
|
||||
if(isset($_GET['nid']) && is_numeric($_GET['nid'])) $msg = $database->getMessage($_GET['nid'], 3);
|
||||
$msg = [];
|
||||
$allMessages = [];
|
||||
$nid = (isset($_GET['nid']) && is_numeric($_GET['nid'])) ? (int) $_GET['nid'] : 0;
|
||||
|
||||
if($nid > 0) $msg = $database->getMessage($nid, 3);
|
||||
else
|
||||
{
|
||||
$sql = "SELECT * FROM " . TB_PREFIX . "mdata ORDER BY time DESC ";
|
||||
@@ -75,5 +79,5 @@ echo stripslashes(nl2br($bbcoded));
|
||||
<div id="read_foot" class="msg_foot"></div>
|
||||
</div><?php
|
||||
}
|
||||
else echo "Message ID ".$_GET['nid']." doesn't exist!";
|
||||
else echo "Message ID ".$nid." doesn't exist!";
|
||||
?>
|
||||
@@ -12,7 +12,13 @@ include_once("../GameEngine/Generator.php");
|
||||
include_once("../GameEngine/Technology.php");
|
||||
include_once("../GameEngine/Message.php");
|
||||
|
||||
if ($_GET['bid']) $rep = $database->getNotice2($_GET['bid']);
|
||||
$rep = null;
|
||||
$rep1 = [];
|
||||
$bid = isset($_GET['bid']) ? (int) $_GET['bid'] : 0;
|
||||
|
||||
if ($bid > 0) {
|
||||
$rep = $database->getNotice2($bid);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT * FROM " . TB_PREFIX . "ndata ORDER BY time DESC ";
|
||||
@@ -20,7 +26,7 @@ else
|
||||
$rep1 = $database->mysqli_fetch_all($result);
|
||||
}
|
||||
|
||||
if($rep1)
|
||||
if(!empty($rep1))
|
||||
{
|
||||
?>
|
||||
<link href="../<?php echo GP_LOCATE; ?>lang/en/lang.css?f4b7d" rel="stylesheet" type="text/css">
|
||||
@@ -34,7 +40,7 @@ if($rep1)
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
elseif($rep)
|
||||
elseif(!empty($rep))
|
||||
{
|
||||
?>
|
||||
<link href="../<?php echo GP_LOCATE; ?>lang/en/lang.css?f4b7d" rel="stylesheet" type="text/css">
|
||||
@@ -50,5 +56,5 @@ elseif($rep)
|
||||
$message->readingNotice = $rep;
|
||||
include ("../Templates/Notice/".$message->getReportType($rep['ntype']).".tpl");
|
||||
}
|
||||
else echo "Report ID ".$_GET['bid']." doesn't exist!";
|
||||
else echo "Report ID ".$bid." doesn't exist!";
|
||||
?>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
@@ -12,10 +12,12 @@
|
||||
include_once("../../GameEngine/config.php");
|
||||
include_once("../../GameEngine/Database.php");
|
||||
|
||||
if (!isset($_SESSION)) {
|
||||
session_start();
|
||||
if (session_status() !== PHP_SESSION_ACTIVE) {
|
||||
session_start();
|
||||
}
|
||||
if (!isset($_SESSION['access']) || (int)$_SESSION['access'] !== (int)ADMIN) {
|
||||
die("<h1><font color=\"red\">Access Denied: You are not Admin!</font></h1>");
|
||||
}
|
||||
if($_SESSION['access'] != ADMIN) die("<h1><font color=\"red\">Access Denied: You are not Admin!</font></h1>");
|
||||
set_time_limit(0);
|
||||
// TODO: truncate ALL tables (in a single query, not like this),
|
||||
// then perform install steps (createDbStructure() && populateWorldData())
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename users.tpl ##
|
||||
## Purpose: Admin users list with pagination ##
|
||||
## ##
|
||||
#################################################################################
|
||||
|
||||
$page = isset($_GET['upage']) ? (int)$_GET['upage'] : 1;
|
||||
if ($page < 1) {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$perPage = 100;
|
||||
$offset = ($page - 1) * $perPage;
|
||||
|
||||
$totalRes = mysqli_query($GLOBALS['link'], "SELECT COUNT(*) AS cnt FROM " . TB_PREFIX . "users");
|
||||
$totalRow = $totalRes ? mysqli_fetch_assoc($totalRes) : ['cnt' => 0];
|
||||
$totalUsers = (int)($totalRow['cnt'] ?? 0);
|
||||
$totalPages = max(1, (int)ceil($totalUsers / $perPage));
|
||||
|
||||
if ($page > $totalPages) {
|
||||
$page = $totalPages;
|
||||
$offset = ($page - 1) * $perPage;
|
||||
}
|
||||
|
||||
$sql = "SELECT id, username, email, access, tribe, gold, timestamp " .
|
||||
"FROM " . TB_PREFIX . "users " .
|
||||
"ORDER BY id DESC LIMIT " . (int)$perPage . " OFFSET " . (int)$offset;
|
||||
$result = mysqli_query($GLOBALS['link'], $sql);
|
||||
|
||||
function tribeLabel($tribe) {
|
||||
$tribe = (int)$tribe;
|
||||
if ($tribe === 1) return 'Roman';
|
||||
if ($tribe === 2) return 'Teuton';
|
||||
if ($tribe === 3) return 'Gaul';
|
||||
return 'N/A';
|
||||
}
|
||||
?>
|
||||
|
||||
<table id="member" cellpadding="1" cellspacing="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7">Users list (<?php echo $totalUsers; ?>)</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>Username</td>
|
||||
<td>Email</td>
|
||||
<td>Access</td>
|
||||
<td>Tribe</td>
|
||||
<td>Gold</td>
|
||||
<td>Last activity</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($result && mysqli_num_rows($result) > 0) { ?>
|
||||
<?php while ($row = mysqli_fetch_assoc($result)) { ?>
|
||||
<tr>
|
||||
<td><?php echo (int)$row['id']; ?></td>
|
||||
<td>
|
||||
<a href="?p=player&uid=<?php echo (int)$row['id']; ?>">
|
||||
<?php echo htmlspecialchars((string)$row['username'], ENT_QUOTES, 'UTF-8'); ?>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<?php if (!empty($row['email'])) { ?>
|
||||
<a href="mailto:<?php echo htmlspecialchars((string)$row['email'], ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<?php echo htmlspecialchars((string)$row['email'], ENT_QUOTES, 'UTF-8'); ?>
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
-
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td><?php echo (int)$row['access']; ?></td>
|
||||
<td><?php echo tribeLabel($row['tribe']); ?></td>
|
||||
<td><?php echo (int)$row['gold']; ?></td>
|
||||
<td><?php echo !empty($row['timestamp']) ? date('d.m.Y H:i:s', (int)$row['timestamp']) : '-'; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<tr>
|
||||
<td colspan="7" class="hab">No users found.</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div style="margin-top:10px;">
|
||||
<?php if ($page > 1) { ?>
|
||||
<a href="?p=users&upage=<?php echo $page - 1; ?>">« Previous</a>
|
||||
<?php } ?>
|
||||
<span style="margin:0 10px;">Page <?php echo $page; ?> / <?php echo $totalPages; ?></span>
|
||||
<?php if ($page < $totalPages) { ?>
|
||||
<a href="?p=users&upage=<?php echo $page + 1; ?>">Next »</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
@@ -131,6 +131,10 @@ if (!empty($_GET['p'])) {
|
||||
$subpage = 'Create Users';
|
||||
break;
|
||||
|
||||
case 'users':
|
||||
$subpage = 'Users List';
|
||||
break;
|
||||
|
||||
case 'admin_log':
|
||||
$subpage = 'Admin Log';
|
||||
break;
|
||||
@@ -559,6 +563,7 @@ if (!empty($_GET['p'])) {
|
||||
</li>
|
||||
<li class="sub"><a href="#">Users</a>
|
||||
<ul>
|
||||
<li><a href="?p=users">List Users</a></li>
|
||||
<li><a href="?p=addUsers">Create Users</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user