function include_racestats_text() { // Get Total Number of Tribes $strSQL = "SELECT COUNT(*) as total " . "FROM " . TBL_STAT . " " . "WHERE " . ALLIANCE . " > 10"; $iTotal = mysql_result(mysql_query($strSQL), 0, 0); $iTotal2 = 0; // Get All Races include_once 'inc/classes/clsRace.php'; $arrRaces = clsRace::getRaces(); $arrActiveRaces = clsRace::getActiveRaces(); // Begin Create Table $strRaceStatsTable = '<table cellspacing="0" cellpadding="0" class="small">' . '<tr class="header">' . '<th colspan="2">' . "Racial Stats" . "</th>" . "</tr>" . '<tr class="subheader">' . "<th>" . "Race" . "</th>" . '<th class="right">' . "%" . "</th>" . "</tr>"; for ($i = 0; $i < count($arrRaces); $i++) { // Give each 3rd row a border down $strStyle = ''; //if (($i % 3) == 0) { $strStyle = ' class = "bsdown" '; } if (!in_array($arrRaces[$i], $arrActiveRaces)) { $strStyle = ' style="font-style:italic;"'; } // Get Number of Tribes of the Current Race $SQL = "SELECT id FROM " . TBL_STAT . " " . "WHERE " . RACE . " = '{$arrRaces[$i]}' AND " . ALLIANCE . " > 10"; $count[$i] = mysql_num_rows(mysql_query($SQL)); $iTotal2 += $count[$i]; $strRaceStatsTable .= '<tr class="data">' . "<th{$strStyle}>" . $arrRaces[$i] . "</th>" . "<td{$strStyle}>" . round($count[$i] / $iTotal * 100, 2) . " %</td>" . "</tr>"; } $strRaceStatsTable .= '<tr class="data">' . "<th>" . "Unknown" . "</th>" . "<td>" . round(($iTotal - $iTotal2) / $iTotal * 100, 2) . " %</td>" . "</tr>" . "</table>"; echo $strRaceStatsTable; }
function getRaces($strFamily = 'All') { return clsRace::getRaces($strFamily); }
function include_targetfinder_text() { global $Host; include_once('inc/functions/tools.php'); include_once("inc/classes/clsUser.php"); require_once('inc/races/clsRace.php'); // value initializations for the echos in the form if(!empty($_POST)) { $landMin=stripslashes($_POST["landMin"]); $landMax=stripslashes($_POST["landMax"]); $strMin=stripslashes($_POST["strMin"]); $strMax=stripslashes($_POST["strMax"]); $fameMin=stripslashes($_POST["fameMin"]); $fameMax=stripslashes($_POST["fameMax"]); if(empty($_POST["races"])) { echo "<div class=\"center negative\">You need to select at least 1 race</div>"; $races[0] = ""; } else { $races=$_POST["races"]; } $sort=$_POST["sort"]; $sortType=$_POST["sortType"]; $error=false; // adding a lil check or max was higher then min if(!empty($landMax)&&$landMin>$landMax) { echo "<div class=\"center negative\">Your land minimum is higher than land maximum!</div>"; $error=true; } if(!empty($strMax)&&$strMin>$strMax) { echo "<div class=\"center negative\">Your strength minimum is higher than strength maximum!</div>"; $error=true; } if(!empty($fameMax)&&$fameMin>$fameMax) { echo "<div class=\"center negative\">Your fame minimum is higher than fame maximum!</div>"; $error=true; } if(!is_numeric($landMin)&&!is_numeric($landMax)&&!is_numeric($strMin)&&!is_numeric($strMax)&&!is_numeric($fameMin)&&!is_numeric($fameMax)) { echo "<div class=\"center negative\">You must fill at least one search criterium!</div>"; $error=true; } } else { $landMin=""; $landMax=""; $strMin=""; $strMax=""; $fameMin=""; $fameMax=""; /*$races[0]="Uruk Hai"; $races[1]="Oleg Hai"; $races[2]="Mori Hai"; $races[3]="Dark Elf"; $races[4]="Wood Elf"; $races[5]="High Elf"; $races[6]="Dwarf"; $races[7]="Brittonian"; $races[8]="Viking"; $races[9]="Raven"; $races[10]="Dragon"; $races[11]="Eagle"; $races[12]="Nazgul"; $races[13]="Undead"; $races[14]="Spirit";*/ $races = clsRace::getRaces(); $sort="land"; $sortType="DESC"; } ?> <form id="tFinder" method="post" action="main.php?cat=game&page=targetfinder&z=do"> <table cellpadding="0" cellspacing="0"> <tbody> <tr class="header"> <th colspan="3">Target Finder</th> </tr> <tr class="subheader"> <th>Type</th> <th colspan="2">Option</th> </tr> <tr class="data"> <th>Land Size: </th> <td>From <input type="text" name="landMin" size="8" maxlength="6" value="<? echo $landMin; ?>" /></td> <td>To <input type="text" name="landMax" size="8" maxlength="6" value="<? echo $landMax; ?>" /></td> </tr> <tr class="data"> <th>Strength: </th> <td>From <input type="text" name="strMin" size="8" maxlength="8" value="<? echo $strMin; ?>" /></td> <td>To <input type="text" name="strMax" size="8" maxlength="8" value="<? echo $strMax; ?>" /></td> </tr> <tr class="data"> <th>Fame: </th> <td>From <input type="text" name="fameMin" size="8" maxlength="6" value="<? echo $fameMin; ?>" /></td> <td>To <input type="text" name="fameMax" size="8" maxlength="6" value="<? echo $fameMax; ?>" /></td> </tr> <tr class="data"> <th> Races: </th> <td colspan="2" class="center"> <table> <tbody> <?php /* <tr class="data"> <td class="left"><input name="races[]" type="checkbox" value="Uruk Hai" <? if(in_array("Uruk Hai",$races)) echo "checked=\"checked\""; ?> /> Uruk Hai</td> <td class="left"><input name="races[]" type="checkbox" value="Oleg Hai" <? if(in_array("Oleg Hai",$races)) echo "checked=\"checked\""; ?> /> Oleg Hai</td> <td class="left"><input name="races[]" type="checkbox" value="Mori Hai" <? if(in_array("Mori Hai",$races)) echo "checked=\"checked\""; ?> /> Mori Hai</td> </tr> <tr class="data"> <td class="left"><input name="races[]" type="checkbox" value="Dark Elf" <? if(in_array("Dark Elf",$races)) echo "checked=\"checked\""; ?> /> Dark Elf</td> <td class="left"><input name="races[]" type="checkbox" value="Wood Elf" <? if(in_array("Wood Elf",$races)) echo "checked=\"checked\""; ?> /> Wood Elf</td> <td class="left"><input name="races[]" type="checkbox" value="High Elf" <? if(in_array("High Elf",$races)) echo "checked=\"checked\""; ?> /> High Elf</td> </tr> <tr class="data"> <td class="left"><input name="races[]" type="checkbox" value="Dwarf" <? if(in_array("Dwarf",$races)) echo "checked=\"checked\""; ?> /> Dwarf</td> <td class="left"><input name="races[]" type="checkbox" value="Brittonian" <? if(in_array("Brittonian",$races)) echo "checked=\"checked\""; ?> /> Brittonian</td> <td class="left"><input name="races[]" type="checkbox" value="Viking" <? if(in_array("Viking",$races)) echo "checked=\"checked\""; ?> /> Viking</td> </tr> <tr class="data"> <td class="left"><input name="races[]" type="checkbox" value="Raven" <? if(in_array("Raven",$races)) echo "checked=\"checked\""; ?> /> Raven</td> <td class="left"><input name="races[]" type="checkbox" value="Dragon" <? if(in_array("Dragon",$races)) echo "checked=\"checked\""; ?> /> Dragon</td> <td class="left"><input name="races[]" type="checkbox" value="Eagle" <? if(in_array("Eagle",$races)) echo "checked=\"checked\""; ?> /> Eagle</td> </tr> <tr class="data"> <td class="left"><input name="races[]" type="checkbox" value="Nazgul" <? if(in_array("Nazgul",$races)) echo "checked=\"checked\""; ?> /> Nazgul</td> <td class="left"><input name="races[]" type="checkbox" value="Undead" <? if(in_array("Undead",$races)) echo "checked=\"checked\""; ?> /> Undead</td> <td class="left"><input name="races[]" type="checkbox" value="Spirit" <? if(in_array("Spirit",$races)) echo "checked=\"checked\""; ?> /> Spirit</td> </tr> */ foreach (clsRace::getRaces() as $number => $race) { if ($number % 3 == 0) { echo '<tr class="data">'; } echo "<td class=\"left\"><input name=\"races[]\" type=\"checkbox\" value=\"{$race}\" "; if (in_array($race, $races)) { echo 'checked="checked"'; } echo " /> {$race}</td>"; if ($number % 3 == 2) { echo '</tr>'; } } ?> </tr> </tbody> </table> <a href="#" onclick="var races=document.getElementById('tFinder')['races[]']; for(var i=0,len=races.length;i<len;i++) races[i].checked=true;">Check All</a> | <a href="#" onclick="var races=document.getElementById('tFinder')['races[]']; for(var i=0,len=races.length;i<len;i++) races[i].checked=false;">Uncheck All</a> </td> </tr> <tr class="data"> <th>Sort By: </th> <td colspan="2"> <select name="sort"> <option value="land" <? if($sort=="land") echo "selected=\"selected\""; ?>>Land</option> <option value="nw" <? if($sort=="nw") echo "selected=\"selected\""; ?>>Strength</option> <option value="fame" <? if($sort=="fame") echo "selected=\"selected\""; ?>>Fame</option> </select> </td> </tr> <tr class="data"> <th>Sort Type: </th> <td colspan="2"> <select name="sortType"> <option value="DESC" <? if($sortType=="DESC") echo "selected=\"selected\""; ?>>Descending</option> <option value="ASC" <? if($sortType=="ASC") echo "selected=\"selected\""; ?>>Ascending</option> </select> </td> </tr> <tr class="data"> <td colspan="3"><input type="submit" name="submit" value="Find Targets" /></td> </tr> </tbody> </table> </form> <br /> <? if(!empty($_POST)) { if(!$error) // call the actual search & print function if something is filled { call_target_find($landMin,$landMax,$strMin,$strMax,$fameMin,$fameMax,$races,$sort,$sortType); } } }
function include_rankings_text() { global $Host; require_once 'inc/races/clsRace.php'; include_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); $iAgeNumber = $objGame->get_game_time(AGE_NUMBER); $show = 'alliance'; if (isset($_GET['show'])) { $show = $_GET['show']; } echo get_rankings_links($show); $link = "main.php?cat=game&page=rankings&show={$show}&type="; $rankingsText = '<div id="textBig">'; switch ($show) { case "annual": $rankingsText .= "<h2>History Rankings</h2>" . "<h3>Alliance</h3>" . "<p>" . " | <a href=\"" . $link . "currentage\">Current Age</a> |" . " <a href=\"" . $link . "topalli\">King Of The Hill</a> |" . " <a href=\"" . $link . "topland\">Largest Alliance</a> |" . "</p>"; if (!isset($_GET['type'])) { $_GET['type'] = 'currentage'; } break; case "personal": $rankingsText .= "<h2>Personal Rankings</h2>" . "<p> | <a href=\"" . $link . "pland\">Land</a> |" . " <a href=\"" . $link . "pstr\">Strength</a> |" . " <a href=\"" . $link . "pfame\">Fame</a> |" . "</p><p>"; //modified to find out about races dynamically - AI 17/02/2007 $races = clsRace::getRaces(); $active_races = clsRace::getActiveRaces(); foreach ($races as $number => $race) { if ($number % 3 == 0) { $rankingsText .= '- '; } $style = ''; if (!in_array($race, $active_races)) { $style = 'style="font-style:italic;"'; } $rankingsText .= "<span {$style}>{$race} [ " . "<a href=\"" . $link . "rland&race={$number}\">Land</a> | " . "<a href=\"" . $link . "rstr&race={$number}\">Strength</a> | " . "<a href=\"" . $link . "rfame&race={$number}\">Fame</a> ] </span>"; if ($number % 3 == 2) { $rankingsText .= '<br />'; } } $rankingsText .= "</p>"; if (!isset($_GET['type'])) { $_GET['type'] = 'pland'; } break; case "alliance": $rankingsText .= "<h2>Alliance Rankings</h2>" . "<p>| <a href=\"" . $link . "aland\">Land</a> | " . " <a href=\"" . $link . "astr\">Strength</a> | " . " <a href=\"" . $link . "afame\">Fame</a> | " . "<a href=\"" . $link . "support\">Top Voting Supporters</a></p>"; if (!isset($_GET['type'])) { $_GET['type'] = 'aland'; } break; } $rankingsText .= '</div>'; echo $rankingsText; if (!isset($_GET['type'])) { include_game_down(); exit; } $strType = $_GET["type"]; if ($strType == "pstr") { $strTitle = "Individual Strength Rankings"; $strRankingType = "p"; $type = "Strength"; $dbtype = "nw"; } elseif ($strType == "pfame") { $strTitle = "Individual Fame Rankings"; $strRankingType = "p"; $type = "Fame"; $dbtype = "fame"; } elseif ($strType == "pland") { $strTitle = "Individual Land Rankings"; $strRankingType = "p"; $type = "Acres"; $dbtype = "land"; } elseif ($strType == "astr") { $strTitle = "Alliance Strength Rankings"; $strRankingType = "a"; $type = "Strength"; $dbtype = "nw"; } elseif ($strType == "aland") { $strTitle = "Alliance Land Rankings"; $strRankingType = "a"; $type = "Acres"; $dbtype = "land"; } elseif ($strType == "afame") { $strTitle = "Alliance Fame Rankings"; $strRankingType = "a"; $type = "Fame"; $dbtype = "fame"; } elseif ($strType == "rstr") { $strTitle = "Individual Race Strength Rankings"; $strRankingType = "r"; $type = "Strength"; $dbtype = "nw"; } elseif ($strType == "rland") { $strTitle = "Individual Race Land Rankings"; $strRankingType = "r"; $type = "Acres"; $dbtype = "land"; } elseif ($strType == "rfame") { $strTitle = "Individual Race Fame Rankings"; $strRankingType = "r"; $type = "Fame"; $dbtype = "fame"; } elseif ($strType == "support") { $strTitle = "Top Supporters"; $strRankingType = "s"; } elseif ($strType == "topalli") { $strTitle = "King Of The Hill History"; $strRankingType = "ta"; } elseif ($strType == "topland") { $strTitle = "Largest Alliance History"; $strRankingType = "tl"; } elseif ($strType == "currentage") { $strTitle = "Age {$iAgeNumber} Rankings"; $strRankingType = "ca"; } // elseif ($strType == "truetopalli") { // $strTitle = "King Of The Hill (In Recent History)"; // $strRankingType = "tta"; // $dbtype = "alli_name"; // } elseif ($strType == "truetopalliid") { // $strTitle = "King Of The Hill (In Recent History)"; // $strRankingType = "tta"; // $dbtype = "alli_id"; // } if (isset($_GET['race'])) { $race = $_GET['race']; //modified to be dynamic - AI 17/02/2007 $races = clsRace::getRaces(); $race = $races[$race]; } echo "<br />"; if ($strRankingType == "p") { $res = mysql_query("SELECT id,tribe_name,race,alli_id," . $dbtype . " FROM rankings_personal WHERE alli_id > 10 ORDER BY " . $dbtype . " DESC LIMIT 200"); echo "<table class=\"big\" cellpadding=\"0\" cellspacing=\"0\">"; echo "<tr class=\"header\"><th colspan=\"4\">" . $strTitle . "</th></tr>"; echo "<tr class=\"subheader\">"; echo "<th>Tribe Name</th>"; echo "<th>Race</th>"; echo "<th>Alliance</th>"; echo "<th class=\"right\">" . $type . "</th>"; echo "</tr>"; $iCount = 1; while ($line = mysql_fetch_assoc($res)) { $cm = $iCount % 2 == 0 ? " even" : " odd"; echo "<tr class=\"data" . $cm . "\">"; echo "<th>{$iCount}. " . stripslashes($line["tribe_name"]) . "</th>"; echo "<td class=\"left\">" . $line["race"] . "</td>"; echo "<td class=\"left\">" . "(#<a href=\"main.php?cat=game&page=alliance&aid=" . $line["alli_id"] . "\">" . $line["alli_id"] . "</a>)</td>"; echo "<td>" . number_format($line[$dbtype]) . "</td>"; echo "</tr>"; $iCount++; } } elseif ($strRankingType == "a") { $res = mysql_query("SELECT id,alli_name,alli_desc," . $dbtype . " FROM rankings_alliance WHERE id > 10 ORDER BY " . $dbtype . " DESC LIMIT 50"); echo "<table class=\"big\" cellpadding=\"0\" cellspacing=\"0\">"; echo "<tr class=\"header\"><th colspan=\"5\">" . $strTitle . "</th></tr>"; echo "<tr class=\"subheader\">"; echo "<th width=\"25\"> </th>"; echo "<th>Alliance Name</th>"; echo "<th class=\"left\">Alliance Description</th>"; echo "<th>#</th>"; echo "<th class=\"right\">" . $type . "</th>"; echo "</tr>"; $iCount = 1; while ($line = mysql_fetch_assoc($res)) { $cm = $iCount % 2 == 0 ? " even" : " odd"; echo "<tr class=\"data" . $cm . "\">"; echo "<th class=\"left\">" . $iCount . ".</th>"; echo "<th class=\"left\">" . stripslashes($line["alli_name"]) . "</th>"; echo "<td class=\"left\">" . stripslashes($line["alli_desc"]) . "</td>"; echo "<td class=\"left\">" . "(#<a href=\"main.php?cat=game&page=alliance&aid=" . $line["id"] . "\">" . $line["id"] . "</a>) " . "</td>"; echo "<td>" . number_format($line[$dbtype]) . "</td>"; echo "</tr>"; $iCount++; } } elseif ($strRankingType == "r") { $res = mysql_query("SELECT id,tribe_name,race,alli_id," . $dbtype . " FROM rankings_personal WHERE alli_id > 10 AND race = '" . $race . "' ORDER BY " . $dbtype . " DESC LIMIT 50"); echo "<table class=\"big\" cellpadding=\"0\" cellspacing=\"0\">"; echo "<tr class=\"header\"><th colspan=\"4\">" . $strTitle . "</th></tr>"; echo "<tr class=\"subheader\">"; echo "<th>Tribe Name</th>"; echo "<th>Race</th>"; echo "<th>Alliance</th>"; echo "<th class=\"right\">" . $type . "</th>"; echo "</tr>"; $iCount = 1; while ($line = mysql_fetch_assoc($res)) { $cm = $iCount % 2 == 0 ? " even" : " odd"; echo "<tr class=\"data" . $cm . "\">"; echo "<th>{$iCount}. " . stripslashes($line["tribe_name"]) . "</th>"; echo "<td class=\"left\">" . $line["race"] . "</td>"; echo "<td class=\"left\">" . "(#<a href=\"main.php?cat=game&page=alliance&aid=" . $line["alli_id"] . "\">" . $line["alli_id"] . "</a>)</td>"; echo "<td>" . number_format($line[$dbtype]) . "</td>"; echo "</tr>"; $iCount++; } } elseif ($strRankingType == "s") { $query = mysql_query("SELECT id, name, vote_count FROM `" . ALLIANCE . "` WHERE id > 1 ORDER BY vote_count DESC LIMIT 0 , 50"); echo "<table class=\"big\" cellpadding=\"0\" cellspacing=\"0\">"; echo "<tr class=\"header\"><th colspan=\"2\">Top Supporters</th></tr>"; echo "<tr class=\"subheader\">"; echo "<th>Alliance Name</th>"; echo "<th class=\"right\">Votes</th>"; echo "</tr>"; $iCount = 1; while ($line = mysql_fetch_assoc($query)) { $cm = $iCount % 2 == 0 ? " even" : " odd"; echo "<tr class=\"data" . $cm . "\">"; echo "<th>{$iCount}. " . stripslashes($line['name']) . " (#<a href=\"main.php?cat=game&page=alliance&aid=" . $line['id'] . "\">" . $line['id'] . "</a>)</th>"; echo "<td>" . number_format($line['vote_count']) . "</td>"; echo "</tr>"; $iCount++; } } elseif ($strRankingType == "ta") { include_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); $iCurrentYear = $objGame->get_year_history(); // Nuvarande $resSQL = mysql_query("SELECT alli_id, alli_name, alli_desc, year, land FROM rankings_history WHERE year = {$iCurrentYear} AND year > 105 LIMIT 1"); // Alla genom history $resSQL2 = mysql_query("SELECT year, alli_id, alli_name, alli_desc FROM rankings_history WHERE alli_id > 10 AND year > 105 GROUP BY year ASC"); // Lista Alla För att summera i PHP $old_id = 0; $iCount = 0; while ($arrRow = mysql_fetch_assoc($resSQL2)) { $new_id = $arrRow['alli_id']; if ($new_id != $old_id) { // prepare for new alliance $iCount++; // Copy SQL result row $arrAlliance[$iCount] = $arrRow; // add a starting year column to display period, eg 100 - 106 OE $arrAlliance[$iCount]['starting_year'] = $arrRow['year']; // add an ending year column to display period, eg 100 - 106 OE $arrAlliance[$iCount]['ending_year'] = $arrRow['year']; // add a year counter column, starting value = 1 $arrAlliance[$iCount]['years'] = 1; // Save alliance id for next loop $old_id = $new_id; } elseif ($new_id == $old_id) { // add another year to our counter column $arrAlliance[$iCount]['years']++; // update ending year column $arrAlliance[$iCount]['ending_year'] = $arrRow['year']; } } //====================================================================== // Sort the array //====================================================================== // Obtain the column to sorty by foreach ($arrAlliance as $key => $row) { $years[$key] = $row['years']; } // Sort the data with years descending // Add $arrAlliance as the last parameter, to sort by the common key array_multisort($years, SORT_DESC, $arrAlliance); //====================================================================== // Done sorting ;) //====================================================================== echo "<table class=\"big\" cellpadding=\"0\" cellspacing=\"0\">"; echo "<tr class=\"header\"><th colspan=\"6\">" . $strTitle . "</th></tr>"; echo "<tr class=\"subheader\">"; echo "<th colspan=\"2\"> Alliance Name </th>"; echo "<th width=\"40%\"> Description </th>"; echo "<th> # </th>"; echo "<th> Period </th>"; echo "<th class=\"right\"> Years </th>"; echo "</tr>"; $iCount = 1; while ($arrAlliance1 = mysql_fetch_array($resSQL)) { // pick out the current year alliance from our history array foreach ($arrAlliance as $arrAlliance2) { if ($arrAlliance1['year'] == $arrAlliance2['ending_year']) { $arrAlliance1 = $arrAlliance2; break; } } $cm = $iCount % 2 == 0 ? " even" : " odd"; echo "<tr class=\"data" . $cm . "\">"; echo "<th width=\"25\" class=\"bsdown\">{$iCount}. </th>"; echo "<th class=\"bsdown\">" . stripslashes($arrAlliance1['alli_name']) . "</th>"; echo "<td class=\"bsdown left\">" . $arrAlliance1['alli_desc'] . "</td>"; echo "<td class=\"bsdown left\">" . "(#<a href=\"main.php?cat=game&page=alliance&aid=" . $arrAlliance1['alli_id'] . "\">" . $arrAlliance1['alli_id'] . "</a>)" . "</td>"; echo "<td class=\"bsdown left\">" . $arrAlliance1['starting_year'] . ' - <strong>' . $arrAlliance1['ending_year'] . "</strong> OE</td>"; echo "<td class=\"bsdown\">" . $arrAlliance1['years'] . "</td>"; echo "</tr>"; $iCount++; } foreach ($arrAlliance as $arrAlliance) { $cm = $iCount % 2 == 0 ? " even" : " odd"; echo "<tr class=\"data" . $cm . "\">"; echo "<th width=\"25\">{$iCount}. </th>"; echo "<th>" . stripslashes($arrAlliance['alli_name']) . "</th>"; echo "<td class=\"left\">" . $arrAlliance['alli_desc'] . "</td>"; echo "<td class=\"left\">" . "(#<a href=\"main.php?cat=game&page=alliance&aid=" . $arrAlliance['alli_id'] . "\">" . $arrAlliance['alli_id'] . "</a>)" . "</td>"; echo "<td class=\"left\">" . $arrAlliance['starting_year'] . ' - ' . $arrAlliance['ending_year'] . " OE</td>"; echo "<td>" . $arrAlliance['years'] . "</td>"; echo "</tr>"; $iCount++; // if ($iCount == 10) // { // break; // } } } elseif ($strRankingType == "tl") { include_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); $iCurrentYear = $objGame->get_year_history(); $query1 = mysql_query("SELECT alli_id,alli_name,alli_desc,year,land FROM rankings_history WHERE year = {$iCurrentYear} AND year > 105 LIMIT 1"); echo "<table class=\"big\" cellpadding=\"0\" cellspacing=\"0\">"; echo "<tr class=\"header\"><th colspan=\"5\">" . $strTitle . "</th></tr>"; echo "<tr class=\"subheader\">"; echo "<th colspan=\"2\"> Alliance Name </th>"; echo "<th> Description </th>"; echo "<th class=\"right\"> Year </th>"; echo "<th class=\"right\"> Acres </th>"; echo "</tr>"; $iCount = 1; while ($line = mysql_fetch_array($query1)) { $cm = $iCount % 2 == 0 ? " even" : " odd"; echo "<tr class=\"data" . $cm . "\">"; echo "<th width=\"25\" class=\"bsdown\">{$iCount}.</th>"; echo "<th class=\"bsdown\">" . stripslashes($line['alli_name']) . " (#<a href=\"main.php?cat=game&page=alliance&aid=" . $line['alli_id'] . "\">" . $line['alli_id'] . "</a>) </th>"; echo "<td class=\"bsdown\">" . $line['alli_desc'] . "</td>"; echo "<td class=\"bsdown\">" . $line['year'] . " OE</td>"; echo "<td class=\"bsdown\">" . number_format($line['land']) . "</td>"; echo "</tr>"; $iCount++; } $query = mysql_query("SELECT alli_id,alli_name,alli_desc,year,MAX(land) as land FROM rankings_history WHERE alli_id > 10 AND year > 105 GROUP BY alli_id ORDER BY land DESC"); // GROUP BY alli_name while ($line = mysql_fetch_array($query)) { $cm = $iCount % 2 == 0 ? " even" : " odd"; echo "<tr class=\"data" . $cm . "\">"; echo "<th width=\"25\">{$iCount}.</th>"; echo "<th>" . stripslashes($line['alli_name']) . " (#<a href=\"main.php?cat=game&page=alliance&aid=" . $line['alli_id'] . "\">" . $line['alli_id'] . "</a>)" . "</th>"; echo "<td>" . $line['alli_desc'] . "</td>"; echo "<td>" . $line['year'] . " OE</td>"; echo "<td>" . number_format($line['land']) . "</td>"; echo "</tr>"; $iCount++; } } elseif ($strRankingType == "ca") { include_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); $iCurrentYear = $objGame->get_year_history(); $iAgeNumber = $objGame->get_game_time(AGE_NUMBER); include_once 'inc/classes/clsAge.php'; $objNewAge = new clsAge(); $objNewAge->loadAge($iAgeNumber); $iFirstYear = $objNewAge->getFirstYear(); $iLastYear = $objNewAge->getLastYear(); // Alla genom history $resSQL2 = mysql_query("SELECT year, alli_id, alli_name, alli_desc FROM rankings_history WHERE alli_id > 10 AND year >= {$iFirstYear} AND year <= {$iLastYear} GROUP BY alli_id,year ASC"); // Lista Alla För att summera i PHP $old_id = 0; $iCount = 0; while ($arrRow = mysql_fetch_assoc($resSQL2)) { $new_id = $arrRow['alli_id']; if ($new_id != $old_id) { // prepare for new alliance $iCount++; // Copy SQL result row $arrAlliance[$iCount] = $arrRow; // add a starting year column to display period, eg 100 - 106 OE $arrAlliance[$iCount]['starting_year'] = $arrRow['year']; // add an ending year column to display period, eg 100 - 106 OE $arrAlliance[$iCount]['ending_year'] = $arrRow['year']; // add a year counter column, starting value = 1 $arrAlliance[$iCount]['years'] = 1; // Save alliance id for next loop $old_id = $new_id; } elseif ($new_id == $old_id) { // add another year to our counter column $arrAlliance[$iCount]['years']++; // update ending year column $arrAlliance[$iCount]['ending_year'] = $arrRow['year']; } } //====================================================================== // Sort the array //====================================================================== // Obtain the column to sorty by foreach ($arrAlliance as $key => $row) { $years[$key] = $row['years']; } // Sort the data with years descending // Add $arrAlliance as the last parameter, to sort by the common key array_multisort($years, SORT_DESC, $arrAlliance); //====================================================================== // Done sorting ;) //====================================================================== echo '<div class="center">' . '<h1 style="margin-top: 0;">Age ' . $iAgeNumber . ' Rankings (' . $iFirstYear . ' - ' . $iLastYear . ' OE)</h1>' . '</div>'; // echo "<h2>Top Alliance History</h2>"; $strTopAllianceCurrentTable = '<table class="big" cellpadding="0" cellspacing="0">' . '<tr class="header">' . '<th colspan="5">King of the Hill</th>' . '</tr>' . '<tr class="subheader">' . '<th> </th>' . '<th>Alliance Name</th>' . '<th>Alliance Description</th>' . '<th>#</th>' . '<th class="right">Years</th>' . '</tr>'; $iCount = 1; foreach ($arrAlliance as $arrAlliance) { $strTopAllianceCurrentTable .= '<tr class="data">' . '<th width="25">' . $iCount . '.</th>' . '<th>' . stripslashes($arrAlliance['alli_name']) . '</th>' . '<td class="left">' . stripslashes($arrAlliance['alli_desc']) . '</td>' . '<td class="left">' . '(#<a href="main.php?cat=game&page=alliance&aid=' . $arrAlliance['alli_id'] . '">' . $arrAlliance['alli_id'] . '</a>)' . '</td>' . '<td>' . $arrAlliance['years'] . ' years on top</td>' . '</tr>'; $iCount++; } $strTopAllianceCurrentTable .= '</table>'; echo $strTopAllianceCurrentTable; //************************************************************************** // 2nd LIST //************************************************************************** function doit1() { include_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); $iCurrentYear = $objGame->get_year_history(); $iAgeNumber = $objGame->get_game_time(AGE_NUMBER); include_once 'inc/classes/clsAge.php'; $objNewAge = new clsAge(); $objNewAge->loadAge($iAgeNumber); $iFirstYear = $objNewAge->getFirstYear(); $iLastYear = $objNewAge->getLastYear(); // echo "<h2>Top Acreage History</h2>"; echo '<br />'; $strTopAcreageCurrentTable = '<table class="big" cellpadding="0" cellspacing="0">' . '<tr class="header">' . '<th colspan="6">Largest Alliance</th>' . '</tr>' . '<tr class="subheader">' . '<th> </th>' . '<th>Alliance Name</th>' . '<th>Alliance Description</th>' . '<th>#</th>' . '<th class="right">Year</th>' . '<th class="right">Acres</th>' . '</tr>'; $iCount = 1; $query = mysql_query("SELECT MAX(land) as land,alli_id,year FROM rankings_history WHERE alli_id > 10 AND year >= {$iFirstYear} AND year <= {$iLastYear} GROUP BY alli_id ORDER BY land DESC"); while ($line = mysql_fetch_array($query)) { $line2 = mysql_fetch_array(mysql_query("SELECT year,alli_name,alli_desc FROM rankings_history WHERE land = {$line['land']} AND alli_id = {$line['alli_id']}")); $cm = $iCount % 2 == 0 ? " even" : " odd"; $strTopAcreageCurrentTable .= '<tr class="data"' . $cm . '">' . '<th width="25">' . $iCount . '.</th>' . '<th>' . stripslashes($line2['alli_name']) . '</th>' . '<td class="left">' . stripslashes($line2['alli_desc']) . '</td>' . '<td class="left">(#<a href="main.php?cat=game&page=alliance&aid=' . $line['alli_id'] . '">' . $line['alli_id'] . '</a>)' . '</td>' . '<td>(' . $line2['year'] . ' OE)</td>' . '<td>' . number_format($line['land']) . ' acres </td>' . '</tr>'; $iCount++; } $strTopAcreageCurrentTable .= '</table>'; echo $strTopAcreageCurrentTable; } doit1(); //************************************************************************** // 3rd LIST //************************************************************************** function doit() { include_once 'inc/classes/clsGame.php'; $objGame = new clsGame(); $iCurrentYear = $objGame->get_year_history(); $iAgeNumber = $objGame->get_game_time(AGE_NUMBER); include_once 'inc/classes/clsAge.php'; $objNewAge = new clsAge(); $objNewAge->loadAge($iAgeNumber); $iFirstYear = $objNewAge->getFirstYear(); $iLastYear = $objNewAge->getLastYear(); // Alla genom history $resSQL2 = mysql_query("SELECT year, alli_id, alli_name, alli_desc FROM rankings_history WHERE alli_id > 10 AND year >= {$iFirstYear} AND year <= {$iLastYear} GROUP BY year ASC"); // Lista Alla För att summera i PHP $old_id = 0; $iCount = 0; while ($arrRow = mysql_fetch_assoc($resSQL2)) { $new_id = $arrRow['alli_id']; if ($new_id != $old_id) { // prepare for new alliance $iCount++; // Copy SQL result row $arrAlliance[$iCount] = $arrRow; // add a starting year column to display period, eg 100 - 106 OE $arrAlliance[$iCount]['starting_year'] = $arrRow['year']; // add an ending year column to display period, eg 100 - 106 OE $arrAlliance[$iCount]['ending_year'] = $arrRow['year']; // add a year counter column, starting value = 1 $arrAlliance[$iCount]['years'] = 1; // Save alliance id for next loop $old_id = $new_id; } elseif ($new_id == $old_id) { // add another year to our counter column $arrAlliance[$iCount]['years']++; // update ending year column $arrAlliance[$iCount]['ending_year'] = $arrRow['year']; } } //====================================================================== // Sort the array //====================================================================== // Obtain the column to sorty by foreach ($arrAlliance as $key => $row) { $years[$key] = $row['starting_year']; } // Sort the data with years descending // Add $arrAlliance as the last parameter, to sort by the common key array_multisort($years, SORT_ASC, $arrAlliance); //====================================================================== // Done sorting ;) //====================================================================== // echo '<div class="center"><h2>Timeline</h2></div>'; echo '<br />'; $strTimelineCurrentTable = '<table class="big" cellpadding="0" cellspacing="0">' . '<tr class="header">' . '<th colspan="5">Timeline</th>' . '</tr>' . '<tr class="subheader">' . '<th>Period</th>' . '<th>Alliance Name</th>' . '<th>Alliance Description</th>' . '<th>#</th>' . '<th class="right">Years</th>' . '</tr>'; $iCount = 1; foreach ($arrAlliance as $arrAlliance) { $strTimelineCurrentTable .= '<tr class="data">' . '<td class="left">(' . $arrAlliance['starting_year'] . ' - ' . $arrAlliance['ending_year'] . ' OE) </td>' . '<th>' . stripslashes($arrAlliance['alli_name']) . '</th>' . '<td class="left">' . stripslashes($arrAlliance['alli_desc']) . '</td>' . '<td class="left">' . '(#<a href="main.php?cat=game&page=alliance&aid=' . $arrAlliance['alli_id'] . '">' . $arrAlliance['alli_id'] . '</a>)</td>' . '<td>' . $arrAlliance['years'] . ' years on top </td>' . '</tr>'; $iCount++; } $strTimelineCurrentTable .= '</table>'; echo $strTimelineCurrentTable; } doit(); } // elseif ($strRankingType == 'tta') // { // $strTable = // '<table class="medium" cellpadding="0" cellspacing="0">' . // '<tr class="header">' . // '<th colspan="4">' .$strTitle . '</th>' . // '</tr>' . // '<tr class="subheader">' . // '<th>Alliance Name</th>' . // '<th>#</th>' . // '<th class="center">Years</th>' . // '<th class="right">Active</th>' . // '</tr>'; // $strSQL = "SELECT alli_name, alli_desc, alli_id, count(year) as years, year FROM rankings_history WHERE alli_id > 10 AND year > 105 GROUP BY $dbtype ORDER BY id DESC"; // $resSQL = mysql_query($strSQL); // $iCount = 1; // while ($arrAlliance = mysql_fetch_array($resSQL)) // { // $strTable .= // '<tr class="data">' . // '<th>' . stripslashes($arrAlliance['alli_name']) . '</th>' . // '<td class="left">' . '(#<a href="main.php?cat=game&page=alliance&aid=' . $arrAlliance['alli_id'] . '">' . $arrAlliance['alli_id'] . '</a>)</td>' . // '<td class="center">' . $arrAlliance['years'] . '</td>' . // '<td>~' . $arrAlliance['year'] . ' OE</td>' . // '</tr>'; // $iCount++; // } // echo $strTable; // } echo '</table>'; }