refactor: multiple calls to getVSumField() replaced by a single one

#313
This commit is contained in:
Martin Ambrus
2017-11-25 20:29:12 +01:00
parent 446e9b5f1d
commit 8d8c96014b
6 changed files with 138 additions and 54 deletions
+17 -8
View File
@@ -1,17 +1,26 @@
<?php
<?php
if(isset($aid)) {
$aid = $aid;
}
else {
$aid = $session->alliance;
}
$varmedal = $database->getProfileMedalAlly($aid);
}
$varmedal = $database->getProfileMedalAlly($aid);
$allianceinfo = $database->getAlliance($aid);
$memberlist = $database->getAllMember($aid);
$totalpop = 0;
$memberIDs = [];
foreach($memberlist as $member) {
$totalpop += $database->getVSumField($member['id'],"pop");
$memberIDs[] = $member['id'];
}
$data = $database->getVSumField($memberIDs,"pop");
if (count($data)) {
foreach ($data as $row) {
$totalpop += $row['Total'];
}
}
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>";
@@ -80,9 +89,9 @@ INDELING CATEGORIEEN:
== 7. in top 3 - verdediging ==
== 8. in top 3 - klimmers ==
== 9. in top 3 - overval ==
******************************/
******************************/
foreach($varmedal as $medal) {
$titel="Bonus";
switch ($medal['categorie']) {
@@ -122,7 +131,7 @@ INDELING CATEGORIEEN:
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>
+31 -22
View File
@@ -5,7 +5,7 @@ $aid = $_GET['aid'];
else {
$aid = $session->alliance;
}
$varmedal = $database->getProfileMedalAlly($aid);
$varmedal = $database->getProfileMedalAlly($aid);
$allianceinfo = $database->getAlliance($aid);
$memberlist = $database->getAllMember($aid);
@@ -14,16 +14,25 @@ if($allianceinfo['tag']==""){
header("Location: allianz.php");
exit;
}
$memberIDs = [];
foreach($memberlist as $member) {
$totalpop += $database->getVSumField($member['id'],"pop");
$memberIDs[] = $member['id'];
}
$data = $database->getVSumField($memberIDs,"pop");
if (count($data)) {
foreach ($data as $row) {
$totalpop += $row['Total'];
}
}
echo "<h1>".$allianceinfo['tag']." - ".$allianceinfo['name']."</h1>";
$profiel="".$allianceinfo['notice']."".md5('skJkev3')."".$allianceinfo['desc']."";
require("medal.php");
$profiel=explode("".md5('skJkev3')."", $profiel);
include("alli_menu.tpl");
include("alli_menu.tpl");
?>
<table cellpadding="1" cellspacing="1" id="profile">
@@ -69,25 +78,25 @@ include("alli_menu.tpl");
</tr>
<?php
foreach($memberlist as $member) {
//rank name
$rank = $database->getAlliancePermission($member['id'],"rank",0);
//username
$name = $database->getUserField($member['id'],"username",0);
//if there is no rank defined, user will not be printed
if($rank == ''){
echo '';
}
//if there is user rank defined, user will be printed
else if($rank != ''){
echo "<tr>";
echo "<th>".stripslashes($rank)."</th>";
echo "<td><a href='spieler.php?uid=".$member['id']."'>".$name."</td>";
echo "</tr>";
}
}
}
if($allianceinfo['forumlink'] != '' && $allianceinfo['forumlink'] != '0'){
echo "<tr>";
@@ -115,7 +124,7 @@ include("alli_menu.tpl");
<th>Player</th>
<th>Population</th>
<th>Villages</th>
<?php
<?php
if($aid == $session->alliance){
echo "<th>&nbsp;</th>";
}
@@ -139,31 +148,31 @@ foreach($memberlist as $member) {
$rank = $rank+1;
$TotalUserPop = $database->getVSumField($member['id'],"pop");
$TotalVillages = $database->getProfileVillages($member['id']);
$TotalVillages = $database->getProfileVillages($member['id']);
echo " <tr>";
echo " <td class=ra>".$rank.".</td>";
echo " <td class=pla><a href=spieler.php?uid=".$member['id'].">".$member['username']."</a></td>";
echo " <td class=hab>".$TotalUserPop."</td>";
echo " <td class=pla><a href=spieler.php?uid=".$member['id'].">".$member['username']."</a></td>";
echo " <td class=hab>".$TotalUserPop."</td>";
echo " <td class=vil>".count($TotalVillages)."</td>";
if($aid == $session->alliance){
if($aid == $session->alliance){
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>";
}elseif ((time()-86400) < $member['timestamp'] && (time()-600) > $member['timestamp']){ // 10 Min - 1 Days
echo " <td class=on><img class=online2 src=img/x.gif title='Offline' alt='Offline' /></td>";
echo " <td class=on><img class=online2 src=img/x.gif title='Offline' alt='Offline' /></td>";
}elseif ((time()-259200) < $member['timestamp'] && (time()-86400) > $member['timestamp']){ // 1-3 Days
echo " <td class=on><img class=online3 src=img/x.gif title='Last 3 days' alt='Last 3 days' /></td>";
echo " <td class=on><img class=online3 src=img/x.gif title='Last 3 days' alt='Last 3 days' /></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>";
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>";
echo " <td class=on><img class=online5 src=img/x.gif title=inactive alt=inactive /></td>";
}
}
echo " </tr>";
echo " </tr>";
}
?>
?>
</tbody>
</table>