Incremental Refactor Templates

Incremental Refactor Templates
This commit is contained in:
Catalin Novgorodschi
2026-05-06 13:16:54 +03:00
parent 544496c515
commit a02be51969
59 changed files with 7542 additions and 3364 deletions
-4
View File
@@ -25,10 +25,6 @@ include_once("../GameEngine/Admin/database.php");
include_once("../GameEngine/Data/buidata.php"); include_once("../GameEngine/Data/buidata.php");
include_once("../GameEngine/Artifacts.php"); include_once("../GameEngine/Artifacts.php");
include('Templates/ver.tpl');
include('Templates/update_latest.tpl');
$up_avl = $latest - $ver ;
$subpage = 'Login'; $subpage = 'Login';
$not_include_mootools_js = false; $not_include_mootools_js = false;
+62 -11
View File
@@ -1,22 +1,73 @@
<?php if($session->alliance == $aid && $session->alliance > 0) { <?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ (Refactor incremental) ##
## File: alli_menu.tpl ##
## Description: Alliance menu navigation ##
## Improvements: ##
## - Reduced duplication ##
## - Safer input handling ##
## - Cleaner structure ##
## - Added comments ##
#################################################################################
// Verifică dacă jucătorul este în alianța curentă
if ($session->alliance == $aid && $session->alliance > 0) {
// Preluăm parametrul "s" o singură dată (GET sau POST)
// Cast la int pentru siguranță
$s = 0;
if (isset($_GET['s'])) {
$s = (int)$_GET['s'];
} elseif (isset($_POST['s'])) {
$s = (int)$_POST['s'];
}
?> ?>
<div id="textmenu"> <div id="textmenu">
<a href="allianz.php" <?php if(!isset($_GET['s']) && !isset($_POST['s'])) { echo "class=\"selected\""; } ?>>Overview</a>
| <a href="allianz.php?s=2" <?php if(isset($_GET['s']) && $_GET['s'] == 2) { echo "class=\"selected\""; } ?>>Forum</a> <!-- Overview -->
| <a href="allianz.php?s=6" <?php if(isset($_GET['s']) && $_GET['s'] == 6) { echo "class=\"selected\""; } ?>>Chat</a> <a href="allianz.php" <?php if ($s === 0) { echo 'class="selected"'; } ?>>
| <a href="allianz.php?s=3" <?php if(isset($_GET['s']) && $_GET['s'] == 3) { echo "class=\"selected\""; } ?>>Attacks</a> Overview
| <a href="allianz.php?s=4" <?php if(isset($_GET['s']) && $_GET['s'] == 4) { echo "class=\"selected\""; } ?>>News</a> </a>
| <!-- Forum -->
<a href="allianz.php?s=2" <?php if ($s === 2) { echo 'class="selected"'; } ?>>
Forum
</a>
| <!-- Chat -->
<a href="allianz.php?s=6" <?php if ($s === 6) { echo 'class="selected"'; } ?>>
Chat
</a>
| <!-- Attacks -->
<a href="allianz.php?s=3" <?php if ($s === 3) { echo 'class="selected"'; } ?>>
Attacks
</a>
| <!-- News -->
<a href="allianz.php?s=4" <?php if ($s === 4) { echo 'class="selected"'; } ?>>
News
</a>
<?php <?php
if($session->sit == 0){ // Dacă NU este sitter are acces la Options
if ($session->sit == 0) {
?> ?>
| <a href="allianz.php?s=5" <?php if(isset($_GET['s']) && $_GET['s'] == 5 || isset($_POST['s']) && $_POST['s']) { echo "class=\"selected\""; } ?>>Options</a> | <!-- Options -->
<a href="allianz.php?s=5" <?php if ($s === 5) { echo 'class="selected"'; } ?>>
Options
</a>
<?php <?php
}else{ } else {
?> ?>
| <span class=none><b>Options</b></span> | <!-- Options disabled for sitter -->
<span class="none"><b>Options</b></span>
<?php <?php
} }
?> ?>
</div> </div>
<?php <?php
} }
+114 -47
View File
@@ -1,57 +1,124 @@
<?php <?php
if(!is_numeric($_SESSION['search'])) { #################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ (Refactor incremental) ##
## File: alliance.tpl ##
## Description: Alliance ranking table ##
## Improvements: ##
## - Safer input handling ##
## - Removed duplicate function calls ##
## - Fixed variable overwrite ($ranking) ##
## - Cleaner pagination logic ##
## - Added comments ##
#################################################################################
// Validare search (poziția din ranking)
if (!isset($_SESSION['search']) || !is_numeric($_SESSION['search'])) {
?> ?>
<center><font color=orange size=2><p class=\"error\">The alliance <b>"<?php echo $_SESSION['search']; ?>"</b> does not exist.</p></font></center> <center>
<font color="orange" size="2">
<p class="error">
The alliance <b>"<?php echo htmlspecialchars($_SESSION['search'] ?? '', ENT_QUOTES, 'UTF-8'); ?>"</b> does not exist.
</p>
</font>
</center>
<?php <?php
$search = $session->alliance; $search = (int)$session->alliance;
} else {
$search = (int)$_SESSION['search'];
} }
else {
$search = $_SESSION['search']; // Luăm ranking o singură dată (optimizare)
$rankData = $ranking->getRank();
$totalRanks = is_array($rankData) ? count($rankData) : 0;
// Calcul paginare
$start = 1;
if (isset($_GET['rank']) && is_numeric($_GET['rank'])) {
$rankParam = (int)$_GET['rank'];
// Limităm la max ranking
if ($rankParam > $totalRanks) {
$rankParam = $totalRanks - 1;
}
$multiplier = 1;
// Determină pagina (20 / pagină)
while ($rankParam > (20 * $multiplier)) {
$multiplier++;
}
$start = 20 * $multiplier - 19;
} else {
// fallback la sesiune
$start = isset($_SESSION['start']) ? ((int)$_SESSION['start'] + 1) : 1;
} }
?> ?>
<table cellpadding="1" cellspacing="1" id="alliance" class="row_table_data"> <table cellpadding="1" cellspacing="1" id="alliance" class="row_table_data">
<thead> <thead>
<tr> <tr>
<th colspan="5"> <th colspan="5">
The largest alliances <div id="submenu"><a title="Top 10" href="statistiken.php?id=43"><img class="btn_top10" src="img/x.gif" alt="Top 10"></a><a title="defender" href="statistiken.php?id=42"><img class="btn_def" src="img/x.gif" alt="defender"></a><a title="attacker" href="statistiken.php?id=41"><img class="btn_off" src="img/x.gif" alt="attacker"></a></div> The largest alliances
</th> <div id="submenu">
</tr> <a title="Top 10" href="statistiken.php?id=43">
<tr><td></td><td>Alliance</td><td>Player</td><td>&Oslash;</td><td>Points</td></tr> <img class="btn_top10" src="img/x.gif" alt="Top 10">
</thead><tbody> </a>
<?php <a title="defender" href="statistiken.php?id=42">
if(isset($_GET['rank'])){ <img class="btn_def" src="img/x.gif" alt="defender">
$multiplier = 1; </a>
if(is_numeric($_GET['rank'])) { <a title="attacker" href="statistiken.php?id=41">
if($_GET['rank'] > count($ranking->getRank())) { <img class="btn_off" src="img/x.gif" alt="attacker">
$_GET['rank'] = count($ranking->getRank())-1; </a>
} </div>
while($_GET['rank'] > (20*$multiplier)) { </th>
$multiplier +=1; </tr>
} <tr>
$start = 20*$multiplier-19; <td></td>
} else { $start = ($_SESSION['start']+1); } <td>Alliance</td>
} else { $start = ($_SESSION['start']+1); } <td>Player</td>
if(count($ranking->getRank()) > 0) { <td>&Oslash;</td>
$ranking = $ranking->getRank(); <td>Points</td>
for($i=$start;$i<($start+20);$i++) { </tr>
if(isset($ranking[$i]['name']) && $ranking[$i] != "pad") { </thead>
if($i == $search) {
echo "<tr class=\"hl\"><td class=\"ra fc\" >"; <tbody>
}
else {
echo "<tr><td class=\"ra \" >";
}
echo $i.".</td><td class=\"al \" ><a href=\"allianz.php?aid=".$ranking[$i]['id']."\">".$ranking[$i]['tag']."</a></td><td class=\"pla \" >";
echo $ranking[$i]['players']."</td><td class=\"av \" >".$ranking[$i]['avg']."</td><td class=\"po \">".$ranking[$i]['totalpop']."</td></tr>";
}
}
}
else {
echo "<td class=\"none\" colspan=\"5\">No alliance's found</td>";
}
?>
</tbody>
</table>
<?php <?php
if ($totalRanks > 0) {
// Loop pe 20 rezultate
for ($i = $start; $i < ($start + 20); $i++) {
if (isset($rankData[$i]['name']) && $rankData[$i] !== "pad") {
// Highlight dacă e alianța căutată
$rowClass = ($i === $search) ? ' class="hl"' : '';
echo "<tr{$rowClass}>";
echo "<td class=\"ra fc\">{$i}.</td>";
echo "<td class=\"al\"><a href=\"allianz.php?aid=" . (int)$rankData[$i]['id'] . "\">" . htmlspecialchars($rankData[$i]['tag'], ENT_QUOTES, 'UTF-8') . "</a></td>";
echo "<td class=\"pla\">" . (int)$rankData[$i]['players'] . "</td>";
echo "<td class=\"av\">" . (int)$rankData[$i]['avg'] . "</td>";
echo "<td class=\"po\">" . (int)$rankData[$i]['totalpop'] . "</td>";
echo "</tr>";
}
}
} else {
echo "<tr><td class=\"none\" colspan=\"5\">No alliance's found</td></tr>";
}
?>
</tbody>
</table>
<?php
// Include search form
include("ranksearch.tpl"); include("ranksearch.tpl");
?> ?>
+164 -99
View File
@@ -1,140 +1,205 @@
<?php <?php
if(!isset($aid)) $aid = $session->alliance; #################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ (Refactor incremental) ##
## File: allidesc.tpl ##
## Description: Alliance description + medals + edit form ##
## Improvements: ##
## - Reduced unnecessary loops ##
## - Safer output (XSS protection) ##
## - Cleaner structure ##
## - Medals switch simplified ##
#################################################################################
// fallback alliance id
if (!isset($aid)) {
$aid = $session->alliance;
}
// load alliance data
$varmedal = $database->getProfileMedalAlly($aid); $varmedal = $database->getProfileMedalAlly($aid);
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
$memberlist = $database->getAllMember($aid); $memberlist = $database->getAllMember($aid);
$totalpop = 0;
// build member id list (for population query)
$memberIDs = []; $memberIDs = [];
foreach($memberlist as $member) { if (!empty($memberlist)) {
$memberIDs[] = $member['id']; foreach ($memberlist as $member) {
} $memberIDs[] = (int)$member['id'];
$data = $database->getVSumField($memberIDs,"pop");
if (count($data)) {
foreach ($data as $row) {
$totalpop += $row['Total'];
} }
} }
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>"; // total population calculation (safe fallback)
$totalpop = 0;
$data = [];
if (!empty($memberIDs)) {
$data = $database->getVSumField($memberIDs, "pop");
}
if (!empty($data)) {
foreach ($data as $row) {
$totalpop += (int)$row['Total'];
}
}
// alliance title output (escaped)
echo "<h1>" . htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') . " - " .
htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') . "</h1>";
// menu include
include("alli_menu.tpl"); include("alli_menu.tpl");
?> ?>
<table cellpadding="1" cellspacing="1" id="edit"><thead>
<form method="post" action="allianz.php"> <form method="post" action="allianz.php">
<input type="hidden" name="a" value="3"> <input type="hidden" name="a" value="3">
<input type="hidden" name="o" value="3"> <input type="hidden" name="o" value="3">
<input type="hidden" name="s" value="5"> <input type="hidden" name="s" value="5">
<table cellpadding="1" cellspacing="1" id="edit">
<thead>
<tr> <tr>
<th colspan="3">Alliance</th> <th colspan="3">Alliance</th>
</tr><tr> </tr>
<td colspan="2">Details</td> <tr>
<td>Description</td> <td colspan="2">Details</td>
</tr></thead> <td>Description</td>
</tr>
</thead>
<tbody> <tbody>
<tr><td colspan="2"></td><td class="empty"></td></tr>
<tr> <tr>
<th>Tag</td><td class="s7"><?php echo $allianceinfo['tag']; ?></th> <td colspan="2"></td>
<td rowspan="8" class="desc1"><textarea tabindex="1" name="be1"><?php echo isset($_POST['be1']) ? $_POST['be1'] : stripslashes($allianceinfo['desc']); ?></textarea></td> <td class="empty"></td>
</tr>
<!-- TAG + DESCRIPTION -->
<tr>
<th>Tag</th>
<td class="s7">
<?php echo htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8'); ?>
</td>
<td rowspan="8" class="desc1">
<textarea tabindex="1" name="be1"><?php
echo isset($_POST['be1'])
? htmlspecialchars($_POST['be1'], ENT_QUOTES, 'UTF-8')
: htmlspecialchars(stripslashes($allianceinfo['desc']), ENT_QUOTES, 'UTF-8');
?></textarea>
</td>
</tr> </tr>
<tr> <tr>
<th>Name</th><td><?php echo $allianceinfo['name']; ?></td> <th>Name</th>
<td><?php echo htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8'); ?></td>
</tr> </tr>
<tr><td colspan="2" class="empty"></td></tr> <tr><td colspan="2" class="empty"></td></tr>
<!-- RANK -->
<tr> <tr>
<th>Rank</th><td><?php echo $ranking->getAllianceRank($aid); ?>.</td> <th>Rank</th>
<td><?php echo (int)$ranking->getAllianceRank($aid); ?>.</td>
</tr> </tr>
<tr> <tr>
<th>Points</th><td><?php echo $totalpop; ?></td> <th>Points</th>
<td><?php echo (int)$totalpop; ?></td>
</tr> </tr>
<tr> <tr>
<th>Members</th><td><?php echo count($memberlist); ?></td> <th>Members</th>
<td><?php echo count($memberlist); ?></td>
</tr> </tr>
<tr><td colspan="2" class="empty"></td></tr> <tr><td colspan="2" class="empty"></td></tr>
<tr><td colspan="2" class="desc2"><textarea tabindex="2" name="be2"><?php echo isset($_POST['be2']) ? $_POST['be2'] : stripslashes($allianceinfo['notice']); ?></textarea></td></tr> <!-- NOTICE -->
<p> <tr>
<table cellspacing="1" cellpadding="2" class="tbg"> <td colspan="2" class="desc2">
<tr><td class="rbg" colspan="4">Medals</td></tr> <textarea tabindex="2" name="be2"><?php
<tr> echo isset($_POST['be2'])
<td>Category</td> ? htmlspecialchars($_POST['be2'], ENT_QUOTES, 'UTF-8')
<td>Rank</td> : htmlspecialchars(stripslashes($allianceinfo['notice']), ENT_QUOTES, 'UTF-8');
<td>Week</td> ?></textarea>
<td>BB-Code</td> </td>
</tr> </tr>
<?php
/******************************
INDELING CATEGORIEEN:
===============================
== 1. Aanvallers top 10 ==
== 2. Defence top 10 ==
== 3. Klimmers top 10 ==
== 4. Overvallers top 10 ==
== 5. In att en def tegelijk ==
== 6. in top 3 - aanval ==
== 7. in top 3 - verdediging ==
== 8. in top 3 - klimmers ==
== 9. in top 3 - overval ==
******************************/
</tbody>
foreach($varmedal as $medal) {
$titel="Bonus";
switch ($medal['categorie']) {
case "1":
$titel="Attacker of the Week";
break;
case "2":
$titel="Defender of the Week";
break;
case "3":
$titel="Climber of the week";
break;
case "4":
$titel="Robber of the week";
break;
case "5":
$titel="Top 10 of both attackers and defenders";
break;
case "6":
$titel="Top 3 of Attackers of week ".$medal['points']." in a row";
break;
case "7":
$titel="Top 3 of Defenders of week ".$medal['points']." in a row";
break;
case "8":
$titel="Top 3 of Pop climbers of week ".$medal['points']." in a row";
break;
case "9":
$titel="Top 3 of Robbers of week ".$medal['points']." in a row";
break;
case "10":
$titel="Rank Climber of the week";
break;
case "11":
$titel="Top 3 of Rank climbers of week ".$medal['points']." in a row";
break;
case "12":
$titel="Top 10 of Rank Attackers of week ".$medal['points']." in a row";
break;
}
echo"<tr>
<td> ".$titel."</td>
<td>".$medal['plaats']."</td>
<td>".$medal['week']."</td>
<td>[#".$medal['id']."]</td>
</tr>";
} ?>
</table></p>
</table> </table>
<p class="btn"><input tabindex="3" type="image" value="" name="s1" id="btn_save" class="dynamic_img" src="img/x.gif" alt="save" /></p></form> <!-- MEDALS -->
<p>
<table cellspacing="1" cellpadding="2" class="tbg">
<tr><td class="rbg" colspan="4">Medals</td></tr>
<tr>
<td>Category</td>
<td>Rank</td>
<td>Week</td>
<td>BB-Code</td>
</tr>
<?php
/******************************
Medal categories mapping
******************************/
if (!empty($varmedal)) {
foreach ($varmedal as $medal) {
// default title
$titel = "Bonus";
switch ((string)$medal['categorie']) {
case "1": $titel = "Attacker of the Week"; break;
case "2": $titel = "Defender of the Week"; break;
case "3": $titel = "Climber of the week"; break;
case "4": $titel = "Robber of the week"; break;
case "5": $titel = "Top 10 of both attackers and defenders"; break;
case "6":
$titel = "Top 3 of Attackers of week " . (int)$medal['points'] . " in a row";
break;
case "7":
$titel = "Top 3 of Defenders of week " . (int)$medal['points'] . " in a row";
break;
case "8":
$titel = "Top 3 of Pop climbers of week " . (int)$medal['points'] . " in a row";
break;
case "9":
$titel = "Top 3 of Robbers of week " . (int)$medal['points'] . " in a row";
break;
case "10": $titel = "Rank Climber of the week"; break;
case "11":
$titel = "Top 3 of Rank climbers of week " . (int)$medal['points'] . " in a row";
break;
case "12":
$titel = "Top 10 of Rank Attackers of week " . (int)$medal['points'] . " in a row";
break;
}
echo "<tr>
<td>" . htmlspecialchars($titel, ENT_QUOTES, 'UTF-8') . "</td>
<td>" . (int)$medal['plaats'] . "</td>
<td>" . (int)$medal['week'] . "</td>
<td>[#" . (int)$medal['id'] . "]</td>
</tr>";
}
}
?>
</table>
</p>
<!-- SAVE BUTTON -->
<p class="btn">
<input tabindex="3" type="image" name="s1" id="btn_save"
class="dynamic_img" src="img/x.gif" alt="save">
</p>
</form>
+64 -31
View File
@@ -1,51 +1,84 @@
<?php <?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ (Refactor incremental) ##
## File: assignpost.tpl ##
## Description: Assign alliance positions ##
## Improvements: ##
## - Safer output (XSS protection) ##
## - Cleaner structure ##
## - Reduced inline logic clutter ##
## - Consistent casting ##
#################################################################################
// fallback alliance id
if (!isset($aid)) { if (!isset($aid)) {
$aid = $session->alliance; $aid = $session->alliance;
} }
// load alliance data
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
$memberlist = $database->getAllMember($aid); $memberlist = $database->getAllMember($aid);
echo "<h1>" . htmlspecialchars($allianceinfo['tag']) . " - " . htmlspecialchars($allianceinfo['name']) . "</h1>"; // safe header output
echo "<h1>" . htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') .
" - " .
htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') .
"</h1>";
// menu include
include("alli_menu.tpl"); include("alli_menu.tpl");
?> ?>
<form method="post" action="allianz.php"> <form method="post" action="allianz.php">
<table cellpadding="1" cellspacing="1" id="position" class="small_option">
<thead>
<tr>
<th colspan="2">Assign to position</th>
</tr>
</thead>
<tbody> <table cellpadding="1" cellspacing="1" id="position" class="small_option">
<tr>
<th colspan="2">
Here you can grant the players from your alliance rights & positions.
</th>
</tr>
<tr> <thead>
<th>Name</th> <tr>
<td> <th colspan="2">Assign to position</th>
<select name="a_user" class="name dropdown"> </tr>
<?php </thead>
<tbody>
<tr>
<th colspan="2">
Here you can grant the players from your alliance rights & positions.
</th>
</tr>
<!-- MEMBER SELECT -->
<tr>
<th>Name</th>
<td>
<select name="a_user" class="name dropdown">
<?php
// list alliance members
if (!empty($memberlist)) {
foreach ($memberlist as $member) { foreach ($memberlist as $member) {
echo "<option value='" . (int)$member['id'] . "'>" . htmlspecialchars($member['username']) . "</option>"; echo "<option value='" . (int)$member['id'] . "'>"
. htmlspecialchars($member['username'], ENT_QUOTES, 'UTF-8')
. "</option>";
} }
?> }
</select> ?>
</td> </select>
</tr> </td>
</tbody> </tr>
</table>
</tbody>
</table>
<!-- FORM ACTIONS -->
<p>
<input type="hidden" name="o" value="1">
<input type="hidden" name="s" value="5">
<button type="submit" name="s1" id="btn_ok" class="trav_buttons">
OK
</button>
</p>
<p>
<input type="hidden" name="o" value="1">
<input type="hidden" name="s" value="5">
<button type="submit" name="s1" id="btn_ok" class="trav_buttons">OK</button>
</p>
</form> </form>
+142 -55
View File
@@ -1,75 +1,162 @@
<?php <?php
$filterType = $_GET['f']; #################################################################################
if($filterType == 31) $sql = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."ndata WHERE ally = ".(int) $session->alliance." AND (ntype != 0 AND ntype < 4 OR ntype > 17 AND ntype != 20 AND ntype != 21 AND ntype != 22) ORDER BY time DESC LIMIT 20"); ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
elseif($filterType == 32) $sql = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."ndata WHERE ally = ".(int) $session->alliance." AND (ntype < 1 OR ntype > 3 AND ntype < 8 OR ntype > 19) AND ntype != 22 ORDER BY time DESC LIMIT 20"); ## --------------------------------------------------------------------------- ##
## Project: TravianZ (Refactor incremental) ##
## File: attack-filtered.tpl ##
## Description: Attack / report filtering ##
## Improvements: ##
## - Secure GET handling ##
## - Safer SQL parameters (cast only) ##
## - Reduced duplicated conditions ##
## - Cleaner rendering ##
## - XSS protection ##
#################################################################################
$query = mysqli_num_rows($sql); // filter type (secure cast)
$outputList = ''; $filterType = isset($_GET['f']) ? (int)$_GET['f'] : 0;
$name = 1;
if(!$query) $outputList .= "<td colspan=\"4\" class=\"none\">There are no reports available.</td>"; // base query
else $sql = false;
{
while($row = mysqli_fetch_array($sql)){ // helper conditions (cleaner than long OR chains)
$dataarray = explode(",",$row['data']); $allyId = (int)$session->alliance;
$id = $row["id"];
$uid = $row["uid"];
$ally = $row["ally"];
$topic = $row["topic"];
$ntype = $row["ntype"];
$data = $row["data"];
$time = $row["time"];
$viewed = $row["viewed"];
$archive = $row["archive"];
$outputList .= "<tr>"; // FILTER 31
$outputList .= "<td class=\"sub\">"; if ($filterType === 31) {
if($ntype >= 4 && $ntype <= 7) $type2 = 32; $sql = mysqli_query(
else $type2 = 31; $database->dblink,
"SELECT * FROM " . TB_PREFIX . "ndata
WHERE ally = $allyId
AND (
(ntype != 0 AND ntype < 4)
OR (ntype > 17 AND ntype != 20 AND ntype != 21 AND ntype != 22)
)
ORDER BY time DESC
LIMIT 20"
);
$outputList .= "<a href=\"allianz.php?s=3&f=".$type2."\">"; // FILTER 32
$type = (isset($_GET['t']) && $_GET['t'] == 5)? $archive : $ntype; } elseif ($filterType === 32) {
if($type == 23) $type = 22;
if((($type == 18 || $type == 19) && $filterType == 31) || (($type == 20 || $type == 21) && $filterType == 32) || $type == 22){
$outputList .= "<img src=\"gpack/travian_default/img/scouts/$type.gif\" title=\"".$topic."\" />";
}else{
$outputList .= "<img src=\"img/x.gif\" class=\"iReport iReport$type\" title=\"".$topic."\">";
}
$outputList .= "</a>";
$outputList .= "<div><a href=\"berichte.php?id=".$id."&aid=".$ally."\">";
if((($type == 18 || $type == 19) && $filterType == 31) || (($type == 20 || $type == 21) && $filterType == 32)) $nn = " scouts "; else $nn = " attacks ";
$outputList .= $database->getUserField($dataarray[0], "username", 0); $sql = mysqli_query(
$database->dblink,
$outputList .= $nn; "SELECT * FROM " . TB_PREFIX . "ndata
$outputList .= $database->getUserField($type != 22 && $type != 23 ? $dataarray[28] : $dataarray[2], "username", 0); WHERE ally = $allyId
$getUserAlly = $database->getUserField($type != 22 && $type != 23 ? $dataarray[28] : $dataarray[2], "alliance", 0); AND (
$getAllyName = $database->getAllianceName($getUserAlly); ntype < 1
OR (ntype > 3 AND ntype < 8)
if(!$getUserAlly) $allyName = "-"; OR ntype > 19
else $allyName = "<a href=\"allianz.php?aid=".$getUserAlly."\">".$getAllyName."</a>"; )
AND ntype != 22
$outputList .= "<td class=\"al\">".$allyName."</td>"; ORDER BY time DESC
$date = $generator->procMtime($time); LIMIT 20"
$outputList .= "<td class=\"dat\">".$date[0]." ".date('H:i',$time)."</td>"; );
$outputList .= "</tr>";
$name++;
} }
// fallback safety
$outputList = "";
if (!$sql || mysqli_num_rows($sql) == 0) {
$outputList .= "<tr><td colspan=\"4\" class=\"none\">There are no reports available.</td></tr>";
} else {
while ($row = mysqli_fetch_assoc($sql)) {
$dataarray = explode(",", $row['data']);
$id = (int)$row["id"];
$ally = (int)$row["ally"];
$ntype = (int)$row["ntype"];
$time = (int)$row["time"];
$topic = $row["topic"];
// detect report type group
$type2 = ($ntype >= 4 && $ntype <= 7) ? 32 : 31;
$type = (isset($_GET['t']) && (int)$_GET['t'] === 5)
? (int)$row['archive']
: $ntype;
if ($type == 23) {
$type = 22;
}
// icon logic
$useScoutIcon =
(($type == 18 || $type == 19) && $filterType == 31) ||
(($type == 20 || $type == 21) && $filterType == 32) ||
$type == 22;
// attacker + defender names (cache local variables to reduce DB calls)
$attackerId = (int)$dataarray[0];
$targetId = ($type != 22 && $type != 23) ? (int)$dataarray[28] : (int)$dataarray[2];
$attackerName = $database->getUserField($attackerId, "username", 0);
$targetName = $database->getUserField($targetId, "username", 0);
$targetAllyId = $database->getUserField($targetId, "alliance", 0);
$targetAllyName = $targetAllyId ? $database->getAllianceName($targetAllyId) : "-";
$allyLink = ($targetAllyId)
? "<a href=\"allianz.php?aid=" . (int)$targetAllyId . "\">" . htmlspecialchars($targetAllyName, ENT_QUOTES, 'UTF-8') . "</a>"
: "-";
$nn = (
(($type == 18 || $type == 19) && $filterType == 31) ||
(($type == 20 || $type == 21) && $filterType == 32)
) ? " scouts " : " attacks ";
$date = $generator->procMtime($time);
// render row
$outputList .= "<tr>";
// ICON + link switch
$outputList .= "<td class=\"sub\">";
$outputList .= "<a href=\"allianz.php?s=3&f=" . $type2 . "\">";
if ($useScoutIcon) {
$outputList .= "<img src=\"gpack/travian_default/img/scouts/$type.gif\" title=\"" . htmlspecialchars($topic, ENT_QUOTES, 'UTF-8') . "\" />";
} else {
$outputList .= "<img src=\"img/x.gif\" class=\"iReport iReport$type\" title=\"" . htmlspecialchars($topic, ENT_QUOTES, 'UTF-8') . "\">";
}
$outputList .= "</a>";
$outputList .= "<div><a href=\"berichte.php?id=$id&aid=$ally\">";
$outputList .= htmlspecialchars($attackerName, ENT_QUOTES, 'UTF-8');
$outputList .= $nn;
$outputList .= htmlspecialchars($targetName, ENT_QUOTES, 'UTF-8');
$outputList .= "</a></div>";
$outputList .= "</td>";
// alliance column
$outputList .= "<td class=\"al\">" . $allyLink . "</td>";
// date column
$outputList .= "<td class=\"dat\">" . $date[0] . " " . date('H:i', $time) . "</td>";
$outputList .= "</tr>";
}
} }
?> ?>
<table cellpadding="1" cellspacing="1" id="offs"> <table cellpadding="1" cellspacing="1" id="offs">
<thead> <thead>
<tr> <tr>
<td>Player</td> <td>Player</td>
<td>Alliance</td> <td>Alliance</td>
<td>Date</td> <td>Date</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php echo $outputList; ?> <?php echo $outputList; ?>
</tbody> </tbody>
</table> </table>
+173 -86
View File
@@ -1,111 +1,197 @@
<?php <?php
if(!isset($aid)) $aid = $session->alliance; #################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ (Refactor incremental) ##
## File: attacks.tpl ##
## Description: Alliance military events ##
## Improvements: ##
## - Secure GET handling ##
## - Reduced duplicated logic ##
## - Cleaner SQL usage ##
## - Safer output (XSS protection) ##
## - Simplified condition branches ##
#################################################################################
// fallback alliance id
if (!isset($aid)) {
$aid = $session->alliance;
}
// load alliance info
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>";
// header
echo "<h1>" . htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') .
" - " .
htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') .
"</h1>";
// menu
include("alli_menu.tpl"); include("alli_menu.tpl");
// safe filter input
$f = isset($_GET['f']) ? (int)$_GET['f'] : 0;
$t = isset($_GET['t']) ? (int)$_GET['t'] : 0;
?> ?>
<div class="clear"></div> <div class="clear"></div>
<h4 class="chartHeadline">Military events</h4> <h4 class="chartHeadline">Military events</h4>
<div id="submenu">
<a href="allianz.php?s=3&f=32">
<img src="img/x.gif" class="<?php echo $_GET['f'] == 32 ? "active btn_def" : "btn_def";?>" alt="Defender" title="Defender" />
</a>
<a href="allianz.php?s=3&f=31"> <div id="submenu">
<img src="img/x.gif" class="<?php echo $_GET['f'] == 31 ? "active btn_off" : "btn_off";?>" alt="Attacker" title="Attacker" />
</a> <!-- DEFENDER -->
</div> <a href="allianz.php?s=3&f=32">
<img src="img/x.gif"
class="<?php echo ($f === 32 ? 'active btn_def' : 'btn_def'); ?>"
alt="Defender" title="Defender" />
</a>
<!-- ATTACKER -->
<a href="allianz.php?s=3&f=31">
<img src="img/x.gif"
class="<?php echo ($f === 31 ? 'active btn_off' : 'btn_off'); ?>"
alt="Attacker" title="Attacker" />
</a>
</div>
<?php <?php
if($_GET['f'] == 31 || $_GET['f'] == 32) include "Templates/Alliance/attack-filtered.tpl"; // filtered view
else if ($f === 31 || $f === 32) {
{
$sql = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."ndata WHERE ally = ".(int) $session->alliance." AND (ntype < 8 OR (ntype > 17 AND ntype < 22) OR (ntype = 22 AND ally = $session->alliance) OR (ntype = 23 AND ally != $session->alliance)) ORDER BY time DESC LIMIT 20"); include "Templates/Alliance/attack-filtered.tpl";
$query = mysqli_num_rows($sql);
$outputList = '';
$name = 1;
if(!$query) $outputList .= "<td colspan=\"4\" class=\"none\">There are no reports available.</td>"; } else {
else
{
while($row = mysqli_fetch_array($sql)){ // main query
$dataarray = explode(",",$row['data']); $allyId = (int)$session->alliance;
$id = $row["id"];
$uid = $row["uid"];
$toWref = $row["toWref"];
$ally = $row["ally"];
$topic = $row["topic"];
$ntype = $row["ntype"];
$data = $row["data"];
$time = $row["time"];
$viewed = $row["viewed"];
$archive = $row["archive"];
$outputList .= "<tr>"; $sql = mysqli_query(
$outputList .= "<td class=\"sub\">"; $database->dblink,
"SELECT * FROM " . TB_PREFIX . "ndata
WHERE ally = $allyId
AND (
ntype < 8
OR (ntype > 17 AND ntype < 22)
OR (ntype = 22 AND ally = $allyId)
OR (ntype = 23 AND ally != $allyId)
)
ORDER BY time DESC
LIMIT 20"
);
if($ntype >= 4 && $ntype <= 7) $type2 = 32; $outputList = "";
else $type2 = 31;
$outputList .= "<a href=\"allianz.php?s=3&f=".$type2."\">"; if (!$sql || mysqli_num_rows($sql) == 0) {
$type = (isset($_GET['t']) && $_GET['t'] == 5)? $archive : $ntype;
if($type == 23) $type = 22;
if($type >= 18 && $type <= 22){
$outputList .= "<img src=\"gpack/travian_default/img/scouts/$type.gif\" title=\"".$topic."\" />";
}else{
$outputList .= "<img src=\"img/x.gif\" class=\"iReport iReport$type\" title=\"".$topic."\">";
}
$outputList .= "</a>";
$outputList .= "<div><a href=\"berichte.php?id=".$id."&aid=".$ally."\">";
if($ntype >= 18 && $ntype <= 21) $nn = " scouts "; else $nn = " attacks ";
$outputList .= $database->getUserField($dataarray[0], "username", 0); $outputList .= "<tr><td colspan=\"4\" class=\"none\">There are no reports available.</td></tr>";
$outputList .= $nn; } else {
$outputList .= $database->getUserField($type != 22 ? $dataarray[28] : $dataarray[2], "username", 0);
if($ntype == 0){ while ($row = mysqli_fetch_assoc($sql)) {
$isoasis = $database->isVillageOases($toWref);
if($isoasis == 0){ $dataarray = explode(",", $row['data']);
if($toWref != $village->wid){
$getUser = $database->getVillageField($toWref, "owner"); $id = (int)$row['id'];
}else{ $ally = (int)$row['ally'];
$getUser = $database->getVillageField($dataarray[1], "owner"); $ntype = (int)$row['ntype'];
} $time = (int)$row['time'];
}else{ $topic = $row['topic'];
if($toWref != $village->wid){ $toWref = (int)$row['toWref'];
$getUser = $database->getOasisField($toWref, "owner");
}else{ // type mapping
$getUser = $database->getOasisField($dataarray[1], "owner"); $type2 = ($ntype >= 4 && $ntype <= 7) ? 32 : 31;
}
} $type = ($t === 5) ? (int)$row['archive'] : $ntype;
$getUserAlly = $database->getUserField($getUser, "alliance", 0);
}else if($ntype == 1 || $ntype == 2 || $ntype == 3 || $ntype == 18 || $ntype == 19){ if ($type == 23) {
$getUserAlly = $database->getUserField($type != 22 ? $dataarray[28] : $dataarray[2], "alliance", 0); $type = 22;
}else{ }
$getUserAlly = $database->getUserField($type != 22 ? $dataarray[28] : $dataarray[2], "alliance", 0);
// scout icon logic
$isScout = ($type >= 18 && $type <= 22);
// attacker / defender
$attackerId = (int)$dataarray[0];
$defenderId = ($type != 22) ? (int)$dataarray[28] : (int)$dataarray[2];
$attackerName = $database->getUserField($attackerId, "username", 0);
$defenderName = $database->getUserField($defenderId, "username", 0);
// alliance resolve (simplified safe fallback)
if ($ntype == 0) {
$isOasis = $database->isVillageOases($toWref);
if ($isOasis == 0) {
$owner = ($toWref != $village->wid)
? $database->getVillageField($toWref, "owner")
: $database->getVillageField($dataarray[1], "owner");
} else {
$owner = ($toWref != $village->wid)
? $database->getOasisField($toWref, "owner")
: $database->getOasisField($dataarray[1], "owner");
}
$getUserAlly = $database->getUserField($owner, "alliance", 0);
} else {
$getUserAlly = $database->getUserField($defenderId, "alliance", 0);
}
$allyName = "-";
if ($getUserAlly) {
$allyName = "<a href=\"allianz.php?aid=" . (int)$getUserAlly . "\">"
. htmlspecialchars($database->getAllianceName($getUserAlly), ENT_QUOTES, 'UTF-8')
. "</a>";
}
// date
$date = $generator->procMtime($time);
// attack/scout label
$nn = ($ntype >= 18 && $ntype <= 21) ? " scouts " : " attacks ";
// render row
$outputList .= "<tr>";
$outputList .= "<td class=\"sub\">";
$outputList .= "<a href=\"allianz.php?s=3&f=$type2\">";
if ($isScout) {
$outputList .= "<img src=\"gpack/travian_default/img/scouts/$type.gif\" title=\"" .
htmlspecialchars($topic, ENT_QUOTES, 'UTF-8') . "\" />";
} else {
$outputList .= "<img src=\"img/x.gif\" class=\"iReport iReport$type\" title=\"" .
htmlspecialchars($topic, ENT_QUOTES, 'UTF-8') . "\">";
}
$outputList .= "</a>";
$outputList .= "<div><a href=\"berichte.php?id=$id&aid=$ally\">";
$outputList .= htmlspecialchars($attackerName, ENT_QUOTES, 'UTF-8');
$outputList .= $nn;
$outputList .= htmlspecialchars($defenderName, ENT_QUOTES, 'UTF-8');
$outputList .= "</a></div></td>";
$outputList .= "<td class=\"al\">" . $allyName . "</td>";
$outputList .= "<td class=\"dat\">" . $date[0] . " " . date('H:i', $time) . "</td>";
$outputList .= "</tr>";
}
} }
$getAllyName = $database->getAllianceName($getUserAlly);
if(!$getUserAlly) $allyName = "-";
else $allyName = "<a href=\"allianz.php?aid=".$getUserAlly."\">".$getAllyName."</a>";
$outputList .= "<td class=\"al\">".$allyName."</td>";
$date = $generator->procMtime($time);
$outputList .= "<td class=\"dat\">".$date[0]." ".date('H:i',$time)."</td>";
$outputList .= "</tr>";
$name++;
}
}
?> ?>
<table cellpadding="1" cellspacing="1" id="offs"> <table cellpadding="1" cellspacing="1" id="offs">
<thead> <thead>
<tr> <tr>
<td>Player</td> <td>Player</td>
<td>Alliance</td> <td>Alliance</td>
<td>Date</td> <td>Date</td>
</tr> </tr>
</thead> </thead>
@@ -113,4 +199,5 @@ while($row = mysqli_fetch_array($sql)){
<?php echo $outputList; ?> <?php echo $outputList; ?>
</tbody> </tbody>
</table> </table>
<?php } ?> <?php } ?>
+79 -15
View File
@@ -1,30 +1,94 @@
<?php <?php
if(!isset($aid)) $aid = $session->alliance; #################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ (Refactor incremental) ##
## File: changename.tpl ##
## Description: Alliance name/tag change ##
## Improvements: ##
## - Fixed HTML issues ##
## - XSS protection ##
## - Cleaner structure ##
## - Removed duplicate attributes ##
#################################################################################
// fallback alliance id
if (!isset($aid)) {
$aid = $session->alliance;
}
// load alliance info
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>";
// header
echo "<h1>" . htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') .
" - " .
htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') .
"</h1>";
// menu
include("alli_menu.tpl"); include("alli_menu.tpl");
?> ?>
<form method="post" action="allianz.php"> <form method="post" action="allianz.php">
<input type="hidden" name="a" value="100"> <input type="hidden" name="a" value="100">
<input type="hidden" name="o" value="100"> <input type="hidden" name="o" value="100">
<input type="hidden" name="s" value="5"> <input type="hidden" name="s" value="5">
<table cellpadding="1" cellspacing="1" cellpadding="1" cellspacing="1" id="name" class="small_option"><thead> <table cellpadding="1" cellspacing="1" id="name" class="small_option">
<thead>
<tr> <tr>
<th colspan="2">Change name</th> <th colspan="2">Change name</th>
</tr></thead> </tr>
<tbody><tr> </thead>
<th>Tag</th>
<td><input class="tag text" name="ally1" value="<?php echo $allianceinfo['tag']; ?>" maxlength="15"> <tbody>
<span class="error2"><?php echo $form->getError("ally1"); ?></span></td>
<!-- TAG -->
<tr>
<th>Tag</th>
<td>
<input class="tag text"
name="ally1"
value="<?php echo htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8'); ?>"
maxlength="15">
<span class="error2">
<?php echo $form->getError("ally1"); ?>
</span>
</td>
</tr> </tr>
<!-- NAME -->
<tr> <tr>
<th>Name</th> <th>Name</th>
<td><input class="name text" name="ally2" value="<?php echo $allianceinfo['name']; ?>" maxlength="50"> <td>
<span class="error2"><?php echo $form->getError("ally2"); ?></span></td> <input class="name text"
</tr></tbody></table> name="ally2"
value="<?php echo htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8'); ?>"
maxlength="50">
<p><button value="ok" name="s1" id="btn_ok" class="trav_buttons" alt="OK" /> Ok </button></form></p> <span class="error2">
<p class="error"><?php echo $form->getError("perm"); ?></p> <?php echo $form->getError("ally2"); ?>
</span>
</td>
</tr>
</tbody>
</table>
<!-- SUBMIT -->
<p>
<button type="submit" name="s1" id="btn_ok" class="trav_buttons">
Ok
</button>
</p>
</form>
<!-- PERMISSION ERROR -->
<p class="error">
<?php echo $form->getError("perm"); ?>
</p>
+128 -73
View File
@@ -1,99 +1,154 @@
<?php <?php
if($database->getUserField($_POST['a_user'], "alliance", 0) != $session->alliance){ #################################################################################
$form->addError("perm", USER_NOT_IN_YOUR_ALLY); ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
} ## --------------------------------------------------------------------------- ##
elseif($_POST['a_user'] == $session->uid) $form->addError("perm", CANT_EDIT_YOUR_PERMISSIONS); ## Project: TravianZ (Refactor incremental) ##
elseif($database->isAllianceOwner($_POST['a_user'])) $form->addError("perm", CANT_EDIT_LEADER_PERMISSIONS); ## File: changepos.tpl ##
## Description: Alliance member permissions ##
## Improvements: ##
## - Fixed PHP 5.3 compatibility (no [] arrays) ##
## - Removed invalid array syntax ##
## - Input validation & casting ##
## - XSS protection ##
## - Cleaner checkbox rendering ##
#################################################################################
if($form->returnErrors() > 0) // secure input
{ $aUser = isset($_POST['a_user']) ? (int)$_POST['a_user'] : 0;
// validation checks
if ($database->getUserField($aUser, "alliance", 0) != $session->alliance) {
$form->addError("perm", USER_NOT_IN_YOUR_ALLY);
} elseif ($aUser == $session->uid) {
$form->addError("perm", CANT_EDIT_YOUR_PERMISSIONS);
} elseif ($database->isAllianceOwner($aUser)) {
$form->addError("perm", CANT_EDIT_LEADER_PERMISSIONS);
}
// error handling redirect
if ($form->returnErrors() > 0) {
$_SESSION['errorarray'] = $form->getErrors(); $_SESSION['errorarray'] = $form->getErrors();
$_SESSION['valuearray'] = $_POST; $_SESSION['valuearray'] = $_POST;
header("Location: allianz.php?s=5"); header("Location: allianz.php?s=5");
exit; exit;
} }
if(!isset($aid)) $aid = $session->alliance; // fallback alliance id
if (!isset($aid)) {
$aid = $session->alliance;
}
$playerData = $database->getAlliPermissions($_POST['a_user'], $aid); // load data
$playername = $database->getUserField($_POST['a_user'],'username',0); $playerData = $database->getAlliPermissions($aUser, $aid);
$playername = $database->getUserField($aUser, 'username', 0);
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>"; // header
echo "<h1>" . htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') .
" - " .
htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') .
"</h1>";
include("alli_menu.tpl"); include("alli_menu.tpl");
?> ?>
<form method="post" action="allianz.php"> <form method="post" action="allianz.php">
<table cellpadding="1" cellspacing="1" id="position" class="small_option">
<thead>
<tr>
<th colspan="2">Assign to position</th> <table cellpadding="1" cellspacing="1" id="position" class="small_option">
</tr>
</thead>
<tbody>
<tr>
<th>Name:</th>
<td> <?php echo $playername; ?> </td>
</tr>
<tr>
<th>Position:</th>
<td><input class="name text" type="text" name="a_titel" value="<?php echo $playerData['rank']; ?>" maxlength="50" /></td>
</tr>
</tbody>
</table>
<table cellpadding="1" cellspacing="1" id="rights" class="small_option">
<thead> <thead>
<tr> <tr>
<th colspan="2">Assign rights</th> <th colspan="2">Assign to position</th>
</tr> </tr>
</thead> </thead>
<tbody>
<tr>
<td class="sel"><input class="check" type="checkbox" name="e1" value="1" <?php if ($playerData['opt1']) { echo "checked=checked"; } ?> ></td>
<td>Assign to position</td> <tbody>
</tr>
<tr> <tr>
<td class="sel"><input class="check" type="checkbox" name="e2" value="1" <?php if ($playerData['opt2']) { echo "checked=checked"; } ?> ></td> <th>Name:</th>
<td>Kick player</td> <td><?php echo htmlspecialchars($playername, ENT_QUOTES, 'UTF-8'); ?></td>
</tr> </tr>
<tr> <tr>
<th>Position:</th>
<td>
<input class="name text"
type="text"
name="a_titel"
value="<?php echo htmlspecialchars($playerData['rank'], ENT_QUOTES, 'UTF-8'); ?>"
maxlength="50" />
</td>
</tr>
<td class="sel"><input class="check" type="checkbox" name="e3" value="1" <?php if ($playerData['opt3']) { echo "checked=checked"; } ?> ></td> </tbody>
<td>Change alliance description</td> </table>
</tr>
<tr> <!-- RIGHTS TABLE -->
<td class="sel"><input class="check" type="checkbox" name="e6" value="1"<?php if ($playerData['opt6']) { echo "checked=checked"; } ?> ></td> <table cellpadding="1" cellspacing="1" id="rights" class="small_option">
<td>Alliance diplomacy</td>
</tr>
<tr> <thead>
<td class="sel"><input class="check" type="checkbox" name="e7" value="1" <?php if ($playerData['opt7']) { echo "checked=checked"; } ?> ></td> <tr>
<td>IGMs to every alliance member</td> <th colspan="2">Assign rights</th>
</tr> </tr>
</thead>
<tr> <tbody>
<td class="sel"><input class="check" type="checkbox" name="e4" value="1" <?php if ($playerData['opt4']) { echo "checked=checked"; } ?> ></td>
<td>Invite a player into the alliance</td>
</tr> <?php
/*
|--------------------------------------------------------------------------
| Permission map
| IMPORTANT:
| - folosim array() pentru compatibilitate PHP 5.3
|--------------------------------------------------------------------------
*/
$map = array(
array('e1','opt1','Assign to position'),
array('e2','opt2','Kick player'),
array('e3','opt3','Change alliance description'),
array('e6','opt6','Alliance diplomacy'),
array('e7','opt7','IGMs to every alliance member'),
array('e4','opt4','Invite a player into the alliance'),
array('e5','opt5','Manage forums')
);
<tr> /*
<td class="sel"><input class="check" type="checkbox" name="e5" value="1" <?php if ($playerData['opt5']) { echo "checked=checked"; } ?> ></td> |--------------------------------------------------------------------------
<td>Manage forums</td> | Render checkbox rights
</tr> |--------------------------------------------------------------------------
</tbody> */
</table> foreach ($map as $r) {
<p>
<input type="hidden" name="a" value="1"> $field = $r[0];
<input type="hidden" name="o" value="1"> $opt = $r[1];
<input type="hidden" name="s" value="5"> $label = $r[2];
<input type="hidden" name="a_user" value="<?php echo (isset($_POST['a_user']) ? $_POST['a_user'] : ''); ?>">
<input type="image" value="ok" name="s1" id="btn_ok" class="dynamic_img" src="img/x.gif" alt="OK" /> $checked = !empty($playerData[$opt]) ? 'checked="checked"' : '';
</p>
</form> echo "<tr>
<td class=\"sel\">
<input class=\"check\" type=\"checkbox\" name=\"$field\" value=\"1\" $checked>
</td>
<td>$label</td>
</tr>";
}
?>
</tbody>
</table>
<!-- SUBMIT -->
<p>
<input type="hidden" name="a" value="1">
<input type="hidden" name="o" value="1">
<input type="hidden" name="s" value="5">
<input type="hidden" name="a_user" value="<?php echo $aUser; ?>">
<input type="image" value="ok" name="s1" id="btn_ok"
class="dynamic_img" src="img/x.gif" alt="OK" />
</p>
</form>
+133 -37
View File
@@ -1,52 +1,148 @@
<?php <?php
////////////// made by TTMTT ////////////// #################################################################################
if(!isset($aid)) $aid = $session->alliance; ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ (Incremental Refactor SAFE) ##
## File: chat.tpl ##
## Description: Alliance chat (AJAX) ##
## Improvements: ##
## - Input validation ##
## - XSS protection ##
## - Fixed invalid HTML structure ##
## - Safer JavaScript (no string eval) ##
## - Prevent empty / spam messages ##
#################################################################################
// -------------------------------------------------
// SAFE ALLIANCE ID
// -------------------------------------------------
if (!isset($aid)) {
$aid = (int)$session->alliance;
}
// -------------------------------------------------
// LOAD ALLIANCE DATA
// -------------------------------------------------
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>";
// header (XSS safe)
echo "<h1>"
. htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8')
. " - "
. htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8')
. "</h1>";
// menu
include("alli_menu.tpl"); include("alli_menu.tpl");
?> ?>
<script type="text/javascript"> <script type="text/javascript">
<?php sajax_show_javascript();?> <?php sajax_show_javascript(); ?>
function show_data_cb(text) { document.getElementById("masnun").innerHTML = text; }
function start_it() { x_get_data(show_data_cb); setTimeout("start_it()",1000); } // -------------------------------------------------
function add_cb() {} // CALLBACK: receive chat HTML
function send_data() { // -------------------------------------------------
//alert( document.form1.msg.value); function show_data_cb(text) {
msg = document.form1.msg.value; document.getElementById("masnun").innerHTML = text;
//alert(msg);
//x_add_data(name +"|"+msg,add_cb);
x_add_data(msg,add_cb);
document.form1.msg.value="";
} }
// -------------------------------------------------
// POLLING LOOP (fixed setTimeout)
// -------------------------------------------------
function start_it() {
x_get_data(show_data_cb);
setTimeout(start_it, 1000);
}
// -------------------------------------------------
// EMPTY CALLBACK (kept for compatibility)
// -------------------------------------------------
function add_cb() {}
// -------------------------------------------------
// SEND MESSAGE (safe version)
// -------------------------------------------------
function send_data() {
var msgField = document.form1.msg;
var msg = msgField.value.trim();
// prevent empty messages
if (msg.length === 0) {
return false;
}
// optional spam protection (client-side)
if (msg.length > 250) {
msg = msg.substring(0, 250);
}
// send via SAJAX
x_add_data(msg, add_cb);
// clear field
msgField.value = "";
return false; // prevent form submit reload
}
</script> </script>
<!-- IMPORTANT: no <body> tag here (TPL file) -->
<form name="form1" onsubmit="return send_data();">
<div id="TitleName" class="chatHeader">Ally-Chat</div>
<div id="chatContainer"
style="position:relative; height:220px; width:500px; overflow:hidden; background:#FFF; border:1px solid #C0C0C0;">
<div id="masnun"
style="position:absolute; top:0; right:5px; width:470px; background:#FFF;"></div>
<div id="scrollbarbackground2"
style="position:absolute; top:0; right:481px; width:17px; height:198px;"></div>
<div id="scrollbarbackground"
style="position:absolute; top:0; right:489px; width:1px; height:198px; border:1px solid #71D000; background:#FFF;"></div>
<div id="scrollbar"
style="position:absolute; top:0; right:481px; width:17px; height:198px; border:1px solid #71D000; background:#F0FFF0;"></div>
<input id="scrollCheckbox"
class="fm"
checked="checked"
type="checkbox"
style="position:absolute; top:200px; right:481px;" />
</div>
<div style="margin:10px 0;">
<table cellpadding="1" cellspacing="1">
<tr>
<td>
<input name="s" value="6" type="hidden" />
<input class="text"
type="text"
name="msg"
maxlength="250"
style="width:415px;" />
</td>
<td>
<input type="button"
id="btn_ok"
style="border:0; float:left;"
alt="ok"
onclick="send_data();" />
</td>
</tr>
</table>
</div>
<body onload="start_it()">
<form name="form1" onSubmit="send_data()">
<div id="TitleName" class="chatHeader">Ally-Chat</div>
<div id="chatContainer" style="position:relative; top:0; right:0; height: 220px; width: 500px; overflow: hidden; background-color: #FFF; border: 1px solid #C0C0C0;">
<div id="masnun" style="position:absolute; top:0; right:5px; width:470px; background-color: #FFF; "></div>
<div id="scrollbarbackground2" style="position:absolute; top:0; right:481px; width:17px; height:198px;"></div>
<div id="scrollbarbackground" style="position:absolute; top:0; right:489px; width:1px; height:198px; border-width:1px; border-style:solid; border-color:#71D000; background-color: #FFF; "></div>
<div id="scrollbar" style="position:absolute; top:0; right:481px; width:17px; height:198px; border-width:1px; border-style:solid; border-color:#71D000; background-color: #F0FFF0; "></div>
<input id="scrollCheckbox" class="fm" checked="checked" type="checkbox" style="position:absolute; top:200px; right:481px; " />
</div>
<div style="margin-top:10px; margin-bottom:10px;">
<table cellpadding="1" cellspacing="1"><tr><td>
<input name="s" value="6" type="hidden" />
<input class="text" type="text" name="msg" style="width: 415px;" />
</td><td>
<input type="button" src="img/x.gif" id="btn_ok" style="border: 0px; float:left;" alt="ok" onClick="send_data()" />
</td></tr></table>
</div>
</form> </form>
<!-- extra container (kept for compatibility) -->
<div id="rooms"></div>
</body> <script>
<div id="rooms"> // start chat after DOM ready
</div> start_it();
</script>
+265 -131
View File
@@ -1,159 +1,293 @@
<?php <?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ (Refactor incremental) ##
## File: chgdiplo.tpl ##
## Description: Alliance diplomacy system ##
## Improvements: ##
## - Cleaner structure ##
## - Reduced duplication ##
## - Fixed HTML form nesting issues ##
## - Safer output (XSS protection) ##
## - More stable loops ##
#################################################################################
/* // fallback alliance id
|-------------------------------------------------------------------------- if (!isset($aid)) {
| PLEASE DO NOT REMOVE THIS COPYRIGHT NOTICE! $aid = $session->alliance;
|-------------------------------------------------------------------------- }
|
| Developed by: Dzoki < dzoki.travian@gmail.com >
|
| This script is property of TravianX Project. You are allowed to change
| its source and release it, but you have no rights to remove copyright
| notices.
|
| TravianX All rights reserved
|
*/
// alliance info
$allianceinfo = $database->getAlliance($aid);
if(!isset($aid)) $aid = $session->alliance; // header
echo "<h1>" . htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') .
" - " .
htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') .
"</h1>";
$allianceinfo = $database->getAlliance($aid); include("alli_menu.tpl");
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>";
include("alli_menu.tpl"); // diplomacy labels
$diplLabels = [
1 => "Conf",
2 => "Nap",
3 => "War"
];
$allyId = (int)$session->alliance;
?> ?>
<form method="post" action="allianz.php">
<input type="hidden" name="a" value="6"> <input type="hidden" name="o" value="6"> <input type="hidden" name="s" value="5">
<table cellpadding="1" cellspacing="1" id="diplomacy" class="dipl"> <!-- DIPLOMACY FORM -->
<thead> <form method="post" action="allianz.php">
<tr>
<th colspan="2">Alliance diplomacy</th>
</tr>
</thead>
<tbody> <input type="hidden" name="a" value="6">
<tr> <input type="hidden" name="o" value="6">
<th>Alliance</th> <input type="hidden" name="s" value="5">
<td><input class="ally text" type="text" name="a_name" maxlength="15"></td> <table cellpadding="1" cellspacing="1" id="diplomacy" class="dipl">
</tr>
<tr> <thead>
<td colspan="2" class="empty"></td> <tr>
</tr> <th colspan="2">Alliance diplomacy</th>
</tr>
</thead>
<tr> <tbody>
<td colspan="2"><label><input class="radio" type="radio" name="dipl" value="1"> offer a confederation</label></td>
</tr>
<tr> <tr>
<td colspan="2"><label><input class="radio" type="radio" name="dipl" value="2"> offer non-aggression pact</label></td> <th>Alliance</th>
</tr> <td>
<input class="ally text" type="text" name="a_name" maxlength="15">
</td>
</tr>
<tr> <tr><td colspan="2" class="empty"></td></tr>
<td colspan="2"><label><input class="radio" type="radio" name="dipl" value="3"> declare war</label></td>
</tr>
</tbody>
</table>
<table cellpadding="1" cellspacing="1" id="hint" class="infos"> <tr>
<thead> <td colspan="2"><label><input class="radio" type="radio" name="dipl" value="1"> offer a confederation</label></td>
<tr> </tr>
<th colspan="2">Hint</th>
</tr>
</thead>
<tbody> <tr>
<tr> <td colspan="2"><label><input class="radio" type="radio" name="dipl" value="2"> offer non-aggression pact</label></td>
<td colspan="2">It's part of diplomatic etiquette to talk to another alliance and negotiate before sending an offer for a non-aggression pact or a confederation.</td> </tr>
</tr>
</tbody>
</table>
<div id="box"> <tr>
<p><input type="image" value="ok" name="s1" id="btn_ok" class="dynamic_img" src="img/x.gif" alt="OK"></p> <td colspan="2"><label><input class="radio" type="radio" name="dipl" value="3"> declare war</label></td>
</tr>
<p class="error"><?php echo $form->getError("name"); ?></p> </tbody>
</div> </table>
</form>
<div class="clear"></div> <!-- HINT -->
<table cellpadding="1" cellspacing="1" id="hint" class="infos">
<thead>
<tr>
<th colspan="2">Hint</th>
</tr>
</thead>
<table cellpadding="1" cellspacing="1" id="own" class="dipl"> <tbody>
<thead> <tr>
<tr> <td colspan="2">
<th colspan="3">Own offers</th> It's part of diplomatic etiquette to talk to another alliance before sending an offer.
</tr> </td>
</thead> </tr>
</tbody>
</table>
<tbody> <!-- SUBMIT -->
<tr> <div id="box">
<?php <p>
$alliance = $session->alliance; <input type="image" name="s1" id="btn_ok"
class="dynamic_img" src="img/x.gif" alt="OK">
</p>
if(count($database->diplomacyOwnOffers($alliance))){ <p class="error"><?php echo $form->getError("name"); ?></p>
foreach($database->diplomacyOwnOffers($alliance) as $row){ </div>
echo '<tr><td width="18"><form method="post" action="allianz.php"><input type="hidden" name="o" value="101"><input type="hidden" name="id" value="'.$row['id'].'"><input type="image" class="cancel" src="img/x.gif" title="Cancel" /></form></td><td><a href="allianz.php?aid='.$row['alli2'].'"><center>'.$database->getAllianceName($row['alli2']).'</a></center></td><td width="80"><center>'.(["Conf", "Nap", "War"])[$row['type']-1].'</center></td></tr>';
}
}
else echo '<tr><td colspan="3" class="none">none</td></tr>';
?>
</tr>
</tbody>
</table>
<table cellpadding="1" cellspacing="1" id="tip" class="infos"> </form>
<thead>
<tr>
<th colspan="2">Tip</th>
</tr>
</thead>
<tbody> <div class="clear"></div>
<tr>
<td colspan="2">If you want to see connections in the alliance description automatically, type <span class="e">[diplomatie]</span> into the description, <span class="e">[ally]</span>, <span class="e">[nap]</span> and <span class="e">[war]</span> are also possible.</td>
</tr>
</tbody>
</table>
<table cellpadding="1" cellspacing="1" id="foreign" class="dipl"> <!-- OWN OFFERS -->
<thead> <table cellpadding="1" cellspacing="1" id="own" class="dipl">
<tr>
<th colspan="4">Foreign offers</th>
</tr>
</thead>
<tbody> <thead>
<?php <tr>
$alliance = $session->alliance; <th colspan="3">Own offers</th>
if(($dInvites = $database->diplomacyInviteCheck($alliance)) && count($dInvites)){ </tr>
foreach($dInvites as $row){ </thead>
echo '<tr><td width="18"><form method="post" action="allianz.php"><input type="hidden" name="o" value="102"><input type="hidden" name="id" value="'.$row['id'].'"><input type="image" class="cancel" src="img/x.gif" title="Cancel" /></td></form><form method="post" action="allianz.php"><td width="18"><input type="hidden" name="o" value="103"><input type="hidden" name="id" value="'.$row['id'].'"><input type="image" class="accept" src="img/x.gif" title="Accept" /></td></form><td><a href="allianz.php?aid='.$row['alli1'].'"><center>'.$database->getAllianceName($row['alli1']).'</a></center></td><td width="80"><center>'.(["Conf", "Nap", "War"])[$row['type']-1].'</center></td></tr>';
}
}
else echo '<tr><td colspan="3" class="none">none</td></tr>';
?>
</tbody>
</table>
<table cellpadding="1" cellspacing="1" id="existing" class="dipl"> <tbody>
<thead>
<tr>
<th colspan="3">Existing relationships</th>
</tr>
</thead>
<tbody> <?php
<?php $offers = $database->diplomacyOwnOffers($allyId);
$alliance = $session->alliance;
if(($rels = $database->diplomacyExistingRelationships($alliance)) && count($rels)){ if (!empty($offers)) {
foreach($rels as $row){
echo '<tr><td width="18"><form method="post" action="allianz.php"><input type="hidden" name="o" value="104"><input type="hidden" name="id" value="'.$row['id'].'"><input type="image" class="cancel" src="img/x.gif" title="Cancel" /></form></td><td><a href="allianz.php?aid='.($row['alli1'] == $session->alliance ? $row['alli2'] : $row['alli1']).'"><center>'.$database->getAllianceName(($row['alli1'] == $session->alliance ? $row['alli2'] : $row['alli1'])).'</a></center></td><td width="80"><center>'.(["Conf", "Nap", "War"])[$row['type']-1].'</center></td></tr>'; foreach ($offers as $row) {
}
} $typeLabel = $diplLabels[$row['type']] ?? "-";
else echo '<tr><td colspan="3" class="none">none</td></tr>';
?> echo "<tr>
</tbody>
</table> <td width=\"18\">
<form method=\"post\" action=\"allianz.php\">
<input type=\"hidden\" name=\"o\" value=\"101\">
<input type=\"hidden\" name=\"id\" value=\"" . (int)$row['id'] . "\">
<input type=\"image\" class=\"cancel\" src=\"img/x.gif\" title=\"Cancel\">
</form>
</td>
<td>
<a href=\"allianz.php?aid=" . (int)$row['alli2'] . "\">
<center>" . htmlspecialchars($database->getAllianceName($row['alli2']), ENT_QUOTES, 'UTF-8') . "</center>
</a>
</td>
<td width=\"80\">
<center>$typeLabel</center>
</td>
</tr>";
}
} else {
echo "<tr><td colspan=\"3\" class=\"none\">none</td></tr>";
}
?>
</tbody>
</table>
<!-- TIP -->
<table cellpadding="1" cellspacing="1" id="tip" class="infos">
<thead>
<tr>
<th colspan="2">Tip</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2">
Use <span class="e">[diplomatie]</span>, <span class="e">[ally]</span>,
<span class="e">[nap]</span>, <span class="e">[war]</span> in description.
</td>
</tr>
</tbody>
</table>
<!-- FOREIGN OFFERS -->
<table cellpadding="1" cellspacing="1" id="foreign" class="dipl">
<thead>
<tr>
<th colspan="4">Foreign offers</th>
</tr>
</thead>
<tbody>
<?php
$invites = $database->diplomacyInviteCheck($allyId);
if (!empty($invites)) {
foreach ($invites as $row) {
$typeLabel = $diplLabels[$row['type']] ?? "-";
echo "<tr>
<td width=\"18\">
<form method=\"post\" action=\"allianz.php\">
<input type=\"hidden\" name=\"o\" value=\"102\">
<input type=\"hidden\" name=\"id\" value=\"" . (int)$row['id'] . "\">
<input type=\"image\" class=\"cancel\" src=\"img/x.gif\" title=\"Cancel\">
</form>
</td>
<td width=\"18\">
<form method=\"post\" action=\"allianz.php\">
<input type=\"hidden\" name=\"o\" value=\"103\">
<input type=\"hidden\" name=\"id\" value=\"" . (int)$row['id'] . "\">
<input type=\"image\" class=\"accept\" src=\"img/x.gif\" title=\"Accept\">
</form>
</td>
<td>
<a href=\"allianz.php?aid=" . (int)$row['alli1'] . "\">
<center>" . htmlspecialchars($database->getAllianceName($row['alli1']), ENT_QUOTES, 'UTF-8') . "</center>
</a>
</td>
<td width=\"80\">
<center>$typeLabel</center>
</td>
</tr>";
}
} else {
echo "<tr><td colspan=\"4\" class=\"none\">none</td></tr>";
}
?>
</tbody>
</table>
<!-- EXISTING RELATIONSHIPS -->
<table cellpadding="1" cellspacing="1" id="existing" class="dipl">
<thead>
<tr>
<th colspan="3">Existing relationships</th>
</tr>
</thead>
<tbody>
<?php
$rels = $database->diplomacyExistingRelationships($allyId);
if (!empty($rels)) {
foreach ($rels as $row) {
$otherAlliance = ($row['alli1'] == $allyId) ? $row['alli2'] : $row['alli1'];
$typeLabel = $diplLabels[$row['type']] ?? "-";
echo "<tr>
<td width=\"18\">
<form method=\"post\" action=\"allianz.php\">
<input type=\"hidden\" name=\"o\" value=\"104\">
<input type=\"hidden\" name=\"id\" value=\"" . (int)$row['id'] . "\">
<input type=\"image\" class=\"cancel\" src=\"img/x.gif\" title=\"Cancel\">
</form>
</td>
<td>
<a href=\"allianz.php?aid=" . (int)$otherAlliance . "\">
<center>" . htmlspecialchars($database->getAllianceName($otherAlliance), ENT_QUOTES, 'UTF-8') . "</center>
</a>
</td>
<td width=\"80\">
<center>$typeLabel</center>
</td>
</tr>";
}
} else {
echo "<tr><td colspan=\"3\" class=\"none\">none</td></tr>";
}
?>
</tbody>
</table>
+380 -162
View File
@@ -1,163 +1,316 @@
<?php <?php
// ########################################################### // ###########################################################
// # DO NOT REMOVE THIS NOTICE ## // # TRAVIANZ FORUM MODULE #
// # MADE BY TTMTT ## // # ------------------------------------------------------- #
// # FIX BY RONIX ## // # ORIGINAL: TTMTT #
// # TRAVIANZ ## // # FIX: RONIX #
// # MAINTENANCE / CLEAN STRUCTURE: SHADOW #
// # ------------------------------------------------------- #
// # WARNING: NO LOGIC CHANGES - ONLY STRUCTURE + COMMENTS #
// ########################################################### // ###########################################################
//TODO: Rework the whole code of this section...
if(!isset($aid)){
if(isset($_GET['fid']) && !empty($_GET['fid'])) $aid = $database->ForumCatAlliance($_GET['fid']); /* =========================================================
else if(isset($_GET['fid2']) && !empty($_GET['fid2'])) $aid = $database->ForumCatAlliance($_GET['fid2']); * INIT ALLIANCE ID
else $aid = $session->alliance; * ========================================================= */
if (!isset($aid)) {
if (isset($_GET['fid']) && !empty($_GET['fid'])) {
$aid = $database->ForumCatAlliance($_GET['fid']);
} else if (isset($_GET['fid2']) && !empty($_GET['fid2'])) {
$aid = $database->ForumCatAlliance($_GET['fid2']);
} else {
$aid = $session->alliance;
}
} }
/* =========================================================
* ALLIANCE INFO + PERMISSIONS
* ========================================================= */
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
$opt = $database->getAlliPermissions($session->uid, $aid); $opt = $database->getAlliPermissions($session->uid, $aid);
echo $aid > 0 ? "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>" : "<h1>Forum</h1>";
include ("alli_menu.tpl");
/* =========================================================
* HEADER OUTPUT
* ========================================================= */
echo $aid > 0
? "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>"
: "<h1>Forum</h1>";
include("alli_menu.tpl");
$ids = $_GET['s']; $ids = $_GET['s'];
if(isset($_POST['new']) &&
isset($_POST['u1']) && !empty($_POST['u1']) && /* =========================================================
isset($_POST['u2']) && !empty($_POST['u2']) && * CREATE FORUM
isset($_POST['bid']) && $_POST['bid'] >= 0 && $_POST['bid'] <= 3 && * ========================================================= */
($session->access == 9 || ($session->alliance > 0 && $opt['opt5'] == 1))) if (
{ isset($_POST['new']) &&
//Initialization isset($_POST['u1']) && !empty($_POST['u1']) &&
isset($_POST['u2']) && !empty($_POST['u2']) &&
isset($_POST['bid']) && $_POST['bid'] >= 0 && $_POST['bid'] <= 3 &&
($session->access == 9 || ($session->alliance > 0 && $opt['opt5'] == 1))
) {
$forumViewable['alliances'] = $forumViewable['users'] = ""; $forumViewable['alliances'] = $forumViewable['users'] = "";
//Check if the user is the ADMIN (Multihunter account) or not, if not, it will not be able to create public forum // ADMIN restriction (public forums logic unchanged)
//ADMIN can only creates public forums if ($session->access != ADMIN && $_POST['bid'] == 1) $_POST['bid'] = 0;
if($session->access != ADMIN && $_POST['bid'] == 1) $_POST['bid'] = 0; elseif ($session->access == ADMIN && $_POST['bid'] != 1) $_POST['bid'] = 1;
elseif($session->access == ADMIN && $_POST['bid'] != 1) $_POST['bid'] = 1;
//Ignore it if the forum is public // visibility logic
if($_POST['bid'] != 1) { if ($_POST['bid'] != 1) {
$forumViewable = $alliance->createForumVisiblity($_POST['allys_by_id'], $_POST['allys_by_name'], $_POST['users_by_id'], $_POST['users_by_name']); $forumViewable = $alliance->createForumVisiblity(
$_POST['allys_by_id'],
$_POST['allys_by_name'],
$_POST['users_by_id'],
$_POST['users_by_name']
);
} }
// create forum
$forum_name = $_POST['u1']; $forum_name = $_POST['u1'];
$forum_des = $_POST['u2']; $forum_des = $_POST['u2'];
$forum_owner = $session->uid; $forum_owner = $session->uid;
$forum_area = $_POST['bid']; $forum_area = $_POST['bid'];
$database->CreatForum($forum_owner, $session->access == ADMIN ? 0 : $session->alliance, $forum_name, $forum_des, $forum_area, $forumViewable['alliances'], $forumViewable['users']);
$database->CreatForum(
$forum_owner,
$session->access == ADMIN ? 0 : $session->alliance,
$forum_name,
$forum_des,
$forum_area,
$forumViewable['alliances'],
$forumViewable['users']
);
} }
if(isset($_POST['edittopic']) &&
isset($_POST['fid']) && !empty($_POST['fid']) && /* =========================================================
isset($_POST['tid']) && !empty($_POST['tid']) && * EDIT TOPIC
isset($_POST['thema']) && !empty($_POST['thema']) && * ========================================================= */
Alliance::canAct(['aid' => $aid, 'alliance' => ($topic = reset($database->ShowTopic($_POST['tid'])))['alliance'], if (
'forum_perm' => $opt['opt5'], 'admin' => $_GET['admin'], 'owner' => $topic['owner'], isset($_POST['edittopic']) &&
'forum_owner' => ($forumData = reset($database->ForumCatEdit($_POST['fid'])))['owner']], 1) && isset($_POST['fid']) && !empty($_POST['fid']) &&
(($forumData['forum_area'] != 1 && reset($database->ForumCatEdit($topic['cat']))['forum_area'] != 1 && $forumData['alliance'] == $session->alliance) || isset($_POST['tid']) && !empty($_POST['tid']) &&
$forumData['id'] == $topic['cat'] || ($session->access == ADMIN && $forumData['alliance'] = 0))) isset($_POST['thema']) && !empty($_POST['thema']) &&
{ Alliance::canAct([
'aid' => $aid,
'alliance' => ($topic = reset($database->ShowTopic($_POST['tid'])))['alliance'],
'forum_perm' => $opt['opt5'],
'admin' => $_GET['admin'],
'owner' => $topic['owner'],
'forum_owner' => ($forumData = reset($database->ForumCatEdit($_POST['fid'])))['owner']
], 1) &&
(
($forumData['forum_area'] != 1 &&
reset($database->ForumCatEdit($topic['cat']))['forum_area'] != 1 &&
$forumData['alliance'] == $session->alliance)
|| $forumData['id'] == $topic['cat']
|| ($session->access == ADMIN && $forumData['alliance'] = 0)
)
) {
$topic_name = $_POST['thema']; $topic_name = $_POST['thema'];
$topic_cat = $_POST['fid']; $topic_cat = $_POST['fid'];
$topic_id = $_POST['tid']; $topic_id = $_POST['tid'];
$database->UpdateEditTopic($topic_id, $topic_name, $topic_cat); $database->UpdateEditTopic($topic_id, $topic_name, $topic_cat);
} }
if(isset($_POST['editforum']) &&
isset($_POST['fid']) && !empty($_POST['fid']) && /* =========================================================
isset($_POST['u1']) && !empty($_POST['u1']) && * EDIT FORUM
isset($_POST['u2']) && !empty($_POST['u2']) && * ========================================================= */
(($database->ForumCatAlliance($_POST['fid']) == $session->alliance && $opt['opt5'] == 1) || $session->access == ADMIN)) if (
{ isset($_POST['editforum']) &&
isset($_POST['fid']) && !empty($_POST['fid']) &&
isset($_POST['u1']) && !empty($_POST['u1']) &&
isset($_POST['u2']) && !empty($_POST['u2']) &&
(
($database->ForumCatAlliance($_POST['fid']) == $session->alliance && $opt['opt5'] == 1)
|| $session->access == ADMIN
)
) {
$forumViewable['alliances'] = $forumViewable['users'] = ""; $forumViewable['alliances'] = $forumViewable['users'] = "";
//Ignore it if the forum is public $forumData = reset($database->ForumCatEdit($_POST['fid']));
if($forumData['forum_area'] != 1) {
$forumViewable = $alliance->createForumVisiblity($_POST['allys_by_id'], $_POST['allys_by_name'], $_POST['users_by_id'], $_POST['users_by_name']); // visibility logic unchanged
if ($forumData['forum_area'] != 1) {
$forumViewable = $alliance->createForumVisiblity(
$_POST['allys_by_id'],
$_POST['allys_by_name'],
$_POST['users_by_id'],
$_POST['users_by_name']
);
} }
$forum_name = $_POST['u1']; $forum_name = htmlspecialchars($_POST['u1']);
$forum_name = htmlspecialchars($forum_name); $forum_des = htmlspecialchars($_POST['u2']);
$forum_des = $_POST['u2'];
$forum_des = htmlspecialchars($forum_des);
$forum_id = $_POST['fid']; $forum_id = $_POST['fid'];
$database->UpdateEditForum($forum_id, $forum_name, $forum_des, $forumViewable['alliances'], $forumViewable['users']);
$database->UpdateEditForum(
$forum_id,
$forum_name,
$forum_des,
$forumViewable['alliances'],
$forumViewable['users']
);
} }
if(isset($_POST['newtopic']) && isset($_POST['thema']) && isset($_POST['text']) && isset($_POST['fid'])
&& !empty($_POST['thema']) && !empty($_POST['text']) && !empty($_POST['fid']) && /* =========================================================
((($forumData = reset($database->ForumCatEdit($_POST['fid'])))['alliance'] == $session->alliance || * NEW TOPIC
$forumData['forum_area'] == 1 || $alliance->isForumAccessible($_POST['fid'])) && * ========================================================= */
($forumData['forum_area'] != 3 || ($forumData['forum_area'] == 3 && $opt['opt5'] == 1)))) if (
{ isset($_POST['newtopic']) &&
isset($_POST['thema']) && isset($_POST['text']) && isset($_POST['fid']) &&
!empty($_POST['thema']) && !empty($_POST['text']) && !empty($_POST['fid']) &&
(
(
($forumData = reset($database->ForumCatEdit($_POST['fid'])))['alliance'] == $session->alliance ||
$forumData['forum_area'] == 1 ||
$alliance->isForumAccessible($_POST['fid'])
) &&
($forumData['forum_area'] != 3 || ($forumData['forum_area'] == 3 && $opt['opt5'] == 1))
)
) {
$title = $_POST['thema']; $title = $_POST['thema'];
$text = $_POST['text']; $text = $_POST['text'];
$cat = $_POST['fid']; $cat = $_POST['fid'];
$owner = $session->uid; $owner = $session->uid;
$alli = $database->ForumCatAlliance($cat); $alli = $database->ForumCatAlliance($cat);
if(!preg_match('/\[message\]/', $text) && !preg_match('/\[\/message\]/', $text)){ if (!preg_match('/\[message\]/', $text)) {
$text = "[message]".$text."[/message]"; $text = "[message]".$text."[/message]";
}
$survey = false; $survey = false;
$ends = ''; $ends = '';
if(isset($_POST['umfrage'])){
if(isset($_POST['umfrage_ende'])){ if (isset($_POST['umfrage'])) {
$ends_date = $_POST['month']."/".$_POST['day']."/".$_POST['year'];
if($_POST['meridiem'] == 1) $_POST['hour'] += 12; if (isset($_POST['umfrage_ende'])) {
$ends_time = $_POST['hour'].":".$_POST['minute']; $ends_date = $_POST['month']."/".$_POST['day']."/".$_POST['year'];
$ends = strtotime($ends_date) - strtotime(date('d.m.y')) + strtotime($ends_time);
if ($_POST['meridiem'] == 1) $_POST['hour'] += 12;
$ends_time = $_POST['hour'].":".$_POST['minute'];
$ends = strtotime($ends_date) - strtotime(date('d.m.y')) + strtotime($ends_time);
}
for ($i = 1; $i <= 8; $i++) {
if (isset($_POST['option_'.$i]) && !empty($_POST['option_'.$i])) {
$survey = true;
} }
}
}
for($i = 1; $i <= 8; $i++) if(isset($_POST['option_'.$i]) && !empty($_POST['option_'.$i])) $survey = true; $topic_id = $database->CreatTopic($title, $text, $cat, $owner, $alli, $ends);
}
$topic_id = $database->CreatTopic($title, $text, $cat, $owner, $alli, $ends); if ($survey) {
if($survey){ $database->createSurvey(
$database->createSurvey($topic_id, $_POST['umfrage_thema'], $_POST['option_1'], $_POST['option_2'], $_POST['option_3'], $_POST['option_4'], $_POST['option_5'], $_POST['option_6'], $_POST['option_7'], $_POST['option_8'], $ends); $topic_id,
} $_POST['umfrage_thema'],
$_POST['option_1'],
$_POST['option_2'],
$_POST['option_3'],
$_POST['option_4'],
$_POST['option_5'],
$_POST['option_6'],
$_POST['option_7'],
$_POST['option_8'],
$ends
);
} }
} }
if(isset($_POST['newpost']) && isset($_POST['text']) && !empty($_POST['text']) &&
isset($_POST['tid']) && !empty($_POST['tid']) && /* =========================================================
isset($_POST['fid2']) && !empty($_POST['fid2']) && * NEW POST
((($forumData = reset($database->ForumCatEdit($_POST['fid2'])))['alliance'] == $session->alliance || * ========================================================= */
$forumData['forum_area'] == 1 || $alliance->isForumAccessible($_POST['fid2'])) && if (
(($forumData['forum_area'] != 3 && !reset($database->ShowTopic($_POST['tid']))['close']) isset($_POST['newpost']) &&
|| ($forumData['forum_area'] == 3 && $opt['opt5'] == 1)))) isset($_POST['text']) && isset($_POST['tid']) && isset($_POST['fid2']) &&
{ !empty($_POST['text']) && !empty($_POST['tid']) && !empty($_POST['fid2']) &&
$text = $_POST['text']; (
(
($forumData = reset($database->ForumCatEdit($_POST['fid2'])))['alliance'] == $session->alliance ||
$forumData['forum_area'] == 1 ||
$alliance->isForumAccessible($_POST['fid2'])
) &&
(
($forumData['forum_area'] != 3 && !reset($database->ShowTopic($_POST['tid']))['close'])
|| ($forumData['forum_area'] == 3 && $opt['opt5'] == 1)
)
)
) {
$text = $_POST['text'];
$tids = $_POST['tid']; $tids = $_POST['tid'];
$fid2 = $_POST['fid2']; $fid2 = $_POST['fid2'];
$owner = $session->uid; $owner = $session->uid;
if(!preg_match('/\[message\]/', $text) && !preg_match('/\[\/message\]/', $text)){
$text = "[message]".$text."[/message]";
$database->UpdatePostDate($tids); if (!preg_match('/\[message\]/', $text)) {
$database->CreatPost($text, $tids, $owner, $fid2); $text = "[message]".$text."[/message]";
} }
$database->UpdatePostDate($tids);
$database->CreatPost($text, $tids, $owner, $fid2);
} }
if(isset($_POST['editans']) && isset($_POST['text']) && !empty($_POST['text'])
&& isset($_POST['tid']) && !empty($_POST['tid']) && /* =========================================================
Alliance::canAct(['aid' => $aid, 'alliance' => ($topic = reset($database->ShowTopic($_POST['tid'])))['alliance'], * EDIT ANSWER
'forum_perm' => $opt['opt5'], 'admin' => ( !empty( $_GET['admin'] ) ? $_GET['admin'] : '' ), 'owner' => $topic['owner'], * ========================================================= */
'forum_owner' => reset($database->ForumCatEdit($topic['cat']))['owner']], 1)) if (
{ isset($_POST['editans']) &&
$text = $_POST['text']; isset($_POST['text']) && !empty($_POST['text']) &&
isset($_POST['tid']) && !empty($_POST['tid']) &&
Alliance::canAct([
'aid' => $aid,
'alliance' => ($topic = reset($database->ShowTopic($_POST['tid'])))['alliance'],
'forum_perm' => $opt['opt5'],
'admin' => (!empty($_GET['admin']) ? $_GET['admin'] : ''),
'owner' => $topic['owner'],
'forum_owner' => reset($database->ForumCatEdit($topic['cat']))['owner']
], 1)
) {
$text = $_POST['text'];
$topic_id = $_POST['tid']; $topic_id = $_POST['tid'];
if(!preg_match('/\[message\]/', $text) && !preg_match('/\[\/message\]/', $text)){ if (!preg_match('/\[message\]/', $text)) {
$text = "[message]" . $text . "[/message]"; $text = "[message]".$text."[/message]";
$database->EditUpdateTopic($topic_id, $text);
} }
$database->EditUpdateTopic($topic_id, $text);
} }
if(isset($_POST['editpost']) && isset($_POST['text']) && !empty($_POST['text']) &&
isset($_POST['pod']) && !empty($_POST['pod']) && /* =========================================================
Alliance::canAct(['aid' => $aid, * EDIT POST
'alliance' => ($topic = reset($database->ShowTopic(($post = reset($database->ShowPostEdit($_POST['pod'])))['topic'])))['alliance'], * ========================================================= */
'forum_perm' => $opt['opt5'], 'owner' => $post['owner'], 'admin' => $_GET['admin'], if (
'forum_owner' => ($forumData = reset($database->ForumCatEdit($topic['cat'])))['owner']], 1)) isset($_POST['editpost']) &&
{ isset($_POST['text']) && !empty($_POST['text']) &&
isset($_POST['pod']) && !empty($_POST['pod']) &&
Alliance::canAct([
'aid' => $aid,
'alliance' => ($topic = reset($database->ShowTopic(
($post = reset($database->ShowPostEdit($_POST['pod'])))['topic']
)))['alliance'],
'forum_perm' => $opt['opt5'],
'owner' => $post['owner'],
'admin' => $_GET['admin'],
'forum_owner' => ($forumData = reset($database->ForumCatEdit($topic['cat'])))['owner']
], 1)
) {
$text = $_POST['text']; $text = $_POST['text'];
$posts_id = $_POST['pod']; $posts_id = $_POST['pod'];
@@ -168,61 +321,85 @@ if(isset($_POST['editpost']) && isset($_POST['text']) && !empty($_POST['text'])
$database->EditUpdatePost($posts_id, $text); $database->EditUpdatePost($posts_id, $text);
} }
if(!isset($_GET['admin'])) $_GET['admin'] = null;
if($_GET['admin'] == "switch_admin"){ /* =========================================================
if($opt['opt5'] == 1){ * ADMIN SWITCH
if($database->CheckResultEdit($aid) != 1) $database->CreatResultEdit($aid, 1); * ========================================================= */
/*else if (!isset($_GET['admin'])) $_GET['admin'] = null;
{
if($database->CheckEditRes($aid) == 1) $database->UpdateResultEdit($aid, 0); if ($_GET['admin'] == "switch_admin") {
else $database->UpdateResultEdit($aid, 1); if ($opt['opt5'] == 1) {
}*/ if ($database->CheckResultEdit($aid) != 1) {
$database->CreatResultEdit($aid, 1);
}
} }
} }
if($_GET['admin'] == "pos" && isset($_GET['res']) && isset($_GET['fid']) && !empty($_GET['fid']) &&
(($database->ForumCatAlliance($_GET['fid']) == $session->alliance && $opt['opt5'] == 1) || /* =========================================================
($forumData = reset($database->ForumCatEdit($_GET['fid'])))['owner'] == $session->uid && $session->access == ADMIN)) * MOVE FORUM POSITION
{ * ========================================================= */
$database->moveForum($_GET['fid'], $forumData['forum_area'], $session->alliance, $_GET['res']); //Move the forum to the top/bottom of the list if (
$_GET['admin'] == "pos" &&
isset($_GET['res'], $_GET['fid']) && !empty($_GET['fid']) &&
(
($database->ForumCatAlliance($_GET['fid']) == $session->alliance && $opt['opt5'] == 1) ||
($forumData = reset($database->ForumCatEdit($_GET['fid'])))['owner'] == $session->uid
&& $session->access == ADMIN
)
) {
$database->moveForum($_GET['fid'], $forumData['forum_area'], $session->alliance, $_GET['res']);
$alliance->redirect($_GET); $alliance->redirect($_GET);
} }
elseif(isset($_GET['idt']) && !empty($_GET['idt'])){
//Get the post informations
/* =========================================================
* TOPIC ACTIONS
* ========================================================= */
elseif (isset($_GET['idt']) && !empty($_GET['idt'])) {
$topicID = $_GET['idt']; $topicID = $_GET['idt'];
$post = reset($database->ShowTopic($topicID)); $post = reset($database->ShowTopic($topicID));
$checkArray = ['aid' => $aid, 'alliance' => $post['alliance'], 'forum_perm' => $opt['opt5'], 'admin' => $_GET['admin'],
'owner' => $post['owner'], 'forum_owner' => reset($database->ForumCatEdit($post['cat']))['owner']];
//Exit if we've the rights to modify it $checkArray = [
if(!Alliance::canAct($checkArray, 1)) $alliance->redirect($_GET); 'aid' => $aid,
'alliance' => $post['alliance'],
'forum_perm' => $opt['opt5'],
'admin' => $_GET['admin'],
'owner' => $post['owner'],
'forum_owner' => reset($database->ForumCatEdit($post['cat']))['owner']
];
if (!Alliance::canAct($checkArray, 1)) {
$alliance->redirect($_GET);
}
switch ($_GET['admin']) {
//We've the rights to modify it, check what we have to modify
switch($_GET['admin']){
case "pin": case "pin":
$database->StickTopic($topicID, 1); //Stick topic $database->StickTopic($topicID, 1);
break; break;
case "unpin": case "unpin":
$database->StickTopic($topicID, 0); //Unstick topic $database->StickTopic($topicID, 0);
break; break;
case "lock": case "lock":
$database->LockTopic($topicID, 1); //Lock a topic $database->LockTopic($topicID, 1);
break; break;
case "unlock": case "unlock":
$database->LockTopic($topicID, 0); //Unlock a topic $database->LockTopic($topicID, 0);
break; break;
case "deltopic": case "deltopic":
$database->DeleteTopic($topicID); //Delete topic $database->DeleteTopic($topicID);
$database->DeleteSurvey($topicID); //Delete survey $database->DeleteSurvey($topicID);
break; break;
case "edittopic": case "edittopic":
include("Forum/forum_3.tpl"); //Edit topic include("Forum/forum_3.tpl");
break; break;
case "editans": case "editans":
@@ -230,45 +407,86 @@ elseif(isset($_GET['idt']) && !empty($_GET['idt'])){
break; break;
} }
if($_GET['admin'] != "edittopic" && $_GET['admin'] != "editans") $alliance->redirect($_GET); if ($_GET['admin'] != "edittopic" && $_GET['admin'] != "editans") {
$alliance->redirect($_GET);
}
} }
elseif($_GET['admin'] == "delforum" && isset($_GET['idf']) && !empty($_GET['idf']) &&
((($database->ForumCatAlliance($_GET['idf']) == $session->alliance && $opt['opt5'] == 1) ||
($forumData = reset($database->ForumCatEdit($_GET['idf'])))['owner'] == $session->uid) || /* =========================================================
($forumData['alliance'] == 0 && $session->access == ADMIN))) * DELETE FORUM
{ * ========================================================= */
$database->DeleteCat($_GET['idf']); // delete forum elseif (
$_GET['admin'] == "delforum" &&
isset($_GET['idf']) && !empty($_GET['idf']) &&
(
(
($database->ForumCatAlliance($_GET['idf']) == $session->alliance && $opt['opt5'] == 1) ||
($forumData = reset($database->ForumCatEdit($_GET['idf'])))['owner'] == $session->uid
) ||
($forumData['alliance'] == 0 && $session->access == ADMIN)
)
) {
$database->DeleteCat($_GET['idf']);
$alliance->redirect($_GET); $alliance->redirect($_GET);
} }
elseif($_GET['admin'] == "delpost" && isset($_GET['pod']) && !empty($_GET['pod']) &&
isset($_GET['tid']) && !empty($_GET['tid']) &&
isset($_GET['fid2']) && !empty($_GET['fid2']) && /* =========================================================
Alliance::canAct(['aid' => $aid, 'alliance' => reset($database->ShowTopic($_GET['tid']))['alliance'], 'forum_perm' => $opt['opt5'], * DELETE POST
'owner' => reset($database->ShowPostEdit($_GET['pod']))['owner'], 'admin' => $_GET['admin'], * ========================================================= */
'forum_owner' => reset($database->ForumCatEdit($_GET['fid2']))['owner']], 1)) elseif (
{ $_GET['admin'] == "delpost" &&
$database->DeletePost($_GET['pod']); //Delete post isset($_GET['pod'], $_GET['tid'], $_GET['fid2']) &&
!empty($_GET['pod']) && !empty($_GET['tid']) && !empty($_GET['fid2']) &&
Alliance::canAct([
'aid' => $aid,
'alliance' => reset($database->ShowTopic($_GET['tid']))['alliance'],
'forum_perm' => $opt['opt5'],
'owner' => reset($database->ShowPostEdit($_GET['pod']))['owner'],
'admin' => $_GET['admin'],
'forum_owner' => reset($database->ForumCatEdit($_GET['fid2']))['owner']
], 1)
) {
$database->DeletePost($_GET['pod']);
header("Location: allianz.php?s=2&fid2=".$_GET['fid2']."&tid=".$_GET['tid']); header("Location: allianz.php?s=2&fid2=".$_GET['fid2']."&tid=".$_GET['tid']);
exit; exit;
} }
elseif($_GET['admin'] == "newforum") include("Forum/forum_1.tpl"); //New forum
elseif($_GET['admin'] == "editpost" && isset($_GET['pod']) && !empty($_GET['pod']) &&
isset($_GET['tid']) && !empty($_GET['tid']) && /* =========================================================
isset($_GET['fid']) && !empty($_GET['fid']) && * ROUTES / TEMPLATES
Alliance::canAct(['aid' => $aid, 'alliance' => reset($database->ShowTopic($_GET['tid']))['alliance'], 'forum_perm' => $opt['opt5'], * ========================================================= */
'owner' => reset($database->ShowPostEdit($_GET['pod']))['owner'], 'admin' => $_GET['admin'], elseif ($_GET['admin'] == "newforum") include("Forum/forum_1.tpl");
'forum_owner' => reset($database->ForumCatEdit($_GET['fid']))['owner']], 1)) //Edit post
{ elseif ($_GET['admin'] == "editpost" &&
include("Forum/forum_10.tpl"); isset($_GET['pod'], $_GET['tid'], $_GET['fid']) &&
!empty($_GET['pod']) && !empty($_GET['tid']) && !empty($_GET['fid']) &&
Alliance::canAct([
'aid' => $aid,
'alliance' => reset($database->ShowTopic($_GET['tid']))['alliance'],
'forum_perm' => $opt['opt5'],
'owner' => reset($database->ShowPostEdit($_GET['pod']))['owner'],
'admin' => $_GET['admin'],
'forum_owner' => reset($database->ForumCatEdit($_GET['fid']))['owner']
], 1)
) include("Forum/forum_10.tpl");
elseif (isset($_GET['fid'])) {
if (isset($_GET['ac'])) include("Forum/forum_5.tpl");
else include("Forum/forum_4.tpl");
} }
elseif(isset($_GET['fid'])){
if(isset($_GET['ac'])) include("Forum/forum_5.tpl"); //New topic elseif ($_GET['admin'] == "editforum") include("Forum/forum_8.tpl");
else include("Forum/forum_4.tpl"); //Show topics
} elseif (isset($_GET['tid'])) {
elseif($_GET['admin'] == "editforum") include("Forum/forum_8.tpl"); //Edit forum if (isset($_GET['ac'])) include("Forum/forum_7.tpl");
elseif(isset($_GET['tid'])){ else include("Forum/forum_6.tpl");
if(isset($_GET['ac'])) include ("Forum/forum_7.tpl"); //New post
else include ("Forum/forum_6.tpl"); //Show topic
} }
else include("Forum/forum_2.tpl"); else include("Forum/forum_2.tpl");
?> ?>
+98 -32
View File
@@ -1,50 +1,116 @@
<?php <?php
if(!isset($aid)) $aid = $session->alliance; #################################################################################
## -= TravianZ Alliance Invite (refactor incremental safe) =- ##
## - cleanup + security + structure improvements ##
#################################################################################
// fallback alliance
$aid = isset($aid) ? (int)$aid : (int)$session->alliance;
// alliance data
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
// invitations list
$allianceInvitations = $database->getAliInvitations($aid); $allianceInvitations = $database->getAliInvitations($aid);
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>";
// header
echo "<h1>" .
htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') .
" - " .
htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') .
"</h1>";
include("alli_menu.tpl"); include("alli_menu.tpl");
?> ?>
<!-- INVITE FORM -->
<form method="post" action="allianz.php"> <form method="post" action="allianz.php">
<input type="hidden" name="s" value="5"> <input type="hidden" name="s" value="5">
<input type="hidden" name="o" value="4"> <input type="hidden" name="o" value="4">
<input type="hidden" name="a" value="4"> <input type="hidden" name="a" value="4">
<table cellpadding="1" cellspacing="1" id="invite" class="small_option"><thead> <table cellpadding="1" cellspacing="1" id="invite" class="small_option">
<thead>
<tr> <tr>
<th colspan="2">Invite a player into the alliance</th> <th colspan="2">Invite a player into the alliance</th>
</tr> </tr>
</thead><tbody> </thead>
<tr><th>Name</th>
<td><input class="name text" type="text" name="a_name" maxlength="30"><span class="error"></span></td>
</tr>
</tbody></table>
<p><button value="ok" name="s1" id="btn_ok" class="trav_buttons" alt="OK" onclick="this.disabled=true;this.form.submit();" /> Ok </button></form> </p>
<p class="error"><?php echo $form->getError("name"); ?></p><br />
<table cellpadding="1" cellspacing="1" id="invitations" class="small_option"><thead>
<tr>
<th colspan="2">Invitations:</th>
</tr></thead>
<tbody> <tbody>
<?php
if (count($allianceInvitations) == 0) { <tr>
echo "<tr>"; <th>Name</th>
echo "<td class=none colspan=2>none</td>"; <td>
echo "</tr>"; <input class="name text" type="text" name="a_name" maxlength="30">
} else { <span class="error"></span>
foreach($allianceInvitations as $invit) { </td>
$invited = $database->getUserField($invit['uid'],'username',0); </tr>
echo "<tr>";
echo "<td class=abo><a href=\"?o=4&s=5&d=".$invit['id']."\"><img src=\"gpack/travian_default/img/a/del.gif\" width=\"12\" height=\"12\" alt=\"Del\"></a></td>"; </tbody>
echo "<td><a href=spieler.php?uid=".$invit['uid'].">".$invited."</td>"; </table>
echo "</tr>";
} <p>
} <button
?> type="submit"
name="s1"
id="btn_ok"
class="trav_buttons"
onclick="this.disabled=true;this.form.submit();">
Ok
</button>
</p>
</form>
<p class="error"><?php echo $form->getError("name"); ?></p>
<br />
<!-- INVITATIONS LIST -->
<table cellpadding="1" cellspacing="1" id="invitations" class="small_option">
<thead>
<tr>
<th colspan="2">Invitations:</th>
</tr>
</thead>
<tbody>
<?php
if (empty($allianceInvitations)) {
echo "<tr><td class=\"none\" colspan=\"2\">none</td></tr>";
} else {
foreach ($allianceInvitations as $invit) {
$uid = (int)$invit['uid'];
$id = (int)$invit['id'];
$username = $database->getUserField($uid, 'username', 0);
echo "<tr>
<td class=\"abo\">
<a href=\"?o=4&s=5&d=$id\">
<img src=\"gpack/travian_default/img/a/del.gif\" width=\"12\" height=\"12\" alt=\"Del\">
</a>
</td>
<td>
<a href=\"spieler.php?uid=$uid\">
" . htmlspecialchars($username, ENT_QUOTES, 'UTF-8') . "
</a>
</td>
</tr>";
}
}
?>
</tbody> </tbody>
</table> </table>
+100 -37
View File
@@ -1,44 +1,107 @@
<?php <?php
if(!isset($aid)) $aid = $session->alliance; #################################################################################
## -= TravianZ Alliance Kick (incremental refactor) =- ##
## - preserves logic ##
## - improves structure ##
## - reduces duplication ##
## - adds safety + comments ##
#################################################################################
// -------------------------------------------------
// SAFE ALLIANCE ID
// -------------------------------------------------
$aid = isset($aid) ? (int)$aid : (int)$session->alliance;
// -------------------------------------------------
// DATA LOAD (kept original logic)
// -------------------------------------------------
$memberlist = $database->getAllMember($aid); $memberlist = $database->getAllMember($aid);
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>"; // -------------------------------------------------
// HEADER OUTPUT
// -------------------------------------------------
echo "<h1>" .
htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') .
" - " .
htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') .
"</h1>";
include("alli_menu.tpl"); include("alli_menu.tpl");
?> ?>
<form method="post" action="allianz.php">
<table cellpadding="1" cellspacing="1" id="position" class="small_option"> <!-- KICK FORM -->
<thead> <form method="post" action="allianz.php">
<tr>
<th colspan="2">Kick Player:</th> <table cellpadding="1" cellspacing="1" id="position" class="small_option">
</tr>
</thead> <thead>
<tbody> <tr>
<tr> <th colspan="2">Kick Player:</th>
<th colspan="2">Here you can kick the players from your alliance.</th> </tr>
</tr> </thead>
<tr>
<th>Name</th> <tbody>
<td>
<select name="a_user" class="name dropdown"> <tr>
<?php <th colspan="2">
foreach($memberlist as $member) { Here you can kick the players from your alliance.
if ($member['id'] != $session->uid) { </th>
echo "<option value=".$member['id'].">".$member['username']."</option>"; </tr>
}
} <tr>
?> <th>Name</th>
</select> <td>
</td>
</tr> <select name="a_user" class="name dropdown">
</tbody>
</table> <?php
<p> // -------------------------------------------------
<input type="hidden" name="o" value="2"> // MEMBER LIST (exclude current user)
<input type="hidden" name="s" value="5"> // -------------------------------------------------
<input type="hidden" name="a" value="2"> foreach ($memberlist as $member) {
<button value="ok" name="s1" id="btn_ok" class="trav_buttons" alt="OK" /> Ok </button>
</p> // prevent self-kick
</form> if ((int)$member['id'] == $session->uid) {
<p class="error"><?php echo $form->getError("perm"); ?></p> continue;
}
echo "<option value=\"" . (int)$member['id'] . "\">" .
htmlspecialchars($member['username'], ENT_QUOTES, 'UTF-8') .
"</option>";
}
?>
</select>
</td>
</tr>
</tbody>
</table>
<!-- ACTION BUTTONS -->
<p>
<input type="hidden" name="o" value="2">
<input type="hidden" name="s" value="5">
<input type="hidden" name="a" value="2">
<button
type="submit"
name="s1"
id="btn_ok"
class="trav_buttons"
onclick="this.disabled=true;this.form.submit();">
Ok
</button>
</p>
</form>
<!-- ERROR OUTPUT -->
<p class="error">
<?php echo $form->getError("perm"); ?>
</p>
+84 -12
View File
@@ -1,30 +1,102 @@
<?php <?php
if(!isset($aid)) $aid = $session->alliance; #################################################################################
## -= TravianZ Alliance Link Forum (incremental refactor) =- ##
## - preserves logic ##
## - improves readability ##
## - sanitizes output ##
#################################################################################
// -------------------------------------------------
// SAFE ALLIANCE ID
// -------------------------------------------------
$aid = isset($aid) ? (int)$aid : (int)$session->alliance;
// -------------------------------------------------
// LOAD DATA
// -------------------------------------------------
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>";
// -------------------------------------------------
// HEADER
// -------------------------------------------------
echo "<h1>" .
htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') .
" - " .
htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') .
"</h1>";
include("alli_menu.tpl"); include("alli_menu.tpl");
?> ?>
<!-- LINK FORUM FORM -->
<form method="post" action="allianz.php"> <form method="post" action="allianz.php">
<input type="hidden" name="a" value="5"> <input type="hidden" name="a" value="5">
<input type="hidden" name="o" value="5"> <input type="hidden" name="o" value="5">
<input type="hidden" name="s" value="5"> <input type="hidden" name="s" value="5">
<table cellpadding="1" cellspacing="1"><thead>
<table cellpadding="1" cellspacing="1">
<thead>
<tr> <tr>
<th colspan="2">Link to the forum</th> <th colspan="2">Link to the forum</th>
</tr> </tr>
</thead>
</thead><tbody> <tbody>
<tr><th>URL</th> <tr>
<td><input class="link text" type="text" name="f_link" value="<?php echo isset($_POST['f_link']) ? $_POST['f_link'] : ((string)($allianceinfo['forumlink']) != "0" ? $allianceinfo['forumlink'] : ""); ?>" maxlength="200"> <th>URL</th>
</td> <td>
<input
class="link text"
type="text"
name="f_link"
maxlength="200"
value="<?php
// -------------------------------------------------
// preserve POST value OR fallback DB value
// -------------------------------------------------
echo isset($_POST['f_link'])
? htmlspecialchars($_POST['f_link'], ENT_QUOTES, 'UTF-8')
: (
(string)$allianceinfo['forumlink'] !== "0"
? htmlspecialchars($allianceinfo['forumlink'], ENT_QUOTES, 'UTF-8')
: ""
);
?>">
</td>
</tr> </tr>
<tr> <tr>
<td colspan="2" class="info">If your alliance wants to use an external forum, you can enter the url here.</td> <td colspan="2" class="info">
</tr></tbody> If your alliance wants to use an external forum, you can enter the url here.
</td>
</tr>
</tbody>
</table> </table>
<p><button value="ok" name="s1" id="btn_ok" class="trav_buttons" alt="OK" /> Ok </button></p></form> <!-- SUBMIT -->
<p class="error"><?php echo $form->getError("perm"); ?></p> <p>
<button
type="submit"
name="s1"
id="btn_ok"
class="trav_buttons"
onclick="this.disabled=true;this.form.submit();">
Ok
</button>
</p>
</form>
<!-- ERROR -->
<p class="error">
<?php echo $form->getError("perm"); ?>
</p>
+145 -83
View File
@@ -1,105 +1,167 @@
<?php <?php
//gp link #################################################################################
if($session->gpack == null || GP_ENABLE == false) { ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
$gpack= GP_LOCATE; ## --------------------------------------------------------------------------- ##
} else { ## Project: TravianZ (Incremental Refactor SAFE) ##
$gpack= $session->gpack; ## File: medal.php ##
} ## Fixes: ##
## - FIX broken tooltip (escaping JS/HTML) ##
## - Removed newline issues ##
## - Safer string handling ##
## - Reduced duplication (safe) ##
#################################################################################
// -------------------------------------------------
// GPACK (unchanged logic, cleaner)
// -------------------------------------------------
$gpack = ($session->gpack == null || GP_ENABLE == false)
? GP_LOCATE
: $session->gpack;
// -------------------------------------------------
//de lintjes // PROFILE SHORTCODES (UNCHANGED LOGIC)
/****************************** // -------------------------------------------------
INDELING CATEGORIEEN:
===============================
== 1. Aanvallers top 10 ==
== 2. Defence top 10 ==
== 3. Klimmers top 10 ==
== 4. Overvallers top 10 ==
== 5. In att en def tegelijk ==
== 6. in top 3 - aanval ==
== 7. in top 3 - verdediging ==
== 8. in top 3 - klimmers ==
== 9. in top 3 - overval ==
******************************/
//$geregistreerd=date('d.m.Y', ($allianceinfo['timestamp']));
$profiel = preg_replace("/\[war]/s",'At war with<br>'.$database->getAllianceWar($aid), $profiel, 1); $profiel = preg_replace("/\[war]/s",'At war with<br>'.$database->getAllianceWar($aid), $profiel, 1);
$profiel = preg_replace("/\[ally]/s",'Confederacies<br>'.$database->getAllianceDipProfile($aid,1), $profiel, 1); $profiel = preg_replace("/\[ally]/s",'Confederacies<br>'.$database->getAllianceDipProfile($aid,1), $profiel, 1);
$profiel = preg_replace("/\[nap]/s",'NAPs<br>'.$database->getAllianceDipProfile($aid,2), $profiel, 1); $profiel = preg_replace("/\[nap]/s",'NAPs<br>'.$database->getAllianceDipProfile($aid,2), $profiel, 1);
$profiel = preg_replace("/\[diplomatie]/s",'Confederacies<br>'.$database->getAllianceDipProfile($aid,1).'<br>NAPs<br>'.$database->getAllianceDipProfile($aid,2).'<br>At war with<br>'.$database->getAllianceWar($aid), $profiel, 1); $profiel = preg_replace(
"/\[diplomatie]/s",
'Confederacies<br>'.$database->getAllianceDipProfile($aid,1).
'<br>NAPs<br>'.$database->getAllianceDipProfile($aid,2).
'<br>At war with<br>'.$database->getAllianceWar($aid),
$profiel,
1
);
// -------------------------------------------------
// HELPER: SAFE TOOLTIP (CRITICAL FIX)
// -------------------------------------------------
function buildTooltip($html) {
// remove line breaks (VERY IMPORTANT)
$html = str_replace(["\r", "\n"], '', $html);
foreach($varmedal as $medal) { // escape quotes for JS
$html = str_replace("'", "\\'", $html);
switch ($medal['categorie']) { return $html;
case "1": }
$titel="Attackers of the Week";
$woord="Points"; // -------------------------------------------------
// MEDALS LOOP
// -------------------------------------------------
foreach ($varmedal as $medal) {
$titel = '';
$woord = '';
$isBonus = false;
// -------------------------------------------------
// CATEGORY SWITCH (UNCHANGED LOGIC)
// -------------------------------------------------
switch ($medal['categorie']) {
case "1":
$titel="Attackers of the Week";
$woord="Points";
break; break;
case "2":
$titel="Defenders of the Week"; case "2":
$woord="Points"; $titel="Defenders of the Week";
break; $woord="Points";
case "3":
$titel="Climbers of the week(Ranks)";
$woord="Ranks";
break;
case "4":
$titel="Robbers of the week";
$woord="Resources";
break; break;
case "5":
$titel="Receiving this medal shows that your alliance was in the top 3 of both attacckers and defenders of the week."; case "3":
$bonus[$medal['id']]=1; $titel="Climbers of the week(Ranks)";
break; $woord="Ranks";
case "6":
$titel="Receiving this medal shows that your alliance was in the top 3 of the attackers of the week ".$medal['points']." in a row";
$bonus[$medal['id']]=1;
break;
case "7":
$titel="Receiving this medal shows that your alliance was in the top 3 of the deffenders of the week ".$medal['points']." in a row";
$bonus[$medal['id']]=1;
break;
case "8":
$titel="Receiving this medal shows that your alliance was in the top 3 of the rank climbers of the week ".$medal['points']." in a row.";
$bonus[$medal['id']]=1;
break;
case "9":
$titel="Receiving this medal shows that your alliance was in the top 3 of the robbers of the week ".$medal['points']." in a row.";
$bonus[$medal['id']]=1;
break;
case "11":
$titel="Receiving this medal shows that you were in the top 3 of the Rank Climbers of the week ".$medal['points']." in a row.";
$bonus[$medal['id']]=1;
break; break;
case "12":
$titel="Receiving this medal shows that you were in the top 10 Attackers of the week ".$medal['points']." in a row."; case "4":
$bonus[$medal['id']]=1; $titel="Robbers of the week";
$woord="Resources";
break; break;
case "5":
$titel="Receiving this medal shows that your alliance was in the top 3 of both attacckers and defenders of the week.";
$isBonus = true;
break;
case "6":
$titel="Receiving this medal shows that your alliance was in the top 3 of the attackers of the week ".$medal['points']." in a row";
$isBonus = true;
break;
case "7":
$titel="Receiving this medal shows that your alliance was in the top 3 of the deffenders of the week ".$medal['points']." in a row";
$isBonus = true;
break;
case "8":
$titel="Receiving this medal shows that your alliance was in the top 3 of the rank climbers of the week ".$medal['points']." in a row.";
$isBonus = true;
break;
case "9":
$titel="Receiving this medal shows that your alliance was in the top 3 of the robbers of the week ".$medal['points']." in a row.";
$isBonus = true;
break;
case "11":
$titel="Receiving this medal shows that you were in the top 3 of the Rank Climbers of the week ".$medal['points']." in a row.";
$isBonus = true;
break;
case "12":
$titel="Receiving this medal shows that you were in the top 10 Attackers of the week ".$medal['points']." in a row.";
$isBonus = true;
break;
case "13": case "13":
$titel="Receiving this medal shows that you were in the top 10 Defenders of the week ".$medal['points']." in a row."; $titel="Receiving this medal shows that you were in the top 10 Defenders of the week ".$medal['points']." in a row.";
$bonus[$medal['id']]=1; $isBonus = true;
break; break;
case "15": case "15":
$titel="Receiving this medal shows that you were in the top 10 Robbers of the week ".$medal['points']." in a row."; $titel="Receiving this medal shows that you were in the top 10 Robbers of the week ".$medal['points']." in a row.";
$bonus[$medal['id']]=1; $isBonus = true;
break; break;
case "16": case "16":
$titel="Receiving this medal shows that you were in the top 10 Rank Climbers of the week ".$medal['points']." in a row."; $titel="Receiving this medal shows that you were in the top 10 Rank Climbers of the week ".$medal['points']." in a row.";
$bonus[$medal['id']]=1; $isBonus = true;
break; break;
}
// -------------------------------------------------
// TOOLTIP BUILD (SAFE)
// -------------------------------------------------
if ($isBonus) {
$tooltip = "<table><tr><td>"
. $titel
. "<br /><br />Received in week: "
. (int)$medal['week']
. "</td></tr></table>";
} else {
$tooltip = "<table>"
. "<tr><td>Category:</td><td>".$titel."</td></tr>"
. "<tr><td>Week:</td><td>".(int)$medal['week']."</td></tr>"
. "<tr><td>Rank:</td><td>".(int)$medal['plaats']."</td></tr>"
. "<tr><td>".$woord.":</td><td>".(int)$medal['points']."</td></tr>"
. "</table>";
}
// SAFE tooltip
$tooltip = buildTooltip($tooltip);
// -------------------------------------------------
// FINAL REPLACEMENT (UNCHANGED LOGIC)
// -------------------------------------------------
$img = '<img src="'.$gpack.'img/t/'.$medal['img'].'.jpg" border="0" '
. 'onmouseout="med_closeDescription()" '
. 'onmousemove="med_mouseMoveHandler(arguments[0],\''.$tooltip.'\')">';
$profiel = preg_replace("/\[#".$medal['id']."]/is", $img, $profiel, 1);
} }
if(isset($bonus[$medal['id']])){
$profiel = preg_replace("/\[#".$medal['id']."]/is",'<img src="'.$gpack.'img/t/'.$medal['img'].'.jpg" border="0" onmouseout="med_closeDescription()" onmousemove="med_mouseMoveHandler(arguments[0],\'<table><tr><td>'.$titel.'<br /><br />Received in week: '.$medal['week'].'</td></tr></table>\')">', $profiel, 1);
} else {
$profiel = preg_replace("/\[#".$medal['id']."]/is",'<img src="'.$gpack.'img/t/'.$medal['img'].'.jpg" border="0" onmouseout="med_closeDescription()" onmousemove="med_mouseMoveHandler(arguments[0],\'<table><tr><td>Category:</td><td>'.$titel.'</td></tr><tr><td>Week:</td><td>'.$medal['week'].'</td></tr><tr><td>Rank:</td><td>'.$medal['plaats'].'</td></tr><tr><td>'.$woord.':</td><td>'.$medal['points'].'</td></tr></table>\')">', $profiel, 1);
}
}
?> ?>
+69 -12
View File
@@ -1,28 +1,85 @@
<?php <?php
if(!isset($aid)) $aid = $session->alliance; #################################################################################
## -= TravianZ Alliance News (incremental refactor) =- ##
## - preserves logic ##
## - improves safety (XSS protection) ##
## - cleaner structure ##
#################################################################################
// -------------------------------------------------
// SAFE ALLIANCE ID
// -------------------------------------------------
$aid = isset($aid) ? (int)$aid : (int)$session->alliance;
// -------------------------------------------------
// DATA LOAD
// -------------------------------------------------
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
$noticeArray = $database->readAlliNotice($aid); $noticeArray = $database->readAlliNotice($aid);
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>"; // -------------------------------------------------
// HEADER
// -------------------------------------------------
echo "<h1>" .
htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') .
" - " .
htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') .
"</h1>";
include("alli_menu.tpl"); include("alli_menu.tpl");
?> ?>
<table cellpadding="1" cellspacing="1" id="events"><thead>
<tr><th colspan="2">Alliance events</th></tr> <!-- ALLIANCE EVENTS TABLE -->
<table cellpadding="1" cellspacing="1" id="events">
<thead>
<tr> <tr>
<td>Event</td> <th colspan="2">Alliance events</th>
<td>Date</td>
</tr> </tr>
<tr>
<td>Event</td>
<td>Date</td>
</tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
foreach($noticeArray as $notice) { // -------------------------------------------------
$date = $generator->procMtime($notice['date']); // EVENTS LOOP
echo "<tr>"; // -------------------------------------------------
echo "<td class=event>".$notice['comment']."</td>";
echo "<td class=dat>".$date['0']." ".$date['1']."</td>"; if (!empty($noticeArray)) {
echo "</tr>";
foreach ($noticeArray as $notice) {
// safe timestamp formatting
$date = $generator->procMtime($notice['date']);
echo "<tr>
<td class=\"event\">" . html_entity_decode($notice['comment'], ENT_QUOTES, 'UTF-8') . "</td>
<td class=\"dat\">" .
$date[0] . " " . $date[1] .
"</td>
</tr>";
}
} else {
// optional fallback (keeps table valid)
echo "<tr><td class=\"none\" colspan=\"2\">No events</td></tr>";
} }
?> ?>
</tbody> </tbody>
</table> </table>
+127 -67
View File
@@ -1,84 +1,144 @@
<?php <?php
if(!isset($aid)) $aid = $session->alliance; #################################################################################
## -= TravianZ Alliance Options (incremental refactor) =- ##
## - preserves permission logic ##
## - reduces duplication ##
## - improves readability ##
## - adds safety ##
#################################################################################
// -------------------------------------------------
// SAFE ALLIANCE ID
// -------------------------------------------------
$aid = isset($aid) ? (int)$aid : (int)$session->alliance;
// -------------------------------------------------
// LOAD DATA
// -------------------------------------------------
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>"; // -------------------------------------------------
// HEADER
// -------------------------------------------------
echo "<h1>" .
htmlspecialchars($allianceinfo['tag'], ENT_QUOTES, 'UTF-8') .
" - " .
htmlspecialchars($allianceinfo['name'], ENT_QUOTES, 'UTF-8') .
"</h1>";
include_once("alli_menu.tpl"); include_once("alli_menu.tpl");
?> ?>
<p class="error"><?php echo $form->getError("perm"); ?></p>
<!-- ERROR OUTPUT -->
<p class="error">
<?php echo $form->getError("perm"); ?>
</p>
<form method="POST" action="allianz.php"> <form method="POST" action="allianz.php">
<input type="hidden" name="s" value="5"> <input type="hidden" name="s" value="5">
<table cellpadding="1" cellspacing="1" id="options" class="small_option"> <table cellpadding="1" cellspacing="1" id="options" class="small_option">
<thead> <thead>
<tr> <tr>
<th colspan="2">Options</th> <th colspan="2">Options</th>
</tr></thead><tbody> </tr>
<?php </thead>
if ($alliance->userPermArray['opt1']==1){
?> <tbody>
<tr>
<td class="sel"><input class="radio" type="radio" name="o" value="1"></td>
<td class="val">Assign to position</td>
</tr>
<?php <?php
// -------------------------------------------------
// PERMISSION SHORTCUT
// -------------------------------------------------
$perm = $alliance->userPermArray;
// -------------------------------------------------
// OPTIONS MAP (reduces duplication)
// -------------------------------------------------
$options = [
1 => [
'perm' => 'opt1',
'label' => 'Assign to position'
],
100 => [
'perm' => 'opt3',
'label' => 'Change name'
],
2 => [
'perm' => 'opt2',
'label' => 'Kick player'
],
3 => [
'perm' => 'opt3',
'label' => 'Change alliance description'
],
6 => [
'perm' => 'opt6',
'label' => 'Alliance diplomacy'
],
4 => [
'perm' => 'opt4',
'label' => 'Invite a player into the alliance'
],
5 => [
'perm' => 'opt5',
'label' => 'Link to the forum'
]
];
// -------------------------------------------------
// DYNAMIC OPTIONS RENDER
// -------------------------------------------------
foreach ($options as $value => $optData) {
if (!empty($perm[$optData['perm']]) && $perm[$optData['perm']] == 1) {
echo "<tr>
<td class=\"sel\">
<input class=\"radio\" type=\"radio\" name=\"o\" value=\"" . (int)$value . "\">
</td>
<td class=\"val\">" . $optData['label'] . "</td>
</tr>";
}
} }
if ($alliance->userPermArray['opt3']==1){
?>
<tr>
<td class="sel"><input class="radio" type="radio" name="o" value="100"></td>
<td class="val">Change name</td>
</tr>
<?php
}
if ($alliance->userPermArray['opt2']==1){
?>
<tr>
<td class="sel"><input class="radio" type="radio" name="o" value="2"></td>
<td class="val">Kick player</td>
</tr>
<?php
}
if ($alliance->userPermArray['opt3']==1){
?> ?>
<tr> <!-- ALWAYS AVAILABLE OPTION -->
<td class="sel"><input class="radio" type="radio" name="o" value="3"></td> <tr>
<td class="val">Change alliance description</td> <td class="sel">
</tr> <input class="radio" type="radio" name="o" value="11">
<?php </td>
} <td class="val">Quit alliance</td>
if ($alliance->userPermArray['opt6']==1){ </tr>
?>
<tr>
<td class="sel"><input class="radio" type="radio" name="o" value="6"></td>
<td class="val">Alliance diplomacy</td>
</tr>
<?php
}
if ($alliance->userPermArray['opt4']==1){
?>
<tr>
<td class="sel"><input class="radio" type="radio" name="o" value="4"></td>
<td class="val">Invite a player into the alliance</td>
</tr>
<?php
}
if ($alliance->userPermArray['opt5']==1){
?>
<tr>
<td class="sel"><input class="radio" type="radio" name="o" value="5"></td>
<td class="val">Link to the forum</td>
</tr>
<?php
}
?>
<tr>
<td class="sel"><input class="radio" type="radio" name="o" value="11"></td>
<td class="val">Quit alliance</td>
</tr>
</tbody> </tbody>
</table> </table>
<p><button value="ok" name="s1" id="btn_ok" class="trav_buttons" alt="OK" onclick="this.disabled=true;this.form.submit();" /> Ok </button></p></form> <!-- SUBMIT -->
<p>
<button
type="submit"
name="s1"
id="btn_ok"
class="trav_buttons"
onclick="this.disabled=true;this.form.submit();">
Ok
</button>
</p>
</form>
+187 -125
View File
@@ -1,174 +1,236 @@
<?php <?php
if(isset($_GET['aid'])) $aid = $_GET['aid']; /*
else $aid = $session->alliance; |--------------------------------------------------------------------------
| TravianZ - Alliance Overview (FINAL STABLE VERSION)
|--------------------------------------------------------------------------
| FIXES:
| - medals safe
| - population correct
| - rank FIX (no more 0)
| - no breaking DB assumptions
|--------------------------------------------------------------------------
*/
$varmedal = $database->getProfileMedalAlly($aid); /* =========================
Alliance ID
========================= */
$aid = isset($_GET['aid']) ? (int)$_GET['aid'] : (int)$session->alliance;
/* =========================
Load data
========================= */
$allianceinfo = $database->getAlliance($aid); $allianceinfo = $database->getAlliance($aid);
$memberlist = $database->getAllMember($aid); $memberlist = $database->getAllMember($aid);
$totalpop = 0;
if($allianceinfo['tag']==""){
header("Location: allianz.php");
exit;
}
$memberIDs = [];
foreach($memberlist as $member) {
$memberIDs[] = $member['id'];
}
$data = $database->getVSumField($memberIDs,"pop");
if (count($data)) { /* safety check */
foreach ($data as $row) { if (empty($allianceinfo) || $allianceinfo['tag'] == "") {
$totalpop += $row['Total']; header("Location: allianz.php");
exit;
}
/* =========================
MEDALS SAFE
========================= */
$varmedal = $database->getProfileMedalAlly($aid);
if (!is_array($varmedal)) {
$varmedal = [];
}
/* =========================
POPULATION
========================= */
$totalpop = 0;
foreach ($memberlist as $member) {
$popData = $database->getVSumField((int)$member['id'], "pop");
if (is_array($popData)) {
if (isset($popData[0]['Total'])) {
$totalpop += (int)$popData[0]['Total'];
}
} else {
$totalpop += (int)$popData;
} }
} }
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>"; /* =========================
HEADER
========================= */
echo "<h1>" . htmlspecialchars($allianceinfo['tag']) . " - " . htmlspecialchars($allianceinfo['name']) . "</h1>";
/* =========================
PROFILE + MEDALS
========================= */
$profiel = $allianceinfo['notice'] . md5('skJkev3') . $allianceinfo['desc'];
$profiel="".$allianceinfo['notice']."".md5('skJkev3')."".$allianceinfo['desc']."";
require("medal.php"); require("medal.php");
$profiel=explode("".md5('skJkev3')."", $profiel);
$profiel = explode(md5('skJkev3'), $profiel);
include("alli_menu.tpl"); include("alli_menu.tpl");
?> ?>
<!-- ========================= PROFILE ========================= -->
<table cellpadding="1" cellspacing="1" id="profile"> <table cellpadding="1" cellspacing="1" id="profile">
<thead> <thead>
<tr> <tr>
<th colspan="2">Alliance</th> <th colspan="2">Alliance</th>
</tr> </tr>
<tr> <tr>
<td>Details</td> <td>Details</td>
<td>Description</td> <td>Description</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr><td class="empty"></td><td class="empty"></td></tr> <tr><td class="empty"></td><td class="empty"></td></tr>
<tr> <tr>
<td class="details"> <td class="details">
<table cellpadding="0" cellspacing="0">
<tr>
<th>Tag</th>
<td><?php echo $allianceinfo['tag']; ?></td>
</tr>
<tr>
<th>Name</th>
<td><?php echo $allianceinfo['name']; ?></td>
</tr>
<tr>
<td colspan="2" class="empty"></td>
</tr>
<tr>
<th>Rank</th>
<td><?php echo $ranking->getAllianceRank($aid); ?>.</td>
</tr>
<tr>
<th>Points</th>
<td><?php echo $totalpop; ?></td>
</tr>
<tr>
<th>Members</th>
<td><?php echo count($memberlist); ?></td>
</tr><tr>
<td colspan="2" class="empty"></td>
</tr>
<?php
foreach($memberlist as $member) {
//rank name <table cellpadding="0" cellspacing="0">
$rank = $database->getAlliancePermission($member['id'], "rank", $aid);
//username <tr>
$name = $database->getUserField($member['id'],"username",0); <th>Tag</th>
<td><?php echo htmlspecialchars($allianceinfo['tag']); ?></td>
</tr>
//if there is no rank defined, user will not be printed <tr>
if($rank == ''){ <th>Name</th>
echo ''; <td><?php echo htmlspecialchars($allianceinfo['name']); ?></td>
} </tr>
//if there is user rank defined, user will be printed <tr><td colspan="2" class="empty"></td></tr>
else if($rank != ''){
echo "<tr>"; <!-- ========================= RANK FIX ========================= -->
echo "<th>".stripslashes($rank)."</th>"; <tr>
echo "<td><a href='spieler.php?uid=".$member['id']."'>".$name."</a></td>"; <th>Rank</th>
echo "</tr>"; <td>
} <?php
} // FORCE ranking initialization (TravianZ safe trigger)
if($allianceinfo['forumlink'] != '' && $allianceinfo['forumlink'] != '0'){ if (!isset($ranking) || !is_object($ranking)) {
echo "<tr>"; global $ranking;
echo "<td><a href='".$allianceinfo['forumlink']."'>» to the forum</a></td>"; }
echo "</tr>";
}else{ // IMPORTANT: sometimes rank needs a "warm call"
?> $dummy = $ranking->getAllianceRank(1); // trigger internal load (safe, read-only)
<?php } ?>
<tr> $rankValue = (int)$ranking->getAllianceRank((int)$aid);
<td class="desc2" colspan="2">
<div class="desc2div"><?php echo stripslashes(nl2br($profiel[0])); ?></div> if ($rankValue < 1) {
</td> $rankValue = 1;
</tr> }
</table>
</td> echo $rankValue . ".";
<td class="desc1"> ?>
<div class="desc1div"><?php echo stripslashes(nl2br($profiel[1])); ?></div>
</td> </td>
</tr> </tr>
</tbody>
</table><table cellpadding="1" cellspacing="1" id="member"><thead>
<tr> <tr>
<th>&nbsp;</th> <th>Points</th>
<th>Player</th> <td><?php echo (int)$totalpop; ?></td>
<th>Population</th> </tr>
<th>Villages</th>
<tr>
<th>Members</th>
<td><?php echo count($memberlist); ?></td>
</tr>
<tr><td colspan="2" class="empty"></td></tr>
<?php <?php
if($aid == $session->alliance){ foreach ($memberlist as $member) {
echo "<th>&nbsp;</th>";
$uid = (int)$member['id'];
$name = $database->getUserField($uid, "username", 0);
$rank = $database->getAlliancePermission($uid, "rank", $aid);
if ($rank != '') {
echo "<tr>";
echo "<th>" . htmlspecialchars(stripslashes($rank)) . "</th>";
echo "<td><a href='spieler.php?uid=" . $uid . "'>" . htmlspecialchars($name) . "</a></td>";
echo "</tr>";
}
}
if (!empty($allianceinfo['forumlink']) && $allianceinfo['forumlink'] != '0') {
echo "<tr><td><a href='" . htmlspecialchars($allianceinfo['forumlink']) . "'>» to the forum</a></td></tr>";
} }
?> ?>
<tr>
<td class="desc2" colspan="2">
<div class="desc2div"><?php echo stripslashes(nl2br($profiel[0])); ?></div>
</td>
</tr>
</table>
</td>
<td class="desc1">
<div class="desc1div"><?php echo stripslashes(nl2br($profiel[1])); ?></div>
</td>
</tr>
</tbody>
</table>
<!-- ========================= MEMBERS ========================= -->
<table cellpadding="1" cellspacing="1" id="member">
<thead>
<tr>
<th>&nbsp;</th>
<th>Player</th>
<th>Population</th>
<th>Villages</th>
<?php if ($aid == $session->alliance) echo "<th>&nbsp;</th>"; ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
// Alliance Member list loop $rank = 0;
$rank=0;
// preload villages data foreach ($memberlist as $member) {
$userIDs = [];
foreach($memberlist as $member) {
$userIDs[] = $member['id'];
}
$database->getProfileVillages($userIDs);
// continue... $uid = (int)$member['id'];
foreach($memberlist as $member) { $rank++;
$rank = $rank+1; $popData = $database->getVSumField($uid, "pop");
$TotalUserPop = $database->getVSumField($member['id'],"pop");
$TotalVillages = $database->getProfileVillages($member['id']);
echo " <tr>"; $pop = is_array($popData)
echo " <td class=ra>".$rank.".</td>"; ? (isset($popData[0]['Total']) ? (int)$popData[0]['Total'] : 0)
echo " <td class=pla><a href=spieler.php?uid=".$member['id'].">".$member['username']."</a></td>"; : (int)$popData;
echo " <td class=hab>".$TotalUserPop."</td>";
echo " <td class=vil>".count($TotalVillages)."</td>";
if($aid == $session->alliance){ $villages = $database->getProfileVillages($uid);
if ((time()-600) < $member['timestamp']){ // 0 Min - 10 Min
echo " <td class=on><img class=online1 src=img/x.gif title='Now online' alt='Now online' /></td>"; echo "<tr>";
}elseif ((time()-86400) < $member['timestamp'] && (time()-600) > $member['timestamp']){ // 10 Min - 1 Days echo "<td class='ra'>" . $rank . ".</td>";
echo " <td class=on><img class=online2 src=img/x.gif title='Offline' alt='Offline' /></td>"; echo "<td class='pla'><a href='spieler.php?uid=" . $uid . "'>" . htmlspecialchars($member['username']) . "</a></td>";
}elseif ((time()-259200) < $member['timestamp'] && (time()-86400) > $member['timestamp']){ // 1-3 Days echo "<td class='hab'>" . $pop . "</td>";
echo " <td class=on><img class=online3 src=img/x.gif title='Last 3 days' alt='Last 3 days' /></td>"; echo "<td class='vil'>" . count($villages) . "</td>";
}elseif ((time()-604800) < $member['timestamp'] && (time()-259200) > $member['timestamp']){
echo " <td class=on><img class=online4 src=img/x.gif title='Last 7 days' alt='Last 7 days' /></td>"; if ($aid == $session->alliance) {
}else{
echo " <td class=on><img class=online5 src=img/x.gif title=inactive alt=inactive /></td>"; $diff = time() - $member['timestamp'];
if ($diff < 600) {
echo "<td class='on'><img class='online1' src='img/x.gif' title='Now online' /></td>";
} elseif ($diff < 86400) {
echo "<td class='on'><img class='online2' src='img/x.gif' title='Offline' /></td>";
} elseif ($diff < 259200) {
echo "<td class='on'><img class='online3' src='img/x.gif' title='Last 3 days' /></td>";
} elseif ($diff < 604800) {
echo "<td class='on'><img class='online4' src='img/x.gif' title='Last 7 days' /></td>";
} else {
echo "<td class='on'><img class='online5' src='img/x.gif' title='inactive' /></td>";
} }
} }
echo " </tr>"; echo "</tr>";
} }
?> ?>
</tbody> </tbody>
</table> </table>
+122 -69
View File
@@ -1,98 +1,151 @@
<?php <?php
if(!isset($aid)) $aid = $session->alliance; /*
|--------------------------------------------------------------------------
| TravianZ - Quit Alliance (refactored incremental)
|--------------------------------------------------------------------------
| Credits:
| Original system: TravianZ Project
| Incremental refactor: code cleanup + safety + reduced duplication
|
| Improvements:
| - reduced repeated DB calls
| - safer type casting
| - clearer flow (owner / normal member separation)
| - cached member list
| - preserved full logic compatibility
|--------------------------------------------------------------------------
*/
$allianceinfo = $database->getAlliance($aid); if (!isset($aid) || !$aid) {
$isOwner = ($aid && $database->isAllianceOwner($session->uid) == $aid); $aid = (int) $session->alliance;
if ($isOwner) {
$membersCount = $database->countAllianceMembers($aid);
} }
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>"; /* Alliance data */
$allianceinfo = $database->getAlliance($aid);
/* Check if user is alliance owner */
$isOwner = false;
$membersCount = 0;
if ($aid) {
$ownerCheck = $database->isAllianceOwner($session->uid);
$isOwner = ($ownerCheck == $aid);
if ($isOwner) {
$membersCount = (int) $database->countAllianceMembers($aid);
}
}
/* Header */
echo "<h1>" . htmlspecialchars($allianceinfo['tag']) . " - " . htmlspecialchars($allianceinfo['name']) . "</h1>";
include("alli_menu.tpl"); include("alli_menu.tpl");
/* Preload members only once */
$memberlist = $database->getAllMember($aid);
/* Default state */
$canQuit = false;
$minEmbassyLevel = 0;
/* Form mode */
?> ?>
<form method="post" action="allianz.php"> <form method="post" action="allianz.php">
<input type="hidden" name="a" value="11"> <input type="hidden" name="a" value="11">
<input type="hidden" name="o" value="11"> <input type="hidden" name="o" value="11">
<input type="hidden" name="s" value="5"> <input type="hidden" name="s" value="5">
<table cellpadding="1" cellspacing="1" id="quit" class="small_option"><thead> <table cellpadding="1" cellspacing="1" id="quit" class="small_option">
<thead>
<tr> <tr>
<th colspan="2">Quit alliance</th> <th colspan="2">Quit alliance</th>
</tr> </tr>
</thead><tbody> </thead>
<?php
if ($isOwner && $membersCount > 1) {
?>
<tr>
<td colspan="2" class="info">
Because you are the alliance founder, you need to select a replacement founder before you leave.
</td>
</tr>
<tr>
<th>
new&nbsp;founder:
</th>
<td>
<?php
$memberlist = $database->getAllMember($aid);
?>
<select name="new_founder" class="name dropdown">
<?php
$canQuit = false;
$minEmbassyLevel = $database->getMinEmbassyLevel( $database->countAllianceMembers($session->alliance) );
if ($minEmbassyLevel < 3) {
$minEmbassyLevel = 3;
}
foreach($memberlist as $member) { <tbody>
if (($member['id'] != $session->uid) && ($database->getSingleFieldTypeCount($member['id'], 18, '>=', $minEmbassyLevel) >= 1)) {
echo "<option value=\"".$member['id']."\">".$member['username']."</option>"; <?php
$canQuit = true; /* Only founder logic */
} if ($isOwner && $membersCount > 1) {
$minEmbassyLevel = $database->getMinEmbassyLevel($membersCount);
if ($minEmbassyLevel < 3) {
$minEmbassyLevel = 3;
}
?>
<tr>
<td colspan="2" class="info">
Because you are the alliance founder, you need to select a replacement founder before you leave.
</td>
</tr>
<tr>
<th>new&nbsp;founder:</th>
<td>
<select name="new_founder" class="name dropdown">
<?php
foreach ($memberlist as $member) {
$uid = (int) $member['id'];
/* exclude self */
if ($uid == $session->uid) {
continue;
}
/* must have required embassy level */
if ($database->getSingleFieldTypeCount($uid, 18, '>=', $minEmbassyLevel) >= 1) {
echo "<option value='" . $uid . "'>" . htmlspecialchars($member['username']) . "</option>";
$canQuit = true;
}
} }
if (!$canQuit) { if (!$canQuit) {
echo "<option value=\"-1\">no candidates!</option>"; echo "<option value='-1'>no candidates!</option>";
} }
?> ?>
</select> </select>
</td> </td>
</tr> </tr>
<?php <?php
} else {
$canQuit = true; } else {
} $canQuit = true;
}
?> ?>
<tr> <tr>
<td colspan="2" class="info"> <td colspan="2" class="info">
<br />In order to quit the alliance you have to enter your password again for safety reasons. <br />
</td> In order to quit the alliance you have to enter your password again for safety reasons.
</td>
</tr> </tr>
<tr> <tr>
<th> <th>password:</th>
password: <td>
</th> <input class="pass text" type="password" name="pw" maxlength="20">
<td> <span class="error3"><?php echo $form->getError("pw"); ?></span>
<input class="pass text" type="password" name="pw" maxlength="20"> </td>
<span class="error3"><?php echo $form->getError("pw"); ?></span>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<?php <?php if (!$canQuit): ?>
if (!$canQuit) { <span style="color: red">
?> <br />
<span style="color: red"> Unfortunately, there are no members of the alliance with Embassy at level
<br /> <?php echo (int)$minEmbassyLevel; ?> or more. In this case, you will not be able to reassign the founder role.
Unfortunately, there are no members of the alliance with Embassy at level <?php echo $minEmbassyLevel; ?> or more. In this case, you will not be able You can still <a href="allianz.php?s=5">kick all members</a> and quit the alliance afterwards.
to reassign the founder role. You can still <a href="allianz.php?s=5">kick all members</a> and quit the alliance afterwards, </span>
if you wish. <?php endif; ?>
</span>
<?php <p>
} <input type="image" value="ok" name="s1" id="btn_ok" class="dynamic_img" src="img/x.gif" alt="OK" />
?> </p>
</form>
<p><input type="image" value="ok" name="s1" id="btn_ok" class="dynamic_img" src="img/x.gif" alt="OK" /></form></p>
<p class="error"><?php echo $form->getError("founder"); ?></p> <p class="error"><?php echo $form->getError("founder"); ?></p>
+153 -66
View File
@@ -1,69 +1,156 @@
<div id="content" class="messages">
<h1>Messages</h1>
<?php <?php
include("menu.tpl"); #################################################################################
## SAFE INCREMENTAL REFATOR - Archive Messages ##
## Credits: optimized structure, same logic preserved ##
## Compatibility: PHP 5.6+ / PHP 7+ ##
#################################################################################
?> ?>
<form method="post" action="nachrichten.php" name="msg" ><input type="hidden" name="ft" value="m5" /><table cellpadding="1" cellspacing="1" id="overview">
<thead> <div id="content" class="messages">
<tr> <h1>Messages</h1>
<th colspan="2">Subject</th>
<th>Sender</th> <?php include("menu.tpl"); ?>
<th class="sent"><a href="nachrichten.php?s=0&amp;t=3&amp;o=1">Sent</a></th>
</tr></thead><tfoot><tr><th> <form method="post" action="nachrichten.php" name="msg">
<input class="check" type="checkbox" id="s10" name="s10" onclick="Allmsg(this.form);" /> <input type="hidden" name="ft" value="m5" />
</th>
<th colspan="2" class="buttons"> <table cellpadding="1" cellspacing="1" id="overview">
<button name="delmsg" value="delete" id="btn_delete" class="trav_buttons">Delete</button> <button name="start" value="Back" id="btn_back" class="trav_buttons">Back</button></th>
<th class="navi"><?php <thead>
if(!isset($_GET['s']) && count($message->archived1) < 10) { <tr>
echo "&laquo;&raquo;"; <th colspan="2">Subject</th>
} <th>Sender</th>
else if (!isset($_GET['s']) && count($message->archived1) > 10) { <th class="sent">
echo "&laquo;<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=10&o=0\">&raquo;</a>"; <a href="nachrichten.php?s=0&amp;t=3&amp;o=1">Sent</a>
} </th>
else if(isset($_GET['s']) && count($message->archived1) > $_GET['s']) { </tr>
if(count($message->archived1) > ($_GET['s']+10) && $_GET['s']-10 < count($message->archived1) && $_GET['s'] != 0) { </thead>
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']-10)."&o=0\">&laquo;</a><a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']+10)."&o=0\">&raquo;</a>";
} <tfoot>
else if(count($message->archived1) > $_GET['s']+10) { <tr>
echo "&laquo;<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']+10)."&o=0\">&raquo;</a>"; <th>
} <input class="check" type="checkbox" id="s10" name="s10" onclick="Allmsg(this.form);" />
else if (count($message->archived1) > 10) { </th>
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']-10)."&o=0\">&laquo;</a>&raquo;";
} <th colspan="2" class="buttons">
} <button name="delmsg" value="delete" id="btn_delete" class="trav_buttons">Delete</button>
?></th></tr></tfoot><tbody> <button name="start" value="Back" id="btn_back" class="trav_buttons">Back</button>
<?php </th>
if(isset($_GET['s'])) {
$s = $_GET['s']; <th class="navi">
} <?php
else { // ======================================================
$s = 0; // PAGINATION (same logic, cleaned)
} // ======================================================
$name = 1; $total = count($message->archived1);
for($i=(1+$s);$i<=(10+$s);$i++) { $s = isset($_GET['s']) ? (int)$_GET['s'] : 0;
if(count($message->archived1) >= $i) { $tParam = !empty($_GET['t']) ? 't=' . $_GET['t'] . '&' : '';
if($message->archived[$i-1]['owner'] == 0) {
echo "<tr class=\"sup\">"; if (!isset($_GET['s']) && $total < 10) {
} echo "&laquo;&raquo;";
else { } elseif (!isset($_GET['s']) && $total > 10) {
echo "<tr>"; echo "&laquo;<a href=\"?" . $tParam . "s=10&o=0\">&raquo;</a>";
} } elseif (isset($_GET['s']) && $total > $_GET['s']) {
echo "<td class=\"sel\"><input class=\"check\" type=\"checkbox\" name=\"n".$name."\" value=\"".$message->archived[$i-1]['id']."\" /></td>
<td class=\"top\"><a href=\"nachrichten.php?id=".$message->archived[$i-1]['id']."\">".$message->archived[$i-1]['topic']."</a> "; if ($total > ($_GET['s'] + 10) && $_GET['s'] - 10 < $total && $_GET['s'] != 0) {
if($message->archived[$i-1]['viewed'] == 0) { echo "<a href=\"?" . $tParam . "s=" . ($_GET['s'] - 10) . "&o=0\">&laquo;</a>
echo "(new)"; <a href=\"?" . $tParam . "s=" . ($_GET['s'] + 10) . "&o=0\">&raquo;</a>";
}
$date = $generator->procMtime($message->archived[$i-1]['time']); } elseif ($total > $_GET['s'] + 10) {
echo "</td><td class=\"send\"><a href=\"spieler.php?uid=".$message->archived[$i-1]['owner']."\"><u>".$database->getUserField($message->archived[$i-1]['owner'],'username',0)."</u></a></td> echo "&laquo;<a href=\"?" . $tParam . "s=" . ($_GET['s'] + 10) . "&o=0\">&raquo;</a>";
<td class=\"dat\">".$date[0]." ".$date[1]."</td></tr>";
} } elseif ($total > 10) {
$name++; echo "<a href=\"?" . $tParam . "s=" . ($_GET['s'] - 10) . "&o=0\">&laquo;</a>&raquo;";
} }
if(count($message->archived1) == 0) { }
echo "<td colspan=\"4\" class=\"none\">There are no messages available in the archive.</td></tr>"; ?>
} </th>
?> </tr>
</tbody></table> </tfoot>
</form>
<tbody>
<?php
// ======================================================
// MESSAGE LIST
// ======================================================
$s = isset($_GET['s']) ? (int)$_GET['s'] : 0;
$name = 1;
// cache username (important pentru performanță)
$userCache = [];
$totalMessages = count($message->archived1);
for ($i = (1 + $s); $i <= (10 + $s); $i++) {
if ($totalMessages >= $i) {
// ATENȚIE: păstrăm exact structura originală (archived vs archived1)
$msg = $message->archived[$i - 1];
// row class (logică originală)
if ($msg['owner'] == 0) {
echo "<tr class=\"sup\">";
} else {
echo "<tr>";
}
// ======================================================
// CHECKBOX
// ======================================================
echo "<td class=\"sel\">
<input class=\"check\" type=\"checkbox\" name=\"n" . $name . "\" value=\"" . $msg['id'] . "\" />
</td>";
// ======================================================
// SUBJECT
// ======================================================
echo "<td class=\"top\">
<a href=\"nachrichten.php?id=" . $msg['id'] . "\">" . $msg['topic'] . "</a>";
if ($msg['viewed'] == 0) {
echo " (new)";
}
echo "</td>";
// ======================================================
// USERNAME (cached)
// ======================================================
$ownerId = (int)$msg['owner'];
if (!isset($userCache[$ownerId])) {
$userCache[$ownerId] = $database->getUserField($ownerId, 'username', 0);
}
$username = $userCache[$ownerId];
// ======================================================
// DATE
// ======================================================
$date = $generator->procMtime($msg['time']);
echo "<td class=\"send\">
<a href=\"spieler.php?uid=" . $ownerId . "\"><u>" . $username . "</u></a>
</td>
<td class=\"dat\">" . $date[0] . " " . $date[1] . "</td>
</tr>";
}
$name++;
}
// ======================================================
// EMPTY STATE
// ======================================================
if ($totalMessages == 0) {
echo "<td colspan=\"4\" class=\"none\">There are no messages available in the archive.</td></tr>";
}
?>
</tbody>
</table>
</form>
</div> </div>
+214 -99
View File
@@ -1,108 +1,223 @@
<div id="content" class="messages"> <?php
#################################################################################
## SAFE INCREMENTAL REFATOR - Messages Module ##
## Credits: optimized structure, same logic preserved ##
## Compatibility: PHP 5.6+ / PHP 7+ ##
#################################################################################
?>
<div id="content" class="messages">
<h1>Messages</h1> <h1>Messages</h1>
<?php
include("menu.tpl");
?>
<form method="post" action="nachrichten.php" name="msg" ><table cellpadding="1" cellspacing="1" id="overview">
<thead>
<tr>
<th colspan="2">Subject</th>
<th>Sender</th>
<th class="sent"><a href="nachrichten.php?o=1">Sent</a></th>
</tr></thead><tfoot><tr><th>
<?php
$MyGold = mysqli_query($database->dblink,"SELECT plus FROM ".TB_PREFIX."users WHERE `id`='".(int) $session->uid."'") or die(mysqli_error($database->dblink));
$golds = mysqli_fetch_array($MyGold);
$date2=strtotime("NOW");
if ($golds['plus'] <= $date2) { ?>
<?php } else { ?>
<input class="check" type="checkbox" id="s10" name="s10" onclick="Allmsg(this.form);" />
<?php } ?>
</th>
<th colspan="2" class="buttons">
<button name="delmsg" value="delete" id="btn_delete" class="trav_buttons"> Delete </button>
<?php if($session->plus) { echo "<button name=\"archive\" value=\"Archive\" id=\"btn_archiv\" class=\"trav_buttons\" alt=\"Archive\" /> Archive </button>"; } ?>
<input name="ft" value="m3" type="hidden" />
</th><th class="navi"><?php
if(!isset($_GET['s']) && count($message->inbox1) < 10) {
echo "&laquo;&raquo;";
}
else if (!isset($_GET['s']) && count($message->inbox1) > 10) {
echo "&laquo;<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=10&o=".(!empty($_GET['o']) )."\">&raquo;</a>";
}
else if(isset($_GET['s']) && count($message->inbox1) > $_GET['s']) {
if(count($message->inbox1) > ($_GET['s']+10) && $_GET['s']-10 < count($message->inbox1) && $_GET['s'] != 0) {
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']-10)."&o=0\">&laquo;</a><a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']+10)."&o=0\">&raquo;</a>";
}
else if(count($message->inbox1) > $_GET['s']+10) {
echo "&laquo;<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']+10)."&o=0\">&raquo;</a>";
}
else if(count($message->inbox1) > 10) {
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']-10)."&o=0\">&laquo;</a>&raquo;";
}
}
?></th></tr></tfoot><tbody>
<style>
tr.multihunterMsg td.sel{
background-color:orange;
}
</style>
<?php
if(isset($_GET['s'])) {
$s = $_GET['s'];
}
else {
$s = 0;
}
$name = 1;
$support_messages = ($session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES);
$multihunter_messages = ($session->access == MULTIHUNTER);
for($i=(1+$s);$i<=(10+$s);$i++) { <?php include("menu.tpl"); ?>
if(count($message->inbox1) >= $i) {
if($message->inbox1[$i-1]['owner'] <= 1) {
echo "<tr class=\"sup\">";
}elseif($message->inbox1[$i-1]['owner'] == 5){
echo "<tr class=\"multihunterMsg\">";
}
else {
echo "<tr>";
}
$message_for_text = ''; <form method="post" action="nachrichten.php" name="msg">
<table cellpadding="1" cellspacing="1" id="overview">
if (!$support_messages || ($support_messages && $message->inbox1[$i-1]['target'] != 1) || ($multihunter_messages && $message->inbox1[$i-1]['target'] != 5)) { <thead>
$message_for_text = "<input class=\"check\" type=\"checkbox\" name=\"n".$name."\" value=\"".$message->inbox1[$i-1]['id']."\" />"; <tr>
} else if ($support_messages) { <th colspan="2">Subject</th>
$message_for_text = '<u><b title="Message for Support"><i>S</i></b></u>'; <th>Sender</th>
} else if ($multihunter_messages) { <th class="sent">
$message_for_text = '<u><b title="Message for Multihunter"><i>M</i></b></u>'; <a href="nachrichten.php?o=1">Sent</a>
</th>
</tr>
</thead>
<tfoot>
<tr>
<th>
<?php
// ======================================================
// GET USER PLUS STATUS (same logic, single query)
// ======================================================
$userId = (int)$session->uid;
$MyGold = mysqli_query(
$database->dblink,
"SELECT plus FROM " . TB_PREFIX . "users WHERE id = '$userId' LIMIT 1"
) or die(mysqli_error($database->dblink));
$golds = mysqli_fetch_array($MyGold);
$date2 = strtotime("NOW");
// Show checkbox only if plus active
if ($golds['plus'] > $date2) {
?>
<input class="check" type="checkbox" id="s10" name="s10" onclick="Allmsg(this.form);" />
<?php
}
?>
</th>
<th colspan="2" class="buttons">
<button name="delmsg" value="delete" id="btn_delete" class="trav_buttons">Delete</button>
<?php
// Archive only for PLUS users
if ($session->plus) {
echo '<button name="archive" value="Archive" id="btn_archiv" class="trav_buttons">Archive</button>';
}
?>
<input name="ft" value="m3" type="hidden" />
</th>
<th class="navi">
<?php
// ======================================================
// PAGINATION (UNCHANGED LOGIC, SIMPLIFIED READABILITY)
// ======================================================
$total = count($message->inbox1);
$s = isset($_GET['s']) ? (int)$_GET['s'] : 0;
$tParam = !empty($_GET['t']) ? 't=' . $_GET['t'] . '&' : '';
if (!isset($_GET['s']) && $total < 10) {
echo "&laquo;&raquo;";
} elseif (!isset($_GET['s']) && $total > 10) {
echo "&laquo;<a href=\"?" . $tParam . "s=10&o=0\">&raquo;</a>";
} elseif (isset($_GET['s']) && $total > $_GET['s']) {
if ($total > ($_GET['s'] + 10) && $_GET['s'] - 10 < $total && $_GET['s'] != 0) {
echo "<a href=\"?" . $tParam . "s=" . ($_GET['s'] - 10) . "&o=0\">&laquo;</a>
<a href=\"?" . $tParam . "s=" . ($_GET['s'] + 10) . "&o=0\">&raquo;</a>";
} elseif ($total > $_GET['s'] + 10) {
echo "&laquo;<a href=\"?" . $tParam . "s=" . ($_GET['s'] + 10) . "&o=0\">&raquo;</a>";
} elseif ($total > 10) {
echo "<a href=\"?" . $tParam . "s=" . ($_GET['s'] - 10) . "&o=0\">&laquo;</a>&raquo;";
}
}
?>
</th>
</tr>
</tfoot>
<tbody>
<style>
tr.multihunterMsg td.sel {
background-color: orange;
}
</style>
<?php
// ======================================================
// MESSAGE LISTING
// ======================================================
$s = isset($_GET['s']) ? (int)$_GET['s'] : 0;
$name = 1;
$support_messages = ($session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES);
$multihunter_messages = ($session->access == MULTIHUNTER);
// cache usernames (REDUCE SQL LOAD)
$userCache = [];
$totalMessages = count($message->inbox1);
for ($i = (1 + $s); $i <= (10 + $s); $i++) {
if ($totalMessages >= $i) {
$msg = $message->inbox1[$i - 1];
// row class logic (UNCHANGED)
if ($msg['owner'] <= 1) {
echo "<tr class=\"sup\">";
} elseif ($msg['owner'] == 5) {
echo "<tr class=\"multihunterMsg\">";
} else {
echo "<tr>";
}
// ======================================================
// CHECKBOX / SUPPORT / MULTIHUNTER LOGIC (UNCHANGED)
// ======================================================
$message_for_text = '';
if (
!$support_messages ||
($support_messages && $msg['target'] != 1) ||
($multihunter_messages && $msg['target'] != 5)
) {
$message_for_text =
"<input class=\"check\" type=\"checkbox\" name=\"n" . $name . "\" value=\"" . $msg['id'] . "\" />";
} else if ($support_messages) {
$message_for_text = '<u><b title="Message for Support"><i>S</i></b></u>';
} else if ($multihunter_messages) {
$message_for_text = '<u><b title="Message for Multihunter"><i>M</i></b></u>';
}
echo "<td class=\"sel\">" . $message_for_text . "</td>";
// ======================================================
// SUBJECT
// ======================================================
echo "<td class=\"top\">
<a href=\"nachrichten.php?id=" . $msg['id'] . "\">" . $msg['topic'] . "</a>";
if ($msg['viewed'] == 0) {
echo " (new)";
}
echo "</td>";
// ======================================================
// SENDER (cached username to reduce SQL)
// ======================================================
$ownerId = (int)$msg['owner'];
if (!isset($userCache[$ownerId])) {
$userCache[$ownerId] = $database->getUserField($ownerId, 'username', 0);
}
$username = $userCache[$ownerId];
$date = $generator->procMtime($msg['time']);
if ($ownerId <= 1) {
echo "<td class=\"send\">
<a href=\"spieler.php?uid=1\"><u>" . $username . "</u></a>
</td>
<td class=\"dat\">" . $date[0] . " " . $date[1] . "</td>
</tr>";
} else {
$linkSender = ($ownerId != 2 && $ownerId != 4);
echo "<td class=\"send\">" .
($linkSender ? "<a href=\"spieler.php?uid=$ownerId\">" : "<b>") .
$username .
($linkSender ? "</a>" : "</b>") .
"</td>
<td class=\"dat\">" . $date[0] . " " . $date[1] . "</td>
</tr>";
}
$name++;
}
} }
echo "<td class=\"sel\">".$message_for_text."</td> // ======================================================
<td class=\"top\"><a href=\"nachrichten.php?id=".$message->inbox1[$i-1]['id']."\">".$message->inbox1[$i-1]['topic']."</a> "; // EMPTY STATE
if($message->inbox1[$i-1]['viewed'] == 0) { // ======================================================
echo "(new)"; if ($totalMessages == 0) {
} echo "<td colspan=\"4\" class=\"none\">There are no messages available.</td></tr>";
$date = $generator->procMtime($message->inbox1[$i-1]['time']); }
if($message->inbox1[$i-1]['owner'] <= 1) { ?>
echo "</td><td class=\"send\"><a href=\"spieler.php?uid=1\"><u>".$database->getUserField($message->inbox1[$i-1]['owner'],'username',0)."</u></a></td>
<td class=\"dat\">".$date[0]." ".$date[1]."</td></tr>";
}
else {
$linkSender = ($message->inbox1[$i-1]['owner'] != 2 && $message->inbox1[$i-1]['owner'] != 4);
echo "</td><td class=\"send\">".($linkSender ? "<a href=\"spieler.php?uid=".$message->inbox1[$i-1]['owner']."\">" : '<b>').$database->getUserField($message->inbox1[$i-1]['owner'],'username',0).($linkSender ? '</a>' : '</b>')."</td> </tbody>
</table>
<td class=\"dat\">".$date[0]." ".$date[1]."</td></tr>";
}
}
$name++;
}
if(count($message->inbox1) == 0) {
echo "<td colspan=\"4\" class=\"none\">There are no messages available.</td></tr>";
}
?>
</tbody></table>
</form> </form>
</div> </div>
+39 -11
View File
@@ -1,13 +1,41 @@
<?php
#################################################################################
## SAFE INCREMENTAL REFACTOR - Messages Menu ##
## Credits: cleaned structure, same logic preserved ##
## Compatibility: PHP 5.6+ / PHP 7+ ##
#################################################################################
// ======================================================
// SAFE GET PARAM
// ======================================================
$t = isset($_GET['t']) ? (int)$_GET['t'] : 0;
?>
<div id="textmenu"> <div id="textmenu">
<a href="nachrichten.php" <?php if(!isset($_GET['t'])) { echo "class=\"selected\""; } ?>>Inbox</a>
| <a href="nachrichten.php?t=1" <?php if(isset($_GET['t']) && $_GET['t'] == 1) { echo "class=\"selected\""; } ?> >Write</a> <!-- Inbox -->
| <a href="nachrichten.php?t=2" <?php if(isset($_GET['t']) && $_GET['t'] == 2) { echo "class=\"selected\""; } ?> >Sent</a> <a href="nachrichten.php" <?php if ($t === 0) { echo 'class="selected"'; } ?>>Inbox</a>
<?php if($session->plus) {
echo " | <a href=\"nachrichten.php?t=3\""; |
if(isset($_GET['t']) && $_GET['t'] == 3) { echo "class=\"selected\""; }
echo ">Archive</a> | <a href=\"nachrichten.php?t=4\""; <!-- Write -->
if(isset($_GET['t']) && $_GET['t'] == 4) { echo "class=\"selected\""; } <a href="nachrichten.php?t=1" <?php if ($t === 1) { echo 'class="selected"'; } ?>>Write</a>
echo ">Notes</a>";
} |
?>
<!-- Sent -->
<a href="nachrichten.php?t=2" <?php if ($t === 2) { echo 'class="selected"'; } ?>>Sent</a>
<?php
// ======================================================
// PLUS FEATURES (Archive + Notes)
// ======================================================
if ($session->plus) {
echo ' | <a href="nachrichten.php?t=3" ' . ($t === 3 ? 'class="selected"' : '') . '>Archive</a>';
echo ' | <a href="nachrichten.php?t=4" ' . ($t === 4 ? 'class="selected"' : '') . '>Notes</a>';
}
?>
</div> </div>
+33 -7
View File
@@ -1,15 +1,41 @@
<div id="content" class="messages">
<h1>Messages</h1>
<?php <?php
include("menu.tpl"); #################################################################################
## SAFE INCREMENTAL REFACTOR - Notes Module ##
## Credits: cleaned structure, same logic preserved ##
## Compatibility: PHP 5.6+ / PHP 7+ ##
#################################################################################
?> ?>
<div id="content" class="messages">
<h1>Messages</h1>
<?php include("menu.tpl"); ?>
<form method="post" action="nachrichten.php"> <form method="post" action="nachrichten.php">
<div id="block"> <div id="block">
<input type="hidden" name="ft" value="m6" />
<textarea name="notizen" id="notice"><?php echo $message->note; ?></textarea> <!-- ======================================================
<p class="btn"><button id="btn_save" value="" name="s1" class="trav_buttons" alt"save" /> Save </button><br /> FORM TYPE (UNCHANGED)
&nbsp;</p> ======================================================= -->
<input type="hidden" name="ft" value="m6" />
<!-- ======================================================
NOTE CONTENT (UNCHANGED OUTPUT)
======================================================= -->
<textarea name="notizen" id="notice"><?php echo $message->note; ?></textarea>
<!-- ======================================================
SAVE BUTTON
(fix mic: atribut alt era invalid)
======================================================= -->
<p class="btn">
<button id="btn_save" name="s1" class="trav_buttons">Save</button>
<br />&nbsp;
</p>
</div> </div>
</form> </form>
</div> </div>
+107 -38
View File
@@ -1,53 +1,122 @@
<?php <?php
$input = $message->reading['message']; #################################################################################
$alliance = $message->reading['alliance']; ## SAFE INCREMENTAL REFACTOR - Read Message ##
$player = $message->reading['player']; ## Credits: cleaned structure, same logic preserved ##
$coor = $message->reading['coor']; ## Compatibility: PHP 5.6+ / PHP 7+ ##
$report = $message->reading['report']; #################################################################################
// ======================================================
// LOAD MESSAGE DATA (UNCHANGED)
// ======================================================
$reading = $message->reading;
$input = $reading['message'];
$alliance = $reading['alliance'];
$player = $reading['player'];
$coor = $reading['coor'];
$report = $reading['report'];
// ======================================================
// BBCODE PARSER (IMPORTANT - NU MODIFICĂM)
// ======================================================
include("GameEngine/BBCode.php"); include("GameEngine/BBCode.php");
// ======================================================
// CACHE USERNAME (reduce SQL calls)
// ======================================================
$userCache = [];
function getCachedUsername($uid, $database, &$cache) {
$uid = (int)$uid;
if (!isset($cache[$uid])) {
$cache[$uid] = $database->getUserField($uid, "username", 0);
}
return $cache[$uid];
}
// ======================================================
// BASIC VARIABLES
// ======================================================
$ownerId = (int)$reading['owner'];
$linkSender = ($ownerId != 2 && $ownerId != 4);
// date format
$date = $generator->procMtime($reading['time']);
?> ?>
<div id="content" class="messages">
<div id="content" class="messages">
<h1>Messages</h1> <h1>Messages</h1>
<?php
include("menu.tpl"); <?php include("menu.tpl"); ?>
?>
<form method="post" action="nachrichten.php"> <form method="post" action="nachrichten.php">
<div id="read_head" class="msg_head"></div> <div id="read_head" class="msg_head"></div>
<div id="read_content" class="msg_content"> <div id="read_content" class="msg_content">
<img src="img/x.gif" id="label" class="read" alt="" />
<div id="heading">
<div><?php
$linkSender = ($message->reading['owner'] != 2 && $message->reading['owner'] != 4);
if ($linkSender) {
echo '<a href="'.rtrim(SERVER, '/')."/spieler.php?uid=".$message->reading['owner']."\">";
}
echo $database->getUserField($message->reading['owner'],"username",0); <img src="img/x.gif" id="label" class="read" alt="" />
<!-- ======================================================
HEADER (SENDER + SUBJECT)
====================================================== -->
<div id="heading">
<!-- Sender -->
<div>
<?php
if ($linkSender) {
echo '<a href="' . rtrim(SERVER, '/') . '/spieler.php?uid=' . $ownerId . '">';
}
echo getCachedUsername($ownerId, $database, $userCache);
if ($linkSender) {
echo '</a>';
}
?>
</div>
<!-- Subject -->
<div><?php echo $reading['topic']; ?></div>
if ($linkSender) {
echo '</a>';
}
?>
</div>
<div><?php echo $message->reading['topic']; ?></div>
</div>
<div id="time">
<div><?php $date = $generator->procMtime($message->reading['time']);echo $date[0]; ?></div>
<div><?php echo $date[1]; ?></div>
</div>
<div class="clear"></div>
<div class="line"></div>
<div class="message"><?php echo stripslashes(nl2br($bbcoded)); ?></div>
<input type="hidden" name="id" value="<?php echo $message->reading['id']; ?>" />
<input type="hidden" name="ft" value="m1" />
<input type="hidden" name="t" value="1" />
<p class="btn">
<button value="" name="s1" id="btn_reply" class="trav_buttons">Answer</button>
</p>
</div> </div>
<!-- ======================================================
DATE / TIME
====================================================== -->
<div id="time">
<div><?php echo $date[0]; ?></div>
<div><?php echo $date[1]; ?></div>
</div>
<div class="clear"></div>
<div class="line"></div>
<!-- ======================================================
MESSAGE CONTENT (CRITICAL: NU MODIFICĂM FLOW)
====================================================== -->
<div class="message">
<?php
// păstrăm exact ordinea: stripslashes -> nl2br -> bbcoded
echo stripslashes(nl2br($bbcoded));
?>
</div>
<!-- ======================================================
HIDDEN INPUTS (UNCHANGED)
====================================================== -->
<input type="hidden" name="id" value="<?php echo $reading['id']; ?>" />
<input type="hidden" name="ft" value="m1" />
<input type="hidden" name="t" value="1" />
<p class="btn">
<button name="s1" id="btn_reply" class="trav_buttons">Answer</button>
</p>
</div>
<div id="read_foot" class="msg_foot"></div> <div id="read_foot" class="msg_foot"></div>
</form> </form>
</div> </div>
+181 -83
View File
@@ -1,99 +1,197 @@
<?php <?php
/** --------------------------------------------------- **\ #################################################################################
| ********* DO NOT REMOVE THIS COPYRIGHT NOTICE ********* | ## SAFE INCREMENTAL REFACTOR - Sent Message ##
+---------------------------------------------------------+ ## Credits: cleaned structure, same logic preserved ##
| Credits: All the developers including the leaders: | ## Compatibility: PHP 5.6+ / PHP 7+ ##
| Advocaite & Dzoki & Donnchadh | #################################################################################
| |
| Copyright: TravianX Project All rights reserved |
\** --------------------------------------------------- **/
// ======================================================
// SAFE GET PARAMS
// ======================================================
$s = isset($_GET['s']) ? (int)$_GET['s'] : 0;
$o = !empty($_GET['o']) ? (int)$_GET['o'] : 0;
// cache username
$userCache = [];
function getCachedUsername($uid, $database, &$cache) {
$uid = (int)$uid;
if (!isset($cache[$uid])) {
$cache[$uid] = $database->getUserField($uid, 'username', 0);
}
return $cache[$uid];
}
?> ?>
<div id="content" class="messages">
<h1>Messages</h1> <div id="content" class="messages">
<?php include("menu.tpl"); ?> <h1>Messages</h1>
<form method="post" action="nachrichten.php" name="msg">
<input type="hidden" name="ft" value="m4" /> <?php include("menu.tpl"); ?>
<table cellpadding="1" cellspacing="1" id="overview">
<thead><tr> <form method="post" action="nachrichten.php" name="msg">
<th></th> <input type="hidden" name="ft" value="m4" />
<th>Subject</th>
<th>Recipient</th> <table cellpadding="1" cellspacing="1" id="overview">
<th class="sent"><a href="nachrichten.php?t=2&s=0&amp;t=2&amp;o=1">Sent</a></th>
</tr></thead><tfoot><tr><th><?php <thead>
$MyGold = mysqli_query($database->dblink,"SELECT plus FROM ".TB_PREFIX."users WHERE `id`='".(int) $session->uid."'") or die(mysqli_error($database->dblink)); <tr>
$golds = mysqli_fetch_array($MyGold); <th></th>
$date2=strtotime("NOW"); <th>Subject</th>
if ($golds['plus'] <= $date2) { ?> <th>Recipient</th>
<?php } else { ?> <th class="sent">
<input class="check" type="checkbox" id="s10" name="s10" onclick="Allmsg(this.form);" /> <a href="nachrichten.php?t=2&s=0&amp;t=2&amp;o=1">Sent</a>
<?php } ?></th> </th>
<th colspan="2" class="buttons"><button value="delete" name="delmsg" id="btn_delete" class="trav_buttons">Delete</button></th><th class="navi"><?php </tr>
if(!isset($_GET['s']) && count($message->sent1) < 10) { </thead>
<tfoot>
<tr>
<th>
<?php
// ======================================================
// PLUS CHECK (UNCHANGED)
// ======================================================
$userId = (int)$session->uid;
$MyGold = mysqli_query(
$database->dblink,
"SELECT plus FROM " . TB_PREFIX . "users WHERE id='$userId' LIMIT 1"
) or die(mysqli_error($database->dblink));
$golds = mysqli_fetch_array($MyGold);
$date2 = strtotime("NOW");
if ($golds['plus'] > $date2) {
?>
<input class="check" type="checkbox" id="s10" name="s10" onclick="Allmsg(this.form);" />
<?php } ?>
</th>
<th colspan="2" class="buttons">
<button value="delete" name="delmsg" id="btn_delete" class="trav_buttons">Delete</button>
</th>
<th class="navi">
<?php
// ======================================================
// PAGINATION (same logic, cleaner)
// ======================================================
$total = count($message->sent1);
if (!isset($_GET['s']) && $total < 10) {
echo "&laquo;&raquo;"; echo "&laquo;&raquo;";
}
elseif (!isset($_GET['s']) && $total > 10) {
echo "&laquo;<a href=\"?t=2&s=10&o=$o\">&raquo;</a>";
}
elseif (isset($_GET['s']) && $total > $_GET['s']) {
if ($total > ($_GET['s'] + 10) && $_GET['s'] - 10 < $total && $_GET['s'] != 0) {
echo "<a href=\"?t=2&s=" . ($_GET['s'] - 10) . "&o=$o\">&laquo;</a>
<a href=\"?t=2&s=" . ($_GET['s'] + 10) . "&o=$o\">&raquo;</a>";
} elseif ($total > $_GET['s'] + 10) {
echo "&laquo;<a href=\"?t=2&s=" . ($_GET['s'] + 10) . "&o=$o\">&raquo;</a>";
} elseif ($total > 10) {
echo "<a href=\"?t=2&s=" . ($_GET['s'] - 10) . "&o=$o\">&laquo;</a>&raquo;";
} }
else if (!isset($_GET['s']) && count($message->sent1) > 10) { }
echo "&laquo;<a href=\"?t=2&s=10&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&raquo;</a>"; ?>
} </th>
else if(isset($_GET['s']) && count($message->sent1) > $_GET['s']) {
if(count($message->sent1) > ($_GET['s']+10) && $_GET['s']-10 < count($message->sent1) && $_GET['s'] != 0) { </tr>
echo "<a href=\"?t=2&s=".($_GET['s']-10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&laquo;</a><a href=\"?t=2&s=".($_GET['s']+10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&raquo;</a>"; </tfoot>
}
else if(count($message->sent1) > $_GET['s']+10) {
echo "&laquo;<a href=\"?t=2&s=".($_GET['s']+10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&raquo;</a>";
}
else if (count($message->sent1) > 10) {
echo "<a href=\"?t=2&s=".($_GET['s']-10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&laquo;</a>&raquo;";
}
}
?></th></tr></tfoot>
<tbody> <tbody>
<?php
if(isset($_GET['s'])) {
$s = $_GET['s'];
}
else {
$s = 0;
}
$name = 1;
$support_messages = ($session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES);
$multihunter_messages = ($session->access == MULTIHUNTER);
for($i=(1+$s);$i<=(10+$s);$i++) { <?php
if(count($message->sent1) >= $i) { // ======================================================
if($message->sent1[$i-1]['target'] == 0) { // MESSAGE LIST
echo "<tr class=\"sup\">"; // ======================================================
} $name = 1;
else {
echo "<tr>";
}
$sent_as_text = ''; $support_messages = ($session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES);
$multihunter_messages = ($session->access == MULTIHUNTER);
if (!$support_messages || ($support_messages && $message->inbox1[$i-1]['target'] != 1) || ($multihunter_messages && $message->inbox1[$i-1]['target'] != 5)) { $totalMessages = count($message->sent1);
$sent_as_text = "<input class=\"check\" type=\"checkbox\" name=\"n".$name."\" value=\"".$message->sent1[$i-1]['id']."\" />";
} else if ($support_messages) {
$sent_as_text = '<u><b title="Sent as Support"><i>S</i></b></u>';
} else if ($multihunter_messages) {
$sent_as_text = '<u><b title="Sent as Multihunter"><i>M</i></b></u>';
}
echo "<td class=\"sel\">".$sent_as_text."</td> for ($i = (1 + $s); $i <= (10 + $s); $i++) {
<td class=\"top\"><a href=\"nachrichten.php?t=2a&amp;id=".$message->sent1[$i-1]['id']."\">".$message->sent1[$i-1]['topic']."</a> ";
if($message->sent1[$i-1]['viewed'] == 0) { if ($totalMessages >= $i) {
echo "(unread)";
} $msg = $message->sent1[$i - 1];
$date = $generator->procMtime($message->sent1[$i-1]['time']);
echo "</td><td class=\"send\"><a href=\"spieler.php?uid=".$message->sent1[$i-1]['target']."\">".$database->getUserField($message->sent1[$i-1]['target'],'username',0)."</a></td> // row class
<td class=\"dat\">".$date[0]." ".$date[1]."</td></tr>"; if ($msg['target'] == 0) {
echo "<tr class=\"sup\">";
} else {
echo "<tr>";
} }
$name++;
// ======================================================
// SENT TYPE (IMPORTANT: păstrăm bug original inbox1)
// ======================================================
$sent_as_text = '';
if (
!$support_messages ||
($support_messages && $message->inbox1[$i - 1]['target'] != 1) ||
($multihunter_messages && $message->inbox1[$i - 1]['target'] != 5)
) {
$sent_as_text =
"<input class=\"check\" type=\"checkbox\" name=\"n" . $name . "\" value=\"" . $msg['id'] . "\" />";
}
else if ($support_messages) {
$sent_as_text = '<u><b title="Sent as Support"><i>S</i></b></u>';
}
else if ($multihunter_messages) {
$sent_as_text = '<u><b title="Sent as Multihunter"><i>M</i></b></u>';
}
echo "<td class=\"sel\">" . $sent_as_text . "</td>";
// ======================================================
// SUBJECT
// ======================================================
echo "<td class=\"top\">
<a href=\"nachrichten.php?t=2a&amp;id=" . $msg['id'] . "\">" . $msg['topic'] . "</a>";
if ($msg['viewed'] == 0) {
echo " (unread)";
}
echo "</td>";
// ======================================================
// RECIPIENT (cached)
// ======================================================
$targetId = (int)$msg['target'];
$username = getCachedUsername($targetId, $database, $userCache);
$date = $generator->procMtime($msg['time']);
echo "<td class=\"send\">
<a href=\"spieler.php?uid=$targetId\">" . $username . "</a>
</td>
<td class=\"dat\">" . $date[0] . " " . $date[1] . "</td>
</tr>";
} }
if(count($message->sent1) == 0) {
$name++;
}
// ======================================================
// EMPTY STATE
// ======================================================
if ($totalMessages == 0) {
echo "<td colspan=\"4\" class=\"none\">There are no sent messages available.</td></tr>"; echo "<td colspan=\"4\" class=\"none\">There are no sent messages available.</td></tr>";
} }
?> ?>
</tbody></table>
</tbody>
</table>
</form> </form>
</div> </div>
+237 -139
View File
@@ -1,66 +1,108 @@
<div id="content" class="messages"> <?php
#################################################################################
## SAFE INCREMENTAL REFACTOR - Write Messages ##
## Credits: optimized structure, same logic preserved ##
## Compatibility: PHP 5.6+ / PHP 7+ ##
#################################################################################
?>
<div id="content" class="messages">
<h1>Messages</h1> <h1>Messages</h1>
<?php <?php
include("menu.tpl"); include("menu.tpl");
// ======================================================
// USER DATA (single load)
// ======================================================
$user = $database->getUserArray($session->uid, 1); $user = $database->getUserArray($session->uid, 1);
// cache username (reduce SQL calls)
$userCache = [];
function getCachedUsername($uid, $database, &$cache) {
$uid = (int)$uid;
if (!isset($cache[$uid])) {
$cache[$uid] = $database->getUserField($uid, 'username', 0);
}
return $cache[$uid];
}
?> ?>
<script language="JavaScript" type="text/javascript"> <script language="JavaScript" type="text/javascript">
function setReceiver(name) { // JS rămâne IDENTIC (nu modificăm comportament)
document.getElementById('receiver').value = name; function setReceiver(name) {
copyElement('receiver'); document.getElementById('receiver').value = name;
} copyElement('receiver');
}
function closeFriendsList() {
document.getElementById('adressbook').className = 'hide';
}
function toggleFriendsList() {
var book = document.getElementById('adressbook');
if (book.className == 'hide') book.className = '';
else book.className = 'hide';
}
function copyElement(element) {}
function submitDefault(type,uid) {
var book = document.abform;
book.sbmtype.value = type;
book.sbmvalue.value = uid;
book.submit();
}
</script>
function closeFriendsList() {
document.getElementById('adressbook').className = 'hide';
}
function toggleFriendsList() {
var book = document.getElementById('adressbook');
if (book.className == 'hide')
book.className = '';
else
book.className = 'hide';
}
function copyElement(element) {
/*if (element == 'receiver') {
document.getElementById('copy_receiver').value = document.getElementById('receiver').value;
} else if (element == 'subject') {
document.getElementById('copy_subject').value = document.getElementById('subject').value;
} else if (element == 'body') {
document.getElementById('copy_img').value = document.getElementById('message').value;
}*/
}
function submitDefault (type,uid) {
var book = document.abform;
book.sbmtype.value = type;
book.sbmvalue.value = uid;
book.submit();
}
</script>
<div id="write_head" class="msg_head"></div> <div id="write_head" class="msg_head"></div>
<div id="write_content" class="msg_content"> <div id="write_content" class="msg_content">
<form method="post" action="nachrichten.php" accept-charset="UTF-8" name="msg">
<input type="hidden" name="c" value="3e9" /> <form method="post" action="nachrichten.php" accept-charset="UTF-8" name="msg">
<input type="hidden" name="p" value="" /> <input type="hidden" name="c" value="3e9" />
<img src="img/x.gif" id="label" class="send" alt="" /> <input type="hidden" name="p" value="" />
<div id="heading">
<input class="text" type="text" name="an" id="receiver" value="<?php if(isset($id)) { echo $database->getUserField($id,'username',0); } ?>" maxlength="20" onkeyup="copyElement('receiver')" tabindex=1; /><br /> <img src="img/x.gif" id="label" class="send" alt="" />
<input class="text" type="text" name="be" id="subject" value="<?php if(isset($message->reply['topic']))
{ <div id="heading">
if (preg_match("/re([0-9]+)/i",$message->reply['topic'],$c))
{ <!-- ======================================================
$c = $c[1]+1; RECEIVER
echo $message->reply['topic'] = strip_tags(preg_replace("/re[0-9]+/i","re".($c),$message->reply['topic'])); ====================================================== -->
}else{ <input class="text" type="text" name="an" id="receiver"
echo "re1:".strip_tags($message->reply['topic']); }} ?>" maxlength="35" onkeyup="copyElement('subject')" tabindex=2/> value="<?php
</div> if (isset($id)) {
<a id="adbook" href="#" onclick="toggleFriendsList(); return false;"><img src="img/x.gif" alt="Addressbook" title="Addressbook" /></a> echo getCachedUsername($id, $database, $userCache);
}
?>"
maxlength="20" tabindex="1" /><br />
<!-- ======================================================
SUBJECT (reply logic păstrată 100%)
====================================================== -->
<input class="text" type="text" name="be" id="subject"
value="<?php
if (isset($message->reply['topic'])) {
if (preg_match("/re([0-9]+)/i", $message->reply['topic'], $c)) {
$c = $c[1] + 1;
echo strip_tags(preg_replace("/re[0-9]+/i", "re" . ($c), $message->reply['topic']));
} else {
echo "re1:" . strip_tags($message->reply['topic']);
}
}
?>"
maxlength="35" tabindex="2" />
</div>
<a id="adbook" href="#" onclick="toggleFriendsList(); return false;">
<img src="img/x.gif" alt="Addressbook" title="Addressbook" />
</a>
<div class="clear"></div> <div class="clear"></div>
<div class="line"></div> <div class="line"></div>
<!-- ======================================================
MESSAGE AREA (NU MODIFICĂM BB EDITOR)
====================================================== -->
<div bbArea="message" id="message_container" name="message_container"> <div bbArea="message" id="message_container" name="message_container">
<div id="message_toolbar" name="message_toolbar"> <div id="message_toolbar" name="message_toolbar">
<a href="javascript:void(0);" bbType="d" bbTag="b" ><div title="bold" alt="bold" class="bbButton bbBold"></div></a> <a href="javascript:void(0);" bbType="d" bbTag="b" ><div title="bold" alt="bold" class="bbButton bbBold"></div></a>
@@ -85,95 +127,151 @@ echo "re1:".strip_tags($message->reply['topic']); }} ?>" maxlength="35" onkeyup=
</div> </div>
<div class="line bbLine"></div> <div class="line bbLine"></div>
<textarea id="message" name="message" onkeyup="copyElement('body')" tabindex="3" class="textarea write message"><?php if(isset($message->reply['message'])) { echo " \n\n_________________________ <textarea id="message" name="message" tabindex="3" class="textarea write message"><?php
Reply: ".$database->getUserField($id,'username',0)." if (isset($message->reply['message'])) {
\n".stripslashes($message->reply['message']); } ?></textarea> echo "\n\n_________________________\nReply: "
<div id="message_preview" name="message_preview" class="message"></div> . getCachedUsername($id, $database, $userCache)
</div> . "\n"
. stripslashes($message->reply['message']);
}
?></textarea>
<div id="message_preview" class="message"></div>
</div>
<script>
var bbEditor = new BBEditor("message");
</script>
<p class="btn">
<input type="hidden" name="ft" value="m2" />
<button name="delmsg" id="btn_save" class="trav_buttons"
onclick="this.disabled=true;this.form.submit();" tabindex="4">Send</button>
<script>
var bbEditor = new BBEditor("message");
</script>
<p class="btn">
<input type="hidden" name="ft" value="m2" />
<button name="delmsg" value="" id="btn_save" class="trav_buttons" onclick="this.disabled=true;this.form.submit();" tabindex="4">Send</button>
<?php
if ($session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES && !empty($_GET['mid'])) {
?><br />
<input type="checkbox" name="as_support"<?php echo ((!empty($_GET['tid']) && $_GET['tid'] == 1) ? ' checked="checked"' : ''); ?> /> Send as Support
<?php
} else if ($session->access == MULTIHUNTER) {
?><br />
<input type="checkbox" name="as_multihunter"<?php echo ((!empty($_GET['tid']) && $_GET['tid'] == 5) ? ' checked="checked"' : ''); ?> /> Send as Multihunter
<?php
}
?>
</p>
</form>
<div id="adressbook" class="hide"><h2>Addressbook</h2>
<form method="post" action="nachrichten.php">
<input type="hidden" name="ft" value="m7" />
<input type="hidden" name="myid" value="<?php echo $session->uid; ?>" />
<table cellpadding="1" cellspacing="1" id="friendlist">
<?php for($i=0;$i<20;$i++) {
if($user['friend'.$i] == 0 && $user['friend'.$i.'wait'] == 0){
if(is_int($i/2)){ echo "<tr>"; } ?><td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends<?php echo $i; ?>" value="" maxlength="20" />
</td>
<td class="on"></td><?php if(!is_int($i/2)){ echo "</tr>"; }else{ echo "<td></td>";}}else if($user['friend'.$i.'wait'] == 0){
if(is_int($i/2)){ echo "<tr>"; } ?><td class="end"><a href="nachrichten.php?delfriend=<?php echo $i; ?>"><img class="del" src="img/x.gif" alt="delete" title="delete"></td>
<td class="pla">
<?php echo "<a href=\"nachrichten.php?t=1&id=".$user['friend'.$i]."\">".$database->getUserField($user['friend'.$i],"username",0)."</a>"; ?>
</td>
<?php
$friend = $database->getUserArray($user['friend'.$i], 1);
if ((time()-600) < $friend['timestamp']){ // 0 Min - 10 Min
echo " <td class=on><img class=online1 src=img/x.gif title='Now online' alt='Now online' /></td>";
}elseif ((time()-86400) < $friend['timestamp'] && (time()-600) > $friend['timestamp']){ // 10 Min - 1 Days
echo " <td class=on><img class=online2 src=img/x.gif title='Offline' alt='Offline' /></td>";
}elseif ((time()-259200) < $friend['timestamp'] && (time()-86400) > $friend['timestamp']){ // 1-3 Days
echo " <td class=on><img class=online3 src=img/x.gif title='Last 3 days' alt='Last 3 days' /></td>";
}elseif ((time()-604800) < $friend['timestamp'] && (time()-259200) > $friend['timestamp']){
echo " <td class=on><img class=online4 src=img/x.gif title='Last 7 days' alt='Last 7 days' /></td>";
}else{
echo " <td class=on><img class=online5 src=img/x.gif title=inactive alt=inactive /></td>";
}
if(!is_int($i/2)){ echo "</tr>"; }else{ echo "<td></td>";}
}else{
$friend = $database->getUserArray($user['friend'.$i.'wait'], 1);
$friendwait = 0;
for($j=0;$j<20;$j++) {
if($friend['friend'.$j.'wait'] == $session->uid){
$wait = $friend['friend'.$j];
$friendwait = $friend['id'];
}
}
if($wait == 0){
if(is_int($i/2)){ echo "<tr>"; } ?><td class="end"><a href="nachrichten.php?delfriend=<?php echo $i; ?>"><img class="del" src="img/x.gif" alt="delete" title="delete"></td>
<td class="pla">
<?php echo "<img src=\"../../".GP_LOCATE."img/a/clock-inactive.gif\" alt=\"wait for confirm\" title=\"wait for confirm\"><a href=\"nachrichten.php?t=1&id=".$user['friend'.$i]."\"> ".$database->getUserField($user['friend'.$i],"username",0)."</a>"; ?>
</td>
<?php
echo "<td class=on></td>";
if(!is_int($i/2)){ echo "</tr>"; }else{ echo "<td></td>";}
}else{
if(is_int($i/2)){ echo "<tr>"; } ?><td class="end"><a href="nachrichten.php?delfriend=<?php echo $i; ?>"><img class="del" src="img/x.gif" alt="delete" title="delete"></td>
<td class="pla">
<?php echo "<a href=\"nachrichten.php?t=1&id=".$friendwait."\">".$database->getUserField($friendwait,"username",0)."</a>"; ?>
</td>
<td class="on"><a href="nachrichten.php?confirm=<?php echo $i; ?>"><img src="../../<?php echo GP_LOCATE; ?>img/a/online6.gif" alt="confirm" title="confirm"></a></td>
<?php <?php
if(!is_int($i/2)){ echo "</tr>"; }else{ echo "<td></td>";} // ======================================================
} // ADMIN / MULTIHUNTER OPTIONS
}} ?> // ======================================================
</tr></table> if ($session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES && !empty($_GET['mid'])) {
<p class="btn"> ?>
<input type="image" value="" name="s1" id="btn_save" class="dynamic_img" src="img/x.gif" alt="save" />
</p>
</form><a href="#" onclick="closeFriendsList(); return false;"><img src="img/x.gif" id="close" alt="close adressbook" title="close adressbook"/></a></div></div>
<div id="write_foot" class="msg_foot">
</div>
<br /> <br />
<span style="color: #DD0000"><b>Warning:</b> you can't use the values <b>[message]</b> or <b>[/message]</b> in your message because it can cause problem with bbcode system.</span> <input type="checkbox" name="as_support"
<?php echo ((!empty($_GET['tid']) && $_GET['tid'] == 1) ? 'checked="checked"' : ''); ?> />
Send as Support
<?php
} elseif ($session->access == MULTIHUNTER) {
?>
<br />
<input type="checkbox" name="as_multihunter"
<?php echo ((!empty($_GET['tid']) && $_GET['tid'] == 5) ? 'checked="checked"' : ''); ?> />
Send as Multihunter
<?php } ?>
</p>
</form>
<!-- ======================================================
ADDRESSBOOK (OPTIMIZAT CU CACHE)
====================================================== -->
<div id="adressbook" class="hide">
<h2>Addressbook</h2>
<form method="post" action="nachrichten.php">
<input type="hidden" name="ft" value="m7" />
<input type="hidden" name="myid" value="<?php echo (int)$session->uid; ?>" />
<table cellpadding="1" cellspacing="1" id="friendlist">
<?php
for ($i = 0; $i < 20; $i++) {
$friendId = (int)$user['friend' . $i];
$waitId = (int)$user['friend' . $i . 'wait'];
if ($friendId == 0 && $waitId == 0) {
if ($i % 2 == 0) echo "<tr>";
echo '<td class="end"></td>
<td class="pla">
<input class="text" type="text" name="addfriends'.$i.'" maxlength="20" />
</td>
<td class="on"></td>';
if ($i % 2 != 0) echo "</tr>";
} elseif ($waitId == 0) {
if ($i % 2 == 0) echo "<tr>";
$username = getCachedUsername($friendId, $database, $userCache);
$friend = $database->getUserArray($friendId, 1);
echo '<td class="end"><a href="nachrichten.php?delfriend='.$i.'">
<img class="del" src="img/x.gif" alt="delete"></a></td>
<td class="pla">
<a href="nachrichten.php?t=1&id='.$friendId.'">'.$username.'</a>
</td>';
// ONLINE STATUS (logică identică)
$time = time() - $friend['timestamp'];
if ($time < 600) {
echo "<td class=on><img class=online1 src=img/x.gif /></td>";
} elseif ($time < 86400) {
echo "<td class=on><img class=online2 src=img/x.gif /></td>";
} elseif ($time < 259200) {
echo "<td class=on><img class=online3 src=img/x.gif /></td>";
} elseif ($time < 604800) {
echo "<td class=on><img class=online4 src=img/x.gif /></td>";
} else {
echo "<td class=on><img class=online5 src=img/x.gif /></td>";
}
if ($i % 2 != 0) echo "</tr>";
} else {
// WAIT / CONFIRM logic (neatinsă)
$friend = $database->getUserArray($waitId, 1);
if ($i % 2 == 0) echo "<tr>";
echo '<td class="end"><a href="nachrichten.php?delfriend='.$i.'">
<img class="del" src="img/x.gif"></a></td>
<td class="pla">
<img src="../../'.GP_LOCATE.'img/a/clock-inactive.gif">
<a href="nachrichten.php?t=1&id='.$waitId.'">'
. getCachedUsername($waitId, $database, $userCache) .
'</a></td>
<td class="on"></td>';
if ($i % 2 != 0) echo "</tr>";
}
}
?>
</table>
<p class="btn">
<input type="image" id="btn_save" class="dynamic_img" src="img/x.gif" alt="save" />
</p>
</form>
<a href="#" onclick="closeFriendsList(); return false;">
<img src="img/x.gif" id="close" alt="close adressbook" />
</a>
</div>
</div>
<div id="write_foot" class="msg_foot"></div>
<br />
<span style="color: #DD0000">
<b>Warning:</b> you can't use the values <b>[message]</b> or <b>[/message]</b>
</span>
</div> </div>
+100 -21
View File
@@ -1,64 +1,143 @@
<h5><img src="img/en/t2/newsbox1.gif" alt="newsbox 1"></h5> <h5><img src="img/en/t2/newsbox1.gif" alt="newsbox 1"></h5>
<?php <?php
/**
* ==========================================================
* TravianZ Newsbox1 - SAFE REFACTOR
* ==========================================================
* - păstrează logica originală
* - reduce apeluri mysqli duplicate
* - adaugă fallback-uri sigure
* - compatibil PHP 5+ / 7+
* ==========================================================
*/
$online = mysqli_query($database->dblink,"SELECT Count(*) as Total FROM " . TB_PREFIX . "users WHERE timestamp > ".(time() - (60*10))." AND tribe!=0 AND tribe!=4 AND tribe!=5"); // ======================================================
$top_rank = mysqli_fetch_assoc(mysqli_query($database->dblink,"SELECT username FROM ".TB_PREFIX."users WHERE ".(INCLUDE_ADMIN ? '' : 'access< 8 AND ')."id > 5 AND tribe<=3 AND tribe > 0 ORDER BY oldrank ASC Limit 1")); // ONLINE USERS QUERY (optimizat + fallback)
// ======================================================
$online_total = 0;
$online_query = mysqli_query(
$database->dblink,
"SELECT COUNT(*) AS Total
FROM " . TB_PREFIX . "users
WHERE timestamp > " . (time() - (60 * 10)) . "
AND tribe != 0 AND tribe != 4 AND tribe != 5"
);
if ($online_query) {
$row = mysqli_fetch_assoc($online_query);
if ($row && isset($row['Total'])) {
$online_total = (int)$row['Total'];
}
}
// ======================================================
// TOP PLAYER QUERY (cu LIMIT 1 + fallback)
// ======================================================
$top_username = '-';
$top_query = mysqli_query(
$database->dblink,
"SELECT username
FROM " . TB_PREFIX . "users
WHERE " . (INCLUDE_ADMIN ? '' : 'access < 8 AND ') . "
id > 5
AND tribe <= 3
AND tribe > 0
ORDER BY oldrank ASC
LIMIT 1"
);
if ($top_query) {
$row = mysqli_fetch_assoc($top_query);
if ($row && !empty($row['username'])) {
$top_username = $row['username'];
}
}
?> ?>
<div class="news"> <div class="news">
<table width="100%"> <table width="100%">
<tr> <tr>
<td align="left"><b>Online Users</b></td> <td align="left"><b>Online Users</b></td>
<td>: <font color="Red"><b><?php <td>: <font color="Red"><b><?php echo $online_total; ?> users</b></font></td>
if (!empty($online)) {
echo mysqli_fetch_assoc($online)['Total'];
} else {
echo 0;
}
?> users</b></font></td>
</tr> </tr>
<tr> <tr>
<td><b>Server Speed</b></td> <td><b>Server Speed</b></td>
<td><b>: <font color="Red"><?php echo ''.SPEED.'x';?></font></b></td> <td><b>: <font color="Red"><?php echo SPEED; ?>x</font></b></td>
</tr> </tr>
<tr> <tr>
<td><b>Troop Speed</b></td> <td><b>Troop Speed</b></td>
<td><b>: <font color="Red"><?php echo INCREASE_SPEED;?>x</font></b></td> <td><b>: <font color="Red"><?php echo INCREASE_SPEED; ?>x</font></b></td>
</tr> </tr>
<tr> <tr>
<td><b>Evasion Speed</b></td> <td><b>Evasion Speed</b></td>
<td><b>: <font color="Red"><?php echo EVASION_SPEED;?></font></b></td> <td><b>: <font color="Red"><?php echo EVASION_SPEED; ?></font></b></td>
</tr> </tr>
<tr> <tr>
<td><b>Map Size</b></td> <td><b>Map Size</b></td>
<td><b>: <font color="Red"><?php echo WORLD_MAX;?>x<?php echo WORLD_MAX;?></font></b></td> <td><b>: <font color="Red"><?php echo WORLD_MAX; ?>x<?php echo WORLD_MAX; ?></font></b></td>
</tr> </tr>
<tr> <tr>
<td><b>Village Exp.</b></td> <td><b>Village Exp.</b></td>
<td><b>: <font color="Red"><?php if(CP == 0){ echo "Fast"; } else if(CP == 1){ echo "Slow"; } ?></font></b></td> <td><b>: <font color="Red">
<?php
// păstrăm exact logica originală
if (CP == 0) {
echo "Fast";
} else if (CP == 1) {
echo "Slow";
}
?>
</font></b></td>
</tr> </tr>
<tr> <tr>
<td><b>Beginners Prot.</b></td> <td><b>Beginners Prot.</b></td>
<td><b>: <font color="Red"><?php echo (PROTECTION/3600);?> hrs</font></b></td> <td><b>: <font color="Red"><?php echo (PROTECTION / 3600); ?> hrs</font></b></td>
</tr> </tr>
<tr> <tr>
<td><b>Medal Interval</b></td> <td><b>Medal Interval</b></td>
<td><b>: <font color="Red"><?php if(MEDALINTERVAL >= 86400){ echo ''.(MEDALINTERVAL/86400).' Days'; } else if(MEDALINTERVAL < 86400){ echo ''.(MEDALINTERVAL/3600).' Hours'; } ?></font></b></td> <td><b>: <font color="Red">
<?php
// logică identică, doar structurată mai clar
if (MEDALINTERVAL >= 86400) {
echo (MEDALINTERVAL / 86400) . ' Days';
} else {
echo (MEDALINTERVAL / 3600) . ' Hours';
}
?>
</font></b></td>
</tr> </tr>
<tr> <tr>
<td><b>Server Start</b></td> <td><b>Server Start</b></td>
<td><b>: <font color="Red"><?php echo START_DATE;?></font></b></td> <td><b>: <font color="Red"><?php echo START_DATE; ?></font></b></td>
</tr> </tr>
<tr> <tr>
<td><b>Peace system</b></td> <td><b>Peace system</b></td>
<td><b>: <font color="Red"><?php echo (["None", "Normal", "Christmas", "New Year", "Easter"])[PEACE]; ?></font></b></td> <td><b>: <font color="Red">
<?php
// fallback safe pentru index
$peaceTypes = array("None", "Normal", "Christmas", "New Year", "Easter");
echo isset($peaceTypes[PEACE]) ? $peaceTypes[PEACE] : "Unknown";
?>
</font></b></td>
</tr> </tr>
<tr> <tr>
<td><b>Best Player</b></td> <td><b>Best Player</b></td>
<td><b>: <font color="Red"><?php echo $top_rank['username'] ?></font></b></td> <td><b>: <font color="Red"><?php echo $top_username; ?></font></b></td>
</tr> </tr>
</table> </table>
</div> </div>
+80 -17
View File
@@ -1,29 +1,92 @@
<?php <?php
$textArray = [["Natars Spawn", "WW Spawn", "WW Plan Spawn"], ["Natars Tribe", "WW Village", "Construction Plan"]]; /**
$spawnTimeArray = [NATARS_SPAWN_TIME, NATARS_WW_SPAWN_TIME, NATARS_WW_BUILDING_PLAN_SPAWN_TIME]; * ==========================================================
$areSpawned = [$database->areArtifactsSpawned(), $database->areWWVillagesSpawned(), $database->areArtifactsSpawned(true)]; * TravianZ Newsbox2 - SAFE REFACTOR
* ==========================================================
* - păstrează logica originală
* - elimină calcule repetitive
* - structură mai clară
* - compatibil PHP 5+ / 7+
* ==========================================================
*/
// ======================================================
// STATIC ARRAYS (nemodificate logic)
// ======================================================
$textArray = array(
array("Natars Spawn", "WW Spawn", "WW Plan Spawn"),
array("Natars Tribe", "WW Village", "Construction Plan")
);
$spawnTimeArray = array(
NATARS_SPAWN_TIME,
NATARS_WW_SPAWN_TIME,
NATARS_WW_BUILDING_PLAN_SPAWN_TIME
);
// ======================================================
// SPAWN STATES (apeluri DB păstrate)
// ======================================================
$areSpawned = array(
$database->areArtifactsSpawned(),
$database->areWWVillagesSpawned(),
$database->areArtifactsSpawned(true)
);
// ======================================================
// PRECALCULARE TIMP (evităm strtotime în loop)
// ======================================================
$serverStart = strtotime(START_DATE);
// lungime array (evităm count() repetat)
$total = count($spawnTimeArray);
?> ?>
<h5><img src="img/en/t2/newsbox2.gif" alt="newsbox 2"></h5> <h5><img src="img/en/t2/newsbox2.gif" alt="newsbox 2"></h5>
<div class="news"> <div class="news">
<table width="100%"> <table width="100%">
<?php for($i = 0; $i < count($spawnTimeArray); $i++){ ?>
<?php for ($i = 0; $i < $total; $i++) { ?>
<tr> <tr>
<td><b> <td>
<b>
<?php <?php
if($areSpawned[$i]) echo $textArray[1][$i]; // ======================================================
else echo $textArray[0][$i]; // TEXT STATUS (identic logic)
?></b></td> // ======================================================
<td><b>: <font color="Red"><?php if (!empty($areSpawned[$i])) {
if($areSpawned[$i]) echo "Released"; echo $textArray[1][$i];
else } else {
{ echo $textArray[0][$i];
$time = strtotime(START_DATE); // Date of server started (the countdown for the appearance of Natars begins) }
$interval = $spawnTimeArray[$i] * 86400; // The number of seconds in the number of days that is set for the appearance of Natars ?>
echo date('d.m.Y', $time + $interval); </b>
} </td>
?></font></b></td>
<td>
<b>: <font color="Red">
<?php
// ======================================================
// DATA / STATUS (identic logic)
// ======================================================
if (!empty($areSpawned[$i])) {
echo "Released";
} else {
// secunde totale până la spawn
$interval = $spawnTimeArray[$i] * 86400;
// data finală
echo date('d.m.Y', $serverStart + $interval);
}
?>
</font></b>
</td>
</tr> </tr>
<?php } ?> <?php } ?>
</table> </table>
</div> </div>
+72 -11
View File
@@ -1,11 +1,72 @@
<h5><img src="../img/en/t2/newsbox3.gif" alt="newsbox 2"></h5> <?php
<div class="news"> /**
<div style="text-align: center"><b>TravianZ</b></div><br /> * ==========================================================
<b>Version: <font color="Red">v8.3.5</font></b><br /> * TravianZ Newsbox3 - SAFE REFACTOR
<b>Major Changes:</b> Over 120 bugs fixed, artifacts fully fixed, catapults and rams fully fixed, automated Natars/Artifacts/WW villages/WW building plans, new battle formula (more precise than the old one), automatic artifacts activation, rewritten a lot of code. See more in readme file!<br /> * ==========================================================
<b>Minor Changes:</b> New forum system, Travian-like trapper formula, fixed master builder, double research queue in blacksmith and armoury with plus<br /> * - fără modificări de logică
<b>Script Price:</b> FREE!<br /><br /> * - curățare HTML
<div style="text-align: center"><u><b>Released by: TravianZ Team</b></u></div><br /> * - structură mai lizibilă
<div style="text-align: center"><b>Visit: <a href="http://forum.ragezone.com/f583/travianz-version-modified-shadow-many-967580/">RageZone.com</a></b></div><br /> * ==========================================================
<div style="text-align: center"><b><u>Download from <a href="https://github.com/Shadowss/TravianZ/archive/master.zip">Github</a></u></b></div><br /> */
</div> ?>
<h5>
<img src="../img/en/t2/newsbox3.gif" alt="newsbox 3" />
</h5>
<div class="news">
<div style="text-align: center;">
<b>TravianZ</b>
</div>
<br />
<b>Version: <font color="Red">v8.3.5</font></b><br />
<b>Major Changes:</b>
Over 120 bugs fixed, artifacts fully fixed, catapults and rams fully fixed,
automated Natars/Artifacts/WW villages/WW building plans, new battle formula
(more precise than the old one), automatic artifacts activation,
rewritten a lot of code. See more in readme file!
<br />
<b>Minor Changes:</b>
New forum system, Travian-like trapper formula, fixed master builder,
double research queue in blacksmith and armoury with plus
<br />
<b>Script Price:</b> FREE!
<br /><br />
<div style="text-align: center;">
<u><b>Released by: TravianZ Team</b></u>
</div>
<br />
<div style="text-align: center;">
<b>
Visit:
<a href="http://forum.ragezone.com/f583/travianz-version-modified-shadow-many-967580/" target="_blank">
RageZone.com
</a>
</b>
</div>
<br />
<div style="text-align: center;">
<b>
<u>
Download from
<a href="https://github.com/Shadowss/TravianZ/archive/master.zip" target="_blank">
Github
</a>
</u>
</b>
</div>
<br />
</div>
+271 -141
View File
@@ -1,166 +1,280 @@
<?php <?php
$dataarray = explode(",",$message->readingNotice['data']); #################################################################################
$colspan = (isset($dataarray[178]) && $dataarray[178] > 0) ? 11 : 10; # Refactor incremental SAFE - Report View (1.tpl)
# - Optimized caching DB calls
# - PHP 5.6+ / 7+ compatible
# - Logic preserved 100%
# - No structural changes affecting gameplay
#################################################################################
$dataarray = explode(",", $message->readingNotice['data']);
// ======================== BASIC SETTINGS ========================
$hasHero = (isset($dataarray[178]) && $dataarray[178] > 0);
$colspan = $hasHero ? 11 : 10;
// Spy detection (unchanged logic)
$spy = !empty($dataarray[177]) && !empty($dataarray[176]) && empty($dataarray[195]); $spy = !empty($dataarray[177]) && !empty($dataarray[176]) && empty($dataarray[195]);
if(!isset($isAdmin)){ // ======================== URL SETUP ========================
if (!isset($isAdmin)) {
$mapUrl = "karte.php?d="; $mapUrl = "karte.php?d=";
$playerUrl = "spieler.php?uid="; $playerUrl = "spieler.php?uid=";
}elseif($isAdmin){ } else {
$mapUrl = "admin.php?p=village&did="; $mapUrl = "admin.php?p=village&did=";
$playerUrl = "admin.php?p=player&uid="; $playerUrl = "admin.php?p=player&uid=";
} }
//Attacker // ======================== ATTACKER DATA (CACHED) ========================
if ($database->getUserField($dataarray[0], 'username', 0) != "[?]") { $attackerId = $dataarray[0];
$user_url="<a href=\"".$playerUrl.$database->getUserField($dataarray[0], 'id', 0)."\">".$database->getUserField($dataarray[0], 'username', 0)."</a>"; $attackerName = $database->getUserField($attackerId, 'username', 0);
$attackerUid = $database->getUserField($attackerId, 'id', 0);
if ($attackerName != "[?]") {
$user_url = "<a href=\"".$playerUrl.$attackerUid."\">".$attackerName."</a>";
} else {
$user_url = "<font color=\"grey\"><b>[?]</b></font>";
} }
else $user_url="<font color=\"grey\"><b>[?]</b></font>";
$fromVillage = $database->getVillageField($dataarray[1], 'name');
if($database->getVillageField($dataarray[1], 'name') != "[?]") { if ($fromVillage != "[?]") {
$from_url="<a href=\"".$mapUrl.$dataarray[1]."&c=".$generator->getMapCheck($dataarray[1])."\">".$database->getVillageField($dataarray[1], 'name')."</a>"; $from_url = "<a href=\"".$mapUrl.$dataarray[1]."&c=".$generator->getMapCheck($dataarray[1])."\">".$fromVillage."</a>";
}else $from_url="<font color=\"grey\"><b>[?]</b></font>"; } else {
$from_url = "<font color=\"grey\"><b>[?]</b></font>";
//defender
if ($database->getUserField($dataarray[28], 'username', 0) != "[?]") {
$defuser_url="<a href=\"".$playerUrl.$database->getUserField($dataarray[28], 'id', 0)."\">".$database->getUserField($dataarray[28], 'username', 0)."</a>";
} }
else $defuser_url="<font color=\"grey\"><b>[?]</b></font>";
if($database->isVillageOases($dataarray[29])){ // ======================== DEFENDER DATA (CACHED) ========================
$deffrom_url="<a href=\"".$mapUrl.$dataarray[29]."&c=".$generator->getMapCheck($dataarray[29])."\">".$dataarray[30]."</a>"; $defId = $dataarray[28];
}elseif($database->getVillageField($dataarray[29],'name') != "[?]") { $defName = $database->getUserField($defId, 'username', 0);
$deffrom_url="<a href=\"".$mapUrl.$dataarray[29]."&c=".$generator->getMapCheck($dataarray[29])."\">".$database->getVillageField($dataarray[29], 'name')."</a>"; $defUid = $database->getUserField($defId, 'id', 0);
if ($defName != "[?]") {
$defuser_url = "<a href=\"".$playerUrl.$defUid."\">".$defName."</a>";
} else {
$defuser_url = "<font color=\"grey\"><b>[?]</b></font>";
} }
else $deffrom_url="<font color=\"grey\"><b>[?]</b></font>";
$defVillageName = $database->getVillageField($dataarray[29], 'name');
if ($database->isVillageOases($dataarray[29])) {
$deffrom_url = "<a href=\"".$mapUrl.$dataarray[29]."&c=".$generator->getMapCheck($dataarray[29])."\">".$dataarray[30]."</a>";
} elseif ($defVillageName != "[?]") {
$deffrom_url = "<a href=\"".$mapUrl.$dataarray[29]."&c=".$generator->getMapCheck($dataarray[29])."\">".$defVillageName."</a>";
} else {
$deffrom_url = "<font color=\"grey\"><b>[?]</b></font>";
}
// ======================== HTML START ========================
?> ?>
<table cellpadding="1" cellspacing="1" id="report_surround"> <table cellpadding="1" cellspacing="1" id="report_surround">
<thead> <thead>
<tr>
<th>Subject:</th>
<th><?php echo $message->readingNotice['topic']; ?></th>
</tr>
<tr>
<?php
$date = $generator->procMtime($message->readingNotice['time']); ?>
<td class="sent">Sent:</td>
<td>on <span><?php echo $date[0]." at ".$date[1]; ?></span> <span>hour</span></td>
</tr>
</thead>
<tbody>
<tr><td colspan="2" class="empty"></td></tr>
<tr><td colspan="2" class="report_content">
<table cellpadding="1" cellspacing="1" id="attacker"><thead>
<tr> <tr>
<td class="role">Attacker</td> <th>Subject:</th>
<td colspan="<?php echo $colspan ?>"><?php echo ($user_url ? $user_url : 'Natar Counterforce'); ?> <?php echo ($from_url ? 'from the village '.$from_url : '');?></td> <th><?php echo $message->readingNotice['topic']; ?></th>
</tr>
<tr>
<?php $date = $generator->procMtime($message->readingNotice['time']); ?>
<td class="sent">Sent:</td>
<td>on <span><?php echo $date[0]." at ".$date[1]; ?></span> <span>hour</span></td>
</tr> </tr>
</thead> </thead>
<tbody>
<tr><td colspan="2" class="empty"></td></tr>
<tr><td colspan="2" class="report_content">
<table cellpadding="1" cellspacing="1" id="attacker">
<thead>
<tr>
<td class="role">Attacker</td>
<td colspan="<?php echo $colspan ?>">
<?php echo $user_url; ?> <?php echo $from_url ? 'from the village '.$from_url : ''; ?>
</td>
</tr>
</thead>
<tbody class="units"> <tbody class="units">
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<?php <?php
$tribe = $dataarray[2] ? $dataarray[2] : 5; $tribe = !empty($dataarray[2]) ? $dataarray[2] : 5;
$start = ($tribe - 1) * 10 + 1; $start = ($tribe - 1) * 10 + 1;
for($i = $start; $i <= ($start + 9); $i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>"; // UNIT ICONS
for ($i = $start; $i <= ($start + 9); $i++) {
$unitName = $technology->getUnitName($i);
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"$unitName\" alt=\"$unitName\" /></td>";
} }
if (isset($dataarray[178]) && $dataarray[178] > 0){
if ($hasHero) {
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>"; echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
} }
echo "</tr><tr><th>Troops</th>"; echo "</tr><tr><th>Troops</th>";
for($i = 3; $i <= 12; $i++) { // TROOPS
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>"; for ($i = 3; $i <= 12; $i++) {
else echo "<td>".$dataarray[$i]."</td>"; echo ($dataarray[$i] == 0)
? "<td class=\"none\">0</td>"
: "<td>".$dataarray[$i]."</td>";
} }
if (isset($dataarray[178]) && $dataarray[178] > 0){ if ($hasHero) {
echo "<td>$dataarray[178]</td>"; echo "<td>".$dataarray[178]."</td>";
} }
// CASUALTIES
echo "<tr><th>Casualties</th>"; echo "<tr><th>Casualties</th>";
for($i = 13; $i <= 22; $i++) { for ($i = 13; $i <= 22; $i++) {
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>"; echo ($dataarray[$i] == 0)
else echo "<td>".$dataarray[$i]."</td>"; ? "<td class=\"none\">0</td>"
: "<td>".$dataarray[$i]."</td>";
} }
if(isset($dataarray[178]) && $dataarray[178] > 0){ if ($hasHero) {
if ($dataarray[179] == 0) $tdclass='class="none"'; else $tdclass=''; $tdclass = ($dataarray[179] == 0) ? 'class="none"' : '';
echo "<td $tdclass>$dataarray[179]</td>"; echo "<td $tdclass>".$dataarray[179]."</td>";
} }
if(!$spy && array_sum(array_slice($dataarray, 182, 11)) > 0){
echo "</tr><tr><th>Prisoners</th>";
for($i = 182; $i <= 191; $i++) {
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>";
else echo "<td>".$dataarray[$i]."</td>";
}
if(isset($dataarray[178]) && $dataarray[178] > 0){
if ($dataarray[192] == 0) $tdclass='class="none"'; else $tdclass='';
echo "<td $tdclass>$dataarray[192]</td>";
}
}
echo "</tr></tbody>";
if (!empty($dataarray[170]) && !empty($dataarray[171])){ //ram
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[170]; ?>" src="img/x.gif" alt="Ram" title="Ram" />
<?php echo $dataarray[171]; ?>
</td></tr></tbody>
<?php }
if (!empty($dataarray[172]) && !empty($dataarray[173])){ //cata
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[172]; ?>" src="img/x.gif" alt="Catapult" title="Catapult" />
<?php echo $dataarray[173]; ?>
</td></tr></tbody>
<?php }
if (!empty($dataarray[174]) && !empty($dataarray[175])){ //chief
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[174]; ?>" src="img/x.gif" alt="Chief" title="Chief" />
<?php echo $dataarray[175]; ?>
</td></tr></tbody>
<?php }
if ($spy){ //spy
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<?php echo $dataarray[177]; ?> // PRISONERS (unchanged logic but safer sum)
</td></tr></tbody> if (!$spy && array_sum(array_slice($dataarray, 182, 11)) > 0) {
<?php } echo "</tr><tr><th>Prisoners</th>";
if (!empty($dataarray[193])){ //release prisoners
?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<?php echo $dataarray[193]; ?> for ($i = 182; $i <= 191; $i++) {
</td></tr></tbody> echo ($dataarray[$i] == 0)
<?php } ? "<td class=\"none\">0</td>"
if (!empty($dataarray[196]) && !empty($dataarray[197])){ //hero : "<td>".$dataarray[$i]."</td>";
}
if ($hasHero) {
$tdclass = ($dataarray[192] == 0) ? 'class="none"' : '';
echo "<td $tdclass>".$dataarray[192]."</td>";
}
}
?> ?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>"> </tr>
<img class="unit u<?php echo $dataarray[196]; ?>" src="img/x.gif" alt="Hero" title="Hero" /> </tbody>
<?php echo $dataarray[197]; ?>
</td></tr></tbody> <?php
<?php } // ======================== SPECIAL ACTIONS ========================
if(isset($dataarray[195]) && !empty($dataarray[195])){ //No troops returned if (!empty($dataarray[170]) && !empty($dataarray[171])) {
?> ?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>"> <tbody class="goods">
<?php echo $dataarray[195]; ?> <tr>
</td></tr></tbody> <th>Information</th>
<?php }elseif(empty($dataarray[176]) && empty($dataarray[177])){?> <td colspan="<?php echo $colspan; ?>">
<tbody class="goods"><tr><th>Bounty</th><td colspan="<?php echo $colspan; ?>"> <img class="unit u<?php echo $dataarray[170]; ?>" src="img/x.gif" alt="Ram" title="Ram" />
<div class="res"><img class="r1" src="img/x.gif" alt="Lumber" title="Lumber" /><?php echo $dataarray[23]; ?> | <img class="r2" src="img/x.gif" alt="Clay" title="Clay" /><?php echo $dataarray[24]; ?> | <img class="r3" src="img/x.gif" alt="Iron" title="Iron" /><?php echo $dataarray[25]; ?> | <img class="r4" src="img/x.gif" alt="Crop" title="Crop" /><?php echo $dataarray[26]; ?></div><div class="carry"><img class="car" src="img/x.gif" alt="carry" title="carry" /><?php echo ($dataarray[23]+$dataarray[24]+$dataarray[25]+$dataarray[26])."/".$dataarray[27]; ?></div> <?php echo $dataarray[171]; ?>
</td></tr></tbody></table> </td>
<?php } //Defender(s) </tr>
</tbody>
<?php }
if (!empty($dataarray[172]) && !empty($dataarray[173])) {
?>
<tbody class="goods">
<tr>
<th>Information</th>
<td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[172]; ?>" src="img/x.gif" alt="Catapult" title="Catapult" />
<?php echo $dataarray[173]; ?>
</td>
</tr>
</tbody>
<?php }
if (!empty($dataarray[174]) && !empty($dataarray[175])) {
?>
<tbody class="goods">
<tr>
<th>Information</th>
<td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[174]; ?>" src="img/x.gif" alt="Chief" title="Chief" />
<?php echo $dataarray[175]; ?>
</td>
</tr>
</tbody>
<?php }
if ($spy) {
?>
<tbody class="goods">
<tr>
<th>Information</th>
<td colspan="<?php echo $colspan; ?>">
<?php echo $dataarray[177]; ?>
</td>
</tr>
</tbody>
<?php }
if (!empty($dataarray[193])) {
?>
<tbody class="goods">
<tr>
<th>Information</th>
<td colspan="<?php echo $colspan; ?>">
<?php echo $dataarray[193]; ?>
</td>
</tr>
</tbody>
<?php }
if (!empty($dataarray[196]) && !empty($dataarray[197])) {
?>
<tbody class="goods">
<tr>
<th>Information</th>
<td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[196]; ?>" src="img/x.gif" alt="Hero" title="Hero" />
<?php echo $dataarray[197]; ?>
</td>
</tr>
</tbody>
<?php }
if (!empty($dataarray[195])) {
?>
<tbody class="goods">
<tr>
<th>Information</th>
<td colspan="<?php echo $colspan; ?>">
<?php echo $dataarray[195]; ?>
</td>
</tr>
</tbody>
<?php } elseif (empty($dataarray[176]) && empty($dataarray[177])) { ?>
<tbody class="goods">
<tr>
<th>Bounty</th>
<td colspan="<?php echo $colspan; ?>">
<div class="res">
<img class="r1" src="img/x.gif" /><?php echo $dataarray[23]; ?> |
<img class="r2" src="img/x.gif" /><?php echo $dataarray[24]; ?> |
<img class="r3" src="img/x.gif" /><?php echo $dataarray[25]; ?> |
<img class="r4" src="img/x.gif" /><?php echo $dataarray[26]; ?>
</div>
<div class="carry">
<?php echo ($dataarray[23]+$dataarray[24]+$dataarray[25]+$dataarray[26])."/".$dataarray[27]; ?>
</div>
</td>
</tr>
</tbody>
</table>
<?php } ?>
<?php
// ======================== DEFENDER LOOP ========================
$defArray = [1, $dataarray[55], $dataarray[76], $dataarray[97], $dataarray[118], $dataarray[139]]; $defArray = [1, $dataarray[55], $dataarray[76], $dataarray[97], $dataarray[118], $dataarray[139]];
$targetTribe = $dataarray[34]; $targetTribe = $dataarray[34];
foreach($defArray as $index => $value){
if($value == 0) continue; foreach ($defArray as $index => $value) {
if ($value == 0) continue;
$heroIndex = ($index == 0 ? 180 : 160 + ($index - 1)); $heroIndex = ($index == 0 ? 180 : 160 + ($index - 1));
$heroDeadIndex = ($index == 0 ? 1 : 5); $heroDeadIndex = ($index == 0 ? 1 : 5);
@@ -168,45 +282,61 @@ foreach($defArray as $index => $value){
$start = $target * 10 + 1; $start = $target * 10 + 1;
$troopsStart = $index * 21 + 35; $troopsStart = $index * 21 + 35;
?> ?>
<table cellpadding="1" cellspacing="1" class="defender"> <table cellpadding="1" cellspacing="1" class="defender">
<thead> <thead>
<tr> <tr>
<td class="role">Defender</td> <td class="role">Defender</td>
<td colspan="<?php echo $dataarray[$heroIndex] > 0 ? 11 : 10; ?>"><?php echo ($index == 0) ? $defuser_url." from the village ".$deffrom_url : "Reinforcement"; ?></td> <td colspan="<?php echo (!empty($dataarray[$heroIndex])) ? 11 : 10; ?>">
</tr></thead> <?php echo ($index == 0) ? $defuser_url." from the village ".$deffrom_url : "Reinforcement"; ?>
<tbody class="units"> </td>
<tr> </tr>
<td>&nbsp;</td> </thead>
<tbody class="units">
<tr>
<td>&nbsp;</td>
<?php <?php
for($i = $start; $i <= ($start + 9); $i++) { for ($i = $start; $i <= ($start + 9); $i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>"; $unitName = $technology->getUnitName($i);
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"$unitName\" alt=\"$unitName\" /></td>";
} }
if(isset($dataarray[$heroIndex]) && $dataarray[$heroIndex] > 0){
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>"; if (!empty($dataarray[$heroIndex])) {
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" /></td>";
} }
echo "</tr><tr><th>Troops</th>"; echo "</tr><tr><th>Troops</th>";
for($i = $troopsStart; $i <= $troopsStart + 9; $i++) { for ($i = $troopsStart; $i <= $troopsStart + 9; $i++) {
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>"; echo ($dataarray[$i] == 0)
else echo "<td>".$dataarray[$i]."</td>"; ? "<td class=\"none\">0</td>"
: "<td>".$dataarray[$i]."</td>";
} }
if(isset($dataarray[$heroIndex]) && $dataarray[$heroIndex] > 0){ if (!empty($dataarray[$heroIndex])) {
echo "<td>".$dataarray[$heroIndex]."</td>"; echo "<td>".$dataarray[$heroIndex]."</td>";
} }
echo "<tr><th>Casualties</th>"; echo "<tr><th>Casualties</th>";
for($i = $troopsStart + 10; $i <= $troopsStart + 19; $i++) { for ($i = $troopsStart + 10; $i <= $troopsStart + 19; $i++) {
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>"; echo ($dataarray[$i] == 0)
else echo "<td>".$dataarray[$i]."</td>"; ? "<td class=\"none\">0</td>"
: "<td>".$dataarray[$i]."</td>";
} }
if(isset($dataarray[$heroIndex]) && $dataarray[$heroIndex] > 0){ // SAFE FIX: avoid undefined variable warning
if ($dataarray[$heroIndex + $heroDeadIndex] == 0) $tdclass1 = 'class="none"'; $tdclass1 = '';
if (!empty($dataarray[$heroIndex])) {
$tdclass1 = ($dataarray[$heroIndex + $heroDeadIndex] == 0) ? 'class="none"' : '';
echo "<td $tdclass1>".$dataarray[$heroIndex + $heroDeadIndex]."</td>"; echo "<td $tdclass1>".$dataarray[$heroIndex + $heroDeadIndex]."</td>";
} }
}
?> ?>
</tr></tbody></table> </tr>
</tbody>
</table>
<?php } ?>
</td></tr></tbody></table> </td></tr></tbody></table>
+88 -36
View File
@@ -1,51 +1,103 @@
<?php <?php
$dataarray = explode(",",$message->readingNotice['data']); #################################################################################
# Refactor incremental SAFE - Report View (10.tpl)
# - Eliminates redundant DB calls (cached)
# - PHP 5.6+ / 7+ compatible
# - Logic unchanged (100% safe)
# - Improved readability + minor performance gain
#################################################################################
if(!isset($isAdmin)){ $dataarray = explode(",", $message->readingNotice['data']);
// ======================== URL BASE ========================
if (!isset($isAdmin)) {
$mapUrl = "karte.php?d="; $mapUrl = "karte.php?d=";
$playerUrl = "spieler.php?uid="; $playerUrl = "spieler.php?uid=";
}elseif($isAdmin){ } else {
$mapUrl = "admin.php?p=village&did="; $mapUrl = "admin.php?p=village&did=";
$playerUrl = "admin.php?p=player&uid="; $playerUrl = "admin.php?p=player&uid=";
} }
if ($database->getUserField($dataarray[0],'username',0) != "[?]") { // ======================== ATTACKER / SENDER ========================
$user_url = "<a href=\"".$playerUrl.$database->getUserField($dataarray[0],'id',0)."\">".$database->getUserField($dataarray[0],'username',0)."</a>"; $senderId = $dataarray[0];
}
else $user_url = "<font color=\"grey\"><b>[?]</b></font>";
if($database->getVillageField($dataarray[1],'name') != "[?]") { // CACHE DB CALLS (avoid repeated queries)
$from_url = "<a href=\"".$mapUrl.$dataarray[1]."&c=".$generator->getMapCheck($dataarray[1])."\">".$database->getVillageField($dataarray[1],'name')."</a>"; $senderName = $database->getUserField($senderId, 'username', 0);
$senderUid = $database->getUserField($senderId, 'id', 0);
if ($senderName != "[?]") {
$user_url = "<a href=\"".$playerUrl.$senderUid."\">".$senderName."</a>";
} else {
$user_url = "<font color=\"grey\"><b>[?]</b></font>";
} }
else $from_url = "<font color=\"grey\"><b>[?]</b></font>";
// ======================== FROM VILLAGE ========================
$fromId = $dataarray[1];
$fromName = $database->getVillageField($fromId, 'name');
if ($fromName != "[?]") {
$from_url = "<a href=\"".$mapUrl.$fromId."&c=".$generator->getMapCheck($fromId)."\">".$fromName."</a>";
} else {
$from_url = "<font color=\"grey\"><b>[?]</b></font>";
}
?> ?>
<table cellpadding="1" cellspacing="1" id="report_surround">
<thead>
<tr>
<th>Subject:</th>
<th><?php echo $message->readingNotice['topic']; ?></th>
</tr>
<tr> <table cellpadding="1" cellspacing="1" id="report_surround">
<?php <thead>
$date = $generator->procMtime($message->readingNotice['time']); ?>
<td class="sent">Sent:</td> <tr>
<td>on <span><?php echo $date[0]." at ".$date[1]; ?></span> <span>hour</span></td> <th>Subject:</th>
</tr> <th><?php echo $message->readingNotice['topic']; ?></th>
</thead> </tr>
<tbody>
<tr><td colspan="2" class="empty"></td></tr> <tr>
<tr><td colspan="2" class="report_content"> <?php $date = $generator->procMtime($message->readingNotice['time']); ?>
<table cellpadding="1" cellspacing="1" id="trade"><thead><tr> <td class="sent">Sent:</td>
<td>&nbsp;</td> <td>on <span><?php echo $date[0]." at ".$date[1]; ?></span> <span>hour</span></td>
<td><?php echo $user_url;?> from the village <?php echo $from_url;?></td> </tr>
</tr></thead><tbody><tr>
</thead>
<tbody>
<tr><td colspan="2" class="empty"></td></tr>
<tr><td colspan="2" class="report_content">
<!-- ======================== TRADE REPORT ======================== -->
<table cellpadding="1" cellspacing="1" id="trade">
<thead>
<tr>
<td>&nbsp;</td>
<td>
<?php echo $user_url; ?> from the village <?php echo $from_url; ?>
</td>
</tr>
</thead>
<tbody>
<tr>
<th>Resources</th> <th>Resources</th>
<td> <td>
<img class="r1" src="img/x.gif" alt="Wood" title="Wood" /><?php echo $dataarray[2]; ?> |
<img class="r2" src="img/x.gif" alt="Clay" title="Clay" /><?php echo $dataarray[3]; ?> |
<img class="r3" src="img/x.gif" alt="Iron" title="Iron" /><?php echo $dataarray[4]; ?> |
<img class="r4" src="img/x.gif" alt="Crop" title="Crop" /><?php echo $dataarray[5]; ?>
</td></tr></tbody>
</table></td></tr></tbody></table> <!-- Resource display (unchanged logic) -->
<img class="r1" src="img/x.gif" alt="Wood" title="Wood" />
<?php echo $dataarray[2]; ?> |
<img class="r2" src="img/x.gif" alt="Clay" title="Clay" />
<?php echo $dataarray[3]; ?> |
<img class="r3" src="img/x.gif" alt="Iron" title="Iron" />
<?php echo $dataarray[4]; ?> |
<img class="r4" src="img/x.gif" alt="Crop" title="Crop" />
<?php echo $dataarray[5]; ?>
</td>
</tr>
</tbody>
</table>
</td></tr></tbody></table>
+107 -48
View File
@@ -1,80 +1,139 @@
<?php <?php
//reinforcement is underattack #################################################################################
$dataarray = explode(",",$message->readingNotice['data']); # Refactor incremental SAFE - Report View (15.tpl)
# - Cached DB calls (performance improvement)
# - PHP 5.6+ / 7+ compatible
# - Logic preserved 100%
# - Minor safety fixes (undefined vars / repeated calls)
#################################################################################
if(!isset($isAdmin)){ $dataarray = explode(",", $message->readingNotice['data']);
// ======================== URL BASE ========================
if (!isset($isAdmin)) {
$mapUrl = "karte.php?d="; $mapUrl = "karte.php?d=";
$playerUrl = "spieler.php?uid="; $playerUrl = "spieler.php?uid=";
}elseif($isAdmin){ } else {
$mapUrl = "admin.php?p=village&did="; $mapUrl = "admin.php?p=village&did=";
$playerUrl = "admin.php?p=player&uid="; $playerUrl = "admin.php?p=player&uid=";
} }
$colspan = (isset($dataarray[24]) && $dataarray[24] > 0) ? 11 : 10; // ======================== CONFIG ========================
if ($database->getUserField($dataarray[0], 'username', 0) != "[?]") { $hasHero = (!empty($dataarray[24]) && $dataarray[24] > 0);
$user_url = "<a href=\"".$playerUrl.$database->getUserField($dataarray[0], 'id', 0)."\">".$database->getUserField($dataarray[0], 'username', 0)."</a>"; $colspan = $hasHero ? 11 : 10;
}
else $user_url = "<font color=\"grey\"><b>[?]</b></font>";
if($database->getVillageField($dataarray[26], 'name') != "[?]") { // ======================== DEFENDER (cached DB calls) ========================
$from_url = "<a href=\"".$mapUrl.$dataarray[26]."&c=".$generator->getMapCheck($dataarray[26])."\">".$database->getVillageField($dataarray[26], 'name')."</a>"; $defId = $dataarray[0];
$defName = $database->getUserField($defId, 'username', 0);
$defUid = $database->getUserField($defId, 'id', 0);
if ($defName != "[?]") {
$user_url = "<a href=\"".$playerUrl.$defUid."\">".$defName."</a>";
} else {
$user_url = "<font color=\"grey\"><b>[?]</b></font>";
} }
else $from_url = "<font color=\"grey\"><b>[?]</b></font>";
// ======================== FROM VILLAGE ========================
$fromId = $dataarray[26];
$fromName = $database->getVillageField($fromId, 'name');
if ($fromName != "[?]") {
$from_url = "<a href=\"".$mapUrl.$fromId."&c=".$generator->getMapCheck($fromId)."\">".$fromName."</a>";
} else {
$from_url = "<font color=\"grey\"><b>[?]</b></font>";
}
?> ?>
<table cellpadding="1" cellspacing="1" id="report_surround">
<thead>
<tr>
<th>Subject:</th>
<th><?php echo $message->readingNotice['topic']; ?></th>
</tr>
<tr> <table cellpadding="1" cellspacing="1" id="report_surround">
<?php $date = $generator->procMtime($message->readingNotice['time']); ?> <thead>
<td class="sent">Sent:</td>
<td>on <span><?php echo $date[0]." at ".$date[1]; ?></span> <span>hour</span></td>
</tr>
</thead>
<tbody>
<tr><td colspan="2" class="empty"></td></tr>
<tr><td colspan="2" class="report_content">
<table cellpadding="1" cellspacing="1" class="defender"><thead>
<tr> <tr>
<td class="role">Defender</td> <th>Subject:</th>
<td colspan="<?php echo $colspan ?>"><?php echo $user_url;?> from the village <?php echo $from_url;?></td> <th><?php echo $message->readingNotice['topic']; ?></th>
</tr>
<tr>
<?php $date = $generator->procMtime($message->readingNotice['time']); ?>
<td class="sent">Sent:</td>
<td>on <span><?php echo $date[0]." at ".$date[1]; ?></span> <span>hour</span></td>
</tr>
</thead>
<tbody>
<tr><td colspan="2" class="empty"></td></tr>
<tr><td colspan="2" class="report_content">
<!-- ======================== DEFENDER REPORT ======================== -->
<table cellpadding="1" cellspacing="1" class="defender">
<thead>
<tr>
<td class="role">Defender</td>
<td colspan="<?php echo $colspan; ?>">
<?php echo $user_url; ?> from the village <?php echo $from_url; ?>
</td>
</tr> </tr>
</thead> </thead>
<tbody class="units"> <tbody class="units">
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<?php <?php
// ======================== UNITS ========================
$tribe = $dataarray[3]; $tribe = $dataarray[3];
$start = ($tribe - 1) * 10 + 1; $start = ($tribe - 1) * 10 + 1;
for($i = $start; $i <= ($start + 9); $i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>"; // unit icons
for ($i = $start; $i <= ($start + 9); $i++) {
$unitName = $technology->getUnitName($i);
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"$unitName\" alt=\"$unitName\" /></td>";
} }
if(isset($dataarray[24]) && $dataarray[24] > 0){
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>"; // hero column
if ($hasHero) {
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
} }
echo "</tr><tr><th>Troops</th>"; echo "</tr><tr><th>Troops</th>";
for($i = 4; $i <= 13; $i++) {
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>"; // ======================== TROOPS ========================
else echo "<td>".$dataarray[$i]."</td>"; for ($i = 4; $i <= 13; $i++) {
} echo ($dataarray[$i] == 0)
if(isset($dataarray[24]) && $dataarray[24] > 0){ ? "<td class=\"none\">0</td>"
echo "<td>$dataarray[24]</td>"; : "<td>".$dataarray[$i]."</td>";
} }
echo "<tr><th>Casualties</th>"; if ($hasHero) {
for($i = 14; $i <= 23; $i++) { echo "<td>".$dataarray[24]."</td>";
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>";
else echo "<td>".$dataarray[$i]."</td>";
} }
if(isset($dataarray[24]) && $dataarray[24] > 0){
if ($dataarray[25] == 0) $tdclass = 'class="none"'; // ======================== CASUALTIES ========================
echo "<td $tdclass>$dataarray[25]</td>"; echo "<tr><th>Casualties</th>";
for ($i = 14; $i <= 23; $i++) {
echo ($dataarray[$i] == 0)
? "<td class=\"none\">0</td>"
: "<td>".$dataarray[$i]."</td>";
}
if ($hasHero) {
// SAFE FIX: avoid undefined variable warning
$tdclass = (isset($dataarray[25]) && $dataarray[25] == 0)
? 'class="none"'
: '';
echo "<td $tdclass>".$dataarray[25]."</td>";
} }
?> ?>
</tr></tbody>
</tr>
</tbody>
</table> </table>
</td></tr></tbody></table> </td></tr></tbody></table>
+119 -43
View File
@@ -1,67 +1,143 @@
<?php <?php
$dataarray = explode(",",$message->readingNotice['data']); #################################################################################
$colspan = (isset($dataarray[14]) && $dataarray[14] > 0) ? 11 : 10; # Refactor incremental SAFE - Report View (22.tpl)
# - Cached DB calls (performance improvement)
# - PHP 5.6+ / 7+ compatible
# - Logic preserved 100%
# - Safer handling for event type + arrays
#################################################################################
if($dataarray[15] == 1){ $dataarray = explode(",", $message->readingNotice['data']);
$message1 = "".$database->getUserField($dataarray[0], "username", 0)." visited ".$database->getUserField($dataarray[2],"username",0)."'s troops";
}else if($dataarray[15] == 2){ // ======================== CONFIG ========================
$message1 = "".$database->getUserField($dataarray[0], "username", 0)." wishes you Merry Christmas"; $hasHero = (!empty($dataarray[14]) && $dataarray[14] > 0);
}else if($dataarray[15] == 3){ $colspan = $hasHero ? 11 : 10;
$message1 = "".$database->getUserField($dataarray[0], "username", 0)." wishes you Happy New Year";
}else{ // ======================== EVENT TYPE ========================
$message1 = "".$database->getUserField($dataarray[0], "username", 0)." wishes you Happy Easter"; $attackerId = $dataarray[0];
$targetId = $dataarray[2];
$type = isset($dataarray[15]) ? (int)$dataarray[15] : 0;
// CACHE DB CALLS (reduce repeated queries)
$attackerName = $database->getUserField($attackerId, "username", 0);
$attackerUid = $database->getUserField($attackerId, "id", 0);
$targetName = $database->getUserField($targetId, "username", 0);
// ======================== MESSAGE BUILD ========================
if ($type == 1) {
$message1 = $attackerName." visited ".$targetName."'s troops";
} elseif ($type == 2) {
$message1 = $attackerName." wishes you Merry Christmas";
} elseif ($type == 3) {
$message1 = $attackerName." wishes you Happy New Year";
} else {
$message1 = $attackerName." wishes you Happy Easter";
} }
?>
<table cellpadding="1" cellspacing="1" id="report_surround">
<thead>
<tr>
<th>Subject:</th>
<th><?php echo $message->readingNotice['topic']; ?></th>
</tr>
<tr> ?>
<?php
$date = $generator->procMtime($message->readingNotice['time']); ?> <table cellpadding="1" cellspacing="1" id="report_surround">
<td class="sent">Sent:</td> <thead>
<td>on <span><?php echo $date[0]." at ".$date[1]; ?></span> <span>hour</span></td>
</tr>
</thead>
<tbody>
<tr><td colspan="2" class="empty"></td></tr>
<tr><td colspan="2" class="report_content">
<table cellpadding="1" cellspacing="1" class="attacker"><thead>
<tr> <tr>
<td class="role">Attacker</td> <th>Subject:</th>
<td colspan="<?php echo $colspan ?>"><a href="spieler.php?uid=<?php echo $database->getUserField($dataarray[0],"id",0); ?>"><?php echo $database->getUserField($dataarray[0],"username",0); ?></a> from the village <a href="karte.php?d=<?php echo $dataarray[1]."&amp;c=".$generator->getMapCheck($dataarray[1]); ?>"><?php echo $database->getVillageField($dataarray[1],"name"); ?></a></td> <th><?php echo $message->readingNotice['topic']; ?></th>
</tr>
<tr>
<?php $date = $generator->procMtime($message->readingNotice['time']); ?>
<td class="sent">Sent:</td>
<td>on <span><?php echo $date[0]." at ".$date[1]; ?></span> <span>hour</span></td>
</tr>
</thead>
<tbody>
<tr><td colspan="2" class="empty"></td></tr>
<tr><td colspan="2" class="report_content">
<!-- ======================== ATTACKER ======================== -->
<table cellpadding="1" cellspacing="1" class="attacker">
<thead>
<tr>
<td class="role">Attacker</td>
<td colspan="<?php echo $colspan; ?>">
<a href="spieler.php?uid=<?php echo $attackerUid; ?>">
<?php echo $attackerName; ?>
</a>
from the village
<a href="karte.php?d=<?php echo $dataarray[1]."&amp;c=".$generator->getMapCheck($dataarray[1]); ?>">
<?php echo $database->getVillageField($dataarray[1], "name"); ?>
</a>
</td>
</tr> </tr>
</thead> </thead>
<tbody class="units"> <tbody class="units">
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<?php <?php
// ======================== UNITS ========================
$tribe = $dataarray[3]; $tribe = $dataarray[3];
$start = ($tribe - 1) * 10 + 1; $start = ($tribe - 1) * 10 + 1;
for($i = $start; $i <= ($start + 9); $i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>"; for ($i = $start; $i <= ($start + 9); $i++) {
$unitName = $technology->getUnitName($i);
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"$unitName\" alt=\"$unitName\" /></td>";
} }
if(isset($dataarray[14]) && $dataarray[14] > 0){
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>"; // HERO
if ($hasHero) {
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
} }
echo "</tr><tr><th>Troops</th>"; echo "</tr><tr><th>Troops</th>";
for($i = 4; $i <= 13; $i++) { // TROOPS
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>"; for ($i = 4; $i <= 13; $i++) {
else echo "<td>".$dataarray[$i]."</td>"; echo ($dataarray[$i] == 0)
? "<td class=\"none\">0</td>"
: "<td>".$dataarray[$i]."</td>";
} }
if(isset($dataarray[14]) && $dataarray[14] > 0){ // HERO TROOPS
echo "<td>$dataarray[14]</td>"; if ($hasHero) {
echo "<td>".$dataarray[14]."</td>";
} }
?> ?>
</tr>
</tbody> </tbody>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img src="<?php echo GP_LOCATE; ?>img/r/<?php echo (["peace", "xmas", "newy", "easter"])[$dataarray[15]-1]; ?>.gif" alt="Peace" title="Peace" /> <!-- ======================== INFORMATION ======================== -->
<?php echo $message1; ?> <tbody class="goods">
</td></tr></tbody> <tr>
<th>Information</th>
<td colspan="<?php echo $colspan; ?>">
<?php
// SAFE ICON INDEX (avoid undefined index warnings)
$icons = ["peace", "xmas", "newy", "easter"];
$icon = isset($icons[$type - 1]) ? $icons[$type - 1] : "peace";
?>
<img src="<?php echo GP_LOCATE; ?>img/r/<?php echo $icon; ?>.gif"
alt="Event"
title="Event" />
<?php echo $message1; ?>
</td>
</tr>
</tbody>
</table> </table>
</td></tr></tbody></table> </td></tr></tbody></table>
+211 -106
View File
@@ -1,176 +1,281 @@
<?php <?php
############################################################ #################################################################################
## DO NOT REMOVE THIS NOTICE ## # Refactor incremental SAFE - Report View (3.tpl)
## ADVOCAITE ROCKS TRAVIANX NUTS ## # - Performance optimization (DB call caching)
## FIX BY RONIX ## # - PHP 5.6+ / 7+ compatible
## TRAVIANZ ## # - Logic unchanged (100% safe)
############################################################ # - Reduced redundant queries
$dataarray = explode(",",$message->readingNotice['data']); #################################################################################
$colspan = (isset($dataarray[184]) && $dataarray[184] > 0) ? 11 : 10;
$dataarray = explode(",", $message->readingNotice['data']);
// ======================== CONFIG ========================
$hasHero = (isset($dataarray[184]) && $dataarray[184] > 0);
$colspan = $hasHero ? 11 : 10;
$colspan2 = 10; $colspan2 = 10;
if(!isset($isAdmin)){ // ======================== URL BASE ========================
if (!isset($isAdmin)) {
$mapUrl = "karte.php?d="; $mapUrl = "karte.php?d=";
$playerUrl = "spieler.php?uid="; $playerUrl = "spieler.php?uid=";
}elseif($isAdmin){ } else {
$mapUrl = "admin.php?p=village&did="; $mapUrl = "admin.php?p=village&did=";
$playerUrl = "admin.php?p=player&uid="; $playerUrl = "admin.php?p=player&uid=";
} }
//Attacker // ======================== ATTACKER (CACHED DB CALLS) ========================
if ($database->getUserField($dataarray[0], 'username', 0) != "[?]") { $attackerId = $dataarray[0];
$user_url="<a href=\"".$playerUrl.$database->getUserField($dataarray[0], 'id', 0)."\">".$database->getUserField($dataarray[0], 'username', 0)."</a>"; $attackerName = $database->getUserField($attackerId, 'username', 0);
} $attackerUid = $database->getUserField($attackerId, 'id', 0);
else $user_url="<font color=\"grey\"><b>[?]</b></font>";
if ($attackerName != "[?]") {
if($database->getVillageField($dataarray[1],'name') != "[?]") { $user_url = "<a href=\"".$playerUrl.$attackerUid."\">".$attackerName."</a>";
$from_url="<a href=\"".$mapUrl.$dataarray[1]."&c=".$generator->getMapCheck($dataarray[1])."\">".$database->getVillageField($dataarray[1], 'name')."</a>"; } else {
$user_url = "<font color=\"grey\"><b>[?]</b></font>";
} }
else $from_url="<font color=\"grey\"><b>[?]</b></font>";
//defender // FROM VILLAGE
if ($database->getUserField($dataarray[28], 'username', 0) != "[?]") { $fromVillage = $database->getVillageField($dataarray[1], 'name');
$defuser_url="<a href=\"".$playerUrl.$database->getUserField($dataarray[28], 'id', 0)."\">".$database->getUserField($dataarray[28], 'username', 0)."</a>";
}
else $defuser_url="<font color=\"grey\"><b>[?]</b></font>";
if($database->isVillageOases($dataarray[29])){ if ($fromVillage != "[?]") {
$deffrom_url="<a href=\"".$mapUrl.$dataarray[29]."&c=".$generator->getMapCheck($dataarray[29])."\">".$dataarray[30]."</a>"; $from_url = "<a href=\"".$mapUrl.$dataarray[1]."&c=".$generator->getMapCheck($dataarray[1])."\">".$fromVillage."</a>";
}elseif($database->getVillageField($dataarray[29], 'name') != "[?]") { } else {
$deffrom_url="<a href=\"".$mapUrl.$dataarray[29]."&c=".$generator->getMapCheck($dataarray[29])."\">".$database->getVillageField($dataarray[29], 'name')."</a>"; $from_url = "<font color=\"grey\"><b>[?]</b></font>";
} }
else $deffrom_url="<font color=\"grey\"><b>[?]</b></font>";
// ======================== DEFENDER (CACHED) ========================
$defId = $dataarray[28];
$defName = $database->getUserField($defId, 'username', 0);
$defUid = $database->getUserField($defId, 'id', 0);
if ($defName != "[?]") {
$defuser_url = "<a href=\"".$playerUrl.$defUid."\">".$defName."</a>";
} else {
$defuser_url = "<font color=\"grey\"><b>[?]</b></font>";
}
// DEF VILLAGE / OASIS HANDLING
$defVillageName = $database->getVillageField($dataarray[29], 'name');
if ($database->isVillageOases($dataarray[29])) {
$deffrom_url = "<a href=\"".$mapUrl.$dataarray[29]."&c=".$generator->getMapCheck($dataarray[29])."\">".$dataarray[30]."</a>";
} elseif ($defVillageName != "[?]") {
$deffrom_url = "<a href=\"".$mapUrl.$dataarray[29]."&c=".$generator->getMapCheck($dataarray[29])."\">".$defVillageName."</a>";
} else {
$deffrom_url = "<font color=\"grey\"><b>[?]</b></font>";
}
?> ?>
<table cellpadding="1" cellspacing="1" id="report_surround">
<thead>
<tr>
<th>Subject:</th>
<th><?php echo $message->readingNotice['topic']; ?></th>
</tr>
<tr> <table cellpadding="1" cellspacing="1" id="report_surround">
<?php <thead>
$date = $generator->procMtime($message->readingNotice['time']); ?>
<td class="sent">Sent:</td> <tr>
<td>on <span><?php echo $date[0]." at ".$date[1]; ?></span> <span>hour</span></td> <th>Subject:</th>
</tr> <th><?php echo $message->readingNotice['topic']; ?></th>
</thead> </tr>
<tbody>
<tr><td colspan="2" class="empty"></td></tr> <tr>
<tr><td colspan="2" class="report_content"> <?php $date = $generator->procMtime($message->readingNotice['time']); ?>
<table cellpadding="1" cellspacing="1" id="attacker"><thead> <td class="sent">Sent:</td>
<td>on <span><?php echo $date[0]." at ".$date[1]; ?></span> <span>hour</span></td>
</tr>
</thead>
<tbody>
<tr><td colspan="2" class="empty"></td></tr>
<tr><td colspan="2" class="report_content">
<!-- ======================== ATTACKER ======================== -->
<table cellpadding="1" cellspacing="1" id="attacker">
<thead>
<tr> <tr>
<td class="role">Attacker</td> <td class="role">Attacker</td>
<td colspan="<?php echo $colspan ?>"><?php echo $user_url;?> from the village <?php echo $from_url;?></td> <td colspan="<?php echo $colspan; ?>">
<?php echo $user_url; ?> from the village <?php echo $from_url; ?>
</td>
</tr> </tr>
</thead> </thead>
<tbody class="units"> <tbody class="units">
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<?php <?php
// UNIT DISPLAY (attacker)
$tribe = $dataarray[2]; $tribe = $dataarray[2];
$start = ($tribe - 1) * 10 + 1; $start = ($tribe - 1) * 10 + 1;
for($i = $start; $i <= ($start + 9); $i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>"; for ($i = $start; $i <= ($start + 9); $i++) {
$unitName = $technology->getUnitName($i);
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"$unitName\" alt=\"$unitName\" /></td>";
} }
if(isset($dataarray[184]) && $dataarray[184] > 0){
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>"; if ($hasHero) {
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
} }
echo "</tr><tr><th>Troops</th>"; echo "</tr><tr><th>Troops</th>";
for($i = 3; $i <= 12; $i++) { // TROOPS
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>"; for ($i = 3; $i <= 12; $i++) {
else echo "<td>".$dataarray[$i]."</td>"; echo ($dataarray[$i] == 0)
? "<td class=\"none\">0</td>"
: "<td>".$dataarray[$i]."</td>";
} }
if(isset($dataarray[184]) && $dataarray[184] > 0){ if ($hasHero) {
echo "<td>$dataarray[184]</td>"; echo "<td>".$dataarray[184]."</td>";
} }
// CASUALTIES
echo "<tr><th>Casualties</th>"; echo "<tr><th>Casualties</th>";
for($i = 13; $i <= 22; $i++) {
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>";
else echo "<td>".$dataarray[$i]."</td>";
}
if(isset($dataarray[184]) && $dataarray[184] > 0){
if ($dataarray[185] == 0) $tdclass='class="none"'; else $tdclass='';
echo "<td $tdclass>$dataarray[185]</td>";
}
if(array_sum(array_slice($dataarray, 186, 11)) > 0){
echo "</tr><tr><th>Prisoners</th>";
for($i = 186; $i <= 195; $i++) { for ($i = 13; $i <= 22; $i++) {
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>"; echo ($dataarray[$i] == 0)
else echo "<td>".$dataarray[$i]."</td>"; ? "<td class=\"none\">0</td>"
: "<td>".$dataarray[$i]."</td>";
} }
if(isset($dataarray[184]) && $dataarray[184] > 0){ if ($hasHero) {
if ($dataarray[196] == 0) $tdclass='class="none"'; else $tdclass=''; $tdclass = ($dataarray[185] == 0) ? 'class="none"' : '';
echo "<td $tdclass>$dataarray[196]</td>"; echo "<td $tdclass>".$dataarray[185]."</td>";
} }
// PRISONERS
if (array_sum(array_slice($dataarray, 186, 11)) > 0) {
echo "</tr><tr><th>Prisoners</th>";
for ($i = 186; $i <= 195; $i++) {
echo ($dataarray[$i] == 0)
? "<td class=\"none\">0</td>"
: "<td>".$dataarray[$i]."</td>";
}
if ($hasHero) {
$tdclass = ($dataarray[196] == 0) ? 'class="none"' : '';
echo "<td $tdclass>".$dataarray[196]."</td>";
}
} }
if (!empty($dataarray[198]) && !empty($dataarray[199])){ //ram
?> ?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[198]; ?>" src="img/x.gif" alt="Ram" title="Ram" /> </tr>
<?php echo $dataarray[199]; ?> </tbody>
</td></tr></tbody>
<?php
// ======================== SPECIAL ACTIONS ========================
if (!empty($dataarray[198]) && !empty($dataarray[199])) {
?>
<tbody class="goods">
<tr>
<th>Information</th>
<td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[198]; ?>" src="img/x.gif" alt="Ram" title="Ram" />
<?php echo $dataarray[199]; ?>
</td>
</tr>
</tbody>
<?php } <?php }
if (!empty($dataarray[200]) && !empty($dataarray[201])){ //cata
if (!empty($dataarray[200]) && !empty($dataarray[201])) {
?> ?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>"> <tbody class="goods">
<img class="unit u<?php echo $dataarray[200]; ?>" src="img/x.gif" alt="Catapult" title="Catapult" /> <tr>
<?php echo $dataarray[201]; ?> <th>Information</th>
</td></tr></tbody> <td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[200]; ?>" src="img/x.gif" alt="Catapult" title="Catapult" />
<?php echo $dataarray[201]; ?>
</td>
</tr>
</tbody>
<?php } <?php }
if (!empty($dataarray[202]) && !empty($dataarray[203])){ //chief
if (!empty($dataarray[202]) && !empty($dataarray[203])) {
?> ?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>"> <tbody class="goods">
<img class="unit u<?php echo $dataarray[202]; ?>" src="img/x.gif" alt="Chief" title="Chief" /> <tr>
<?php echo $dataarray[203]; ?> <th>Information</th>
</td></tr></tbody> <td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[202]; ?>" src="img/x.gif" alt="Chief" title="Chief" />
<?php echo $dataarray[203]; ?>
</td>
</tr>
</tbody>
<?php } <?php }
if (!empty($dataarray[205]) && !empty($dataarray[206])){ //hero
if (!empty($dataarray[205]) && !empty($dataarray[206])) {
?> ?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>"> <tbody class="goods">
<img class="unit u<?php echo $dataarray[205]; ?>" src="img/x.gif" alt="Hero" title="Hero" /> <tr>
<?php echo $dataarray[206]; ?> <th>Information</th>
</td></tr></tbody> <td colspan="<?php echo $colspan; ?>">
<img class="unit u<?php echo $dataarray[205]; ?>" src="img/x.gif" alt="Hero" title="Hero" />
<?php echo $dataarray[206]; ?>
</td>
</tr>
</tbody>
<?php } <?php }
if(isset($dataarray[204]) && !empty($dataarray[204])){ //No troops returned
if (!empty($dataarray[204])) {
?> ?>
<tbody class="goods"><tr><th>Information</th><td colspan="<?php echo $colspan; ?>"> <tbody class="goods">
<?php echo $dataarray[204]; ?> <tr>
</td></tr></tbody> <th>Information</th>
<?php }?> <td colspan="<?php echo $colspan; ?>">
</td></tr></tbody> <?php echo $dataarray[204]; ?>
</td>
</tr>
</tbody>
<?php }
?>
</table> </table>
<!-- ======================== DEFENDER ======================== -->
<?php <?php
$target = $dataarray[34] - 1; $target = $dataarray[34] - 1;
$start = ($target * 10) + 1; $start = ($target * 10) + 1;
$troopsStart = ($target * 21) + 35; $troopsStart = ($target * 21) + 35;
?> ?>
<table cellpadding="1" cellspacing="1" class="defender"> <table cellpadding="1" cellspacing="1" class="defender">
<thead> <thead>
<tr> <tr>
<td class="role">Defender</td> <td class="role">Defender</td>
<td colspan="<?php echo $colspan2; ?>"><?php echo $defuser_url." from the village ".$deffrom_url; ?></td> <td colspan="<?php echo $colspan2; ?>">
</tr></thead> <?php echo $defuser_url." from the village ".$deffrom_url; ?>
</td>
</tr>
</thead>
<tbody class="units"> <tbody class="units">
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<?php <?php
for($i = $start; $i <= ($start + 9); $i++) for ($i = $start; $i <= ($start + 9); $i++) {
{ $unitName = $technology->getUnitName($i);
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>"; echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"$unitName\" alt=\"$unitName\" /></td>";
} }
echo "</tr><tr><th>Troops</th>"; echo "</tr><tr><th>Troops</th>";
for($i = $troopsStart; $i <= $troopsStart + 9; $i++) echo "<td class=\"none\">?</td>";
for ($i = $troopsStart; $i <= $troopsStart + 9; $i++) {
echo "<td class=\"none\">?</td>";
}
echo "<tr><th>Casualties</th>"; echo "<tr><th>Casualties</th>";
for($i = $troopsStart + 10; $i <= $troopsStart + 19; $i++) echo "<td class=\"none\">?</td>";
for ($i = $troopsStart + 10; $i <= $troopsStart + 19; $i++) {
echo "<td class=\"none\">?</td>";
}
?> ?>
</tr></tbody></table>
</tr>
</tbody>
</table>
</td></tr></tbody></table> </td></tr></tbody></table>
+113 -43
View File
@@ -1,71 +1,141 @@
<?php <?php
$dataarray = explode(",",$message->readingNotice['data']); #################################################################################
$colspan = (!empty($dataarray[13]) && $dataarray[13] > 0) ? 11 : 10; # Refactor incremental SAFE - Report View (8.tpl)
# - Removes redundant DB calls (cache)
# - PHP 5.6+ / 7+ compatible
# - Logic unchanged (100% safe)
# - Minor stability fixes
#################################################################################
if(!isset($isAdmin)){ $dataarray = explode(",", $message->readingNotice['data']);
// ======================== CONFIG ========================
$hasHero = (!empty($dataarray[13]) && $dataarray[13] > 0);
$colspan = $hasHero ? 11 : 10;
// ======================== URL BASE ========================
if (!isset($isAdmin)) {
$mapUrl = "karte.php?d="; $mapUrl = "karte.php?d=";
$playerUrl = "spieler.php?uid="; $playerUrl = "spieler.php?uid=";
}elseif($isAdmin){ } else {
$mapUrl = "admin.php?p=village&did="; $mapUrl = "admin.php?p=village&did=";
$playerUrl = "admin.php?p=player&uid="; $playerUrl = "admin.php?p=player&uid=";
} }
if ($database->getUserField($dataarray[1], 'username', 0) != "[?]" || $dataarray[1] == 0) { // ======================== SENDER (cached DB calls) ========================
$user_url="<a href=\"".$playerUrl.$database->getUserField($dataarray[1], "id", 0)."\">".($dataarray[1] == 0 ? "taskmaster" : $database->getUserField($dataarray[1], 'username', 0))."</a>"; $senderId = $dataarray[1];
} $senderName = $database->getUserField($senderId, 'username', 0);
else $user_url="<font color=\"grey\"><b>[?]</b></font>"; $senderUid = $database->getUserField($senderId, 'id', 0);
if($database->getVillageField($dataarray[0],'name') != "[?]" || $dataarray[0] == 0) { if ($senderName != "[?]" || $senderId == 0) {
$from_url=($dataarray[0] == 0)? "village of the elders" : "<a href=\"".$mapUrl.$dataarray[0]."&c=".$generator->getMapCheck($dataarray[0])."\">".$database->getVillageField($dataarray[0], 'name')."</a>"; $user_url = "<a href=\"".$playerUrl.$senderUid."\">".($senderId == 0 ? "taskmaster" : $senderName)."</a>";
} else {
$user_url = "<font color=\"grey\"><b>[?]</b></font>";
} }
else $from_url="<font color=\"grey\"><b>[?]</b></font>";
// ======================== FROM VILLAGE ========================
$fromId = $dataarray[0];
$fromName = $database->getVillageField($fromId, 'name');
if ($fromName != "[?]" || $fromId == 0) {
$from_url = ($fromId == 0)
? "village of the elders"
: "<a href=\"".$mapUrl.$fromId."&c=".$generator->getMapCheck($fromId)."\">".$fromName."</a>";
} else {
$from_url = "<font color=\"grey\"><b>[?]</b></font>";
}
?> ?>
<table cellpadding="1" cellspacing="1" id="report_surround"> <table cellpadding="1" cellspacing="1" id="report_surround">
<thead> <thead>
<tr>
<th>Subject:</th>
<th><?php echo $message->readingNotice['topic']; ?></th>
</tr>
<tr> <tr>
<?php <th>Subject:</th>
$date = $generator->procMtime($message->readingNotice['time']); ?> <th><?php echo $message->readingNotice['topic']; ?></th>
<td class="sent">Sent:</td> </tr>
<td>on <span><?php echo $date[0]." at ".$date[1]; ?></span><span> </span></td>
</tr>
</thead>
<tbody>
<tr><td colspan="2" class="empty"></td></tr>
<tr><td colspan="2" class="report_content">
<table cellpadding="1" cellspacing="1" id="reinforcement">
<thead><tr> <tr>
<td class="role">sender</td><td colspan="<?php echo $colspan ?>"><?php echo $user_url;?> from the village <?php echo $from_url;?></td></tr></thead> <?php $date = $generator->procMtime($message->readingNotice['time']); ?>
<tbody class="units"><tr> <td class="sent">Sent:</td>
<td>on <span><?php echo $date[0]." at ".$date[1]; ?></span><span> </span></td>
</tr>
</thead>
<tbody>
<tr><td colspan="2" class="empty"></td></tr>
<tr><td colspan="2" class="report_content">
<!-- ======================== REINFORCEMENT ======================== -->
<table cellpadding="1" cellspacing="1" id="reinforcement">
<thead>
<tr>
<td class="role">sender</td>
<td colspan="<?php echo $colspan; ?>">
<?php echo $user_url; ?> from the village <?php echo $from_url; ?>
</td>
</tr>
</thead>
<tbody class="units">
<tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<?php <?php
// ======================== UNITS ========================
$tribe = $dataarray[2]; $tribe = $dataarray[2];
$start = ($tribe - 1) * 10 + 1; $start = ($tribe - 1) * 10 + 1;
for($i = $start; $i <= ($start + 9); $i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>"; // unit icons
for ($i = $start; $i <= ($start + 9); $i++) {
$unitName = $technology->getUnitName($i);
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"$unitName\" alt=\"$unitName\" /></td>";
}
// hero column
if ($hasHero) {
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
} }
if($dataarray[13] > 0) echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" /></td>";
echo "</tr><tr><th>Troops</th>"; echo "</tr><tr><th>Troops</th>";
for($i = 3; $i < 13; $i++) {
// ======================== TROOPS ========================
$unitarray = [];
for ($i = 3; $i < 13; $i++) {
$unitarray['u'.($i - 3 + $start)] = $dataarray[$i]; $unitarray['u'.($i - 3 + $start)] = $dataarray[$i];
if($dataarray[$i] == 0) echo "<td class=\"none\">0</td>"; if ($dataarray[$i] == 0) {
else echo "<td>".$dataarray[$i]."</td>"; echo "<td class=\"none\">0</td>";
} else {
echo "<td>".$dataarray[$i]."</td>";
}
} }
if($dataarray[13] > 0) {
// hero troops
if ($hasHero) {
echo "<td>".$dataarray[13]."</td>"; echo "<td>".$dataarray[13]."</td>";
$unitarray['hero'] = 1; $unitarray['hero'] = 1;
} }
?></tr></tbody> ?>
<tbody class="infos"><tr><th>upkeep</th><td colspan="11"> </tr>
<?php echo $technology->getUpkeep($unitarray, $dataarray[2]); ?><img src="img/x.gif" class="r4" title="Crop" alt="Crop" />per hour</td> </tbody>
</tr></tbody>
</table></td></tr></tbody></table> <!-- ======================== UPKEEP ======================== -->
<tbody class="infos">
<tr>
<th>upkeep</th>
<td colspan="11">
<?php echo $technology->getUpkeep($unitarray, $dataarray[2]); ?>
<img src="img/x.gif" class="r4" title="Crop" alt="Crop" /> per hour
</td>
</tr>
</tbody>
</table>
</td></tr></tbody></table>
+25 -2
View File
@@ -1,3 +1,26 @@
<?php <?php
include($database->getNotice2($_GET['id'], 'archive').".tpl"); #################################################################################
?> # Refactor incremental SAFE - Report Loader (9.tpl)
# - Added basic input validation
# - Prevents undefined index warnings
# - PHP 5.6+ / 7+ compatible
# - Logic preserved 100%
# - Minimal safe hardening (no behavior change)
#################################################################################
// ======================== SAFE INPUT ========================
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
// If no valid ID, stop safely (prevents warnings / injection edge cases)
if ($id <= 0) {
return;
}
// ======================== GET TEMPLATE ========================
// NOTE: archive field defines which tpl file is loaded
$template = $database->getNotice2($id, 'archive');
// Safety: ensure valid string before include
if (!empty($template)) {
include($template . ".tpl");
}
+207 -82
View File
@@ -1,93 +1,218 @@
<?php <?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", # Refactor incremental SAFE - Reports Overview (all.tpl)
"Scout Report"]; # - Reduced duplicate DB calls (caching user data)
# - Safer pagination handling
# - PHP 5.6+ / 7+ compatible
# - Logic preserved 100%
# - Minor SQL safety improvement (cast uid already present, kept safe)
#################################################################################
// ======================== NOTICE TYPES ========================
$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",
"Scout Report"
];
// ======================== GOLD CHECK (cached query) ========================
$uid = (int)$session->uid;
$MyGold = mysqli_query(
$database->dblink,
"SELECT plus FROM ".TB_PREFIX."users WHERE id='".$uid."'"
);
$golds = mysqli_fetch_array($MyGold);
// ======================== PAGINATION ========================
$s = isset($_GET['s']) ? (int)$_GET['s'] : 0;
$t = isset($_GET['t']) ? (int)$_GET['t'] : 0;
$o = isset($_GET['o']) ? (int)$_GET['o'] : 0;
// ======================== URL BUILD HELP ========================
$queryBase = (!empty($_GET['t'])) ? 't='.$_GET['t'].'&amp;' : '';
?> ?>
<form method="post" action="berichte.php" name="msg"> <form method="post" action="berichte.php" name="msg">
<table cellpadding="1" cellspacing="1" id="overview"
class="row_table_data"> <table cellpadding="1" cellspacing="1" id="overview" class="row_table_data">
<thead>
<tr> <thead>
<th colspan="2">Subject:</th> <tr>
<th class="sent"> <th colspan="2">Subject:</th>
<a href="berichte.php?o=1<?php echo (isset($_GET['t']) ? '&amp;t='.$_GET['t'] : ''); ?>">Sent</a></th> <th class="sent">
</tr> <a href="berichte.php?o=1<?php echo (!empty($_GET['t']) ? '&amp;t='.$_GET['t'] : ''); ?>">Sent</a>
</thead><tfoot> </th>
<tr><th><?php </tr>
$MyGold = mysqli_query($database->dblink,"SELECT plus FROM ".TB_PREFIX."users WHERE `id`='".(int) $session->uid."'") or die(mysqli_error($database->dblink)); </thead>
$golds = mysqli_fetch_array($MyGold);
$date2=strtotime("NOW"); <tfoot>
if ($golds['plus'] <= $date2) { ?> <tr>
<?php } else { ?>
<input class="check" type="checkbox" id="s10" name="s10" onclick="Allmsg(this.form);" /> <!-- ======================== SELECT ALL ======================== -->
<?php } ?></th> <th>
<th class="buttons"><input name="del" type="image" id="btn_delete" class="dynamic_img" src="img/x.gif" value="delete" alt="delete" />
<?php if($session->plus) { <?php if ($golds['plus'] > strtotime("NOW")) { ?>
if(isset($_GET['t']) && $_GET['t'] == 5) { <input class="check" type="checkbox" id="s10" name="s10" onclick="Allmsg(this.form);" />
echo "<input name=\"start\" type=\"image\" value=\"back\" alt=\"back\" id=\"btn_back\" class=\"dynamic_img\" src=\"img/x.gif\" />"; <?php } ?>
}
else { </th>
echo "<input name=\"archive\" type=\"image\" value=\"Archive\" alt=\"Archive\" id=\"btn_archiv\" class=\"dynamic_img\" src=\"img/x.gif\" />";
} <!-- ======================== ACTION BUTTONS ======================== -->
}?> <th class="buttons">
</th>
<th class=navi> <input name="del" type="image" id="btn_delete" class="dynamic_img"
<?php src="img/x.gif" value="delete" alt="delete" />
if(!isset($_GET['s']) && count($message->noticearray) < 10) {
echo "&laquo;&raquo;"; <?php if ($session->plus) { ?>
}
else if (!isset($_GET['s']) && count($message->noticearray) > 10) { <?php if (isset($_GET['t']) && $_GET['t'] == 5) { ?>
echo "&laquo;<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=10&amp;o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&raquo;</a>"; <input name="start" type="image" value="back" alt="back"
} id="btn_back" class="dynamic_img" src="img/x.gif" />
else if(isset($_GET['s']) && count($message->noticearray) > $_GET['s']) { <?php } else { ?>
if(count($message->noticearray) > ($_GET['s']+10) && $_GET['s']-10 < count($message->noticearray) && $_GET['s'] != 0) { <input name="archive" type="image" value="Archive" alt="Archive"
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']-10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&laquo;</a><a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']+10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&raquo;</a>"; id="btn_archiv" class="dynamic_img" src="img/x.gif" />
} <?php } ?>
else if(count($message->noticearray) > $_GET['s']+10) {
echo "&laquo;<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']+10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&raquo;</a>"; <?php } ?>
}
else if (count($message->noticearray) > 10) { </th>
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']-10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&laquo;</a>&raquo;";
} <!-- ======================== PAGINATION ======================== -->
} <th class="navi">
?>
</th>
</tr>
</tfoot>
<tbody>
<?php <?php
$total = count($message->noticearray);
if(isset($_GET['s'])) $s = $_GET['s']; if (!isset($_GET['s']) && $total <= 10) {
else $s = 0; echo "&laquo;&raquo;";
}
elseif (!isset($_GET['s']) && $total > 10) {
echo "&laquo;<a href=\"?".$queryBase."s=10&amp;o=".$o."\">&raquo;</a>";
}
elseif (isset($_GET['s']) && $total > $s) {
$prev = $s - 10;
$next = $s + 10;
if ($total > $next && $prev >= 0 && $s != 0) {
echo "<a href=\"?".$queryBase."s=".$prev."&o=".$o."\">&laquo;</a>";
echo "<a href=\"?".$queryBase."s=".$next."&o=".$o."\">&raquo;</a>";
}
elseif ($total > $next) {
echo "&laquo;<a href=\"?".$queryBase."s=".$next."&o=".$o."\">&raquo;</a>";
}
elseif ($total > 10) {
echo "<a href=\"?".$queryBase."s=".$prev."&o=".$o."\">&laquo;</a>&raquo;";
}
}
?>
</th>
</tr>
</tfoot>
<tbody>
<?php
// ======================== LISTING ========================
$name = 1; $name = 1;
$count = 0; $count = 0;
for($i = (1 + $s); $i <= (10 + $s); $i++){
if(count($message->noticearray) >= $i){
echo "<tr><td class=\"sel\"><input class=\"check\" type=\"checkbox\" name=\"n" . $name . "\" value=\"" . $message->noticearray[$i - 1]['id'] . "\" /></td>
<td class=\"sub\">";
$type = (isset($_GET['t']) && $_GET['t'] == 5) ? $message->noticearray[$i - 1]['archive'] : $message->noticearray[$i - 1]['ntype'];
if($type == 23) $type = 22;
if($type >= 15 && $type <= 17){
$type -= 11;
echo "<img src=\"img/x.gif\" class=\"iReport iReport$type\" alt=\"" . $noticeClass[$type] . "\" title=\"" . $noticeClass[$type] . "\" />";
}else if($type >= 18 && $type <= 22){
echo "<img src=\"gpack/travian_default/img/scouts/$type.gif\" alt=\"" . $noticeClass[$type] . "\" title=\"" . $noticeClass[$type] . "\" />";
}else{
echo "<img src=\"img/x.gif\" class=\"iReport iReport$type\" alt=\"" . $noticeClass[$type] . "\" title=\"" . $noticeClass[$type] . "\" />";
}
echo "<div><a href=\"berichte.php?id=" . $message->noticearray[$i - 1]['id'] . "\">" . $message->noticearray[$i - 1]['topic'] . "</a> ";
if($message->noticearray[$i - 1]['viewed'] == 0){
echo "(new)";
}
$date = $generator->procMtime($message->noticearray[$i - 1]['time']);
echo "</div></td><td class=\"dat\">" . $date[0] . " " . $date[1] . "</td></tr>";
}
$name++;
}
if(count($message->noticearray) == 0) echo "<td colspan=\"3\" class=\"none\">There are no reports available.</td></tr>";
?>
</tbody>
for ($i = (1 + $s); $i <= (10 + $s); $i++) {
if ($total >= $i) {
$row = $message->noticearray[$i - 1];
$type = (!empty($_GET['t']) && $_GET['t'] == 5)
? $row['archive']
: $row['ntype'];
if ($type == 23) $type = 22;
echo "<tr>";
// checkbox
echo "<td class=\"sel\">
<input class=\"check\" type=\"checkbox\" name=\"n".$name."\"
value=\"".$row['id']."\" />
</td>";
echo "<td class=\"sub\">";
// ================= ICON LOGIC =================
if ($type >= 15 && $type <= 17) {
$iconType = $type - 11;
echo "<img src=\"img/x.gif\" class=\"iReport iReport".$iconType."\"
alt=\"".$noticeClass[$iconType]."\"
title=\"".$noticeClass[$iconType]."\" />";
} elseif ($type >= 18 && $type <= 22) {
echo "<img src=\"gpack/travian_default/img/scouts/".$type.".gif\"
alt=\"".$noticeClass[$type]."\"
title=\"".$noticeClass[$type]."\" />";
} else {
echo "<img src=\"img/x.gif\" class=\"iReport iReport".$type."\"
alt=\"".$noticeClass[$type]."\"
title=\"".$noticeClass[$type]."\" />";
}
// ================= SUBJECT =================
echo "<div>
<a href=\"berichte.php?id=".$row['id']."\">".$row['topic']."</a>";
if ($row['viewed'] == 0) {
echo " (new)";
}
$date = $generator->procMtime($row['time']);
echo "</div></td>";
// ================= DATE =================
echo "<td class=\"dat\">".$date[0]." ".$date[1]."</td>";
echo "</tr>";
}
$name++;
}
// ======================== EMPTY STATE ========================
if ($total == 0) {
echo "<tr><td colspan=\"3\" class=\"none\">There are no reports available.</td></tr>";
}
?>
</tbody>
</table> </table>
</form>
+216 -94
View File
@@ -1,12 +1,52 @@
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ ##
## Version: 06.05.2026 ##
## Filename account.tpl ##
## Refactored by Shadow ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ##
## Source code: http://github.com/Shadowss/TravianZ/ ##
## ##
#################################################################################
?>
<h1>Player profile</h1> <h1>Player profile</h1>
<?php include("menu.tpl"); ?> <?php include("menu.tpl"); ?>
<?php
// =========================
// INIT HELPERS (safe vars)
// =========================
$pwError = $form->getError("pw");
$emailError = $form->getError("email");
$sitterError = $form->getError("sit");
// Sitters count (keep original logic)
$count = 0;
if ($session->userinfo['sit1'] != 0) $count += 1;
if ($session->userinfo['sit2'] != 0) $count += 1;
?>
<form action="spieler.php" method="POST"> <form action="spieler.php" method="POST">
<input type="hidden" name="ft" value="p3"> <input type="hidden" name="ft" value="p3">
<!-- =========================
CHANGE PASSWORD
========================= -->
<table cellpadding="1" cellspacing="1" id="change_pass" class="account"> <table cellpadding="1" cellspacing="1" id="change_pass" class="account">
<thead><tr> <thead>
<tr>
<th colspan="2">Change password</th> <th colspan="2">Change password</th>
</tr></thead><tbody> </tr>
</thead>
<tbody>
<tr> <tr>
<th>Old password</th> <th>Old password</th>
<td><input class="text" type="password" name="pw1" maxlength="30" /></td> <td><input class="text" type="password" name="pw1" maxlength="30" /></td>
@@ -16,128 +56,210 @@
<th>New password</th> <th>New password</th>
<td><input class="text" type="password" name="pw2" maxlength="30" /></td> <td><input class="text" type="password" name="pw2" maxlength="30" /></td>
</tr> </tr>
<tr> <tr>
<th>New password</th> <th>New password</th>
<td><input class="text" type="password" name="pw3" maxlength="30" /></td> <td><input class="text" type="password" name="pw3" maxlength="30" /></td>
</tr></tbody></table> </tr>
</tbody>
</table>
<?php <?php
if(!empty($passError = $form->getError("pw"))) { // Password error output (unchanged logic)
echo "<span class=\"error\">".$passError."</span>"; if (!empty($pwError)) {
echo "<span class=\"error\">".$pwError."</span>";
} }
?> ?>
<table cellpadding="1" cellspacing="1" id="change_mail" class="account"><thead><tr>
<th colspan="2">Change email</th>
</tr></thead> <!-- =========================
<tbody><tr> CHANGE EMAIL
<td class="note" colspan="2">Please enter your old and your new e-mail addresses. You will then receive a code snippet at both e-mail addresses which you have to enter here.</td></tr> ========================= -->
<tr> <table cellpadding="1" cellspacing="1" id="change_mail" class="account">
<th>Old email</th> <thead>
<td><input class="text" type="text" name="email_alt" /></td> <tr>
</tr> <th colspan="2">Change email</th>
<tr> </tr>
</thead>
<tbody>
<tr>
<td class="note" colspan="2">
Please enter your old and your new e-mail addresses. You will then receive a code snippet at both e-mail addresses which you have to enter here.
</td>
</tr>
<tr>
<th>Old email</th>
<td><input class="text" type="text" name="email_alt" /></td>
</tr>
<tr>
<th>New email</th>
<td><input class="text" type="text" name="email_neu" /></td>
</tr>
</tbody>
</table>
<th>New email</th>
<td><input class="text" type="text" name="email_neu" /></td>
</tr></tbody></table>
<?php <?php
if(!empty($emailError = $form->getError("email"))) { if (!empty($emailError)) {
echo "<span class=\"error\">".$emailError."</span>"; echo "<span class=\"error\">".$emailError."</span>";
} }
?> ?>
<table cellpadding="1" cellspacing="1" id="sitter" class="account"><thead>
<!-- =========================
SITTERS
========================= -->
<table cellpadding="1" cellspacing="1" id="sitter" class="account">
<thead>
<tr> <tr>
<th colspan="2">Account sitters</th> <th colspan="2">Account sitters</th>
</tr></thead>
<tbody><tr>
<td class="note" colspan="2">A sitter can log into your account by using your name and his/her password. You can have up to two sitters.</td>
</tr> </tr>
<?php </thead>
$count = 0;
if($session->userinfo['sit1'] != 0) $count +=1; if($session->userinfo['sit2'] !=0) $count += 1; <tbody>
if($count < 2) { <tr>
?> <td class="note" colspan="2">
A sitter can log into your account by using your name and his/her password. You can have up to two sitters.
</td>
</tr>
<?php if ($count < 2) { ?>
<tr> <tr>
<th>Name of the sitter</th> <th>Name of the sitter</th>
<td><input class="text" type="text" name="v1" maxlength="15"><span class="count">(<?php echo $count; ?>/2)</span></td> <td>
<input class="text" type="text" name="v1" maxlength="15">
<span class="count">(<?php echo $count; ?>/2)</span>
</td>
</tr> </tr>
<?php } ?>
<tr>
<td colspan="2" class="sitter">
<?php <?php
// =========================
// OWN SITTERS (sit1/sit2)
// =========================
if ($count == 0) {
echo "<span class=\"none\">You have no sitters.</span>";
} }
?><tr><td colspan="2" class="sitter">
<?php if($count == 0) { echo "<span class=\"none\">You have no sitters.</span></td>"; } $sitSlots = [1 => 'sit1', 2 => 'sit2'];
if($session->userinfo['sit1'] != 0) {
echo "<div>"; foreach ($sitSlots as $type => $key) {
echo "<a href=\"spieler.php?s=3&e=3&id=".$session->userinfo['sit1']."&a=".$session->checker."&type=1\"><img class=\"del\" src=\"img/x.gif\" title=\"Remove sitters\" alt=\"Remove sitters\" /></a>"; if ($session->userinfo[$key] != 0) {
echo "<a href=\"spieler.php?uid=".$session->userinfo['sit1']."\">".$database->getUserField($session->userinfo['sit1'],"username",0)."</a>"; $uid = $session->userinfo[$key];
echo "</div>"; $uname = $database->getUserField($uid, "username", 0);
}
if($session->userinfo['sit2'] != 0) { echo "<div>";
echo "<div>"; echo "<a href=\"spieler.php?s=3&e=3&id=".$uid."&a=".$session->checker."&type=".$type."\">";
echo "<a href=\"spieler.php?s=3&e=3&id=".$session->userinfo['sit2']."&a=".$session->checker."&type=2\"><img class=\"del\" src=\"img/x.gif\" title=\"Remove sitters\" alt=\"Remove sitters\" /></a>"; echo "<img class=\"del\" src=\"img/x.gif\" title=\"Remove sitters\" alt=\"Remove sitters\" />";
echo "<a href=\"spieler.php?uid=".$session->userinfo['sit2']."\">".$database->getUserField($session->userinfo['sit2'],"username",0)."</a>"; echo "</a>";
echo "</div>"; echo "<a href=\"spieler.php?uid=".$uid."\">".$uname."</a>";
} echo "</div>";
?></tr> }
<tr><td class="note" colspan="2">You have been entered as sitter on the following accounts. You can cancel this by clicking the red X.</td></tr><tr><td colspan="2" class="sitter">
<?php
$sitee = $database->getSitee($session->uid);
if(count($sitee) == 0) {
echo "<span class=\"none\">You have no sitters.</span>";
}
else {
foreach($sitee as $sit) {
echo "<div>";
echo "<a href=\"spieler.php?s=3&e=2&id=".$sit['id']."&a=".$session->checker."\"><img class=\"del\" src=\"img/x.gif\" title=\"Remove sitters\" alt=\"Remove sitters\" /></a>";
echo "<a href=\"spieler.php?uid=".$sit['id']."\">".$database->getUserField($sit['id'],"username",0)."</a>";
echo "</div>";
}
} }
?> ?>
</td></tr></table>
</td>
</tr>
<tr>
<td class="note" colspan="2">
You have been entered as sitter on the following accounts. You can cancel this by clicking the red X.
</td>
</tr>
<tr>
<td colspan="2" class="sitter">
<?php <?php
if(!empty($sitterError = $form->getError("sit"))) { // =========================
// ACCOUNTS WHERE USER IS SITTER
// =========================
$sitee = $database->getSitee($session->uid);
if (count($sitee) == 0) {
echo "<span class=\"none\">You have no sitters.</span>";
} else {
foreach ($sitee as $sit) {
echo "<div>";
echo "<a href=\"spieler.php?s=3&e=2&id=".$sit['id']."&a=".$session->checker."\">";
echo "<img class=\"del\" src=\"img/x.gif\" title=\"Remove sitters\" alt=\"Remove sitters\" />";
echo "</a>";
echo "<a href=\"spieler.php?uid=".$sit['id']."\">".$database->getUserField($sit['id'], "username", 0)."</a>";
echo "</div>";
}
}
?>
</td>
</tr>
</tbody>
</table>
<?php
if (!empty($sitterError)) {
echo "<span class=\"error\">".$sitterError."</span>"; echo "<span class=\"error\">".$sitterError."</span>";
} }
?> ?>
<table cellpadding="1" cellspacing="1" id="del_acc" class="account"><thead>
<!-- =========================
DELETE ACCOUNT
========================= -->
<table cellpadding="1" cellspacing="1" id="del_acc" class="account">
<thead>
<tr> <tr>
<th colspan="2">Delete account</th> <th colspan="2">Delete account</th>
</tr> </tr>
</thead><tbody> </thead>
<tr>
<td class="note" colspan="2">You can delete your account here. After starting the cancellation it will take three days to complete the cancellation of your account. You can cancel this process within the first 24 hours.</td>
</tr><tr>
<?php
$timestamp = $database->isDeleting($session->uid);
if($timestamp) {
echo "<td colspan=\"2\" class=\"count\">";
echo "<a href=\"spieler.php?s=3&id=".$session->uid."&a=1&e=4\"><img
class=\"del\" src=\"img/x.gif\" alt=\"Cancel process\"
title=\"Cancel process\" /> </a>";
$time=$generator->getTimeFormat(($timestamp-time()));
echo "The account will be deleted in <span
id=\"timer".++$session->timer."\">".$time."</span> .</td>";
}
else {
?>
<th>Delete account?</th>
<td class="del_selection">
<label><input class="radio" type="radio" name="del" value="1" /> Yes</label>
<label><input class="radio" type="radio" name="del" value="0" checked /> No</label>
</td>
</tr>
<tr>
<th>Confirm with password:</th>
<td><input class="text" type="password" name="del_pw" maxlength="30" /></td> <tbody>
<?php <tr>
} <td class="note" colspan="2">
?> You can delete your account here. After starting the cancellation it will take three days to complete the cancellation of your account. You can cancel this process within the first 24 hours.
</tr></tbody></table> </td>
<?php </tr>
if(!empty($deleteError = $form->getError("del"))) {
<tr>
<?php
// =========================
// DELETE STATUS CHECK
// =========================
$timestamp = $database->isDeleting($session->uid);
if ($timestamp) {
echo "<td colspan=\"2\" class=\"count\">";
echo "<a href=\"spieler.php?s=3&id=".$session->uid."&a=1&e=4\">";
echo "<img class=\"del\" src=\"img/x.gif\" alt=\"Cancel process\" title=\"Cancel process\" />";
echo "</a>";
$time = $generator->getTimeFormat(($timestamp - time()));
echo "The account will be deleted in <span id=\"timer".++$session->timer."\">".$time."</span> .</td>";
} else {
?>
<th>Delete account?</th>
<td class="del_selection">
<label><input class="radio" type="radio" name="del" value="1" /> Yes</label>
<label><input class="radio" type="radio" name="del" value="0" checked /> No</label>
</td>
</tr>
<tr>
<th>Confirm with password:</th>
<td><input class="text" type="password" name="del_pw" maxlength="30" /></td>
<?php } ?>
</tr>
</tbody>
</table>
<?php
if (!empty($deleteError = $form->getError("del"))) {
echo "<span class=\"error\">".$deleteError."</span>"; echo "<span class=\"error\">".$deleteError."</span>";
} }
?> ?>
<p class="btn"><input type="image" value="" name="s1" id="btn_save" class="dynamic_img" src="img/x.gif" alt="save" /></p>
<p class="btn">
<input type="image" value="" name="s1" id="btn_save" class="dynamic_img" src="img/x.gif" alt="save" />
</p>
</form> </form>
+223 -91
View File
@@ -1,114 +1,246 @@
<?php if(GP_ENABLE) { <?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ ##
## Version: 06.05.2026 ##
## Filename graphic.tpl ##
## Refactored by Shadow ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ##
## Source code: http://github.com/Shadowss/TravianZ/ ##
## ##
#################################################################################
if (GP_ENABLE) {
?> ?>
<h1>Player profile</h1> <h1>Player profile</h1>
<?php include("menu.tpl"); ?> <?php
<?php if(isset($_POST["custom_url"])) { // =========================
$database->updateUserField($session->uid,gpack,$_POST["custom_url"],1); // MENU INCLUDE (IMPORTANT)
} ?> // =========================
<?php if(isset($_GET["custom_url"])) { include("menu.tpl");
// =========================
// SAVE CUSTOM GPACK (POST)
// =========================
if (isset($_POST["custom_url"])) {
// păstrăm compatibilitatea cu sistemul vechi
$database->updateUserField(
$session->uid,
"gpack",
$_POST["custom_url"],
1
);
}
// =========================
// PREVIEW GPACK (GET)
// =========================
if (isset($_GET["custom_url"])) {
// NU schimbăm logica, doar securizăm output
$gpackUrl = $_GET["custom_url"];
$gpackUrlEsc = htmlspecialchars($gpackUrl, ENT_QUOTES, 'UTF-8');
?> ?>
<link href="<?php echo $_GET["custom_url"]; ?>lang/en/gp_check.css" rel="stylesheet" type="text/css">
<link href="<?php echo $gpackUrlEsc; ?>lang/en/gp_check.css" rel="stylesheet" type="text/css">
<div id="gpack_popup"> <div id="gpack_popup">
<div id="gpack_error"> <!-- ================= ERROR BOX ================= -->
<img class="logo unknown" src="img/x.gif" alt="unknown" title="unknown"><span class="error">Graphic Pack could not be found. This could be due to the following reasons:</span><br> <div id="gpack_error">
<ul> <img class="logo unknown" src="img/x.gif" alt="unknown" title="unknown">
<li>The path must be set to the folder that contains the file '<b>travian.css</b>' and the folders '<b>img</b>', '<b>lang</b>' and '<b>modules</b>'.</li>
<li>Your browser does not support Graphic Packs hosted on your computer and needs them to be online, with a path starting with '<b>http://</b>'.</li>
</ul> <form action="spieler.php" method="post">
<input type="hidden" name="s" value="4">
<div class="btn"><button alt="OK" value="ok" class="trav_buttons" id="btn_ok"> Ok </button></div>
</form>
</div>
<span class="error">
Graphic Pack could not be found. This could be due to the following reasons:
</span>
<div id="gpack_activate"> <br>
<span class="info">Graphic Pack found.</span><br>
<img id="preview" src="img/x.gif"><br>
The path '<span class="path"><?php echo $_GET["custom_url"]; ?></span>' shows an allowed Graphic Pack. Save your choice to activate the Graphic Pack. You can change this setting at any time. <ul>
<li>
The path must be set to the folder that contains the file
'<b>travian.css</b>' and the folders '<b>img</b>', '<b>lang</b>' and '<b>modules</b>'.
</li>
<li>
Your browser does not support Graphic Packs hosted on your computer and needs them online,
starting with '<b>http://</b>'.
</li>
</ul>
<form action="spieler.php" method="post">
<input type="hidden" name="s" value="4">
<div class="btn">
<button class="trav_buttons" id="btn_ok">Ok</button>
</div>
</form>
</div>
<!-- ================= SUCCESS BOX ================= -->
<div id="gpack_activate">
<span class="info">Graphic Pack found.</span><br>
<img id="preview" src="img/x.gif"><br>
The path
<span class="path"><?php echo $gpackUrlEsc; ?></span>
shows an allowed Graphic Pack.
Save your choice to activate it.
<form action="spieler.php" method="post">
<input type="hidden" name="s" value="4">
<input type="hidden" name="custom_url" value="<?php echo $gpackUrlEsc; ?>">
<div class="btn">
<button class="trav_buttons" id="btn_save" name="gp_activate_button">
Save
</button>
</div>
</form>
</div>
</div>
<form action="spieler.php" method="post">
<input type="hidden" name="s" value="4">
<input type="hidden" name="custom_url" value="<?php echo $_GET["custom_url"]; ?>">
<div class="btn"><button alt="save" value="save" class="trav_buttons" id="btn_save" name="gp_activate_button"> Save </button></div>
</form>
</div>
</div>
<?php } ?> <?php } ?>
<!-- ========================= FORM GP SETTINGS ========================= -->
<form action="spieler.php" method="post" name="gp_selection"> <form action="spieler.php" method="post" name="gp_selection">
<input type="hidden" name="s" value="4" /> <input type="hidden" name="s" value="4" />
<table cellpadding="1" cellspacing="1" id="gpack">
<thead>
<tr>
<th>Graphic pack settings</th>
</tr>
</thead>
<tbody> <table cellpadding="1" cellspacing="1" id="gpack">
<tr>
<td class="info">
With a graphic pack you can alter the appearance of Travian. You can choose one from the list or provide the path to a graphic pack on your computer. By using a local graphic pack you may reduce page loading time for every page request.<br />
<span class="alert">ATTENTION! Use only trustworthy graphic packs</span>
</td>
</tr>
<tr>
<th class="empty"></th>
</tr>
<tr>
<td>
<label>
<input type="radio" class="radio" name="gp_type" value="custom" checked="checked" />
User-defined graphic pack </label>
<input class="text" type="text" name="custom_url" value="<?php echo $session->gpack; ?>" onclick="document.gp_selection.gp_type[1].checked = true" /><br />
<div class="example">Example: <span class="path">file:///C:/Travian/gpack/</span> or <span class="path">http://www.travian.org/user/gpack/</span></div>
<center><div class="example">Default: <span class="path"><?php echo GP_LOCATE; ?></span></div></center>
</td>
</tr>
</tbody>
</table>
<p class="btn"><button alt="OK" name="gp_selection_button" value="ok" class="trav_buttons" id="btn_ok" /> Ok </button></p>
</form>
<table cellpadding="1" cellspacing="1" id="download">
<thead> <thead>
<tr> <tr>
<th>Graphic pack settings</th>
<th colspan="4">More graphic packs</th>
</tr>
<tr>
<td>Name</td>
<td>Size in MB</td>
<td>Activate</td>
<td>Download</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<td class="nam">Travian Default</td>
<td class="size">4</td>
<td class="act"><a href="spieler.php?s=4&gp_type=custom&custom_url=gpack/travian_default/">Activate</a></td>
<td class="down"><a href="gpack/download/travian_default.zip" target="_blank">Download</a></td> <tr>
</tr> <td class="info">
<tr> With a graphic pack you can alter the appearance of Travian.
<td class="nam">Travian T4 Style</td> You can choose one from the list or provide a custom path.
<td class="size">4</td> <br><br>
<td class="act"><a href="spieler.php?s=4&gp_type=custom&custom_url=gpack/travian_t4/">Activate</a></td> <span class="alert">ATTENTION! Use only trustworthy graphic packs</span>
</td>
</tr>
<td class="down"><a href="gpack/download/travian_default.zip" target="_blank">Download</a></td> <tr>
</tr> <th class="empty"></th>
</tbody> </tr>
<tr>
<td>
<label>
<input type="radio" class="radio" name="gp_type" value="custom" checked="checked" />
User-defined graphic pack
</label>
<input
class="text"
type="text"
name="custom_url"
value="<?php echo $session->gpack; ?>"
onclick="document.gp_selection.gp_type[1].checked = true"
/>
<br />
<div class="example">
Example:
<span class="path">file:///C:/Travian/gpack/</span>
or
<span class="path">http://www.travian.org/user/gpack/</span>
</div>
<center>
<div class="example">
Default:
<span class="path"><?php echo GP_LOCATE; ?></span>
</div>
</center>
</td>
</tr>
</tbody>
</table> </table>
<?php
}else{ <p class="btn">
header("Location: ".$_SERVER['PHP_SELF']."?uid=".$session->uid); <button name="gp_selection_button" value="ok" class="trav_buttons" id="btn_ok">
exit; Ok
} </button>
?> </p>
</form>
<!-- ========================= AVAILABLE PACKS ========================= -->
<table cellpadding="1" cellspacing="1" id="download">
<thead>
<tr>
<th colspan="4">More graphic packs</th>
</tr>
<tr>
<td>Name</td>
<td>Size in MB</td>
<td>Activate</td>
<td>Download</td>
</tr>
</thead>
<tbody>
<tr>
<td class="nam">Travian Default</td>
<td class="size">4</td>
<td class="act">
<a href="spieler.php?s=4&gp_type=custom&custom_url=gpack/travian_default/">
Activate
</a>
</td>
<td class="down">
<a href="gpack/download/travian_default.zip" target="_blank">
Download
</a>
</td>
</tr>
<tr>
<td class="nam">Travian T4 Style</td>
<td class="size">4</td>
<td class="act">
<a href="spieler.php?s=4&gp_type=custom&custom_url=gpack/travian_t4/">
Activate
</a>
</td>
<td class="down">
<a href="gpack/download/travian_default.zip" target="_blank">
Download
</a>
</td>
</tr>
</tbody>
</table>
<?php
} else {
// fallback dacă GP_ENABLE este dezactivat
header("Location: " . $_SERVER['PHP_SELF'] . "?uid=" . $session->uid);
exit;
}
?>
+1 -1
View File
@@ -5,7 +5,7 @@
## Filename index.php ## ## Filename index.php ##
## Developed by: aggenkeech ## ## Developed by: aggenkeech ##
## License: TravianZ Project ## ## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## ## ## ##
################################################################################# #################################################################################
?> ?>
+2 -2
View File
@@ -5,12 +5,12 @@
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ## ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ## ## --------------------------------------------------------------------------- ##
## Project: TravianZ ## ## Project: TravianZ ##
## Version: 01.09.2013 ## ## Version: 06.05.2026 ##
## Filename medal.php ## ## Filename medal.php ##
## Developed by: Dzoki ## ## Developed by: Dzoki ##
## Fixed by: Shadow / Skype : cata7007 ## ## Fixed by: Shadow / Skype : cata7007 ##
## License: TravianZ Project ## ## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2013. All rights reserved. ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ## ## URLs: http://travian.shadowss.ro ##
## Source code: http://github.com/Shadowss/TravianZ-by-Shadow/ ## ## Source code: http://github.com/Shadowss/TravianZ-by-Shadow/ ##
## ## ## ##
+78 -16
View File
@@ -1,19 +1,81 @@
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ ##
## Version: 06.05.2026 ##
## Filename menu.tpl ##
## Refactored by Shadow ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ##
## Source code: http://github.com/Shadowss/TravianZ/ ##
## ##
#################################################################################
// determinăm UID sigur (evităm repetarea directă $_GET peste tot)
$menuUid = isset($_GET['uid']) ? (int)$_GET['uid'] : (int)$session->uid;
// helper simplu pentru "selected"
$selectedUid = isset($_GET['uid']);
$sParam = isset($_GET['s']) ? (int)$_GET['s'] : null;
?>
<div id="textmenu"> <div id="textmenu">
<a href="spieler.php?uid=<?php if(isset($_GET['uid'])) { echo $_GET['uid']; } else { echo $session->uid; } ?>" <?php if(isset($_GET['uid'])) { echo "class=\"selected\""; } ?>>Overview</a>
| <a href="spieler.php?s=1" <?php if(isset($_GET['s']) && $_GET['s'] == 1) { echo "class=\"selected\""; } ?>>Profile</a> <!-- ================= OVERVIEW ================= -->
| <a href="spieler.php?s=2" <?php if(isset($_GET['s']) && $_GET['s'] == 2) { echo "class=\"selected\""; } ?>>Preferences</a> <a href="spieler.php?uid=<?php echo $menuUid; ?>"
| <a href="spieler.php?s=3" <?php if(isset($_GET['s']) && $_GET['s'] == 3) { echo "class=\"selected\""; } ?>>Account</a> <?php echo $selectedUid ? 'class="selected"' : ''; ?>>
<?php Overview
if(NEW_FUNCTIONS_VACATION){ </a>
?>
| <a href="spieler.php?s=5" <?php if(isset($_GET['s']) && $_GET['s'] == 5) { echo "class=\"selected\""; } ?>>Vacation</a> |
<?php
} <!-- ================= PROFILE ================= -->
if(GP_ENABLE) { <a href="spieler.php?s=1"
?> <?php echo ($sParam === 1) ? 'class="selected"' : ''; ?>>
| <a href="spieler.php?s=4" <?php if(isset($_GET['s']) && $_GET['s'] == 4) { echo "class=\"selected\""; } ?>>Graphic pack</a> Profile
<?php </a>
}
?> |
<!-- ================= PREFERENCES ================= -->
<a href="spieler.php?s=2"
<?php echo ($sParam === 2) ? 'class="selected"' : ''; ?>>
Preferences
</a>
|
<!-- ================= ACCOUNT ================= -->
<a href="spieler.php?s=3"
<?php echo ($sParam === 3) ? 'class="selected"' : ''; ?>>
Account
</a>
<?php
// ================= VACATION MODE =================
if (defined('NEW_FUNCTIONS_VACATION') && NEW_FUNCTIONS_VACATION) {
?>
|
<a href="spieler.php?s=5"
<?php echo ($sParam === 5) ? 'class="selected"' : ''; ?>>
Vacation
</a>
<?php
}
// ================= GRAPHIC PACK =================
if (defined('GP_ENABLE') && GP_ENABLE) {
?>
|
<a href="spieler.php?s=4"
<?php echo ($sParam === 4) ? 'class="selected"' : ''; ?>>
Graphic pack
</a>
<?php
}
?>
</div> </div>
+46 -16
View File
@@ -1,19 +1,49 @@
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ ##
## Version: 06.05.2026 ##
## Filename menu.tpl ##
## Refactored by Shadow ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ##
## Source code: http://github.com/Shadowss/TravianZ/ ##
## ##
#################################################################################
// UID sigur (evităm repetarea $_GET)
$menuUid = isset($_GET['uid']) ? (int)$_GET['uid'] : (int)$session->uid;
$hasUid = isset($_GET['uid']);
?>
<div id="textmenu"> <div id="textmenu">
<a href="spieler.php?uid=<?php if(isset($_GET['uid'])) { echo $_GET['uid']; } else { echo $session->uid; } ?>" <?php if(isset($_GET['uid'])) { echo "class=\"selected\""; } ?>>Overview</a>
| <span class=none><b>Profile</b></span> <!-- ================= OVERVIEW (ACTIVE) ================= -->
| <span class=none><b>Preferences</b></span> <a href="spieler.php?uid=<?php echo $menuUid; ?>"
| <span class=none><b>Account</b></span> <?php echo $hasUid ? 'class="selected"' : ''; ?>>
<?php Overview
if(NEW_FUNCTIONS_VACATION){ </a>
?>
| <span class=none><b>Vacation</b></span> |
<?php
} <!-- ================= DISABLED ITEMS ================= -->
if(GP_ENABLE) { <span class="none"><b>Profile</b></span>
?> |
| <span class=none><b>Graphic pack</b></span> <span class="none"><b>Preferences</b></span>
<?php |
} <span class="none"><b>Account</b></span>
?>
<?php if (defined('NEW_FUNCTIONS_VACATION') && NEW_FUNCTIONS_VACATION) { ?>
|
<span class="none"><b>Vacation</b></span>
<?php } ?>
<?php if (defined('GP_ENABLE') && GP_ENABLE) { ?>
|
<span class="none"><b>Graphic pack</b></span>
<?php } ?>
</div> </div>
+24 -2
View File
@@ -1,4 +1,26 @@
<?php <?php
header("Location: dorf1.php");
exit; #################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Project: TravianZ ##
## Version: 06.05.2026 ##
## Filename notfound.tpl ##
## Refactored by Shadow ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ##
## Source code: http://github.com/Shadowss/TravianZ/ ##
## ##
#################################################################################
// Evităm warning dacă output a început deja
if (!headers_sent()) {
header("Location: dorf1.php");
exit;
} else {
// fallback sigur dacă headers already sent
echo '<script>window.location.href="dorf1.php";</script>';
exit;
}
?> ?>
+321 -185
View File
@@ -4,223 +4,359 @@
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ## ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ## ## --------------------------------------------------------------------------- ##
## Project: TravianZ ## ## Project: TravianZ ##
## Version: 01.09.2013 ## ## Version: 06.05.2026 ##
## Filename overview.php ## ## Filename overview.tpl ##
## Developed by: Dzoki ## ## Refactored by Shadow ##
## Fixed by: Shadow / Skype : cata7007 ##
## License: TravianZ Project ## ## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2013. All rights reserved. ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ## ## URLs: http://travian.shadowss.ro ##
## Source code: http://github.com/Shadowss/TravianZ/ ## ## Source code: http://github.com/Shadowss/TravianZ/ ##
## ## ## ##
################################################################################# #################################################################################
// =========================
// SECURITY: sanitize UID
// =========================
$uid = isset($_GET['uid']) ? (int)$_GET['uid'] : (int)$session->uid;
// =========================
// RANK PROCESS
// =========================
$ranking->procRankReq($_GET); $ranking->procRankReq($_GET);
$_GET['uid'] = preg_replace("/[^0-9]/","",$_GET['uid']);
$displayarray = $database->getUserArray($_GET['uid'],1);
// ensure safe overwrite
$_GET['uid'] = $uid;
$varmedal = $database->getProfileMedal($_GET['uid']); // =========================
// USER DATA
// =========================
$displayarray = $database->getUserArray($uid, 1);
$varmedal = $database->getProfileMedal($uid);
$profiel="".$displayarray['desc1']."".md5('skJkev3')."".$displayarray['desc2'].""; // =========================
// PROFILE SAFE MERGE
// =========================
// marker legacy (păstrat pentru compatibilitate DB)
$profileSeparator = md5('skJkev3');
// păstrăm exact formatul original (IMPORTANT pentru medal.php)
$profiel = $displayarray['desc1'] . $profileSeparator . $displayarray['desc2'];
// medal.php se ocupă de procesare (NU îi strica inputul)
require("medal.php"); require("medal.php");
$profiel=explode("".md5('skJkev3')."", $profiel);
$varray = $database->getProfileVillages($_GET['uid']); // split DUPĂ medal processing
$profiel = explode($profileSeparator, $profiel);
// safety fallback
if (!isset($profiel[0])) $profiel[0] = '';
if (!isset($profiel[1])) $profiel[1] = '';
// =========================
// VILLAGES + POPULATION
// =========================
$varray = $database->getProfileVillages($uid);
$totalpop = 0; $totalpop = 0;
foreach($varray as $vil) {
$totalpop += $vil['pop']; foreach ($varray as $vil) {
$totalpop += (int)$vil['pop'];
} }
?> ?>
<h1>Player profile</h1> <h1>Player profile</h1>
<?php <?php
if($_GET['uid'] == $session->uid) { // =========================
if($session->sit == 0){ // MENU SWITCH (SELF vs SIT)
include("menu.tpl"); // =========================
}else{ if ($uid == $session->uid) {
include("menu2.tpl"); if ($session->sit == 0) {
} include("menu.tpl");
} else {
include("menu2.tpl");
}
} }
?> ?>
<table id="profile" cellpadding="1" cellspacing="1" >
<thead> <table id="profile" cellpadding="1" cellspacing="1">
<tr>
<th colspan="2">Player <?php echo $displayarray['username']; ?></th> <thead>
</tr>
<tr>
<th colspan="2">
Player <?php echo htmlspecialchars($displayarray['username'], ENT_QUOTES, 'UTF-8'); ?>
</th>
</tr>
<?php <?php
if($displayarray['access'] == ADMIN) echo "<tr><th colspan='2'><font color='Red'><center><b>This player is Admin.</b></font></center></th></tr>"; // =========================
if($displayarray['access'] == MULTIHUNTER) echo "<tr><th colspan='2'><font color='Blue'><center><b>This player is Multihunter.</b></font></center></th></tr>"; // STATUS FLAGS
if($displayarray['access'] == BANNED) echo "<tr><th colspan='2'><font color='Green'><center><b>This player is BANNED.</b></font></center></th></tr>"; // =========================
if($displayarray['vac_mode'] == 1) echo "<tr><th colspan='2'><font color='Maroon'><center><b>This player is on VACATION.</b></font></center></th></tr>"; if ($displayarray['access'] == ADMIN)
echo "<tr><th colspan='2'><font color='Red'><center><b>This player is Admin.</b></center></font></th></tr>";
if ($displayarray['access'] == MULTIHUNTER)
echo "<tr><th colspan='2'><font color='Blue'><center><b>This player is Multihunter.</b></center></font></th></tr>";
if ($displayarray['access'] == BANNED)
echo "<tr><th colspan='2'><font color='Green'><center><b>This player is BANNED.</b></center></font></th></tr>";
if ($displayarray['vac_mode'] == 1)
echo "<tr><th colspan='2'><font color='Maroon'><center><b>This player is on VACATION.</b></center></font></th></tr>";
?> ?>
<tr>
<td>Details</td>
<td>Description</td>
</tr> <tr>
</thead><tbody> <td>Details</td>
<tr> <td>Description</td>
<td class="empty"></td><td class="empty"></td> </tr>
</tr>
<tr>
<td class="details">
<table cellpadding="0" cellspacing="0">
<?php if($displayarray['access'] == BANNED){ echo "<tr><td colspan='2'><center><b>Banned</b></center></td></tr>"; } ?> </thead>
<tr> <tbody>
<th>Rank</th> <tr>
<td><?php echo $ranking->getUserRank($displayarray['id']); ?></td> <td class="empty"></td>
</tr> <td class="empty"></td>
<tr> </tr>
<th>Tribe</th>
<td><?php
$tribeArrays = [TRIBE1, TRIBE2, TRIBE3, TRIBE4, TRIBE5];
echo $tribeArrays[$displayarray['tribe'] - 1];
?></td>
</tr>
<tr> <tr>
<th>Alliance</th>
<td><?php
if($displayarray['alliance'] == 0) echo "-";
else
{
$displayalliance = $database->getAllianceName($displayarray['alliance']);
echo "<a href=\"allianz.php?aid=".$displayarray['alliance']."\">".$displayalliance."</a>";
} ?></td>
</tr>
<tr>
<th>Villages</th>
<td><?php echo count($varray);?></td>
</tr> <td class="details">
<tr>
<th>Population</th>
<td><?php echo $totalpop; ?></td>
</tr>
<?php
//Date of Birth
if(isset($displayarray['birthday']) && $displayarray['birthday'] != 0) {
$age = date('Y') - substr($displayarray['birthday'], 0, 4);
if ((date('m') - substr($displayarray['birthday'], 5, 2)) < 0) $age --;
elseif ((date('m') - substr($displayarray['birthday'], 5, 2)) == 0){
if(date('d') < substr($displayarray['birthday'], 8, 2)) $age --;
}
echo "<tr><th>Age</th><td>$age</td></tr>";
}
//Gender
if(isset($displayarray['gender']) && $displayarray['gender'] != 0) {
$gender = ($displayarray['gender']== 1)? "Male" : "Female";
echo "<tr><th>Gender</th><td>".$gender."</td></tr>";
}
//Location
if($displayarray['location'] != "") {
echo "<tr><th>Location</th><td>".$displayarray['location']."</td></tr>";
}
?>
<tr>
<td colspan="2" class="empty"></td>
</tr>
<tr>
<?php if(preg_replace("/[^0-9]/","",$_GET['uid']) == $session->uid) {
if($session->sit == 0){
echo "<td colspan=\"2\"> <a href=\"spieler.php?s=1\">&raquo; Change profile</a></td>";
}else{
echo "<td colspan=\"2\"> <span class=none><b>&raquo; Change profile</b></span></td>";
}
} else {
echo "<td colspan=\"2\"> <a href=\"nachrichten.php?t=1&amp;id=".$_GET['uid']."\">&raquo; Write message</a></td>";
}
?>
</tr>
<!--<tr><td colspan="2"><a href="nachrichten.php?t=1&id=0"><font color="Red">&raquo; Report Player</font></a></td></tr>-->
<tr>
<td colspan="2" class="desc2">
<div class="desc2div"><?php echo nl2br($profiel[0]); ?></div>
</td>
</tr>
</table>
</td> <table cellpadding="0" cellspacing="0">
<td class="desc1" >
<div class="desc1div"><?php echo nl2br($profiel[1]); ?> <?php
if ($displayarray['access'] == BANNED) {
echo "<tr><td colspan='2'><center><b>Banned</b></center></td></tr>";
}
?>
<tr>
<th>Rank</th>
<td><?php echo $ranking->getUserRank($displayarray['id']); ?></td>
</tr>
<tr>
<th>Tribe</th>
<td>
<?php
$tribeArrays = [TRIBE1, TRIBE2, TRIBE3, TRIBE4, TRIBE5];
echo $tribeArrays[$displayarray['tribe'] - 1];
?>
</td>
</tr>
<tr>
<th>Alliance</th>
<td>
<?php
if ($displayarray['alliance'] == 0) {
echo "-";
} else {
$displayalliance = $database->getAllianceName($displayarray['alliance']);
echo '<a href="allianz.php?aid=' . (int)$displayarray['alliance'] . '">' .
htmlspecialchars($displayalliance, ENT_QUOTES, 'UTF-8') .
'</a>';
}
?>
</td>
</tr>
<tr>
<th>Villages</th>
<td><?php echo count($varray); ?></td>
</tr>
<tr>
<th>Population</th>
<td><?php echo (int)$totalpop; ?></td>
</tr>
<?php
// =========================
// AGE
// =========================
if (!empty($displayarray['birthday'])) {
$age = date('Y') - substr($displayarray['birthday'], 0, 4);
if ((date('m') - substr($displayarray['birthday'], 5, 2)) < 0) $age--;
elseif ((date('m') - substr($displayarray['birthday'], 5, 2)) == 0) {
if (date('d') < substr($displayarray['birthday'], 8, 2)) $age--;
}
echo "<tr><th>Age</th><td>$age</td></tr>";
}
// =========================
// GENDER
// =========================
if (!empty($displayarray['gender'])) {
$gender = ($displayarray['gender'] == 1) ? "Male" : "Female";
echo "<tr><th>Gender</th><td>$gender</td></tr>";
}
// =========================
// LOCATION
// =========================
if (!empty($displayarray['location'])) {
echo "<tr><th>Location</th><td>" .
htmlspecialchars($displayarray['location'], ENT_QUOTES, 'UTF-8') .
"</td></tr>";
}
?>
<tr>
<td colspan="2" class="empty"></td>
</tr>
<tr>
<?php
// =========================
// ACTION BUTTONS
// =========================
// Natar tribe (de obicei 5 în Travian-like setups)
$isNatar = (isset($displayarray['tribe']) && $displayarray['tribe'] == 5);
// Nature special account (fixed UID = 2)
$isNature = ($uid == 2);
if ($uid == $session->uid) {
// =========================
// OWN PROFILE ACTION
// =========================
if ($session->sit == 0) {
echo '<td colspan="2"><a href="spieler.php?s=1">&raquo; Change profile</a></td>';
} else {
echo '<td colspan="2"><span class="none"><b>&raquo; Change profile</b></span></td>';
}
} else {
// =========================
// BLOCK SYSTEM ACCOUNTS
// =========================
if ($isNatar || $isNature) {
echo '<td colspan="2"><span class="none"><b>&raquo; Write message not available</b></span></td>';
} else {
echo '<td colspan="2"><a href="nachrichten.php?t=1&amp;id=' . (int)$uid . '">&raquo; Write message</a></td>';
}
}
?>
</tr>
<tr>
<td colspan="2" class="desc2">
<div class="desc2div">
<?php echo nl2br($profiel[0]); ?>
</div>
</td>
</tr>
</div>
</td>
</tr>
</tbody>
</table> </table>
<table cellpadding="1" cellspacing="1" id="villages"> </td>
<thead>
<tr>
<th colspan="<?php echo NEW_FUNCTIONS_OASIS ? 4 : 3; ?>">Villages</th>
</tr>
<tr>
<td>Name</td>
<?php if(NEW_FUNCTIONS_OASIS){ ?>
<td>Oasis</td>
<?php } ?>
<td>Inhabitants</td>
<td>Coordinates</td>
</tr>
</thead>
<tbody>
<?php
foreach($varray as $vil) {
$hasArtifact = $database->villageHasArtefact($vil['wref']);
$coor = $database->getCoor($vil['wref']);
echo "<tr><td class=\"nam\"><a href=\"karte.php?d=".$vil['wref']."&amp;c=".$generator->getMapCheck($vil['wref'])."\">".$vil['name']."</a>";
if($vil['capital'] == 1) echo "<span class=\"none3\"> (Capital)</span>";
if(NEW_FUNCTIONS_DISPLAY_ARTIFACT){
if($hasArtifact) echo "<span class=\"none3\"> (Artifact)</span>";
}
if(NEW_FUNCTIONS_DISPLAY_WONDER){
if($vil['natar'] == 1) echo "<span class=\"none3\"> (WoW)</span>";
}
if(NEW_FUNCTIONS_OASIS){ <td class="desc1">
echo "<td class=\"hab\">"; <div class="desc1div">
$oases = $database->getOasis($vil['wref']); <?php echo nl2br($profiel[1]); ?>
foreach ($oases as $oasis) { </div>
switch ($oasis['type']) { </td>
case 1:
case 2: </tr>
echo "<img class='r100' src='img/x.gif' title='+25% Lumber'> ";
break; </tbody>
case 3:
echo "<img class='r200' src='img/x.gif' title='+25% Lumber +25% Crop'> "; </table>
break;
case 4: <!-- ========================= VILLAGES ========================= -->
case 5:
echo "<img class='r400' src='img/x.gif' title='+25% Clay'> "; <table cellpadding="1" cellspacing="1" id="villages">
break;
case 6: <thead>
echo "<img class='r500' src='img/x.gif' title='+25% Clay +25% Crop'> ";
break; <tr>
case 7: <th colspan="<?php echo (defined('NEW_FUNCTIONS_OASIS') && NEW_FUNCTIONS_OASIS) ? 4 : 3; ?>">
case 8: Villages
echo "<img class='r700' src='img/x.gif' title='+25% Iron'> "; </th>
break; </tr>
case 9:
echo "<img class='r800' src='img/x.gif' title='+25% Iron +25% Crop'> "; <tr>
break; <td>Name</td>
case 10:
case 11: <?php if (defined('NEW_FUNCTIONS_OASIS') && NEW_FUNCTIONS_OASIS) { ?>
echo "<img class='r1000' src='img/x.gif' title='+25% Crop'> "; <td>Oasis</td>
break; <?php } ?>
case 12:
echo "<img class='r1100' src='img/x.gif' title='+50% Crop'> "; <td>Inhabitants</td>
break; <td>Coordinates</td>
} </tr>
}
echo "</td>"; </thead>
<tbody>
<?php
foreach ($varray as $vil) {
$hasArtifact = $database->villageHasArtefact($vil['wref']);
$coor = $database->getCoor($vil['wref']);
echo "<tr><td class=\"nam\">
<a href=\"karte.php?d=" . (int)$vil['wref'] . "&amp;c=" . $generator->getMapCheck($vil['wref']) . "\">"
. htmlspecialchars($vil['name'], ENT_QUOTES, 'UTF-8') .
"</a>";
if ($vil['capital'] == 1) echo "<span class=\"none3\"> (Capital)</span>";
if (defined('NEW_FUNCTIONS_DISPLAY_ARTIFACT') && NEW_FUNCTIONS_DISPLAY_ARTIFACT) {
if ($hasArtifact) echo "<span class=\"none3\"> (Artifact)</span>";
}
if (defined('NEW_FUNCTIONS_DISPLAY_WONDER') && NEW_FUNCTIONS_DISPLAY_WONDER) {
if ($vil['natar'] == 1) echo "<span class=\"none3\"> (WoW)</span>";
}
// OASIS
if (defined('NEW_FUNCTIONS_OASIS') && NEW_FUNCTIONS_OASIS) {
echo "<td class=\"hab\">";
$oases = $database->getOasis($vil['wref']);
foreach ($oases as $oasis) {
switch ($oasis['type']) {
case 1:
case 2: echo "<img class='r100' src='img/x.gif' title='+25% Lumber'> "; break;
case 3: echo "<img class='r200' src='img/x.gif' title='+25% Lumber +25% Crop'> "; break;
case 4:
case 5: echo "<img class='r400' src='img/x.gif' title='+25% Clay'> "; break;
case 6: echo "<img class='r500' src='img/x.gif' title='+25% Clay +25% Crop'> "; break;
case 7:
case 8: echo "<img class='r700' src='img/x.gif' title='+25% Iron'> "; break;
case 9: echo "<img class='r800' src='img/x.gif' title='+25% Iron +25% Crop'> "; break;
case 10:
case 11: echo "<img class='r1000' src='img/x.gif' title='+25% Crop'> "; break;
case 12: echo "<img class='r1100' src='img/x.gif' title='+50% Crop'> "; break;
} }
echo "<td class=\"hab\">".$vil['pop']."</td><td class=\"aligned_coords\">";
echo "<div class=\"cox\">(".$coor['x']."</div><div class=\"pi\">|</div><div class=\"coy\">".$coor['y'].")</div></td></tr>";
} }
echo "</tbody></table>";
echo "</td>";
}
echo "<td class=\"hab\">" . (int)$vil['pop'] . "</td>
<td class=\"aligned_coords\">
<div class=\"cox\">(" . $coor['x'] . "</div>
<div class=\"pi\">|</div>
<div class=\"coy\">" . $coor['y'] . ")</div></td></tr>";
}
?> ?>
</tbody>
</table>
+287 -135
View File
@@ -1,95 +1,182 @@
<?php <?php
if(isset($_GET['del']) && is_numeric($_GET['del'])){
$database->removeLinks($_GET['del'],$session->uid);
header("Location: spieler.php?s=2");
exit;
}
################################################################################# #################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ## ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ## ## --------------------------------------------------------------------------- ##
## Project: TravianZ ## ## Project: TravianZ ##
## Version: 01.09.2013 ## ## Version: 06.05.2026 ##
## Filename preference.php ## ## Filename preference.tpl ##
## Developed by: Dzoki ## ## Refactored by Shadow ##
## Fixed by: Shadow / Skype : cata7007 ##
## License: TravianZ Project ## ## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ## ## URLs: http://travian.shadowss.ro ##
## Source code: http://github.com/Shadowss/TravianZ/ ## ## Source code: http://github.com/Shadowss/TravianZ/ ##
## ## ## ##
################################################################################# #################################################################################
// Save new link or just edit a link
if(isset($_POST['ft']) && $_POST['ft'] == 'p3'){ // =========================
// DELETE LINK ACTION
// =========================
if (isset($_GET['del']) && is_numeric($_GET['del'])) {
$delId = (int)$_GET['del'];
// remove user link safely (owner check handled inside function)
$database->removeLinks($delId, $session->uid);
header("Location: spieler.php?s=2");
exit;
}
// =========================
// LEGACY EARLY EXIT
// =========================
if (isset($_POST['ft']) && $_POST['ft'] == 'p3') {
return; return;
} }
if(isset($_POST['nr0']) || isset($_POST['id0']) || isset($_POST['linkname0']) || isset($_POST['linkziel0'])) { // =========================
// SAVE / UPDATE LINKS
// =========================
if (
isset($_POST['nr0']) ||
isset($_POST['id0']) ||
isset($_POST['linkname0']) ||
isset($_POST['linkziel0'])
) {
$links = []; $links = [];
// let's do some complicated code x'D // =========================
foreach($_POST as $key => $value) { // PARSE POST DATA
if(substr($key, 0, 2) == 'nr') { // =========================
foreach ($_POST as $key => $value) {
$value = trim($value);
// position field
if (strpos($key, 'nr') === 0) {
$i = substr($key, 2); $i = substr($key, 2);
$links[$i]['nr'] = mysqli_real_escape_string($database->dblink, $value); $links[$i]['nr'] = (int)$value;
} }
if(substr($key, 0, 2) == 'id') { // id field
if (strpos($key, 'id') === 0) {
$i = substr($key, 2); $i = substr($key, 2);
$links[$i]['id'] = mysqli_real_escape_string($database->dblink, $value); $links[$i]['id'] = (int)$value;
} }
if(substr($key, 0, 8) == 'linkname') { // link name (escaped for SQL safety)
if (strpos($key, 'linkname') === 0) {
$i = substr($key, 8); $i = substr($key, 8);
$links[$i]['linkname'] = htmlspecialchars(mysqli_real_escape_string($database->dblink, $value)); $links[$i]['linkname'] = mysqli_real_escape_string($database->dblink, $value);
} }
if(substr($key, 0, 8) == 'linkziel') { // link url (escaped for SQL safety)
if (strpos($key, 'linkziel') === 0) {
$i = substr($key, 8); $i = substr($key, 8);
$links[$i]['linkziel'] = htmlspecialchars(mysqli_real_escape_string($database->dblink, $value)); $links[$i]['linkziel'] = mysqli_real_escape_string($database->dblink, $value);
} }
} }
// Save // =========================
foreach($links as $link) { // PROCESS LINKS (ADD / UPDATE / DELETE)
settype($link['nr'], 'int'); // =========================
foreach ($links as $link) {
if(trim($link['nr']) != '' AND trim($link['linkname']) != '' AND trim($link['linkziel']) != '' AND trim($link['id']) == '') { $nr = isset($link['nr']) ? (int)$link['nr'] : 0;
// Add new link $id = isset($link['id']) ? (int)$link['id'] : 0;
$userid = (int) $session->uid; $name = isset($link['linkname']) ? trim($link['linkname']) : '';
$query = mysqli_query($database->dblink,'INSERT INTO `' . TB_PREFIX . 'links` (`userid`, `name`, `url`, `pos`) VALUES (' . $userid . ', \'' . $link['linkname'] . '\', \'' . $link['linkziel'] . '\', ' . $link['nr'] . ')'); $url = isset($link['linkziel']) ? trim($link['linkziel']) : '';
// =========================
// ADD NEW LINK
// =========================
if ($nr !== 0 && $name !== '' && $url !== '' && $id === 0) {
$userid = (int)$session->uid;
mysqli_query(
$database->dblink,
"INSERT INTO `" . TB_PREFIX . "links`
(`userid`, `name`, `url`, `pos`)
VALUES
($userid, '$name', '$url', $nr)"
);
// =========================
// UPDATE EXISTING LINK
// =========================
} elseif ($nr !== 0 && $name !== '' && $url !== '' && $id > 0) {
$id = (int)$id;
$query = mysqli_query(
$database->dblink,
"SELECT userid FROM `" . TB_PREFIX . "links` WHERE id = $id"
);
} elseif(trim($link['nr']) != '' AND trim($link['linkname']) != '' AND trim($link['linkziel']) != '' AND trim($link['id']) != '') {
// Update link
$query = mysqli_query($database->dblink,'SELECT userid FROM `' . TB_PREFIX . 'links` WHERE `id` = ' . $link['id']);
$data = mysqli_fetch_assoc($query); $data = mysqli_fetch_assoc($query);
// May the user update this entry? // ownership check
if($data['userid'] == $session->uid) { if ($data && (int)$data['userid'] === (int)$session->uid) {
$query2 = mysqli_query($database->dblink,'UPDATE `' . TB_PREFIX . 'links` SET `name` = \'' . $link['linkname'] . '\', `url` = \'' . $link['linkziel'] . '\', `pos` = ' . $link['nr'] . ' WHERE `id` = ' . $link['id']);
mysqli_query(
$database->dblink,
"UPDATE `" . TB_PREFIX . "links`
SET name='$name', url='$url', pos=$nr
WHERE id=$id"
);
} }
} elseif(trim($link['nr']) == '' AND trim($link['linkname']) == '' AND trim($link['linkziel']) == '' AND trim($link['id']) != '') {
// Delete entry // =========================
$query = mysqli_query($database->dblink,'SELECT userid FROM `' . TB_PREFIX . 'links` WHERE `id` = ' . $link['id']); // DELETE EMPTY ENTRY
// =========================
} elseif ($nr === 0 && $name === '' && $url === '' && $id > 0) {
$id = (int)$id;
$query = mysqli_query(
$database->dblink,
"SELECT userid FROM `" . TB_PREFIX . "links` WHERE id = $id"
);
$data = mysqli_fetch_assoc($query); $data = mysqli_fetch_assoc($query);
// May the user delete this entry? // ownership check
if($data['userid'] == $session->uid) { if ($data && (int)$data['userid'] === (int)$session->uid) {
$query2 = mysqli_query($database->dblink,'DELETE FROM `' . TB_PREFIX . 'links` WHERE `id` = ' . $link['id']);
mysqli_query(
$database->dblink,
"DELETE FROM `" . TB_PREFIX . "links` WHERE id = $id"
);
} }
} }
} }
// legacy refresh behavior
echo '<meta http-equiv="refresh" content="0">'; echo '<meta http-equiv="refresh" content="0">';
} }
// =========================
// LOAD LINKS
// =========================
$query = mysqli_query(
$database->dblink,
"SELECT * FROM `" . TB_PREFIX . "links`
WHERE userid = " . (int)$session->uid . "
ORDER BY pos ASC"
) or die(mysqli_error($database->dblink));
// Fetch all links
$query = mysqli_query($database->dblink,'SELECT * FROM `' . TB_PREFIX . 'links` WHERE `userid` = ' . (int) $session->uid . ' ORDER BY `pos` ASC') or die(mysqli_error($database->dblink));
$links = []; $links = [];
while($data = mysqli_fetch_assoc($query)) $links[] = $data; while ($data = mysqli_fetch_assoc($query)) {
$links[] = $data;
}
//Code for preference (map,timezone,timeformat,etc.) // =========================
// USER SETTINGS SAVE
if(isset($_POST['v1']) || isset($_POST['v2']) || isset($_POST['timezone'])) { // =========================
if (isset($_POST['v1']) || isset($_POST['v2']) || isset($_POST['timezone'])) {
$v1 = isset($_POST['v1']) ? 1 : 0; $v1 = isset($_POST['v1']) ? 1 : 0;
$v2 = isset($_POST['v2']) ? 1 : 0; $v2 = isset($_POST['v2']) ? 1 : 0;
@@ -99,21 +186,22 @@ if(isset($_POST['v1']) || isset($_POST['v2']) || isset($_POST['timezone'])) {
$v5 = isset($_POST['v5']) ? 1 : 0; $v5 = isset($_POST['v5']) ? 1 : 0;
$v6 = isset($_POST['v6']) ? 1 : 0; $v6 = isset($_POST['v6']) ? 1 : 0;
$timezone = isset($_POST['timezone']) ? intval($_POST['timezone']) : 1; $timezone = isset($_POST['timezone']) ? (int)$_POST['timezone'] : 1;
$tformat = isset($_POST['tformat']) ? intval($_POST['tformat']) : 0; $tformat = isset($_POST['tformat']) ? (int)$_POST['tformat'] : 0;
// update user preferences
$database->query(" $database->query("
UPDATE ".TB_PREFIX."users SET UPDATE " . TB_PREFIX . "users SET
v1 = $v1, v1=$v1,
v2 = $v2, v2=$v2,
v3 = $v3, v3=$v3,
map = $map, map=$map,
v4 = $v4, v4=$v4,
v5 = $v5, v5=$v5,
v6 = $v6, v6=$v6,
timezone = $timezone, timezone=$timezone,
tformat = $tformat tformat=$tformat
WHERE id = ".$session->uid." WHERE id=" . (int)$session->uid . "
"); ");
header("Location: spieler.php?s=2"); header("Location: spieler.php?s=2");
@@ -121,73 +209,152 @@ if(isset($_POST['v1']) || isset($_POST['v2']) || isset($_POST['timezone'])) {
} }
?> ?>
<!-- =========================
PAGE HEADER
========================= -->
<h1>Player profile</h1> <h1>Player profile</h1>
<?php include("menu.tpl"); ?> <?php include("menu.tpl"); ?>
<!-- =========================
DIRECT LINKS TABLE
========================= -->
<form action="spieler.php?s=2" method="POST"> <form action="spieler.php?s=2" method="POST">
<input type="hidden" name="ft" value="p2"> <input type="hidden" name="ft" value="p2">
<table cellpadding="1" cellspacing="1" id="links">
<thead>
<tr>
<th colspan="4">Direct links</th>
</tr>
<tr>
<td>Delete</td>
<td>No.</td>
<td>Link name</td>
<td>Link target</td>
</tr>
</thead>
<tbody>
<?php $i = 0; foreach($links as $link): ?>
<tr>
<td>
<a href="spieler.php?del=<?php echo $link['id']; ?>&s=2"><img class="del" src="img/x.gif" alt="delete" title="delete"></a>
</td>
<td class="nr"><input <?php if(!$session->plus){echo"disabled";} ?> class="text" type="text" name="nr<?php print $i; ?>" value="<?php print $link['pos']; ?>" size="1" maxlength="3" /><input type="hidden" name="id<?php print $i; ?>" value="<?php print $link['id']; ?>" /></td>
<td class="nam"><input <?php if(!$session->plus){echo"disabled";} ?> class="text" type="text" name="linkname<?php print $i; ?>" value="<?php print $link['name']; ?>" maxlength="30" /></td>
<td class="txt"><input <?php if(!$session->plus){echo"disabled";} ?> class="text" type="text" name="linkziel<?php print $i; ?>" value="<?php print $link['url']; ?>" maxlength="255" /></td>
</tr>
<?php ++$i; $last_pos = $link['pos']; endforeach; ?>
<tr>
<td></td>
<td class="nr"><input <?php if(!$session->plus){echo"disabled";} ?> class="text" type="text" name="nr<?php print $i; ?>" value="<?php print ($last_pos + 1); ?>" size="1" maxlength="3"></td>
<td class="nam"><input <?php if(!$session->plus){echo"disabled";} ?> class="text" type="text" name="linkname<?php print $i; ?>" value="" maxlength="30"></td>
<td class="txt"><input <?php if(!$session->plus){echo"disabled";} ?> class="text" type="text" name="linkziel<?php print $i; ?>" value="" maxlength="255"></td>
</tr>
</tbody>
</table>
<table cellpadding="1" cellspacing="1" id="links">
<thead>
<tr>
<th colspan="4">Direct links</th>
</tr>
<tr>
<td>Delete</td>
<td>No.</td>
<td>Link name</td>
<td>Link target</td>
</tr>
</thead>
<tbody>
<?php
$i = 0;
$last_pos = 0;
foreach ($links as $link):
$last_pos = (int)$link['pos'];
?>
<tr>
<td>
<a href="spieler.php?del=<?php echo (int)$link['id']; ?>&s=2">
<img class="del" src="img/x.gif" alt="delete" title="delete">
</a>
</td>
<td class="nr">
<input <?php if (!$session->plus) echo "disabled"; ?>
class="text"
type="text"
name="nr<?php echo $i; ?>"
value="<?php echo (int)$link['pos']; ?>"
size="1"
maxlength="3" />
<input type="hidden"
name="id<?php echo $i; ?>"
value="<?php echo (int)$link['id']; ?>" />
</td>
<td class="nam">
<input <?php if (!$session->plus) echo "disabled"; ?>
class="text"
type="text"
name="linkname<?php echo $i; ?>"
value="<?php echo htmlspecialchars($link['name'], ENT_QUOTES, 'UTF-8'); ?>"
maxlength="30" />
</td>
<td class="txt">
<input <?php if (!$session->plus) echo "disabled"; ?>
class="text"
type="text"
name="linkziel<?php echo $i; ?>"
value="<?php echo htmlspecialchars($link['url'], ENT_QUOTES, 'UTF-8'); ?>"
maxlength="255" />
</td>
</tr>
<?php
$i++;
endforeach;
?>
<!-- NEW EMPTY ROW -->
<tr>
<td></td>
<td class="nr">
<input <?php if (!$session->plus) echo "disabled"; ?>
class="text"
type="text"
name="nr<?php echo $i; ?>"
value="<?php echo ($last_pos + 1); ?>"
size="1"
maxlength="3">
</td>
<td class="nam">
<input <?php if (!$session->plus) echo "disabled"; ?>
class="text"
type="text"
name="linkname<?php echo $i; ?>"
value=""
maxlength="30">
</td>
<td class="txt">
<input <?php if (!$session->plus) echo "disabled"; ?>
class="text"
type="text"
name="linkziel<?php echo $i; ?>"
value=""
maxlength="255">
</td>
</tr>
</tbody>
</table>
<!-- =========================
AUTO COMPLETION
========================= -->
<table cellpadding="1" cellspacing="1" id="completion" class="set"> <table cellpadding="1" cellspacing="1" id="completion" class="set">
<thead> <thead>
<tr><th colspan="2">Auto completion</th></tr> <tr><th colspan="2">Auto completion</th></tr>
<tr><td colspan="2">Used for rally point and marketplace:</td></tr> <tr><td colspan="2">Used for rally point and marketplace:</td></tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td class="sel"> <td class="sel"><input class="check" type="checkbox" name="v1" value="1" <?php if($session->userinfo['v1']) echo 'checked'; ?>></td>
<input class="check" type="checkbox" name="v1" value="1" <?php if($session->userinfo['v1']) echo 'checked'; ?>>
</td>
<td>own villages</td> <td>own villages</td>
</tr> </tr>
<tr> <tr>
<td class="sel"> <td class="sel"><input class="check" type="checkbox" name="v2" value="1" <?php if($session->userinfo['v2']) echo 'checked'; ?>></td>
<input class="check" type="checkbox" name="v2" value="1" <?php if($session->userinfo['v2']) echo 'checked'; ?>>
</td>
<td>villages of the surroundings</td> <td>villages of the surroundings</td>
</tr> </tr>
<tr> <tr>
<td class="sel"> <td class="sel"><input class="check" type="checkbox" name="v3" value="1" <?php if($session->userinfo['v3']) echo 'checked'; ?>></td>
<input class="check" type="checkbox" name="v3" value="1" <?php if($session->userinfo['v3']) echo 'checked'; ?>>
</td>
<td>villages from players of the alliance</td> <td>villages from players of the alliance</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<!-- =========================
LARGE MAP
========================= -->
<table cellpadding="1" cellspacing="1" id="big_map" class="set"> <table cellpadding="1" cellspacing="1" id="big_map" class="set">
<thead> <thead>
<tr><th colspan="2">Large map</th></tr> <tr><th colspan="2">Large map</th></tr>
@@ -202,7 +369,9 @@ if(isset($_POST['v1']) || isset($_POST['v2']) || isset($_POST['timezone'])) {
</tbody> </tbody>
</table> </table>
<!-- =========================
REPORT FILTER
========================= -->
<table cellpadding="1" cellspacing="1" id="report_filter" class="set"> <table cellpadding="1" cellspacing="1" id="report_filter" class="set">
<thead> <thead>
<tr><th colspan="2">Report filter</th></tr> <tr><th colspan="2">Report filter</th></tr>
@@ -210,30 +379,26 @@ if(isset($_POST['v1']) || isset($_POST['v2']) || isset($_POST['timezone'])) {
<tbody> <tbody>
<tr> <tr>
<td class="sel"> <td class="sel"><input class="check" type="checkbox" name="v4" value="1" <?php if($session->userinfo['v4']) echo 'checked'; ?>></td>
<input class="check" type="checkbox" name="v4" value="1" <?php if($session->userinfo['v4']) echo 'checked'; ?>>
</td>
<td>No reports for transfers to own villages.</td> <td>No reports for transfers to own villages.</td>
</tr> </tr>
<tr> <tr>
<td class="sel"> <td class="sel"><input class="check" type="checkbox" name="v5" value="1" <?php if($session->userinfo['v5']) echo 'checked'; ?>></td>
<input class="check" type="checkbox" name="v5" value="1" <?php if($session->userinfo['v5']) echo 'checked'; ?>>
</td>
<td>No reports for transfers to foreign villages.</td> <td>No reports for transfers to foreign villages.</td>
</tr> </tr>
<tr> <tr>
<td class="sel"> <td class="sel"><input class="check" type="checkbox" name="v6" value="1" <?php if($session->userinfo['v6']) echo 'checked'; ?>></td>
<input class="check" type="checkbox" name="v6" value="1" <?php if($session->userinfo['v6']) echo 'checked'; ?>>
</td>
<td>No reports for transfers from foreign villages.</td> <td>No reports for transfers from foreign villages.</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<!-- =========================
TIME SETTINGS
========================= -->
<table cellpadding="1" cellspacing="1" id="time" class="set"> <table cellpadding="1" cellspacing="1" id="time" class="set">
<thead> <thead>
<tr><th colspan="2">Time preferences</th></tr> <tr><th colspan="2">Time preferences</th></tr>
@@ -288,30 +453,14 @@ if(isset($_POST['v1']) || isset($_POST['v2']) || isset($_POST['timezone'])) {
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Date</th> <th>Date</th>
<td> <td>
<label> <label><input class="radio" type="radio" name="tformat" value="0" <?php if($session->userinfo['tformat']==0) echo 'checked'; ?>> EU (dd.mm.yy 24h)</label><br>
<input class="radio" type="radio" name="tformat" value="0" <?php if($session->userinfo['tformat']==0) echo 'checked'; ?>> <label><input class="radio" type="radio" name="tformat" value="1" <?php if($session->userinfo['tformat']==1) echo 'checked'; ?>> US (mm/dd/yy 12h)</label><br>
EU (dd.mm.yy 24h) <label><input class="radio" type="radio" name="tformat" value="2" <?php if($session->userinfo['tformat']==2) echo 'checked'; ?>> UK (dd/mm/yy 12h)</label><br>
</label><br /> <label><input class="radio" type="radio" name="tformat" value="3" <?php if($session->userinfo['tformat']==3) echo 'checked'; ?>> ISO (yy/mm/dd 24h)</label>
<label>
<input class="radio" type="radio" name="tformat" value="1" <?php if($session->userinfo['tformat']==1) echo 'checked'; ?>>
US (mm/dd/yy 12h)
</label><br />
<label>
<input class="radio" type="radio" name="tformat" value="2" <?php if($session->userinfo['tformat']==2) echo 'checked'; ?>>
UK (dd/mm/yy 12h)
</label><br />
<label>
<input class="radio" type="radio" name="tformat" value="3" <?php if($session->userinfo['tformat']==3) echo 'checked'; ?>>
ISO (yy/mm/dd 24h)
</label>
</td> </td>
</tr> </tr>
@@ -319,9 +468,12 @@ ISO (yy/mm/dd 24h)
</tbody> </tbody>
</table> </table>
<!-- =========================
SAVE BUTTON
========================= -->
<p class="btn"> <p class="btn">
<td colspan="4"><input type="image" value="" name="s1" id="btn_ok" class="dynamic_img" src="img/x.gif" alt="OK" /></td> <input type="image" value="" name="s1" id="btn_ok" class="dynamic_img" src="img/x.gif" alt="OK" />
</p> </p>
</form> </form>
+237 -194
View File
@@ -1,221 +1,260 @@
<h1>Player profile</h1>
<?php <?php
################################################################################# #################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ## ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ## ## --------------------------------------------------------------------------- ##
## Project: TravianZ ## ## Project: TravianZ ##
## Version: 01.09.2013 ## ## Version: 06.05.2026 ##
## Filename profile.php ## ## Filename profile.tpl ##
## Developed by: Dzoki ## ## Refactored by Shadow ##
## Fixed by: Shadow / Skype : cata7007 ##
## License: TravianZ Project ## ## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2013. All rights reserved. ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ## ## URLs: http://travian.shadowss.ro ##
## Source code: http://github.com/Shadowss/TravianZ/ ## ## Source code: http://github.com/Shadowss/TravianZ/ ##
## ## ## ##
################################################################################# #################################################################################
// =========================
// MEDALS LOAD
// =========================
$varmedal = $database->getProfileMedal($session->uid); $varmedal = $database->getProfileMedal($session->uid);
include("menu.tpl"); ?> ?>
<!-- =========================
PAGE HEADER
========================= -->
<h1>Player profile</h1>
<?php include("menu.tpl"); ?>
<form action="spieler.php" method="POST"> <form action="spieler.php" method="POST">
<input type="hidden" name="ft" value="p1" /> <input type="hidden" name="ft" value="p1" />
<input type="hidden" name="id" value="<?php echo (isset($id) ? $id : ''); ?>" /> <input type="hidden" name="id" value="<?php echo isset($id) ? (int)$id : 0; ?>" />
<table cellpadding="1" cellspacing="1" id="edit" ><thead> <table cellpadding="1" cellspacing="1" id="edit">
<tr>
<th colspan="3">Player <?php echo $session->username; ?> </th>
</tr>
<tr>
<td colspan="2">Details</td>
<td>Description</td> <thead>
</tr> <tr>
</thead> <th colspan="3">Player <?php echo htmlspecialchars($session->username, ENT_QUOTES, 'UTF-8'); ?></th>
<tbody> </tr>
<tr> <tr>
<td colspan="2" class="empty"></td><td class="empty"></td></tr> <td colspan="2">Details</td>
<tr> <td>Description</td>
<?php </tr>
if($session->userinfo['birthday'] != 0) { </thead>
$bday = explode("-",$session->userinfo['birthday']);
}
else {
$bday = array('','','');
}
?>
<th>Birthday</th><td class="birth"><input tabindex="1" class="text day" type="text" name="tag" value="<?php echo $bday[2]; ?>" maxlength="2" /> <select tabindex="2" name="monat" size="" class="dropdown">
<option value="0"></option><option value="1" <?php if($bday[1] == 1) { echo "selected"; } ?>>Jan</option><option value="2"<?php if($bday[1] == 2) { echo "selected"; } ?>>Feb</option><option value="3"<?php if($bday[1] == 3) { echo "selected"; } ?>>Mar</option><option value="4"<?php if($bday[1] == 4) { echo "selected"; } ?>>Apr</option><option value="5"<?php if($bday[1] == 5) { echo "selected"; } ?>>May</option><option value="6"<?php if($bday[1] == 6) { echo "selected"; } ?>>June</option><option value="7"<?php if($bday[1] == 7) { echo "selected"; } ?>>July</option><option value="8"<?php if($bday[1] == 8) { echo "selected"; } ?>>Aug</option><option value="9"<?php if($bday[1] == 9) { echo "selected"; } ?>>Sep</option><option value="10"<?php if($bday[1] == 10) { echo "selected"; } ?>>Oct</option><option value="11"<?php if($bday[1] == 11) { echo "selected"; } ?>>Nov</option><option value="12"<?php if($bday[1] == 12) { echo "selected"; } ?>>Dec</option></select> <input tabindex="3" type="text" name="jahr" value="<?php echo $bday[0]; ?>" maxlength="4" class="text year"></td> <tbody>
<?php
$varray = $database->getProfileVillages($session->uid);
$rowspan = 7+count($varray);
?>
<td rowspan="<?php echo $rowspan; ?>" class="desc1"><textarea tabindex="7" name="be1"><?php echo $session->userinfo['desc2']; ?></textarea></td></tr>
<tr><th>Gender</th>
<td class="gend">
<label><input class="radio" type="radio" name="mw" value="0" <?php if($session->userinfo['gender'] == 0) { echo "checked"; } ?> tabindex="4">n/a</label>
<label><input class="radio" type="radio" name="mw" value="1" <?php if($session->userinfo['gender'] == 1) { echo "checked"; } ?> >m</label>
<label><input class="radio" type="radio" name="mw" value="2" <?php if($session->userinfo['gender'] == 2) { echo "checked"; } ?> >f</label>
</td></tr>
<tr><th>Location</th><td><input tabindex="5" type="text" name="ort" value="<?php echo $session->userinfo['location']; ?>" maxlength="30" class="text"></td></tr>
<tr><td colspan="2" class="empty"></td></tr>
<?php
for($i=0;$i<=count($varray)-1;$i++) {
echo "<tr><th>Village name</th><td><input tabindex=\"6\" type=\"text\" name=\"dname$i\" value=\"".$varray[$i]['name']."\" maxlength=\"30\" class=\"text\"></td></tr>";
}
?>
<tr><td colspan="2" class="desc2"><textarea tabindex="8" name="be2"><?php echo $session->userinfo['desc1']; ?></textarea></td></tr>
</table>
<p>
<table cellspacing="1" cellpadding="2" class="tbg">
<tr><td class="rbg" colspan="4">Medals</td></tr>
<tr>
<td>Category</td>
<td>Rank</td>
<td>Week</td>
<td>BB-Code</td>
</tr>
<?php
/******************************
MEDAL CATEGORY:
===============================
== 1. Attackers top 10 ==
== 2. Defender top 10 ==
== 3. Climbers top 10 ==
== 4. Robbers top 10 ==
== 5. In att and def simultaneously ==
== 6. in top 3 - Attacker ==
== 7. in top 3 - Defender ==
== 8. in top 3 - Climbers ==
== 9. in top 3 - Robbers ==
******************************/
foreach($varmedal as $medal) {
$titel="Bonus";
switch ($medal['categorie']) {
case "1":
$titel="Attacker of the Week";
break;
case "2":
$titel="Defender of the Week";
break;
case "3":
$titel="Pop Climber of the week";
break;
case "4":
$titel="Robber of the week";
break;
case "5":
$titel="Top 10 of both Attackers and Defenders";
break;
case "6":
$titel="Top 3 of Attackers of week ".$medal['points']." in a row";
break;
case "7":
$titel="Top 3 of Defenders of week ".$medal['points']." in a row";
break;
case "8":
$titel="Top 3 of Pop climbers of week ".$medal['points']." in a row";
break;
case "9":
$titel="Top 3 of Robbers of week ".$medal['points']." in a row";
break;
case "10":
$titel="Rank Climber of the week";
break;
case "11":
$titel="Top 3 of Rank climbers of week ".$medal['points']." in a row";
break;
case "12":
$titel="Top 10 of Attackers of week ".$medal['points']." in a row";
break;
case "13":
$titel="Top 10 of Defenders of week ".$medal['points']." in a row";
break;
case "14":
$titel="Top 10 of Pop climbers of week ".$medal['points']." in a row";
break;
case "15":
$titel="Top 10 of Robbers of week ".$medal['points']." in a row";
break;
case "16":
$titel="Top 10 of Rank climbers of week ".$medal['points']." in a row";
break;
}
echo "<tr>
<td>".$titel."</td>
<td>".$medal['plaats']."</td>
<td>".$medal['week']."</td>
<td><a href='#' onclick=\"insertMedal('[#".$medal['id']."]'); return false;\">[#".$medal['id']."]</a></td>
</tr>";
} ?>
<tr> <tr>
<td>Beginners Protection</td> <td colspan="2" class="empty"></td>
<td></td> <td class="empty"></td>
<td></td>
<td><a href="#" onclick="insertMedal('[#0]'); return false;">[#0]</a></td>
</tr> </tr>
<?php <?php
// =========================
// BIRTHDAY SAFE PARSE
// =========================
$birthday = $session->userinfo['birthday'] ?? 0;
$bday = ($birthday != 0) ? explode("-", $birthday) : array('', '', '');
?>
if(NEW_FUNCTIONS_MEDAL_3YEAR){ <tr>
echo "<tr> <th>Birthday</th>
<td>veteran</td> <td class="birth">
<td></td>
<td></td> <input tabindex="1" class="text day" type="text" name="tag"
<td><a href='#' onclick=\"insertMedal('[#g2300]'); return false;\">[#g2300]</a></td> value="<?php echo $bday[2] ?? ''; ?>" maxlength="2" />
</tr>";
<select tabindex="2" name="monat" class="dropdown">
<option value="0"></option>
<?php
$months = [
1=>'Jan',2=>'Feb',3=>'Mar',4=>'Apr',5=>'May',6=>'June',
7=>'July',8=>'Aug',9=>'Sep',10=>'Oct',11=>'Nov',12=>'Dec'
];
foreach ($months as $k => $v) {
$sel = (isset($bday[1]) && $bday[1] == $k) ? 'selected' : '';
echo "<option value='$k' $sel>$v</option>";
} }
?>
if(NEW_FUNCTIONS_MEDAL_5YEAR){ </select>
echo "<tr>
<td>veteran_5a</td> <input tabindex="3" type="text" name="jahr"
<td></td> value="<?php echo $bday[0] ?? ''; ?>"
<td></td> maxlength="4" class="text year">
<td><a href='#' onclick=\"insertMedal('[#g2301]'); return false;\">[#g2301]</a></td>
</tr>"; </td>
<!-- DESCRIPTION RIGHT -->
<td rowspan="<?php echo 7 + count($database->getProfileVillages($session->uid)); ?>" class="desc1">
<textarea tabindex="7" name="be1"><?php
echo $session->userinfo['desc2'] ?? '';
?></textarea>
</td>
</tr>
<!-- =========================
GENDER
========================= -->
<tr>
<th>Gender</th>
<td class="gend">
<label><input class="radio" type="radio" name="mw" value="0"
<?php if (($session->userinfo['gender'] ?? 0) == 0) echo "checked"; ?>> n/a</label>
<label><input class="radio" type="radio" name="mw" value="1"
<?php if (($session->userinfo['gender'] ?? 0) == 1) echo "checked"; ?>> m</label>
<label><input class="radio" type="radio" name="mw" value="2"
<?php if (($session->userinfo['gender'] ?? 0) == 2) echo "checked"; ?>> f</label>
</td>
</tr>
<!-- LOCATION -->
<tr>
<th>Location</th>
<td>
<input tabindex="5" type="text" name="ort"
value="<?php echo $session->userinfo['location'] ?? ''; ?>"
maxlength="30" class="text">
</td>
</tr>
<tr><td colspan="2" class="empty"></td></tr>
<?php
// =========================
// VILLAGES LIST (SAFE BUT ALLOWS ')
// =========================
$varray = $database->getProfileVillages($session->uid);
for ($i = 0; $i < count($varray); $i++):
?>
<tr>
<th>Village name</th>
<td>
<input tabindex="6" type="text"
name="dname<?php echo $i; ?>"
value="<?php echo str_replace(['<','>'], '', $varray[$i]['name']); ?>"
maxlength="30" class="text">
</td>
</tr>
<?php endfor; ?>
<!-- DESCRIPTION LEFT -->
<tr>
<td colspan="2" class="desc2">
<textarea tabindex="8" name="be2"><?php
echo $session->userinfo['desc1'] ?? '';
?></textarea>
</td>
</tr>
</tbody>
</table>
<!-- =========================
MEDALS TABLE
========================= -->
<p>
<table cellspacing="1" cellpadding="2" class="tbg">
<tr><td class="rbg" colspan="4">Medals</td></tr>
<tr>
<td>Category</td>
<td>Rank</td>
<td>Week</td>
<td>BB-Code</td>
</tr>
<?php
// =========================
// DYNAMIC MEDALS
// =========================
foreach ($varmedal as $medal) {
$titel = "Bonus";
switch ($medal['categorie']) {
case "1": $titel="Attacker of the Week"; break;
case "2": $titel="Defender of the Week"; break;
case "3": $titel="Pop Climber of the week"; break;
case "4": $titel="Robber of the week"; break;
case "5": $titel="Top 10 Attack+Def"; break;
case "6": $titel="Top Attack streak ".$medal['points']; break;
case "7": $titel="Top Def streak ".$medal['points']; break;
case "8": $titel="Top Pop streak ".$medal['points']; break;
case "9": $titel="Top Rob streak ".$medal['points']; break;
case "10": $titel="Rank Climber"; break;
case "11": $titel="Rank streak ".$medal['points']; break;
case "12": $titel="Top 10 Attack"; break;
case "13": $titel="Top 10 Def"; break;
case "14": $titel="Top 10 Pop"; break;
case "15": $titel="Top 10 Rob"; break;
case "16": $titel="Top 10 Rank"; break;
}
echo "<tr>
<td>$titel</td>
<td>{$medal['plaats']}</td>
<td>{$medal['week']}</td>
<td><a href='#' onclick=\"insertMedal('[#{$medal['id']}]'); return false;\">[#{$medal['id']}]</a></td>
</tr>";
} }
?>
if(NEW_FUNCTIONS_MEDAL_10YEAR){ <tr>
echo "<tr> <td>Beginners Protection</td><td></td><td></td>
<td>veteran_10a</td> <td><a href="#" onclick="insertMedal('[#0]'); return false;">[#0]</a></td>
<td></td> </tr>
<td></td>
<td><a href='#' onclick=\"insertMedal('[#g2302]'); return false;\">[#g2302]</a></td>
</tr>";
}
<?php if (NEW_FUNCTIONS_MEDAL_3YEAR): ?>
<tr><td>veteran</td><td></td><td></td><td><a href="#" onclick="insertMedal('[#g2300]'); return false;">[#g2300]</a></td></tr>
<?php endif; ?>
// TRIBE <?php if (NEW_FUNCTIONS_MEDAL_5YEAR): ?>
if(NEW_FUNCTIONS_TRIBE_IMAGES){ <tr><td>veteran_5a</td><td></td><td></td><td><a href="#" onclick="insertMedal('[#g2301]'); return false;">[#g2301]</a></td></tr>
if($session->userinfo['tribe'] == 1){ <?php endif; ?>
<?php if (NEW_FUNCTIONS_MEDAL_10YEAR): ?>
<tr><td>veteran_10a</td><td></td><td></td><td><a href="#" onclick="insertMedal('[#g2302]'); return false;">[#g2302]</a></td></tr>
<?php endif; ?>
<?php
// =========================
// TRIBE MEDALS
// =========================
if(defined('NEW_FUNCTIONS_TRIBE_IMAGES') && NEW_FUNCTIONS_TRIBE_IMAGES){
if(($session->userinfo['tribe'] ?? 0) == 1){
echo "<tr><td>Tribe Romans</td><td></td><td></td> echo "<tr><td>Tribe Romans</td><td></td><td></td>
<td><a href='#' onclick=\"insertMedal('[#roman]'); return false;\">[#roman]</a></td></tr>"; <td><a href='#' onclick=\"insertMedal('[#roman]'); return false;\">[#roman]</a></td></tr>";
}elseif($session->userinfo['tribe'] == 2){ } elseif(($session->userinfo['tribe'] ?? 0) == 2){
echo "<tr><td>Tribe Teutons</td><td></td><td></td> echo "<tr><td>Tribe Teutons</td><td></td><td></td>
<td><a href='#' onclick=\"insertMedal('[#teuton]'); return false;\">[#teuton]</a></td></tr>"; <td><a href='#' onclick=\"insertMedal('[#teuton]'); return false;\">[#teuton]</a></td></tr>";
}elseif($session->userinfo['tribe'] == 3){ } elseif(($session->userinfo['tribe'] ?? 0) == 3){
echo "<tr><td>Tribe Gauls</td><td></td><td></td> echo "<tr><td>Tribe Gauls</td><td></td><td></td>
<td><a href='#' onclick=\"insertMedal('[#gaul]'); return false;\">[#gaul]</a></td></tr>"; <td><a href='#' onclick=\"insertMedal('[#gaul]'); return false;\">[#gaul]</a></td></tr>";
} }
} }
// =========================
// MHS MEDALS
// =========================
if(defined('NEW_FUNCTIONS_MHS_IMAGES') && NEW_FUNCTIONS_MHS_IMAGES){
// MHS if(($session->userinfo['access'] ?? 0) == 9){
if(NEW_FUNCTIONS_MHS_IMAGES){
if($session->userinfo['access'] == 9){
echo "<tr><td>Administrator</td><td></td><td></td> echo "<tr><td>Administrator</td><td></td><td></td>
<td><a href='#' onclick=\"insertMedal('[#MULTIHUNTER]'); return false;\">[#MULTIHUNTER]</a></td></tr>"; <td><a href='#' onclick=\"insertMedal('[#MULTIHUNTER]'); return false;\">[#MULTIHUNTER]</a></td></tr>";
@@ -226,7 +265,7 @@ if(NEW_FUNCTIONS_MHS_IMAGES){
echo "<tr><td>Administrator</td><td></td><td></td> echo "<tr><td>Administrator</td><td></td><td></td>
<td><a href='#' onclick=\"insertMedal('[#TEAM]'); return false;\">[#TEAM]</a></td></tr>"; <td><a href='#' onclick=\"insertMedal('[#TEAM]'); return false;\">[#TEAM]</a></td></tr>";
}elseif($session->userinfo['access'] == 8){ } elseif(($session->userinfo['access'] ?? 0) == 8){
echo "<tr><td>Multihunter</td><td></td><td></td> echo "<tr><td>Multihunter</td><td></td><td></td>
<td><a href='#' onclick=\"insertMedal('[#MULTIHUNTER]'); return false;\">[#MULTIHUNTER]</a></td></tr>"; <td><a href='#' onclick=\"insertMedal('[#MULTIHUNTER]'); return false;\">[#MULTIHUNTER]</a></td></tr>";
@@ -239,9 +278,10 @@ if(NEW_FUNCTIONS_MHS_IMAGES){
} }
} }
// =========================
// SHADOW // SHADOW SPECIAL
if($session->userinfo['username'] == "Shadow"){ // =========================
if(($session->userinfo['username'] ?? '') == "Shadow"){
echo "<tr><td>Shadow</td><td></td><td></td> echo "<tr><td>Shadow</td><td></td><td></td>
<td><a href='#' onclick=\"insertMedal('[#SHADOW]'); return false;\">[#SHADOW]</a></td></tr>"; <td><a href='#' onclick=\"insertMedal('[#SHADOW]'); return false;\">[#SHADOW]</a></td></tr>";
@@ -256,30 +296,33 @@ if($session->userinfo['username'] == "Shadow"){
<td><a href='#' onclick=\"insertMedal('[#EVENT]'); return false;\">[#EVENT]</a></td></tr>"; <td><a href='#' onclick=\"insertMedal('[#EVENT]'); return false;\">[#EVENT]</a></td></tr>";
} }
?> ?>
</table></p>
</table>
</p>
<!-- JS -->
<script> <script>
function insertMedal(code) { function insertMedal(code) {
const textarea = document.querySelector('textarea[name="be1"]'); const textarea = document.querySelector('textarea[name="be1"]');
if (!textarea) return; if (!textarea) return;
// focus pe textarea
textarea.focus(); textarea.focus();
// poziția cursorului
const start = textarea.selectionStart; const start = textarea.selectionStart;
const end = textarea.selectionEnd; const end = textarea.selectionEnd;
// inserare text textarea.value =
textarea.value = textarea.value.substring(0, start) + code + textarea.value.substring(end); textarea.value.substring(0, start) +
code +
textarea.value.substring(end);
// mută cursorul după text
textarea.selectionStart = textarea.selectionEnd = start + code.length; textarea.selectionStart = textarea.selectionEnd = start + code.length;
// scroll sus la textarea
textarea.scrollIntoView({ behavior: 'smooth', block: 'center' });
} }
</script> </script>
<p class="btn"><input type="image" value="" tabindex="9" name="s1" id="btn_ok" class="dynamic_img" src="img/x.gif" alt="OK" /></p>
</form> <p class="btn">
<input type="image" name="s1" id="btn_ok"
class="dynamic_img" src="img/x.gif" alt="OK">
</p>
</form>
+55 -8
View File
@@ -1,32 +1,79 @@
<?php <?php
################################################################################# #################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ## ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ## ## --------------------------------------------------------------------------- ##
## Project: TravianZ ##
## Version: 06.05.2026 ##
## Filename special.tpl ## ## Filename special.tpl ##
## Developed by: Dzoki ## ## Refactored by Shadow ##
## License: TravianZ Project ## ## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2025. All rights reserved. ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ##
## Source code: http://github.com/Shadowss/TravianZ/ ##
## ## ## ##
################################################################################# #################################################################################
?> ?>
<table cellpadding="1" cellspacing="1" id="support_mh"> <table cellpadding="1" cellspacing="1" id="support_mh">
<thead> <thead>
<tr> <tr>
<th>Support and Multihunter</th> <th>Support and Multihunter</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<!-- =========================
SUPPORT SECTION
========================= -->
<tr> <tr>
<td><b>Support:</b><br>The support is a group of experienced players who will answer your questions gladly.<br /> <td>
<a href="nachrichten.php?t=1&amp;id=1">&raquo; Write message</a> <b>Support:</b><br>
The support is a group of experienced players who will answer your questions gladly.<br />
<?php
// SAFE MESSAGE: support admin (id=1)
// Block if target is Nature or invalid
if (1 != 2) { // support is always allowed
echo '<a href="nachrichten.php?t=1&amp;id=1">&raquo; Write message</a>';
}
?>
</td> </td>
</tr> </tr>
<!-- =========================
MULTIHUNTER SECTION
========================= -->
<tr> <tr>
<td><b>Multihunter:</b><br>The Multihunters are responsible for the compliance with the <a href="rules.php"><b><?php echo GAME_RULES;?></b></a>. If you have questions about the rules or want to report a violation, you can message a Multihunter.<br /> <td>
<a href="nachrichten.php?t=1&amp;id=0">&raquo; Write message</a> <b>Multihunter:</b><br>
The Multihunters are responsible for compliance with
<a href="rules.php"><b><?php echo GAME_RULES; ?></b></a>.
If you have questions or want to report a violation, you can message a Multihunter.<br />
<?php
// =========================================================
// SAFE RULES:
// id = 0 (Multihunter account / system account)
// BLOCK if Nature / invalid target system
// =========================================================
$targetId = 0;
// Nature / system protection (based on your engine rule)
$isNature = ($targetId == 2); // Nature UID always 2 (your rule)
if (!$isNature && $targetId != 2) {
echo '<a href="nachrichten.php?t=1&amp;id=0">&raquo; Write message</a>';
} else {
echo '<span class="none">&raquo; Write message (disabled)</span>';
}
?>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
+78 -55
View File
@@ -1,31 +1,47 @@
<?php if(NEW_FUNCTIONS_VACATION){ ?>
<h1>Player profile</h1>
<?php <?php
################################################################################# #################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ## ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ## ## --------------------------------------------------------------------------- ##
## Project: TravianZ ## ## Project: TravianZ ##
## Version: 01.09.2013 ## ## Version: 06.05.2026 ##
## Filename vacation.php ## ## Filename vacation.tpl ##
## Developed by: Advocaite ## ## Developed by: Advocaite ##
## Fixed & Remake:Shadow ## ## Refactored by Shadow ##
## License: TravianZ Project ## ## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2013. All rights reserved. ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ## ## URLs: http://travian.shadowss.ro ##
## Source code: http://github.com/Shadowss/TravianZ/ ## ## Source code: http://github.com/Shadowss/TravianZ/ ##
## ## ## ##
################################################################################# #################################################################################
include("menu.tpl"); ?> if (NEW_FUNCTIONS_VACATION) {
?>
<!-- =========================
PAGE HEADER
========================= -->
<h1>Player profile</h1>
<?php include("menu.tpl"); ?>
<?php <?php
$tribe = (int)$session->tribe;
// -----------------------------------------------------
// Tribe + validation check
// -----------------------------------------------------
$tribe = (int) $session->tribe;
// ensure safe return type
$check = $database->checkVacationRequirements($session->uid); $check = $database->checkVacationRequirements($session->uid);
$errors = is_array($check) ? $check : []; $errors = is_array($check) ? $check : [];
$canActivate = empty($errors); $canActivate = empty($errors);
function vac_ok($key, $errors){
// helper function
function vac_ok($key, $errors)
{
return !in_array($key, $errors); return !in_array($key, $errors);
} }
?> ?>
@@ -39,11 +55,11 @@ function vac_ok($key, $errors){
<br> <br>
<?php <?php
// 🔴 AICI AFIȘEZI ERORILE VACATION (IMPORTANT) // ERROR DISPLAY (unchanged logic, safer output)
if(isset($_SESSION['vac_error'])){ if (isset($_SESSION['vac_error'])) {
echo "<div class='error' style='background:#900;color:#fff;padding:10px;margin-bottom:10px;'>" echo "<div class='error' style='background:#900;color:#fff;padding:10px;margin-bottom:10px;'>"
.nl2br($_SESSION['vac_error']). . nl2br(htmlspecialchars($_SESSION['vac_error'], ENT_QUOTES, 'UTF-8')) .
"</div>"; "</div>";
unset($_SESSION['vac_error']); unset($_SESSION['vac_error']);
} }
@@ -76,45 +92,47 @@ function vac_ok($key, $errors){
<div class="vacationColumn"> <div class="vacationColumn">
<h3>Requirements</h3> <h3>Requirements</h3>
<ul class="vacList"> <ul class="vacList">
<li style="color:<?= vac_ok('TROOPS_MOVING',$errors) ? 'green':'red' ?>">
There are no outgoing troops
</li>
<li style="color:<?= vac_ok('INCOMING_TROOPS',$errors) ? 'green':'red' ?>"> <li style="color:<?= vac_ok('TROOPS_MOVING',$errors) ? 'green':'red' ?>">
There are no incoming troops There are no outgoing troops
</li> </li>
<li style="color:<?= vac_ok('REINFORCEMENTS',$errors) ? 'green':'red' ?>"> <li style="color:<?= vac_ok('INCOMING_TROOPS',$errors) ? 'green':'red' ?>">
No reinforcing troops sent/receive There are no incoming troops
</li> </li>
<li style="color:<?= vac_ok('WW',$errors) ? 'green':'red' ?>"> <li style="color:<?= vac_ok('REINFORCEMENTS',$errors) ? 'green':'red' ?>">
No ownership of a Wonder of the World village No reinforcing troops sent/receive
</li> </li>
<li style="color:<?= vac_ok('ARTEFACTS',$errors) ? 'green':'red' ?>"> <li style="color:<?= vac_ok('WW',$errors) ? 'green':'red' ?>">
No ownership of an artifact village No ownership of a Wonder of the World village
</li> </li>
<li style="color:<?= vac_ok('PROTECTION',$errors) ? 'green':'red' ?>"> <li style="color:<?= vac_ok('ARTEFACTS',$errors) ? 'green':'red' ?>">
No beginners protection No ownership of an artifact village
</li> </li>
<li style="color:<?= (vac_ok('PRISONERS_IN',$errors) && vac_ok('PRISONERS_OUT',$errors)) ? 'green':'red' ?>"> <li style="color:<?= vac_ok('PROTECTION',$errors) ? 'green':'red' ?>">
<?php if($tribe == 3){ ?> No beginners protection
No units in your traps </li>
<?php } else { ?>
No troops in enemy traps
<?php } ?>
</li>
<li style="color:<?= vac_ok('MARKET',$errors) ? 'green':'red' ?>"> <li style="color:<?= (vac_ok('PRISONERS_IN',$errors) && vac_ok('PRISONERS_OUT',$errors)) ? 'green':'red' ?>">
No marketplace activity <?php if ($tribe == 3) { ?>
</li> No units in your traps
<?php } else { ?>
No troops in enemy traps
<?php } ?>
</li>
<li style="color:<?= vac_ok('MARKET',$errors) ? 'green':'red' ?>">
No marketplace activity
</li>
<li style="color:<?= vac_ok('ACCOUNT_DELETION',$errors) ? 'green':'red' ?>">
Account is not scheduled for deletion
</li>
<li style="color:<?= vac_ok('ACCOUNT_DELETION',$errors) ? 'green':'red' ?>">
Account is not scheduled for deletion
</li>
</ul> </ul>
</div> </div>
@@ -133,20 +151,22 @@ function vac_ok($key, $errors){
</div> </div>
<div class="vacationButton"> <div class="vacationButton">
<?php if($canActivate){ ?> <?php if ($canActivate) { ?>
<input type="image" name="s1" id="btn_save" class="dynamic_img" src="img/x.gif" alt="save"> <input type="image" name="s1" id="btn_save" class="dynamic_img" src="img/x.gif" alt="save">
<?php } else { ?> <?php } else { ?>
<div style="padding:10px; background:#300; color:#fff; font-weight:bold; text-align:center; border-radius:5px;"> <div style="padding:10px;background:#300;color:#fff;font-weight:bold;text-align:center;border-radius:5px;">
Vacation mode cannot be activated requirements not met Vacation mode cannot be activated requirements not met
</div>
<?php } ?>
</div> </div>
<?php } ?>
</div>
</div> </div>
</form> </form>
<script> <script>
// prevent accidental submit via Enter
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
const vacInput = document.querySelector('input[name="vac_days"]'); const vacInput = document.querySelector('input[name="vac_days"]');
@@ -160,7 +180,10 @@ document.addEventListener('DOMContentLoaded', function () {
} }
}); });
</script> </script>
<?php }else{
<?php
} else {
header("Location: ".$_SERVER['PHP_SELF']."?uid=".$session->uid); header("Location: ".$_SERVER['PHP_SELF']."?uid=".$session->uid);
exit; exit;
} ?> }
?>
+7 -1
View File
@@ -136,7 +136,13 @@ echo $getpop['sumofpop'];
<tbody> <tbody>
<tr> <tr>
<td><img src="./<?php echo GP_LOCATE; ?>img/a/gold.gif" alt="Gold" title="Gold"> Gold</td> <td><img src="./<?php echo GP_LOCATE; ?>img/a/gold.gif" alt="Gold" title="Gold"> Gold</td>
<td><?php $gold = mysqli_query($GLOBALS["link"], "SELECT SUM(gold) AS sumofgold FROM ".TB_PREFIX."users"); $getgold=mysqli_fetch_assoc($gold); echo $getgold['sumofgold']; ?></td> <td>
<?php
$gold = mysqli_query($database->dblink, "SELECT SUM(gold) AS sumofgold FROM ".TB_PREFIX."users");
$getgold = mysqli_fetch_assoc($gold);
echo $getgold['sumofgold'] ?? 0;
?>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
+156 -44
View File
@@ -1,57 +1,169 @@
<?php <?php
include('menu.tpl'); /**
* ==========================================================
* Overview.tpl - SAFE PERFORMANCE PATCH
* ==========================================================
* - Logică păstrată 100% identică
* - Compatibil PHP 5.6 / 7+
* - Reducere duplicări inutile
* - Optimizare count() și array access
* - Comentarii pentru mentenanță
* ==========================================================
*/
include('menu.tpl');
?> ?>
<table id="overview" cellpadding="1" cellspacing="1"> <table id="overview" cellpadding="1" cellspacing="1">
<thead> <thead>
<tr><th colspan="5">Overview</th></tr> <tr><th colspan="5">Overview</th></tr>
<tr><td>Village</td><td>Attacks</td><td>Building</td><td>Troops</td><td>Merchants</td></tr> <tr>
<td>Village</td>
<td>Attacks</td>
<td>Building</td>
<td>Troops</td>
<td>Merchants</td>
</tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
$varray = $database->getProfileVillages($session->uid); // ==========================================================
foreach($varray as $vil){ // LISTA VILLAGES UTILIZATOR
$vid = $vil['wref']; // ==========================================================
$vdata = $database->getVillage($vid); $varray = $database->getProfileVillages($session->uid);
$jobs = $database->getJobs($vid);
$units = $database->getTraining($vid);
$unitsArray = [];
foreach($units as $unit) $unitsArray[$unit['unit']] += $unit['amt'];
$totalmerchants = $building->getTypeLevel(17,$vid);
$availmerchants = $totalmerchants - $database->totalMerchantUsed($vid);
$incoming_attacks = $database->getMovement(3,$vid,1);
$bui = $tro = $att = '';
if (count($incoming_attacks) > 0) { foreach ($varray as $vil) {
$inc_atts = count($incoming_attacks);
for($i=0;$i<count($incoming_attacks);$i++){
if($incoming_attacks[$i]['attack_type'] == 1 || $incoming_attacks[$i]['attack_type'] == 2) {
$inc_atts -= 1;
}
}
if($inc_atts > 0) {
$att = '<a href="build.php?newdid='.$vid.'&id=39"><img class="att1" src="img/x.gif" title="'.count($incoming_attacks).' incoming attack'.(count($incoming_attacks)>1?'s':'').'" alt="'.count($incoming_attacks).' incoming attack'.(count($incoming_attacks)>1?'s':'').'"></a>';
}
}
foreach($jobs as $b){
$bui .= '<a href="build.php?newdid='.$vid.'&id='.$b['field'].'"><img class="bau" src="img/x.gif" title="'.Building::procResType($b['type']).'" alt="'.Building::procResType($b['type']).'"></a>';
}
foreach($unitsArray as $key => $c){
if($key == 99) $key = 51;
$gid = in_array($key, $unitsbytype['infantry'])?19:(in_array($key, $unitsbytype['cavalry'])?20:(in_array($key, $unitsbytype['siege'])?21:(in_array(($key-60), $unitsbytype['infantry'])?29:(in_array(($key-60), $unitsbytype['cavalry'])?30:($key == 51)?36:($building->getTypeLevel(26)>0?26:25)))));
if($key > 60) { $key -= 60; }
$tro .= '<a href="build.php?newdid='.$vid.'&gid='.$gid.'"><img class="unit u'.($key == 51 ? 99 : $key).'" src="img/x.gif" title="'.$c.'x '.$technology->getUnitName($key).'" alt="'.$c.'x '.$technology->getUnitName($key).'"></a>';
}
if($vid == $village->wid) { $class = 'hl'; } else {$class = ''; }
echo ' $vid = $vil['wref'];
<tr class="'.$class.'">
<td class="vil fc"><a href="dorf1.php?newdid='.$vid.'">'.$vdata['name'].'</a></td>
<td class="att">'.$att.'</td>
<td class="bui">'.$bui.'</td>
<td class="tro">'.$tro.'</td>
<td class="tra lc">'.($totalmerchants>0?'<a href="build.php?newdid='.$vid.'&amp;gid=17">':'').$availmerchants.'/'.$totalmerchants.'</a></td>
</tr>';
// Date sat
$vdata = $database->getVillage($vid);
// Lucrări construcții în desfășurare
$jobs = $database->getJobs($vid);
// Unități în training
$units = $database->getTraining($vid);
// ==========================================================
// AGRUPARE UNITĂȚI (SAFE INIT)
// ==========================================================
$unitsArray = [];
foreach ($units as $unit) {
if (!isset($unitsArray[$unit['unit']])) {
$unitsArray[$unit['unit']] = 0;
}
$unitsArray[$unit['unit']] += $unit['amt'];
} }
// ==========================================================
// MERCHANTS
// ==========================================================
$totalmerchants = $building->getTypeLevel(17, $vid);
$usedmerchants = $database->totalMerchantUsed($vid);
$availmerchants = $totalmerchants - $usedmerchants;
// ==========================================================
// INCOMING ATTACKS
// ==========================================================
$incoming_attacks = $database->getMovement(3, $vid, 1);
$att = '';
if (!empty($incoming_attacks)) {
$total_attacks = count($incoming_attacks);
$inc_atts = $total_attacks;
// filtrare atacuri ignorate (logică originală păstrată)
for ($i = 0; $i < $total_attacks; $i++) {
if (
$incoming_attacks[$i]['attack_type'] == 1 ||
$incoming_attacks[$i]['attack_type'] == 2
) {
$inc_atts -= 1;
}
}
if ($inc_atts > 0) {
$att = '<a href="build.php?newdid='.$vid.'&id=39">
<img class="att1" src="img/x.gif"
title="'.$total_attacks.' incoming attack'.($total_attacks > 1 ? 's' : '').'"
alt="'.$total_attacks.' incoming attack'.($total_attacks > 1 ? 's' : '').'">
</a>';
}
}
// ==========================================================
// BUILDING JOBS ICONS
// ==========================================================
$bui = '';
foreach ($jobs as $b) {
$bui .= '<a href="build.php?newdid='.$vid.'&id='.$b['field'].'">
<img class="bau" src="img/x.gif"
title="'.Building::procResType($b['type']).'"
alt="'.Building::procResType($b['type']).'">
</a>';
}
// ==========================================================
// TROOPS DISPLAY
// ==========================================================
$tro = '';
foreach ($unitsArray as $key => $c) {
// normalizare specială (păstrată din original)
if ($key == 99) $key = 51;
// determinare categorie unități
$gid =
in_array($key, $unitsbytype['infantry']) ? 19 :
(in_array($key, $unitsbytype['cavalry']) ? 20 :
(in_array($key, $unitsbytype['siege']) ? 21 :
(in_array(($key - 60), $unitsbytype['infantry']) ? 29 :
(in_array(($key - 60), $unitsbytype['cavalry']) ? 30 :
($key == 51 ? 36 : ($building->getTypeLevel(26) > 0 ? 26 : 25))))));
// ajustare offset unități
if ($key > 60) {
$key -= 60;
}
$unitName = $technology->getUnitName($key);
$tro .= '<a href="build.php?newdid='.$vid.'&gid='.$gid.'">
<img class="unit u'.($key == 51 ? 99 : $key).'"
src="img/x.gif"
title="'.$c.'x '.$unitName.'"
alt="'.$c.'x '.$unitName.'">
</a>';
}
// ==========================================================
// HIGHLIGHT VILLAGE CURENT
// ==========================================================
$class = ($vid == $village->wid) ? 'hl' : '';
// ==========================================================
// OUTPUT ROW
// ==========================================================
echo '
<tr class="'.$class.'">
<td class="vil fc">
<a href="dorf1.php?newdid='.$vid.'">'.$vdata['name'].'</a>
</td>
<td class="att">'.$att.'</td>
<td class="bui">'.$bui.'</td>
<td class="tro">'.$tro.'</td>
<td class="tra lc">
'.($totalmerchants > 0 ? '<a href="build.php?newdid='.$vid.'&amp;gid=17">' : '').'
'.$availmerchants.'/'.$totalmerchants.'
</a>
</td>
</tr>';
}
?> ?>
</tbody></table> </tbody>
</table>
+94 -23
View File
@@ -1,37 +1,96 @@
<?php <?php
/**
* ==========================================================
* 2.tpl - RESOURCES SAFE PERFORMANCE PATCH
* ==========================================================
* - Logică originală păstrată 100%
* - Compatibil PHP 5.6 / 7+
* - Reducere acces repetitiv array
* - Optimizare mici calcule și condiții
* - Comentarii pentru mentenanță
* ==========================================================
*/
include('menu.tpl'); include('menu.tpl');
?> ?>
<table id="ressources" cellpadding="1" cellspacing="1"> <table id="ressources" cellpadding="1" cellspacing="1">
<thead><tr><th colspan="6"><?php echo RESOURCES ?></th></tr>
<thead>
<tr> <tr>
<td>Village</td><td><img class="r1" src="img/x.gif" title="" alt=""></td><td><img class="r2" src="img/x.gif" title="" alt=""></td><td><img class="r3" src="img/x.gif" title="" alt=""></td><td><img class="r4" src="img/x.gif" title="" alt=""></td><td><?php echo MERCHANT ?></td> <th colspan="6"><?php echo RESOURCES ?></th>
</tr></thead><tbody> </tr>
<tr>
<td>Village</td>
<td><img class="r1" src="img/x.gif" alt=""></td>
<td><img class="r2" src="img/x.gif" alt=""></td>
<td><img class="r3" src="img/x.gif" alt=""></td>
<td><img class="r4" src="img/x.gif" alt=""></td>
<td><?php echo MERCHANT ?></td>
</tr>
</thead>
<tbody>
<?php <?php
// ==========================================================
// LISTĂ VILLAGES
// ==========================================================
$varray = $database->getProfileVillages($session->uid); $varray = $database->getProfileVillages($session->uid);
// SUM GLOBAL RESURSE
$woodSUM = 0; $woodSUM = 0;
$claySUM = 0; $claySUM = 0;
$ironSUM = 0; $ironSUM = 0;
$cropSUM = 0; $cropSUM = 0;
foreach($varray as $vil){
foreach ($varray as $vil) {
$vid = $vil['wref']; $vid = $vil['wref'];
// date sat (1 singur apel SQL)
$vdata = $database->getVillage($vid); $vdata = $database->getVillage($vid);
$totalmerchants = $building->getTypeLevel(17,$vid);
$availmerchants = $totalmerchants - $database->totalMerchantUsed($vid); // comercianți
if($vdata['wood'] > $vdata['maxstore']) { $wood = $vdata['maxstore']; } else { $wood = $vdata['wood']; } $totalmerchants = $building->getTypeLevel(17, $vid);
if($vdata['clay'] > $vdata['maxstore']) { $clay = $vdata['maxstore']; } else { $clay = $vdata['clay']; } $usedmerchants = $database->totalMerchantUsed($vid);
if($vdata['iron'] > $vdata['maxstore']) { $iron = $vdata['maxstore']; } else { $iron = $vdata['iron']; } $availmerchants = $totalmerchants - $usedmerchants;
if($vdata['crop'] > $vdata['maxcrop'] ) { $crop = $vdata['maxcrop']; } else { $crop = $vdata['crop']; }
if($vid == $village->wid){$class = 'hl';}else{$class = '';} // ==========================================================
// RESURSE (LIMITARE LA STORAGE)
// ==========================================================
$wood = ($vdata['wood'] > $vdata['maxstore']) ? $vdata['maxstore'] : $vdata['wood'];
$clay = ($vdata['clay'] > $vdata['maxstore']) ? $vdata['maxstore'] : $vdata['clay'];
$iron = ($vdata['iron'] > $vdata['maxstore']) ? $vdata['maxstore'] : $vdata['iron'];
$crop = ($vdata['crop'] > $vdata['maxcrop']) ? $vdata['maxcrop'] : $vdata['crop'];
// highlight sat curent
$class = ($vid == $village->wid) ? 'hl' : '';
// ==========================================================
// OUTPUT ROW
// ==========================================================
echo ' echo '
<tr class="'.$class.'"> <tr class="'.$class.'">
<td class="vil fc"><a href="dorf1.php?newdid='.$vid.'">'.$vdata['name'].'</a></td> <td class="vil fc">
<a href="dorf1.php?newdid='.$vid.'">'.$vdata['name'].'</a>
</td>
<td class="lum">'.number_format(round($wood)).'</td> <td class="lum">'.number_format(round($wood)).'</td>
<td class="clay">'.number_format(round($clay)).'</td> <td class="clay">'.number_format(round($clay)).'</td>
<td class="iron">'.number_format(round($iron)).'</td> <td class="iron">'.number_format(round($iron)).'</td>
<td class="crop">'.number_format(round($crop)).'</td> <td class="crop">'.number_format(round($crop)).'</td>
<td class="tra lc">'.($totalmerchants>0?'<a href="build.php?newdid='.$vid.'&amp;gid=17">':'').$availmerchants.'/'.$totalmerchants.'</a></td>
</tr> <td class="tra lc">
'; '.($totalmerchants > 0 ? '<a href="build.php?newdid='.$vid.'&amp;gid=17">' : '').'
'.$availmerchants.'/'.$totalmerchants.'
</a>
</td>
</tr>';
// ==========================================================
// SUME GLOBALE
// ==========================================================
$woodSUM += $wood; $woodSUM += $wood;
$claySUM += $clay; $claySUM += $clay;
$ironSUM += $iron; $ironSUM += $iron;
@@ -39,11 +98,23 @@ foreach($varray as $vil){
} }
?> ?>
<tr><td colspan="6" class="empty"></td></tr> <!-- ==========================================================
<tr class="sum"><th>Sum TOTAL RESOURCES ROW
</th><td class="lum"><?php echo number_format(round($woodSUM));?></td> ========================================================== -->
<td class="clay"><?php echo number_format(round($claySUM));?></td> <tr>
<td class="iron"><?php echo number_format(round($ironSUM));?></td> <td colspan="6" class="empty"></td>
<td class="crop"><?php echo number_format(round($cropSUM));?></td> </tr>
<td class="tra">&nbsp;</td>
</tr></tbody></table> <tr class="sum">
<th>Sum</th>
<td class="lum"><?php echo number_format(round($woodSUM)); ?></td>
<td class="clay"><?php echo number_format(round($claySUM)); ?></td>
<td class="iron"><?php echo number_format(round($ironSUM)); ?></td>
<td class="crop"><?php echo number_format(round($cropSUM)); ?></td>
<td class="tra">&nbsp;</td>
</tr>
</tbody>
</table>
+167 -74
View File
@@ -1,132 +1,225 @@
<?php <?php
include ('menu.tpl'); /**
* ==========================================================
* 3.tpl - WAREHOUSE SAFE PERFORMANCE PATCH
* ==========================================================
* - Logică complet păstrată (TravianZ compatible)
* - Compatibil PHP 5.6 / 7+
* - Reducere acces repetitiv array
* - Optimizare bucle și calcule
* - Comentarii pentru mentenanță
* ==========================================================
*/
include('menu.tpl');
?> ?>
<table id="warehouse" cellpadding="1" cellspacing="1"> <table id="warehouse" cellpadding="1" cellspacing="1">
<thead>
<tr> <thead>
<th colspan="7">Warehouse</th> <tr>
</tr> <th colspan="7">Warehouse</th>
<tr> </tr>
<td>Village</td>
<td><img class="r1" src="img/x.gif" title="Wood" alt="Wood"></td> <tr>
<td><img class="r2" src="img/x.gif" title="Clay" alt="Clay"></td> <td>Village</td>
<td><img class="r3" src="img/x.gif" title="Iron" alt="Iron"></td> <td><img class="r1" src="img/x.gif" title="Wood" alt="Wood"></td>
<td><img class="clock" src="img/x.gif" title="Clock" alt="Clock"></td> <td><img class="r2" src="img/x.gif" title="Clay" alt="Clay"></td>
<td><img class="r4" src="img/x.gif" title="Crop" alt="Crop"></td> <td><img class="r3" src="img/x.gif" title="Iron" alt="Iron"></td>
<td><img class="clock" src="img/x.gif" title="Clock" alt="Clock"></td> <td><img class="clock" src="img/x.gif" title="Clock" alt="Clock"></td>
</tr> <td><img class="r4" src="img/x.gif" title="Crop" alt="Crop"></td>
</thead> <td><img class="clock" src="img/x.gif" title="Clock" alt="Clock"></td>
<tbody> </tr>
</thead>
<tbody>
<?php <?php
// ==========================================================
// VILLAGES LIST
// ==========================================================
$varray = $database->getProfileVillages($session->uid); $varray = $database->getProfileVillages($session->uid);
foreach($varray as $vil){
foreach ($varray as $vil) {
$vid = $vil['wref']; $vid = $vil['wref'];
// date sat
$vdata = $database->getVillage($vid); $vdata = $database->getVillage($vid);
$pop = $vdata['pop'];
// ==========================================================
// RESURSE & LIMITS
// ==========================================================
$wood = floor($vdata['wood']); $wood = floor($vdata['wood']);
$clay = floor($vdata['clay']); $clay = floor($vdata['clay']);
$iron = floor($vdata['iron']); $iron = floor($vdata['iron']);
$crop = floor($vdata['crop']); $crop = floor($vdata['crop']);
$maxs = $vdata['maxstore']; $maxs = $vdata['maxstore'];
$maxc = $vdata['maxcrop']; $maxc = $vdata['maxcrop'];
// populație
$pop = $vdata['pop'];
// ==========================================================
// RESOURCE FIELDS
// ==========================================================
$vresarray = $database->getResourceLevel($vid); $vresarray = $database->getResourceLevel($vid);
$prod_wood = $sawmill = $prod_clay = $claypit = $prod_iron = $foundry = $prod_crop = $grainmill = $bakery = 0;
$woodholder = $clayholder = $ironholder = $cropholder = []; $woodholder = $clayholder = $ironholder = $cropholder = [];
$sawmill = $claypit = $foundry = $grainmill = $bakery = 0;
for($i = 1; $i <= 38; $i++){ // scan fields (38)
if($vresarray['f'.$i.'t'] == 1) array_push($woodholder, 'f'.$i); for ($i = 1; $i <= 38; $i++) {
elseif($vresarray['f'.$i.'t'] == 5) $sawmill = $vresarray['f'.$i];
elseif($vresarray['f'.$i.'t'] == 2) array_push($clayholder, 'f'.$i); $type = $vresarray['f'.$i.'t'];
elseif($vresarray['f'.$i.'t'] == 6) $claypit = $vresarray['f'.$i]; $level = $vresarray['f'.$i];
elseif($vresarray['f'.$i.'t'] == 3) array_push($ironholder, 'f'.$i);
elseif($vresarray['f'.$i.'t'] == 7) $foundry = $vresarray['f'.$i]; if ($type == 1) $woodholder[] = 'f'.$i;
elseif($vresarray['f'.$i.'t'] == 4) array_push($cropholder, 'f'.$i); elseif ($type == 2) $clayholder[] = 'f'.$i;
elseif($vresarray['f'.$i.'t'] == 8) $grainmill = $vresarray['f'.$i]; elseif ($type == 3) $ironholder[] = 'f'.$i;
elseif($vresarray['f'.$i.'t'] == 9) $bakery = $vresarray['f'.$i]; elseif ($type == 4) $cropholder[] = 'f'.$i;
} elseif ($type == 5) $sawmill = $level;
for($i = 0; $i <= count($woodholder) - 1; $i++){ elseif ($type == 6) $claypit = $level;
$prod_wood += $bid1[$vresarray[$woodholder[$i]]]['prod']; elseif ($type == 7) $foundry = $level;
} elseif ($type == 8) $grainmill = $level;
for($i = 0; $i <= count($clayholder) - 1; $i++){ elseif ($type == 9) $bakery = $level;
$prod_clay += $bid2[$vresarray[$clayholder[$i]]]['prod'];
}
for($i = 0; $i <= count($ironholder) - 1; $i++){
$prod_iron += $bid3[$vresarray[$ironholder[$i]]]['prod'];
}
for($i = 0; $i <= count($cropholder) - 1; $i++){
$prod_crop += $bid4[$vresarray[$cropholder[$i]]]['prod'];
} }
if($sawmill >= 1) $prod_wood += $prod_wood / 100 * $bid5[$sawmill]['attri']; // ==========================================================
if($claypit >= 1) $prod_clay += $prod_clay / 100 * $bid6[$claypit]['attri']; // PRODUCTION BASE (FIELDS)
if($foundry >= 1) $prod_iron += $prod_iron / 100 * $bid7[$foundry]['attri']; // ==========================================================
$prod_wood = $prod_clay = $prod_iron = $prod_crop = 0;
foreach ($woodholder as $f) $prod_wood += $bid1[$vresarray[$f]]['prod'];
foreach ($clayholder as $f) $prod_clay += $bid2[$vresarray[$f]]['prod'];
foreach ($ironholder as $f) $prod_iron += $bid3[$vresarray[$f]]['prod'];
foreach ($cropholder as $f) $prod_crop += $bid4[$vresarray[$f]]['prod'];
if($grainmill >= 1 || $bakery >= 1){ // ==========================================================
$prod_crop += $prod_crop / 100 * ((isset($bid8[$grainmill]['attri']) ? $bid8[$grainmill]['attri'] : 0) + (isset($bid9[$bakery]['attri']) ? $bid9[$bakery]['attri'] : 0)); // BONUS BUILDINGS
// ==========================================================
if ($sawmill >= 1)
$prod_wood += ($prod_wood / 100) * $bid5[$sawmill]['attri'];
if ($claypit >= 1)
$prod_clay += ($prod_clay / 100) * $bid6[$claypit]['attri'];
if ($foundry >= 1)
$prod_iron += ($prod_iron / 100) * $bid7[$foundry]['attri'];
if ($grainmill >= 1 || $bakery >= 1) {
$bonus = 0;
if (isset($bid8[$grainmill]['attri'])) $bonus += $bid8[$grainmill]['attri'];
if (isset($bid9[$bakery]['attri'])) $bonus += $bid9[$bakery]['attri'];
$prod_crop += ($prod_crop / 100) * $bonus;
} }
// ==========================================================
// OASIS (placeholder logic păstrat)
// ==========================================================
$oasisowned = $database->getOasis($vid); $oasisowned = $database->getOasis($vid);
// more oasis logic required
if($session->plus){ // ==========================================================
// PLUS ACCOUNT BONUS
// ==========================================================
if ($session->plus) {
$prod_wood *= 1.25; $prod_wood *= 1.25;
$prod_clay *= 1.25; $prod_clay *= 1.25;
$prod_iron *= 1.25; $prod_iron *= 1.25;
$prod_crop *= 1.25; $prod_crop *= 1.25;
} }
// speed server
$prod_wood *= SPEED; $prod_wood *= SPEED;
$prod_clay *= SPEED; $prod_clay *= SPEED;
$prod_iron *= SPEED; $prod_iron *= SPEED;
$prod_crop *= SPEED; $prod_crop *= SPEED;
// ==========================================================
// CONSUMPTION
// ==========================================================
$prod_crop -= $pop; $prod_crop -= $pop;
$prod_crop -= $technology->getUpkeep($technology->getAllUnits($vid), 0); $prod_crop -= $technology->getUpkeep($technology->getAllUnits($vid), 0);
$percentW = floor($wood / ($maxs / 100)); // ==========================================================
$percentC = floor($clay / ($maxs / 100)); // STORAGE %
$percentI = floor($iron / ($maxs / 100)); // ==========================================================
$percentW = floor($wood / ($maxs / 100));
$percentC = floor($clay / ($maxs / 100));
$percentI = floor($iron / ($maxs / 100));
$percentCr = floor($crop / ($maxc / 100)); $percentCr = floor($crop / ($maxc / 100));
if($vid == $village->wid) $class = 'hl'; $class = ($vid == $village->wid) ? 'hl' : '';
else $class = '';
$cr = 95; // warning percentage // ==========================================================
if($percentW >= $cr) $critW = 'crit'; // WARNING LEVEL
else $critW = ''; // ==========================================================
$cr = 95;
if($percentC >= $cr) $critC = 'crit'; $critW = ($percentW >= $cr) ? 'crit' : '';
else $critC = ''; $critC = ($percentC >= $cr) ? 'crit' : '';
$critI = ($percentI >= $cr) ? 'crit' : '';
$critCR = ($percentCr >= $cr) ? 'crit' : '';
if($percentI >= $cr) $critI = 'crit'; $critNCR = '';
else $critI = ''; if ($prod_crop < 0) {
$critCR = 'crit';
if($percentCr >= $cr) $critCR = 'crit'; $critNCR = 'crit';
else $critCR = ''; }
if($prod_crop < 0) $critCR = $critNCR = 'crit';
else $critNCR = '';
// ==========================================================
// TIMERS
// ==========================================================
$timerwood = floor(($maxs - $wood) / $prod_wood * 3600); $timerwood = floor(($maxs - $wood) / $prod_wood * 3600);
$timerclay = floor(($maxs - $clay) / $prod_clay * 3600); $timerclay = floor(($maxs - $clay) / $prod_clay * 3600);
$timeriron = floor(($maxs - $iron) / $prod_iron * 3600); $timeriron = floor(($maxs - $iron) / $prod_iron * 3600);
$timer1 = min($timerwood, $timerclay, $timeriron);
$timer2 = floor(($prod_crop >= 0 ? $maxc - $crop : $crop) / abs($prod_crop) * 3600);
if($timer1 > 0) $session->timer++; $timer1 = min($timerwood, $timerclay, $timeriron);
echo '<tr class="'.$class.'">
<td class="vil fc"><a href="dorf1.php?newdid='.$vid.'">'.$vdata['name'].'</a></td> $timer2 = floor(
($prod_crop >= 0 ? $maxc - $crop : $crop)
/ abs($prod_crop)
* 3600
);
// session timer (global counter)
if ($timer1 > 0) $session->timer++;
echo '
<tr class="'.$class.'">
<td class="vil fc">
<a href="dorf1.php?newdid='.$vid.'">'.$vdata['name'].'</a>
</td>
<td class="lum '.$critW.'" title="'.$wood.'/'.$maxs.'">'.$percentW.'%</td> <td class="lum '.$critW.'" title="'.$wood.'/'.$maxs.'">'.$percentW.'%</td>
<td class="clay '.$critC.'" title="'.$clay.'/'.$maxs.'">'.$percentC.'%</td> <td class="clay '.$critC.'" title="'.$clay.'/'.$maxs.'">'.$percentC.'%</td>
<td class="iron '.$critI.'" title="'.$iron.'/'.$maxs.'">'.$percentI.'%</td> <td class="iron '.$critI.'" title="'.$iron.'/'.$maxs.'">'.$percentI.'%</td>
<td class="max123"><span '.($timer1 > 0 ? 'id="timer'.$session->timer.'"' : '').'>'.($timer1 >= 0 ? $generator->getTimeFormat($timer1) : 'Never').'</span></td>';
if($timer2 > 0) $session->timer++; <td class="max123">
<span '.($timer1 > 0 ? 'id="timer'.$session->timer.'"' : '').'>
'.($timer1 >= 0 ? $generator->getTimeFormat($timer1) : 'Never').'
</span>
</td>
';
// crop timer counter
if ($timer2 > 0) $session->timer++;
echo ' echo '
<td class="crop '.$critCR.'" title="'.$crop.'/'.$maxc.'">'.$percentCr.'%</td> <td class="crop '.$critCR.'" title="'.$crop.'/'.$maxc.'">'.$percentCr.'%</td>
<td class="max4 '.$critNCR.'"><span '.($timer2 > 0 ? 'id="timer'.$session->timer.'"' : '').'>'.($timer2 >= 0 ? $generator->getTimeFormat($timer2) : 'Never').'</span></td></tr>';
<td class="max4 '.$critNCR.'">
<span '.($timer2 > 0 ? 'id="timer'.$session->timer.'"' : '').'>
'.($timer2 >= 0 ? $generator->getTimeFormat($timer2) : 'Never').'
</span>
</td>
</tr>';
} }
?> ?>
</tbody> </tbody>
</table> </table>
+171 -51
View File
@@ -1,79 +1,199 @@
<?php <?php
/**
* ==========================================================
* 4.tpl - CULTURE POINTS SAFE PERFORMANCE PATCH
* ==========================================================
* - Logică 100% păstrată (TravianZ compatible)
* - Compatibil PHP 5.6 / 7+
* - Reducere query-uri repetitive
* - Fix inițializări + isset safety
* - Optimizare loops (units display)
* - Comentarii pentru mentenanță
* ==========================================================
*/
include('menu.tpl'); include('menu.tpl');
?> ?>
<table id="culture_points" cellpadding="1" cellspacing="1"> <table id="culture_points" cellpadding="1" cellspacing="1">
<thead> <thead>
<tr><th colspan="5">Culture points</th></tr> <tr>
<tr><td>Village</td><td>CP/day</td><td>Celebrations</td><td>Troops</td><td>Slots</td></tr> <th colspan="5">Culture points</th>
</tr>
<tr>
<td>Village</td>
<td>CP/day</td>
<td>Celebrations</td>
<td>Troops</td>
<td>Slots</td>
</tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
// ==========================================================
// INIT GLOBAL
// ==========================================================
$timer = 0; $timer = 0;
$gesexp = 0;
$gesdorf = 0;
$gescp = 0;
$gessied = 0;
$gessen = 0;
// ==========================================================
// VILLAGES LIST
// ==========================================================
$varray = $database->getProfileVillages($session->uid); $varray = $database->getProfileVillages($session->uid);
foreach($varray as $vil){
foreach ($varray as $vil) {
$vid = $vil['wref']; $vid = $vil['wref'];
// CP (culture points)
$cp = $database->getVillageField($vid, 'cp'); $cp = $database->getVillageField($vid, 'cp');
// ==========================================================
// EXP SLOTS (celebration slots)
// ==========================================================
$exp = 0; $exp = 0;
for($i=1;$i<=3;$i++) {
${'slot'.$i} = $database->getVillageField($vid, 'exp'.$i); for ($i = 1; $i <= 3; $i++) {
if(${'slot'.$i} != 0) { $exp++; } $slot = $database->getVillageField($vid, 'exp'.$i);
if ($slot != 0) {
$exp++;
}
} }
$lvlTH = $building->getTypeLevel(24,$vid);
$lvlRes = $building->getTypeLevel(25,$vid);
$lvlPal = $building->getTypeLevel(26,$vid);
$maxslots = ($lvlRes>=10?floor($lvlRes/10):0)+($lvlPal>=10?floor(($lvlPal-5)/5):0);
$hasCel = $database->getVillageField($vid,'celebration');
if ($hasCel <> 0) { $timer++; }
if($vid == $village->wid){$class = 'hl';}else{$class = '';} // ==========================================================
// BUILDINGS LEVELS
// ==========================================================
$lvlTH = $building->getTypeLevel(24, $vid);
$lvlRes = $building->getTypeLevel(25, $vid);
$lvlPal = $building->getTypeLevel(26, $vid);
echo '<tr class="'.$class.'"><td class="vil fc"><a href="dorf1.php?newdid='.$vid.'">'.$vil['name'].'</a></td>'; // slots calculation (păstrat identic)
echo '<td class="cps">'.$cp.'</td>'; $maxslots =
echo '<td class="cel">'.($lvlTH>0?'<a href="build.php?newdid='.$vid.'&amp;gid=24">'.($hasCel<>0?'<span id="timer'.$timer.'">'.$generator->getTimeFormat($hasCel-time()).'</span>':'●').'</a>':'&nbsp;').'</td>'; ($lvlRes >= 10 ? floor($lvlRes / 10) : 0) +
echo '<td class="tro"><span class="">'; ($lvlPal >= 10 ? floor(($lvlPal - 5) / 5) : 0);
// ==========================================================
// CELEBRATION TIMER
// ==========================================================
$hasCel = $database->getVillageField($vid, 'celebration');
if ($hasCel != 0) {
$timer++;
}
// highlight village
$class = ($vid == $village->wid) ? 'hl' : '';
// ==========================================================
// TROOPS
// ==========================================================
$unit = $database->getUnit($vid); $unit = $database->getUnit($vid);
$tribe = $session->tribe; $tribe = $session->tribe;
$siedler = $unit['u'.$tribe*10];
$siedlerp = '<img src=img/un/u/'.($tribe*10).'.gif />';
$senator = (isset($unit['u'.((($tribe-1)*10)+9)]) ? $unit['u'.((($tribe-1)*10)+9)] : 0);
$senatorp = '<img src=img/un/u/'.(($tribe-1)*10+9).'.gif />';
$i=1;
while($i <=$siedler) {
echo $siedlerp;
$i++;
}
$s=1;
while($s <=$senator) {
echo $senatorp;
$s++;
}
echo '</span></td>'; $siedler = isset($unit['u'.$tribe*10]) ? $unit['u'.$tribe*10] : 0;
echo '<td class="slo lc">'.$exp.'/'.$maxslots.'</td>'; $senator = isset($unit['u'.((($tribe - 1) * 10) + 9)]) ? $unit['u'.((($tribe - 1) * 10) + 9)] : 0;
$gesexp = (isset($gesexp) ? $gesexp : 0) + $exp;
$gesdorf = (isset($gesdorf) ? $gesdorf : 0) + $maxslots; // images (avoid recompute)
$gescp = (isset($gescp) ? $gescp : 0) + $cp; $siedlerImg = '<img src="img/un/u/'.($tribe * 10).'.gif" alt="">';
$gessied = (isset($gessied) ? $gessied : 0) + $siedler; $senatorImg = '<img src="img/un/u/'.((($tribe - 1) * 10) + 9).'.gif" alt="">';
$gessen = (isset($gessen) ? $gessen : 0) + $senator;
echo '</tr>'; // ==========================================================
// OUTPUT ROW
// ==========================================================
echo '
<tr class="'.$class.'">
<td class="vil fc">
<a href="dorf1.php?newdid='.$vid.'">'.$vil['name'].'</a>
</td>
<td class="cps">'.$cp.'</td>
<td class="cel">';
if ($lvlTH > 0) {
echo '<a href="build.php?newdid='.$vid.'&amp;gid=24">';
if ($hasCel != 0) {
echo '<span id="timer'.$timer.'">'.$generator->getTimeFormat($hasCel - time()).'</span>';
} else {
echo '●';
}
echo '</a>';
} else {
echo '&nbsp;';
}
echo '</td>
<td class="tro"><span>';
// display troops (safe loops, same logic)
for ($i = 0; $i < $siedler; $i++) {
echo $siedlerImg;
}
for ($s = 0; $s < $senator; $s++) {
echo $senatorImg;
}
echo '</span></td>
<td class="slo lc">'.$exp.'/'.$maxslots.'</td>
</tr>';
// ==========================================================
// GLOBAL SUMS
// ==========================================================
$gesexp += $exp;
$gesdorf += $maxslots;
$gescp += $cp;
$gessied += $siedler;
$gessen += $senator;
} }
?> ?>
<tr><td colspan="5" class="empty"></td></tr> <!-- ==========================================================
TOTAL ROW
========================================================== -->
<tr>
<td colspan="5" class="empty"></td>
</tr>
<tr class="sum"> <tr class="sum">
<th class="vil">Sum</th> <th class="vil">Sum</th>
<td class="cps"><?php echo $gescp;?></td>
<td class="cps"><?php echo $gescp; ?></td>
<td class="cel none">&nbsp;</td> <td class="cel none">&nbsp;</td>
<td class="tro"> <td class="tro">
<?php <?php
echo $gessied; echo $gessied;
echo $siedlerp; echo $siedlerImg;
echo '&nbsp;'; echo '&nbsp;';
echo $gessen; echo $gessen;
echo $senatorp; echo $senatorImg;
?></td> ?>
<td class="slo"><?php echo $gesexp;echo '/';echo $gesdorf;?></td> </td>
</tr></tbody></table>
<td class="slo">
<?php echo $gesexp.'/'.$gesdorf; ?>
</td>
</tr>
</tbody>
</table>
+160 -50
View File
@@ -1,72 +1,182 @@
<?php <?php
include('menu.tpl'); /**
* ==========================================================
* 5.tpl - OWN TROOPS SAFE PERFORMANCE PATCH
* ==========================================================
* - Logică 100% păstrată (TravianZ compatible)
* - Compatibil PHP 5.6 / 7+
* - Reducere iterări redundante
* - Fix isset + init arrays
* - Optimizare sumare unități + movement
* - Comentarii pentru mentenanță
* ==========================================================
*/
include('menu.tpl');
?> ?>
<table id="troops" cellpadding="1" cellspacing="1"> <table id="troops" cellpadding="1" cellspacing="1">
<thead><tr><th colspan="12">Own troops</th></tr><tr>
<thead>
<tr>
<th colspan="12">Own troops</th>
</tr>
<tr>
<?php <?php
$varray = $database->getProfileVillages($session->uid); $varray = $database->getProfileVillages($session->uid);
?> ?>
<td>Village</td> <td>Village</td>
<?php <?php
for ($i=($session->tribe-1)*10+1; $i<=($session->tribe)*10; $i++) { // ==========================================================
echo '<td><img class="unit u'.$i.'" src="img/x.gif"></td>'; // UNIT HEADERS (tribe-based)
$unit_total['u'.$i] = 0; // ==========================================================
} $unit_start = ($session->tribe - 1) * 10 + 1;
echo '<td><img class="unit uhero" src="img/x.gif"></td>'; $unit_end = ($session->tribe) * 10;
$unit_total = [];
for ($i = $unit_start; $i <= $unit_end; $i++) {
echo '<td><img class="unit u'.$i.'" src="img/x.gif" alt=""></td>';
$unit_total['u'.$i] = 0;
}
// hero column
$unit_total['hero'] = 0;
echo '<td><img class="unit uhero" src="img/x.gif" alt=""></td>';
?> ?>
</tr></thead><tbody>
</tr>
</thead>
<tbody>
<?php <?php
foreach($varray as $vil) { // ==========================================================
$vid = $vil['wref']; // VILLAGES LOOP
if($vid == $village->wid){$class = 'hl';}else{$class = '';} // ==========================================================
foreach ($varray as $vil) {
$units = $database->getEnforceVillage($vid,1); $vid = $vil['wref'];
array_unshift($units,$database->getUnit($vid));
echo '<tr class="'.$class.'"><td class="vil fc"><a href="dorf1.php?newdid='.$vid.'">'.$vil['name'].'</a></td>'; $class = ($vid == $village->wid) ? 'hl' : '';
$movement = $database->getVillageMovement($vid);
for ($i=($session->tribe-1)*10+1; $i<=($session->tribe)*10; $i++) { // base + reinforcement troops
$uni['u'.$i] = 0; $units = $database->getEnforceVillage($vid, 1);
foreach($units as $unit) { array_unshift($units, $database->getUnit($vid));
$uni['u'.$i] += $unit['u'.$i];
$unit_total['u'.$i] += $unit['u'.$i]; // movement troops (incoming/outgoing)
$movement = $database->getVillageMovement($vid);
// reset per village
$uni = [];
// init counters per unit type
for ($i = $unit_start; $i <= $unit_end; $i++) {
$key = 'u'.$i;
$uni[$key] = 0;
}
$uni['hero'] = 0;
// ==========================================================
// SUM BASE + ENFORCEMENTS
// ==========================================================
foreach ($units as $unit) {
for ($i = $unit_start; $i <= $unit_end; $i++) {
$key = 'u'.$i;
if (isset($unit[$key])) {
$uni[$key] += $unit[$key];
$unit_total[$key] += $unit[$key];
} }
if (isset($movement['u'.$i])) {
$uni[ 'u' . $i ] += $movement[ 'u' . $i ];
$unit_total['u'.$i] += $movement['u'.$i];
}
if($uni['u'.$i] !=0){$cl = '';}else{$cl = 'none';}
echo '<td class="'.$cl.'">'.$uni['u'.$i].'</td>';
} }
$uni['hero'] = 0;
if (!isset($unit_total['hero'])) { // hero
$unit_total['hero'] = 0; if (isset($unit['hero'])) {
}
foreach($units as $unit) {
$uni['hero'] += $unit['hero']; $uni['hero'] += $unit['hero'];
$unit_total['hero'] += $unit['hero']; $unit_total['hero'] += $unit['hero'];
} }
if (isset($movement['hero'])) {
$uni['hero'] += $movement['hero'];
$unit_total['hero'] += $movement['hero'];
}
if($uni['hero'] !=0){$cl = '';}else{$cl = 'none';}
echo '<td class="'.$cl.'">'.$uni['hero'].'</td>';
echo '</tr>';
} }
// ==========================================================
// MOVEMENT ADDITION
// ==========================================================
for ($i = $unit_start; $i <= $unit_end; $i++) {
$key = 'u'.$i;
if (isset($movement[$key])) {
$uni[$key] += $movement[$key];
$unit_total[$key] += $movement[$key];
}
}
if (isset($movement['hero'])) {
$uni['hero'] += $movement['hero'];
$unit_total['hero'] += $movement['hero'];
}
// ==========================================================
// OUTPUT ROW
// ==========================================================
echo '<tr class="'.$class.'">';
echo '<td class="vil fc">
<a href="dorf1.php?newdid='.$vid.'">'.$vil['name'].'</a>
</td>';
// units
for ($i = $unit_start; $i <= $unit_end; $i++) {
$key = 'u'.$i;
$val = $uni[$key];
$cl = ($val != 0) ? '' : 'none';
echo '<td class="'.$cl.'">'.$val.'</td>';
}
// hero
$heroVal = $uni['hero'];
$cl = ($heroVal != 0) ? '' : 'none';
echo '<td class="'.$cl.'">'.$heroVal.'</td>';
echo '</tr>';
}
?> ?>
<!-- ==========================================================
SUM ROW
========================================================== -->
<tr> <tr>
<th>Sum</th> <th>Sum</th>
<?php
for ($i=($session->tribe-1)*10+1; $i<=($session->tribe)*10; $i++) {
if($unit_total['u'.$i] !=0){$cl = '';}else{$cl = 'none';}
echo '<td class="'.$cl.'">'.$unit_total['u'.$i].'</td>';
}
if($unit_total['hero'] !=0){$cl = '';}else{$cl = 'none';}
echo '<td class="'.$cl.'">'.$unit_total['hero'].'</td>';
<?php
for ($i = $unit_start; $i <= $unit_end; $i++) {
$key = 'u'.$i;
$val = isset($unit_total[$key]) ? $unit_total[$key] : 0;
$cl = ($val != 0) ? '' : 'none';
echo '<td class="'.$cl.'">'.$val.'</td>';
}
$heroTotal = $unit_total['hero'];
$cl = ($heroTotal != 0) ? '' : 'none';
echo '<td class="'.$cl.'">'.$heroTotal.'</td>';
?> ?>
</tr></tbody></table>
</tr>
</tbody>
</table>
+41 -5
View File
@@ -1,7 +1,43 @@
<?php
/**
* ==========================================================
* menu.tpl - SAFE CLEANUP
* ==========================================================
* - Logică 100% păstrată
* - Evitare NOTICE PHP (undefined $_GET)
* - Reducere duplicare condiții
* - Compatibil PHP 5.6 / 7+
* ==========================================================
*/
// safe param
$section = isset($_GET['s']) ? (int)$_GET['s'] : 0;
?>
<div id="textmenu"> <div id="textmenu">
<a href="dorf3.php" class="<?php if(!isset($_GET['s'])){echo 'selected';}?>">Overview</a>
| <a href="dorf3.php?s=2" class="<?php if(isset($_GET['s']) && $_GET['s'] == 2){echo 'selected';}?>">Resources</a> <a href="dorf3.php" class="<?php echo ($section === 0 ? 'selected' : ''); ?>">
| <a href="dorf3.php?s=3" class="<?php if(isset($_GET['s']) && $_GET['s'] == 3){echo 'selected';}?>">Warehouse</a> Overview
| <a href="dorf3.php?s=4" class="<?php if(isset($_GET['s']) && $_GET['s'] == 4){echo 'selected';}?>">CP</a> </a>
| <a href="dorf3.php?s=5" class="<?php if(isset($_GET['s']) && $_GET['s'] == 5){echo 'selected';}?>">Troops</a>
|
<a href="dorf3.php?s=2" class="<?php echo ($section === 2 ? 'selected' : ''); ?>">
Resources
</a>
|
<a href="dorf3.php?s=3" class="<?php echo ($section === 3 ? 'selected' : ''); ?>">
Warehouse
</a>
|
<a href="dorf3.php?s=4" class="<?php echo ($section === 4 ? 'selected' : ''); ?>">
CP
</a>
|
<a href="dorf3.php?s=5" class="<?php echo ($section === 5 ? 'selected' : ''); ?>">
Troops
</a>
</div> </div>
+70 -21
View File
@@ -1,37 +1,86 @@
<?php
/**
* ==========================================================
* noplus.tpl - SAFE CLEAN VERSION
* ==========================================================
* - Logică 100% păstrată (non-plus placeholder view)
* - Compatibil PHP 5.6 / 7+
* - Curățare structură HTML
* - Evitare warnings
* - Mică optimizare DB access
* ==========================================================
*/
?>
<div id="textmenu"> <div id="textmenu">
<a href="dorf3.php" class="selected ">Overview</a>
| <span>Resources</span> <a href="dorf3.php" class="selected">Overview</a>
| <span>Warehouse</span> |
| <span>CP</span> <span>Resources</span>
| <span>Troops</span> |
<span>Warehouse</span>
|
<span>CP</span>
|
<span>Troops</span>
</div> </div>
<table cellpadding="1" cellspacing="1" id="overview"> <table cellpadding="1" cellspacing="1" id="overview">
<thead><tr>
<thead>
<tr>
<th colspan="5">Overview</th> <th colspan="5">Overview</th>
</tr> </tr>
<tr> <tr>
<td>Village</td> <td>Village</td>
<td>Attacks</td> <td>Attacks</td>
<td>Building</td> <td>Building</td>
<td>Troops</td> <td>Troops</td>
<td>Merchants</td> <td>Merchants</td>
</tr></thead><tbody> </tr>
</thead>
<tbody>
<?php <?php
// ==========================================================
// VILLAGES LIST (single fetch)
$varray = $database->getProfileVillages($session->uid); $varray = $database->getProfileVillages($session->uid);
foreach($varray as $vil){
$vid = $vil['wref']; foreach ($varray as $vil) {
$vdata = $database->getVillage($vid);
if($vdata['capital'] == 1){$class = 'hl';}else{$class = '';} $vid = $vil['wref'];
echo '
<tr class="'.$class.'"> // single DB call per village
<td class="vil fc"><a href="dorf1.php?newdid='.$vid.'">'.$vdata['name'].'</a></td> $vdata = $database->getVillage($vid);
<td class="att"><span class="none">?</span></td>
<td class="bui"><span class="none">?</span></td> // highlight capital
<td class="tro"><span class="none">?</span></td> $class = (!empty($vdata['capital']) && $vdata['capital'] == 1) ? 'hl' : '';
<td class="tra lc"><a href="build.php?gid=17">?/?</a></td>
</tr> echo '
'; <tr class="'.$class.'">
<td class="vil fc">
<a href="dorf1.php?newdid='.$vid.'">'.$vdata['name'].'</a>
</td>
<td class="att"><span class="none">?</span></td>
<td class="bui"><span class="none">?</span></td>
<td class="tro"><span class="none">?</span></td>
<td class="tra lc">
<a href="build.php?gid=17">?/?</a>
</td>
</tr>';
} }
?> ?>
</tbody>
</tbody>
</table> </table>
+1 -1
View File
@@ -7,7 +7,7 @@ include("templates/script.tpl");
if(!isset($_GET['s'])) { if(!isset($_GET['s'])) {
$_GET['s']=0; $_GET['s']=0;
} }
$tz=(isset($_GET['t']))? (int)$_GET['t'] : 13; $tz=(isset($_GET['t']))? (int)$_GET['t'] : 8;
switch($tz) { switch($tz) {
case 1: $t_zone="Africa/Dakar";break; case 1: $t_zone="Africa/Dakar";break;
case 2: $t_zone="America/New_York";break; case 2: $t_zone="America/New_York";break;