예제 #1
0
function get_rank_data($alliance_id)
{
    $arrRanking[LAND] = get_alli_ranking(LAND, $alliance_id);
    $arrRanking[STRENGTH] = get_alli_ranking(STRENGTH, $alliance_id);
    $arrRanking[FAME] = get_alli_ranking(FAME, $alliance_id);
    //==========================================================================
    //                                                     Martel, July 25, 2006
    // If this alliance is #1 we check if we should update the annual ranks
    //==========================================================================
    if ($arrRanking[LAND] == 1) {
        include_once 'inc/classes/clsGame.php';
        $objGame = new clsGame();
        // Get Game Year & Most Recent Year Saved
        $iOrkYears = $objGame->get_year_oe();
        $iLastYear = $objGame->get_year_history();
        if ($iOrkYears != $iLastYear) {
            include_once 'inc/classes/clsAlliance.php';
            $objTmpAlliance = new clsAlliance($alliance_id);
            $arrTmpRankings = $objTmpAlliance->get_rankings_alliances();
            $strAlliName = $arrTmpRankings[ALLI_NAME];
            $strAlliDesc = $arrTmpRankings[ALLI_DESC];
            $arrNewHistory = array(YEAR => $iOrkYears, LAND => $arrTmpRankings[LAND], RANK_FAME => $arrRanking[FAME], RANK_STRENGTH => $arrRanking[STRENGTH], ALLI_ID => $arrTmpRankings[ID], ALLI_NAME => "'{$strAlliName}'", ALLI_DESC => "'{$strAlliDesc}'", LAST_UPDATE => date(TIMESTAMP_FORMAT, time()));
            $objGame->set_historys($arrNewHistory);
        }
    }
    //==========================================================================
    return $arrRanking;
}
예제 #2
0
 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;
     $count = 0;
     while ($arrRow = mysql_fetch_assoc($resSQL2)) {
         $new_id = $arrRow['alli_id'];
         if ($new_id != $old_id) {
             // prepare for new alliance
             $count++;
             // Copy SQL result row
             $arrAlliance[$count] = $arrRow;
             // add a starting year column to display period, eg 100 - 106 OE
             $arrAlliance[$count]['starting_year'] = $arrRow['year'];
             // add an ending year column to display period, eg 100 - 106 OE
             $arrAlliance[$count]['ending_year'] = $arrRow['year'];
             // add a year counter column, starting value = 1
             $arrAlliance[$count]['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[$count]['years']++;
             // update ending year column
             $arrAlliance[$count]['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 "<h2>Timeline</h2>";
     echo "<table class=\"big\" cellpadding=\"0\" cellspacing=\"0\">";
     $count = 1;
     foreach ($arrAlliance as $arrAlliance) {
         echo "<tr class=\"data\">";
         echo "<td class=\"left\">(" . $arrAlliance['starting_year'] . ' - ' . $arrAlliance['ending_year'] . " OE) </td>";
         echo "<th>" . stripslashes($arrAlliance['alli_name']) . "</th>";
         echo "<td class=\"left\">" . "(#<A HREF=\"main.php?cat=game&amp;page=alliance&amp;aid=" . $arrAlliance['alli_id'] . "\">" . $arrAlliance['alli_id'] . "</A>)" . "</td>";
         echo "<td>" . $arrAlliance['years'] . " years on top </td>";
         $count++;
         echo "</tr>";
     }
     echo "</table>";
 }
예제 #3
0
 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&amp;page=alliance&amp;aid=' . $arrAlliance['alli_id'] . '">' . $arrAlliance['alli_id'] . '</a>)</td>' . '<td>' . $arrAlliance['years'] . ' years on top </td>' . '</tr>';
         $iCount++;
     }
     $strTimelineCurrentTable .= '</table>';
     echo $strTimelineCurrentTable;
 }