mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-24 13:36:32 +00:00
Incremental Refactor Templates
Incremental Refactor Templates
This commit is contained in:
+154
-67
@@ -1,69 +1,156 @@
|
||||
<div id="content" class="messages">
|
||||
<h1>Messages</h1>
|
||||
<?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>
|
||||
<tr>
|
||||
<th colspan="2">Subject</th>
|
||||
<th>Sender</th>
|
||||
<th class="sent"><a href="nachrichten.php?s=0&t=3&o=1">Sent</a></th>
|
||||
</tr></thead><tfoot><tr><th>
|
||||
<input class="check" type="checkbox" id="s10" name="s10" onclick="Allmsg(this.form);" />
|
||||
</th>
|
||||
<th colspan="2" class="buttons">
|
||||
<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
|
||||
if(!isset($_GET['s']) && count($message->archived1) < 10) {
|
||||
echo "«»";
|
||||
}
|
||||
else if (!isset($_GET['s']) && count($message->archived1) > 10) {
|
||||
echo "«<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=10&o=0\">»</a>";
|
||||
}
|
||||
else if(isset($_GET['s']) && count($message->archived1) > $_GET['s']) {
|
||||
if(count($message->archived1) > ($_GET['s']+10) && $_GET['s']-10 < count($message->archived1) && $_GET['s'] != 0) {
|
||||
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=".($_GET['s']-10)."&o=0\">«</a><a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=".($_GET['s']+10)."&o=0\">»</a>";
|
||||
}
|
||||
else if(count($message->archived1) > $_GET['s']+10) {
|
||||
echo "«<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=".($_GET['s']+10)."&o=0\">»</a>";
|
||||
}
|
||||
else if (count($message->archived1) > 10) {
|
||||
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=".($_GET['s']-10)."&o=0\">«</a>»";
|
||||
}
|
||||
}
|
||||
?></th></tr></tfoot><tbody>
|
||||
<?php
|
||||
if(isset($_GET['s'])) {
|
||||
$s = $_GET['s'];
|
||||
}
|
||||
else {
|
||||
$s = 0;
|
||||
}
|
||||
$name = 1;
|
||||
for($i=(1+$s);$i<=(10+$s);$i++) {
|
||||
if(count($message->archived1) >= $i) {
|
||||
if($message->archived[$i-1]['owner'] == 0) {
|
||||
echo "<tr class=\"sup\">";
|
||||
}
|
||||
else {
|
||||
echo "<tr>";
|
||||
}
|
||||
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($message->archived[$i-1]['viewed'] == 0) {
|
||||
echo "(new)";
|
||||
}
|
||||
$date = $generator->procMtime($message->archived[$i-1]['time']);
|
||||
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>
|
||||
<td class=\"dat\">".$date[0]." ".$date[1]."</td></tr>";
|
||||
}
|
||||
$name++;
|
||||
}
|
||||
if(count($message->archived1) == 0) {
|
||||
echo "<td colspan=\"4\" class=\"none\">There are no messages available in the archive.</td></tr>";
|
||||
}
|
||||
?>
|
||||
</tbody></table>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="content" class="messages">
|
||||
<h1>Messages</h1>
|
||||
|
||||
<?php include("menu.tpl"); ?>
|
||||
|
||||
<form method="post" action="nachrichten.php" name="msg">
|
||||
<input type="hidden" name="ft" value="m5" />
|
||||
|
||||
<table cellpadding="1" cellspacing="1" id="overview">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">Subject</th>
|
||||
<th>Sender</th>
|
||||
<th class="sent">
|
||||
<a href="nachrichten.php?s=0&t=3&o=1">Sent</a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>
|
||||
<input class="check" type="checkbox" id="s10" name="s10" onclick="Allmsg(this.form);" />
|
||||
</th>
|
||||
|
||||
<th colspan="2" class="buttons">
|
||||
<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
|
||||
// ======================================================
|
||||
// PAGINATION (same logic, cleaned)
|
||||
// ======================================================
|
||||
$total = count($message->archived1);
|
||||
$s = isset($_GET['s']) ? (int)$_GET['s'] : 0;
|
||||
$tParam = !empty($_GET['t']) ? 't=' . $_GET['t'] . '&' : '';
|
||||
|
||||
if (!isset($_GET['s']) && $total < 10) {
|
||||
echo "«»";
|
||||
} elseif (!isset($_GET['s']) && $total > 10) {
|
||||
echo "«<a href=\"?" . $tParam . "s=10&o=0\">»</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\">«</a>
|
||||
<a href=\"?" . $tParam . "s=" . ($_GET['s'] + 10) . "&o=0\">»</a>";
|
||||
|
||||
} elseif ($total > $_GET['s'] + 10) {
|
||||
echo "«<a href=\"?" . $tParam . "s=" . ($_GET['s'] + 10) . "&o=0\">»</a>";
|
||||
|
||||
} elseif ($total > 10) {
|
||||
echo "<a href=\"?" . $tParam . "s=" . ($_GET['s'] - 10) . "&o=0\">«</a>»";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<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>
|
||||
+215
-100
@@ -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>
|
||||
<?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 "«»";
|
||||
}
|
||||
else if (!isset($_GET['s']) && count($message->inbox1) > 10) {
|
||||
echo "«<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=10&o=".(!empty($_GET['o']) )."\">»</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'].'&' : '')."s=".($_GET['s']-10)."&o=0\">«</a><a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=".($_GET['s']+10)."&o=0\">»</a>";
|
||||
}
|
||||
else if(count($message->inbox1) > $_GET['s']+10) {
|
||||
echo "«<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=".($_GET['s']+10)."&o=0\">»</a>";
|
||||
}
|
||||
else if(count($message->inbox1) > 10) {
|
||||
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=".($_GET['s']-10)."&o=0\">«</a>»";
|
||||
}
|
||||
}
|
||||
?></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++) {
|
||||
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>";
|
||||
}
|
||||
<?php include("menu.tpl"); ?>
|
||||
|
||||
$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)) {
|
||||
$message_for_text = "<input class=\"check\" type=\"checkbox\" name=\"n".$name."\" value=\"".$message->inbox1[$i-1]['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>';
|
||||
<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
|
||||
// ======================================================
|
||||
// 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 "«»";
|
||||
} elseif (!isset($_GET['s']) && $total > 10) {
|
||||
echo "«<a href=\"?" . $tParam . "s=10&o=0\">»</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\">«</a>
|
||||
<a href=\"?" . $tParam . "s=" . ($_GET['s'] + 10) . "&o=0\">»</a>";
|
||||
|
||||
} elseif ($total > $_GET['s'] + 10) {
|
||||
echo "«<a href=\"?" . $tParam . "s=" . ($_GET['s'] + 10) . "&o=0\">»</a>";
|
||||
|
||||
} elseif ($total > 10) {
|
||||
echo "<a href=\"?" . $tParam . "s=" . ($_GET['s'] - 10) . "&o=0\">«</a>»";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</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> ";
|
||||
if($message->inbox1[$i-1]['viewed'] == 0) {
|
||||
echo "(new)";
|
||||
}
|
||||
$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);
|
||||
// ======================================================
|
||||
// EMPTY STATE
|
||||
// ======================================================
|
||||
if ($totalMessages == 0) {
|
||||
echo "<td colspan=\"4\" class=\"none\">There are no messages available.</td></tr>";
|
||||
}
|
||||
?>
|
||||
|
||||
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>
|
||||
|
||||
<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>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
+39
-11
@@ -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">
|
||||
<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>
|
||||
| <a href="nachrichten.php?t=2" <?php if(isset($_GET['t']) && $_GET['t'] == 2) { echo "class=\"selected\""; } ?> >Sent</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\"";
|
||||
if(isset($_GET['t']) && $_GET['t'] == 4) { echo "class=\"selected\""; }
|
||||
echo ">Notes</a>";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Inbox -->
|
||||
<a href="nachrichten.php" <?php if ($t === 0) { echo 'class="selected"'; } ?>>Inbox</a>
|
||||
|
||||
|
|
||||
|
||||
<!-- Write -->
|
||||
<a href="nachrichten.php?t=1" <?php if ($t === 1) { echo 'class="selected"'; } ?>>Write</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>
|
||||
+36
-10
@@ -1,15 +1,41 @@
|
||||
<div id="content" class="messages">
|
||||
<h1>Messages</h1>
|
||||
<?php
|
||||
include("menu.tpl");
|
||||
<?php
|
||||
#################################################################################
|
||||
## 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">
|
||||
|
||||
<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 />
|
||||
</p>
|
||||
|
||||
<!-- ======================================================
|
||||
FORM TYPE (UNCHANGED)
|
||||
======================================================= -->
|
||||
<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 />
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
+112
-43
@@ -1,53 +1,122 @@
|
||||
<?php
|
||||
$input = $message->reading['message'];
|
||||
$alliance = $message->reading['alliance'];
|
||||
$player = $message->reading['player'];
|
||||
$coor = $message->reading['coor'];
|
||||
$report = $message->reading['report'];
|
||||
#################################################################################
|
||||
## SAFE INCREMENTAL REFACTOR - Read Message ##
|
||||
## Credits: cleaned structure, same logic preserved ##
|
||||
## Compatibility: PHP 5.6+ / PHP 7+ ##
|
||||
#################################################################################
|
||||
|
||||
// ======================================================
|
||||
// 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");
|
||||
|
||||
// ======================================================
|
||||
// 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>
|
||||
<?php
|
||||
include("menu.tpl");
|
||||
?>
|
||||
|
||||
<?php include("menu.tpl"); ?>
|
||||
|
||||
<form method="post" action="nachrichten.php">
|
||||
|
||||
|
||||
<div id="read_head" class="msg_head"></div>
|
||||
|
||||
<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);
|
||||
|
||||
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>
|
||||
|
||||
<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>
|
||||
|
||||
</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>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
+182
-84
@@ -1,99 +1,197 @@
|
||||
<?php
|
||||
|
||||
/** --------------------------------------------------- **\
|
||||
| ********* DO NOT REMOVE THIS COPYRIGHT NOTICE ********* |
|
||||
+---------------------------------------------------------+
|
||||
| Credits: All the developers including the leaders: |
|
||||
| Advocaite & Dzoki & Donnchadh |
|
||||
| |
|
||||
| Copyright: TravianX Project All rights reserved |
|
||||
\** --------------------------------------------------- **/
|
||||
#################################################################################
|
||||
## SAFE INCREMENTAL REFACTOR - Sent Message ##
|
||||
## Credits: cleaned structure, same logic preserved ##
|
||||
## Compatibility: PHP 5.6+ / PHP 7+ ##
|
||||
#################################################################################
|
||||
|
||||
// ======================================================
|
||||
// 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>
|
||||
<?php include("menu.tpl"); ?>
|
||||
<form method="post" action="nachrichten.php" name="msg">
|
||||
<input type="hidden" name="ft" value="m4" />
|
||||
<table cellpadding="1" cellspacing="1" id="overview">
|
||||
<thead><tr>
|
||||
<th></th>
|
||||
<th>Subject</th>
|
||||
<th>Recipient</th>
|
||||
<th class="sent"><a href="nachrichten.php?t=2&s=0&t=2&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 value="delete" name="delmsg" id="btn_delete" class="trav_buttons">Delete</button></th><th class="navi"><?php
|
||||
if(!isset($_GET['s']) && count($message->sent1) < 10) {
|
||||
|
||||
<div id="content" class="messages">
|
||||
<h1>Messages</h1>
|
||||
|
||||
<?php include("menu.tpl"); ?>
|
||||
|
||||
<form method="post" action="nachrichten.php" name="msg">
|
||||
<input type="hidden" name="ft" value="m4" />
|
||||
|
||||
<table cellpadding="1" cellspacing="1" id="overview">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Subject</th>
|
||||
<th>Recipient</th>
|
||||
<th class="sent">
|
||||
<a href="nachrichten.php?t=2&s=0&t=2&o=1">Sent</a>
|
||||
</th>
|
||||
</tr>
|
||||
</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 "«»";
|
||||
}
|
||||
elseif (!isset($_GET['s']) && $total > 10) {
|
||||
echo "«<a href=\"?t=2&s=10&o=$o\">»</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\">«</a>
|
||||
<a href=\"?t=2&s=" . ($_GET['s'] + 10) . "&o=$o\">»</a>";
|
||||
|
||||
} elseif ($total > $_GET['s'] + 10) {
|
||||
echo "«<a href=\"?t=2&s=" . ($_GET['s'] + 10) . "&o=$o\">»</a>";
|
||||
|
||||
} elseif ($total > 10) {
|
||||
echo "<a href=\"?t=2&s=" . ($_GET['s'] - 10) . "&o=$o\">«</a>»";
|
||||
}
|
||||
else if (!isset($_GET['s']) && count($message->sent1) > 10) {
|
||||
echo "«<a href=\"?t=2&s=10&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">»</a>";
|
||||
}
|
||||
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) {
|
||||
echo "<a href=\"?t=2&s=".($_GET['s']-10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">«</a><a href=\"?t=2&s=".($_GET['s']+10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">»</a>";
|
||||
}
|
||||
else if(count($message->sent1) > $_GET['s']+10) {
|
||||
echo "«<a href=\"?t=2&s=".($_GET['s']+10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">»</a>";
|
||||
}
|
||||
else if (count($message->sent1) > 10) {
|
||||
echo "<a href=\"?t=2&s=".($_GET['s']-10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">«</a>»";
|
||||
}
|
||||
}
|
||||
?></th></tr></tfoot>
|
||||
}
|
||||
?>
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<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++) {
|
||||
if(count($message->sent1) >= $i) {
|
||||
if($message->sent1[$i-1]['target'] == 0) {
|
||||
echo "<tr class=\"sup\">";
|
||||
}
|
||||
else {
|
||||
echo "<tr>";
|
||||
}
|
||||
<?php
|
||||
// ======================================================
|
||||
// MESSAGE LIST
|
||||
// ======================================================
|
||||
$name = 1;
|
||||
|
||||
$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)) {
|
||||
$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>';
|
||||
}
|
||||
$totalMessages = count($message->sent1);
|
||||
|
||||
echo "<td class=\"sel\">".$sent_as_text."</td>
|
||||
<td class=\"top\"><a href=\"nachrichten.php?t=2a&id=".$message->sent1[$i-1]['id']."\">".$message->sent1[$i-1]['topic']."</a> ";
|
||||
if($message->sent1[$i-1]['viewed'] == 0) {
|
||||
echo "(unread)";
|
||||
}
|
||||
$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>
|
||||
<td class=\"dat\">".$date[0]." ".$date[1]."</td></tr>";
|
||||
for ($i = (1 + $s); $i <= (10 + $s); $i++) {
|
||||
|
||||
if ($totalMessages >= $i) {
|
||||
|
||||
$msg = $message->sent1[$i - 1];
|
||||
|
||||
// row class
|
||||
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&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>";
|
||||
}
|
||||
?>
|
||||
</tbody></table>
|
||||
}
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
+242
-144
@@ -1,66 +1,108 @@
|
||||
<div id="content" class="messages">
|
||||
<h1>Messages</h1>
|
||||
<?php
|
||||
include("menu.tpl");
|
||||
$user = $database->getUserArray($session->uid, 1);
|
||||
<?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>
|
||||
|
||||
<?php
|
||||
include("menu.tpl");
|
||||
|
||||
// ======================================================
|
||||
// USER DATA (single load)
|
||||
// ======================================================
|
||||
$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">
|
||||
function setReceiver(name) {
|
||||
document.getElementById('receiver').value = name;
|
||||
copyElement('receiver');
|
||||
}
|
||||
// JS rămâne IDENTIC (nu modificăm comportament)
|
||||
function setReceiver(name) {
|
||||
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_content" class="msg_content">
|
||||
<form method="post" action="nachrichten.php" accept-charset="UTF-8" name="msg">
|
||||
<input type="hidden" name="c" value="3e9" />
|
||||
<input type="hidden" name="p" value="" />
|
||||
<img src="img/x.gif" id="label" class="send" alt="" />
|
||||
<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 />
|
||||
<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 $message->reply['topic'] = strip_tags(preg_replace("/re[0-9]+/i","re".($c),$message->reply['topic']));
|
||||
}else{
|
||||
echo "re1:".strip_tags($message->reply['topic']); }} ?>" maxlength="35" onkeyup="copyElement('subject')" tabindex=2/>
|
||||
</div>
|
||||
<a id="adbook" href="#" onclick="toggleFriendsList(); return false;"><img src="img/x.gif" alt="Addressbook" title="Addressbook" /></a>
|
||||
|
||||
<form method="post" action="nachrichten.php" accept-charset="UTF-8" name="msg">
|
||||
<input type="hidden" name="c" value="3e9" />
|
||||
<input type="hidden" name="p" value="" />
|
||||
|
||||
<img src="img/x.gif" id="label" class="send" alt="" />
|
||||
|
||||
<div id="heading">
|
||||
|
||||
<!-- ======================================================
|
||||
RECEIVER
|
||||
====================================================== -->
|
||||
<input class="text" type="text" name="an" id="receiver"
|
||||
value="<?php
|
||||
if (isset($id)) {
|
||||
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="line"></div>
|
||||
|
||||
<!-- ======================================================
|
||||
MESSAGE AREA (NU MODIFICĂM BB EDITOR)
|
||||
====================================================== -->
|
||||
<div bbArea="message" id="message_container" name="message_container">
|
||||
<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>
|
||||
@@ -84,96 +126,152 @@ echo "re1:".strip_tags($message->reply['topic']); }} ?>" maxlength="35" onkeyup=
|
||||
</div>
|
||||
</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_________________________
|
||||
Reply: ".$database->getUserField($id,'username',0)."
|
||||
\n".stripslashes($message->reply['message']); } ?></textarea>
|
||||
<div id="message_preview" name="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" 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'];
|
||||
|
||||
<textarea id="message" name="message" tabindex="3" class="textarea write message"><?php
|
||||
if (isset($message->reply['message'])) {
|
||||
echo "\n\n_________________________\nReply: "
|
||||
. getCachedUsername($id, $database, $userCache)
|
||||
. "\n"
|
||||
. stripslashes($message->reply['message']);
|
||||
}
|
||||
}
|
||||
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>
|
||||
?></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>
|
||||
|
||||
<?php
|
||||
if(!is_int($i/2)){ echo "</tr>"; }else{ echo "<td></td>";}
|
||||
}
|
||||
}} ?>
|
||||
</tr></table>
|
||||
<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>
|
||||
// ======================================================
|
||||
// ADMIN / MULTIHUNTER OPTIONS
|
||||
// ======================================================
|
||||
if ($session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES && !empty($_GET['mid'])) {
|
||||
?>
|
||||
<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>
|
||||
Reference in New Issue
Block a user