fix: sorting in messages and reports does not work

#327
This commit is contained in:
Martin Ambrus
2017-11-26 17:33:10 +01:00
parent d3b51a34ec
commit cb148b9aec
4 changed files with 24 additions and 23 deletions
+11 -10
View File
@@ -4125,10 +4125,10 @@ References: User ID/Message ID, Mode
global $session;
switch($mode) {
case 1:
$q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target IN($id) and send = 0 and archived = 0 ORDER BY time DESC";
$q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target IN($id) and send = 0 and archived = 0 ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC');
break;
case 2:
$q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner IN($id) ORDER BY time DESC";
$q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner IN($id) ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC');
break;
case 3:
$q = "SELECT * FROM " . TB_PREFIX . "mdata where id = $id";
@@ -4140,7 +4140,7 @@ References: User ID/Message ID, Mode
$q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,viewed = 1 where id IN(".implode(', ', $id).")";
break;
case 6:
$q = "SELECT * FROM " . TB_PREFIX . "mdata where target IN($id) and send = 0 and archived = 1";
$q = "SELECT * FROM " . TB_PREFIX . "mdata where target IN($id) and send = 0 and archived = 1 ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC');
break;
case 7:
$q = "UPDATE " . TB_PREFIX . "mdata set delowner = 1 where id IN(".implode(', ', $id).")";
@@ -4149,15 +4149,16 @@ References: User ID/Message ID, Mode
$q = "UPDATE " . TB_PREFIX . "mdata set deltarget = 1,delowner = 1,viewed = 1 where IN(".implode(', ', $id).")";
break;
case 9:
$q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target IN($id) and send = 0 and archived = 0 and deltarget = 0 ORDER BY time DESC";
$q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE target IN($id) and send = 0 and archived = 0 and deltarget = 0 ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC');
break;
case 10:
$q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner IN($id) and delowner = 0 ORDER BY time DESC";
$q = "SELECT * FROM " . TB_PREFIX . "mdata WHERE owner IN($id) and delowner = 0 ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC');
break;
case 11:
$q = "SELECT * FROM " . TB_PREFIX . "mdata where target IN($id) and send = 0 and archived = 1 and deltarget = 0";
$q = "SELECT * FROM " . TB_PREFIX . "mdata where target IN($id) and send = 0 and archived = 1 and deltarget = 0 ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC');
break;
}
if($mode <= 3 || $mode == 6 || $mode > 8) {
$result = mysqli_query($this->dblink,$q);
return $this->mysqli_fetch_all($result);
@@ -4226,7 +4227,7 @@ References: User ID/Message ID, Mode
function getNotice($uid) {
list($uid) = $this->escape_input((int) $uid);
$q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid and del = 0 ORDER BY time DESC";
$q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid and del = 0 ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC');
$result = mysqli_query($this->dblink,$q);
return $this->mysqli_fetch_all($result);
}
@@ -4240,7 +4241,7 @@ References: User ID/Message ID, Mode
return $cachedValue[$field];
}
$q = "SELECT * FROM " . TB_PREFIX . "ndata where `id` = $id ORDER BY time DESC LIMIT 1";
$q = "SELECT * FROM " . TB_PREFIX . "ndata where `id` = $id ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC')." LIMIT 1";
$result = mysqli_query($this->dblink,$q);
$dbarray = mysqli_fetch_array($result);
@@ -4257,7 +4258,7 @@ References: User ID/Message ID, Mode
return $cachedValue;
}
$q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid ORDER BY time DESC";
$q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC');
$result = mysqli_query($this->dblink,$q);
$noticesCacheByUId[$uid] = $this->mysqli_fetch_all($result);
@@ -4271,7 +4272,7 @@ References: User ID/Message ID, Mode
function getUnViewNotice($uid) {
list($uid) = $this->escape_input((int) $uid);
$q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid AND viewed=0";
$q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid AND viewed=0 ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC');
$result = mysqli_query($this->dblink,$q);
return $this->mysqli_fetch_all($result);
}
+5 -5
View File
@@ -8,7 +8,7 @@
<tr>
<th colspan="2">Subject</th>
<th>Sender</th>
<th class="sent">Sent</th>
<th class="sent"><a href="nachrichten.php?o=1">Sent</a></th>
</tr></thead><tfoot><tr><th>
<?php
$MyGold = mysqli_query($GLOBALS['link'],"SELECT plus FROM ".TB_PREFIX."users WHERE `id`='".(int) $session->uid."'") or die(mysqli_error($database->dblink));
@@ -28,17 +28,17 @@
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=0\">&raquo;</a>";
echo "&laquo;<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=10&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&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>";
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>";
}
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>";
echo "&laquo;<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']+10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&raquo;</a>";
}
else {
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']-10)."&o=0\">&laquo;</a>&raquo;";
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']-10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&laquo;</a>&raquo;";
}
}
?></th></tr></tfoot><tbody>
+4 -4
View File
@@ -34,17 +34,17 @@
echo "&laquo;&raquo;";
}
else if (!isset($_GET['s']) && count($message->sent1) > 10) {
echo "&laquo;<a href=\"?t=2&s=10&o=0\">&raquo;</a>";
echo "&laquo;<a href=\"?t=2&s=10&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&raquo;</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=0\">&laquo;</a><a href=\"?t=2&s=".($_GET['s']+10)."&o=0\">&raquo;</a>";
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>";
}
else if(count($message->sent1) > $_GET['s']+10) {
echo "&laquo;<a href=\"?t=2&s=".($_GET['s']+10)."&o=0\">&raquo;</a>";
echo "&laquo;<a href=\"?t=2&s=".($_GET['s']+10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&raquo;</a>";
}
else {
echo "<a href=\"?t=2&s=".($_GET['s']-10)."&o=0\">&laquo;</a>&raquo;";
echo "<a href=\"?t=2&s=".($_GET['s']-10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&laquo;</a>&raquo;";
}
}
?></th></tr></tfoot>
+4 -4
View File
@@ -35,17 +35,17 @@ $noticeClass = array("Scout Report","Won as attacker without losses","Won as att
echo "&laquo;&raquo;";
}
else if (!isset($_GET['s']) && count($message->noticearray) > 10) {
echo "&laquo;<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=10&amp;o=0\">&raquo;</a>";
echo "&laquo;<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=10&amp;o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&raquo;</a>";
}
else if(isset($_GET['s']) && count($message->noticearray) > $_GET['s']) {
if(count($message->noticearray) > ($_GET['s']+10) && $_GET['s']-10 < count($message->noticearray) && $_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>";
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>";
}
else if(count($message->noticearray) > $_GET['s']+10) {
echo "&laquo;<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']+10)."&o=0\">&raquo;</a>";
echo "&laquo;<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']+10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&raquo;</a>";
}
else {
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']-10)."&o=0\">&laquo;</a>&raquo;";
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&amp;' : '')."s=".($_GET['s']-10)."&o=".(!empty($_GET['o']) ? $_GET['o'] : 0)."\">&laquo;</a>&raquo;";
}
}
?>