mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-21 10:37:14 +00:00
63c94fa961
Implement the "Time Preference" section of the player preferences (issue #198), which until now was stored in DB but never applied in-game. procMtime() — the central date/time formatter used across reports, messages, notices and troop movements — now honours the per-user settings: - timezone: the stored value is mapped to a DateTimeZone, either a named DST-aware region (Europe, UK, Turkey, Kolkata, Bangkok, New York, Chicago, New Zealand) or a fixed UTC offset (general zones); timestamps are converted before formatting. - tformat: drives the date layout and 12h/24h clock (0=EU dd.mm.yy 24h, 1=US mm/dd/yy 12h, 2=UK dd/mm/yy 12h, 3=ISO yy/mm/dd 24h). tformat 0 keeps the previous EU output unchanged. The today/yesterday sentinels are preserved (callers compare them) and are computed in the player's timezone. The time-only path (mode 9) stays 24h H:i:s because it feeds the live JS clock counters (unx.js), which parse "H:i:s" by splitting on ":". A few alliance/report/farm-list rows that combined procMtime's day part with a raw date('H:i') now take the time from the same procMtime result, to avoid mixing timezones. A second "local time" clock is shown next to the server-time one: a small vanilla-JS snippet emitted once from menu.tpl finds the visible #tp1 clock and appends a row ticking in the player's timezone (Date.now() + UTC offset), independent of the browser timezone and of the unx.js counters. It aligns the value under the server time, is skipped when the player's timezone matches the server's, and lets the clock box grow so the extra row fits the frame. Adds the LOCAL_TIME string (EN/FR/RO). When no player session is available (admin / pre-login) procMtime falls back to the server timezone and EU layout, i.e. the previous behaviour. Removes the last "not coded yet" tag from the preferences form. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
296 lines
7.3 KiB
Smarty
296 lines
7.3 KiB
Smarty
<?php
|
|
|
|
$t = $_GET['t'] ?? null;
|
|
$action = $_GET['action'] ?? null;
|
|
$postAction = $_POST['action'] ?? null;
|
|
|
|
$isFarmlistPage = ($t == 99);
|
|
$isAddListPost = ($postAction === 'addList');
|
|
|
|
/* =========================
|
|
CREATE FARM LIST
|
|
========================= */
|
|
if ($isFarmlistPage && $action == 0) {
|
|
|
|
if (
|
|
$isFarmlistPage &&
|
|
$isAddListPost &&
|
|
!empty($_POST['did']) &&
|
|
!empty($_POST['name']) &&
|
|
$database->getVillageField((int)$_POST['did'], 'owner') == $session->uid
|
|
) {
|
|
$did = (int)$_POST['did'];
|
|
$name = trim($_POST['name']);
|
|
|
|
$database->createFarmList($did, $session->uid, $name);
|
|
|
|
} else if ($isFarmlistPage && $postAction === 'addList') {
|
|
header("Location: build.php?gid=16&t=99&action=addList");
|
|
exit;
|
|
}
|
|
|
|
}
|
|
|
|
/* =========================
|
|
FARM LIST QUERY (CLEAN)
|
|
========================= */
|
|
$farmlists = mysqli_query(
|
|
$database->dblink,
|
|
"SELECT id, name, owner, wref
|
|
FROM ".TB_PREFIX."farmlist
|
|
WHERE owner = ".(int)$session->uid."
|
|
ORDER BY wref DESC"
|
|
);
|
|
|
|
?>
|
|
|
|
<form action="build.php?id=39&t=99&action=startRaid" method="post" name="msg">
|
|
<input type="hidden" name="action" value="startRaid">
|
|
|
|
<?php
|
|
$query = mysqli_num_rows($farmlists);
|
|
|
|
while ($row = mysqli_fetch_array($farmlists)) {
|
|
|
|
$lid = $row["id"];
|
|
$lname = $row["name"];
|
|
$lwref = $row["wref"];
|
|
|
|
$lvname = $database->getVillageField($lwref, 'name');
|
|
?>
|
|
|
|
<div class="listTitleText">
|
|
<a href="build.php?gid=16&t=99&action=deleteList&lid=<?php echo $lid; ?>">
|
|
<img class="del" src="img/x.gif" alt="<?php echo DELETE; ?>" title="<?php echo DELETE; ?>">
|
|
</a>
|
|
<?php echo $lvname; ?> - <?php echo $lname; ?>
|
|
</div>
|
|
|
|
<div class="openedClosedSwitch switchOpened"></div>
|
|
<div class="clear"></div>
|
|
|
|
<div class="listContent">
|
|
<div class="detail">
|
|
|
|
<table id="raidList" cellpadding="1" cellspacing="1">
|
|
<thead>
|
|
<tr>
|
|
<td></td>
|
|
<td><?php echo VILLAGE; ?></td>
|
|
<td><?php echo TZ_POP; ?></td>
|
|
<td><?php echo DISTANCE; ?></td>
|
|
<td><?php echo TROOPS; ?></td>
|
|
<td><?php echo TZ_LAST_RAID; ?></td>
|
|
<td></td>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<?php
|
|
$sql2 = mysqli_query(
|
|
$database->dblink,
|
|
"SELECT * FROM ".TB_PREFIX."raidlist
|
|
WHERE lid = ".(int)$lid."
|
|
ORDER BY distance ASC"
|
|
);
|
|
|
|
$query2 = mysqli_num_rows($sql2);
|
|
|
|
if (!$query2) {
|
|
echo '<td class="noData" colspan="7">'.NO_VILLAGES.'</td>';
|
|
} else {
|
|
|
|
while ($row = mysqli_fetch_array($sql2)) {
|
|
|
|
$id = $row['id'];
|
|
$towref = $row['towref'];
|
|
$x = $row['x'];
|
|
$y = $row['y'];
|
|
$distance = $row['distance'];
|
|
|
|
for ($i = 1; $i <= 6; $i++) {
|
|
${'t'.$i} = $row['t'.$i];
|
|
}
|
|
|
|
$vdata = $database->getVillage($towref);
|
|
$oasistype = $database->getVillageType2($towref);
|
|
?>
|
|
|
|
<tr class="slotRow">
|
|
|
|
<td class="checkbox">
|
|
<input name="slot[]" value="<?php echo $id; ?>" type="checkbox" class="markSlot">
|
|
</td>
|
|
|
|
<td class="village">
|
|
|
|
<?php
|
|
$attacks = $database->getMovement(3, $towref, 1);
|
|
$attacksCount = count($attacks);
|
|
|
|
if ($attacksCount > 0) {
|
|
foreach ($attacks as $attack) {
|
|
if ($attack['attack_type'] != 4) {
|
|
$attacksCount--;
|
|
}
|
|
}
|
|
|
|
if ($attacksCount > 0) {
|
|
echo '<img class="att2" src="img/x.gif" title="'.OWN_ATTACKING_TROOPS.'" />';
|
|
}
|
|
}
|
|
?>
|
|
|
|
<label>
|
|
<?php
|
|
if ($oasistype != 0) {
|
|
$thisVillageName = $database->getOasisField($towref, 'conqured') ? OCCUOASIS : UNOCCUOASIS;
|
|
} else {
|
|
$thisVillageName = $vdata["name"];
|
|
}
|
|
?>
|
|
|
|
<span class="coordinates coordinatesWithText">
|
|
<span class="coordText"><?php echo $thisVillageName; ?></span>
|
|
<span class="coordinatesWrapper">
|
|
<span class="coordinateY">(<?php echo $x; ?></span>
|
|
<span class="coordinatePipe">|</span>
|
|
<span class="coordinateX"><?php echo $y; ?>)</span>
|
|
</span>
|
|
</span>
|
|
|
|
</label>
|
|
|
|
</td>
|
|
|
|
<td class="ew">
|
|
<?php echo ($oasistype == 0) ? $vdata['pop'] : "-"; ?>
|
|
</td>
|
|
|
|
<td class="distance"><?php echo $distance; ?></td>
|
|
|
|
<td class="troops">
|
|
|
|
<?php
|
|
$start = ($session->tribe - 1) * 10 + 1;
|
|
$end = $start + 5;
|
|
|
|
for ($i = $start; $i <= $end; $i++) {
|
|
$index = $i - $start + 1;
|
|
|
|
if (${'t'.$index} > 0) {
|
|
echo '<div class="troopIcon">
|
|
<img class="unit u'.$i.'" title="'.$technology->getUnitName($i).'" src="img/x.gif">
|
|
<span class="troopIconAmount">'.${'t'.$index}.'</span>
|
|
</div>';
|
|
}
|
|
}
|
|
?>
|
|
|
|
</td>
|
|
|
|
<td class="lastRaid">
|
|
|
|
<?php
|
|
$noticeClass = [
|
|
"Scout Report", "Won as attacker without losses", "Won as attacker with losses",
|
|
"Lost as attacker with losses", "Won as defender without losses",
|
|
"Won as defender with losses", "Lost as defender with losses",
|
|
"Lost as defender without losses", "Reinforcement arrived", "",
|
|
"Wood Delivered", "Clay Delivered", "Iron Delivered", "Crop Delivered",
|
|
"", "Won as defender without losses", "Won as defender with losses",
|
|
"Lost as defender with losses", "Won scouting as attacker",
|
|
"Lost scouting as attacker", "Won scouting as defender",
|
|
"Lost scouting as defender"
|
|
];
|
|
|
|
$getnotice = mysqli_query(
|
|
$database->dblink,
|
|
"SELECT ntype, data, time, id
|
|
FROM ".TB_PREFIX."ndata
|
|
WHERE ntype < 4
|
|
AND toWref = ".(int)$towref."
|
|
AND uid = ".(int)$session->uid."
|
|
ORDER BY time DESC LIMIT 1"
|
|
);
|
|
|
|
if (mysqli_num_rows($getnotice) > 0) {
|
|
|
|
while ($row2 = mysqli_fetch_array($getnotice)) {
|
|
|
|
$dataarray = explode(",", $row2['data']);
|
|
$type2 = $row2['ntype'];
|
|
|
|
echo '<img src="img/x.gif" class="iReport iReport'.$type2.'" title="'.$noticeClass[$type2].'">';
|
|
|
|
$allres = $dataarray[23] + $dataarray[24] + $dataarray[25] + $dataarray[26];
|
|
$carry = $dataarray[27];
|
|
|
|
echo '<img title="'.$allres.'/'.$carry.'" src="img/x.gif" class="carry"/>';
|
|
|
|
$date = $generator->procMtime($row2['time']);
|
|
echo '<a href="berichte.php?id='.$row2['id'].'">'
|
|
.$date[0]." ".substr($date[1],0,5).'</a>';
|
|
}
|
|
}
|
|
?>
|
|
|
|
</td>
|
|
|
|
<td class="action">
|
|
<a class="arrow" href="build.php?id=39&t=99&action=showSlot&eid=<?php echo $id; ?>"><?php echo EDIT; ?></a>
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<?php } ?>
|
|
|
|
<?php if ($database->getVilFarmlist($session->uid)) { ?>
|
|
|
|
<div class="markAll">
|
|
<input type="checkbox" onclick="Allmsg(this.form);">
|
|
<label><?php echo TZ_SELECT_ALL; ?></label>
|
|
</div>
|
|
|
|
<div class="addSlot">
|
|
<button type="button" onclick="window.location.href='?gid=16&t=99&action=addraid';"><?php echo TZ_ADD_RAID; ?></button>
|
|
<button type="submit"><?php echo TZ_START_RAID; ?></button>
|
|
</div>
|
|
|
|
<?php } ?>
|
|
|
|
<div class="options">
|
|
<a class="arrow" href="build.php?gid=16&t=99&action=addList"><?php echo TZ_CREATE_A_NEW_LIST; ?></a>
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<?php
|
|
/* =========================
|
|
INCLUDE FORMS (UNCHANGED)
|
|
========================= */
|
|
|
|
if ($create == 1) {
|
|
$hideevasion = 1;
|
|
include("Templates/goldClub/farmlist_add.tpl");
|
|
|
|
} else if ($create == 2) {
|
|
$hideevasion = 1;
|
|
include("Templates/goldClub/farmlist_addraid.tpl");
|
|
|
|
} else if ($create == 3) {
|
|
$hideevasion = 1;
|
|
include("Templates/goldClub/farmlist_editraid.tpl");
|
|
}
|
|
?> |