Pos = $position; $this->Name=$nam; $this->Rank=$rnk; $this->Money = $mon; // convert money from string to number by removing alphanum chars $this->MoneyAsNumber = eregi_replace(",", "", str_replace("\$","", $mon )); $this->KillsAsNumber = eregi_replace(",", "", $kil); $this->Kills = $kil; $this->TimeOnline = $time; // convert time to a comparable time format $timeparts = explode(":",$time); $tmp = 0; $this->TimeOnlineSecs = ($timeparts[0]*3600 + $timeparts[1]*60 + $timeparts[2]); $timeparts = NULL; $this->MissionsAsNumber = eregi_replace(",", "", $miss); $this->Missions = $miss; $this->Systems = $syst; $this->Bases = $bas; $this->Holes = $hol; $this->LastLogin = $last; $this->LastLoginComparable = NULL; } function setLastLoginComparable( $newVal) { $this->LastLoginComparable = $newVal; } function printTableRow( $linenr=' ', $fgcolor='black', $bgcolor='white' ) { echo "\t\n"; echo "\t\t$linenr\n"; echo "\t\t$this->Name\n"; echo "\t\t$this->Rank\n"; echo "\t\t$this->Money\n"; echo "\t\t$this->Kills\n"; echo "\t\t$this->TimeOnline\n"; echo "\t\t$this->Missions\n"; echo "\t\t$this->Systems\n"; echo "\t\t$this->Bases\n"; echo "\t\t$this->Holes\n"; echo "\t\t$this->LastLogin\n"; echo "\t\n"; } // give $statsCreationDate as timestamp of CreationDate 00:00:00 function updateLastLoginComparable( $statsCreationDate ) { $TimeAndDate = explode("-",$this->LastLogin ); // TimeAndDate[0] = Time // TimeAndDate[1] = Date // Time can be kept, Date needs to be altered. if (eregi("Today", $this->LastLogin) ) { // replace yesterday with todays date - 1 day $this->LastLoginComparable = 0+(date("Ymd", $statsCreationDate)).eregi_replace(":","", trim($TimeAndDate[0])); } elseif (eregi("Yesterday", $this->LastLogin) ) { // replace today with current date $this->LastLoginComparable = 0+(date("Ymd", $statsCreationDate-86400)).eregi_replace(":","", trim($TimeAndDate[0])); } else { $DateParts = explode(" ", trim($TimeAndDate[1])); // make new String $tmpDate = (2000+$DateParts[2]).""; switch($DateParts[1]) { case "Jan": $tmpDate.="01"; break; case "Feb": $tmpDate.="02"; break; case "Mar": $tmpDate.="03"; break; case "Apr": $tmpDate.="04"; break; case "May": $tmpDate.="05"; break; case "Jun": $tmpDate.="06"; break; case "Jul": $tmpDate.="07"; break; case "Aug": $tmpDate.="08"; break; case "Sep": $tmpDate.="09"; break; case "Oct": $tmpDate.="10"; break; case "Nov": $tmpDate.="11"; break; case "Dec": $tmpDate.="12"; break; } $tmpDate.=$DateParts[0]; $tmpDate.=(eregi_replace(":","", trim($TimeAndDate[0]))); $this->setLastLoginComparable(0+$tmpDate); } // echo "$this->LastLogin ---> $this->LastLoginComparable\n"; } }; function initPilots() { global $Pilots; global $header; global $sourceURL; global $statsSaveFile; /* if pilots was not yet loaded - load stats and create display */ if ($Pilots==NULL) { $maxColumns = 0; // nr of Colums $running = 1; // current record /* for future use if ( !file_exists($statsSaveFile)) { if (@!copy($sourceURL,$statsSaveFile)) { echo "Error on storing Statistisfile"; session_destroy(); exit(); } } * */ $source = @fopen($sourceURL, "r"); if ( !$source ) { echo "The Asgard Statistics File could not be loaded. Please try again later."; session_destroy(); exit(); } while(!feof($source)){ $aLine=trim(fgets($source)); if ( eregi(" - Last updated on Sat Jul 23 02:00:27 2005 - Generated by FLstat v1.4, in 25 secs - */ if ( $Pilots ) { $aLine=trim(fgets($source)); // get creationTimestamp $fields = explode(" ",trim(str_replace("-"," ",strip_tags($aLine)))); switch($fields[4]) { case "Jan": $mon="1"; break; case "Feb": $mon="2"; break; case "Mar": $mon="3"; break; case "Apr": $mon="4"; break; case "May": $mon="5"; break; case "Jun": $mon="6"; break; case "Jul": $mon="7"; break; case "Aug": $mon="8"; break; case "Sep": $mon="9"; break; case "Oct": $mon="10"; break; case "Nov": $mon="11"; break; case "Dec": $mon="12"; break; } $creationTimestamp = mktime(2,0,0,$mon,$fields[5],$fields[7]); } break; } else { // new record $column = 1; } } if (eregi("updateLastLoginComparable($creationTimestamp); } return $Pilots; } else { return NULL; } } // if ($Pilots==NULL) else return $Pilots; } //default sort Rank/Cash function sortByRank($a,$b) { if ($a->Pos == $b->Pos) return 0; return ($a->Pos < $b->Pos) ? -1 : 1; } function sortByName($a,$b) { $aU = strtoupper($a->Name); $bU = strtoupper($b->Name); if (!strcmp($aU,$bU)) return 0; return (strcmp($aU,$bU) < 0) ? -1 : 1; } function sortByCash($a,$b) { if ($a->MoneyAsNumber == $b->MoneyAsNumber) return 0; return ($a->MoneyAsNumber > $b->MoneyAsNumber) ? -1 : 1; } function sortByKills($a,$b) { if ($a->KillsAsNumber == $b->KillsAsNumber) return 0; return ($a->KillsAsNumber > $b->KillsAsNumber) ? -1 : 1; } function sortByTime($a,$b) { if ($a->TimeOnlineSecs == $b->TimeOnlineSecs) return 0; return ($a->TimeOnlineSecs > $b->TimeOnlineSecs) ? -1 : 1; } function sortByMissions($a,$b) { if ($a->MissionsAsNumber == $b->MissionsAsNumber) return 0; return ($a->MissionsAsNumber > $b->MissionsAsNumber) ? -1 : 1; } function sortByLastLogin($a,$b) { if ($a->LastLoginComparable == $b->LastLoginComparable) return 0; return ($a->LastLoginComparable > $b->LastLoginComparable) ? -1 : 1; } function printResultTableHeader() { global $header; echo "

Click on Name, Rank, Money, Kills, Missions, Time Online or Last Login to sort

\n"; echo "\n"; echo "\t\n"; foreach ($header as $cName) { echo "\t\t\n"; } echo "\t\n"; } function printResultTableFoot(){ echo "
"; switch($cName){ case "Name": echo "$cName"; break; case "Rank": echo "$cName"; break; case "Money": echo "$cName"; break; case "Time Online": echo "$cName"; break; case "Kills": echo "$cName"; break; case "Missions": echo "$cName"; break; case "Last Login": echo "$cName"; break; default: echo $cName; } // switch echo "
\n"; echo "
"; } function printResultTable( $Table ) { echo "
"; if ($Table != NULL) { $i=1; printResultTableHeader(); foreach ( $Table as $Rec ) { if ($i % 2 == 0) { $Rec->printTableRow($i, "black", "silver"); } else{ $Rec->printTableRow($i, "black", "white"); } $i++; } printResultTableFoot(); } else { echo "SORRY THERE IS NO DATA TO DISPLAY"; } echo "
"; } function printMenuLink() { echo <<< ende
Main Menu
ende; } function showMenu() { echo <<< ende

 

ende; echo <<< ende
Main Menu

Show Sortable Pilot Rankings
Show Faction Overview

ende; } function showTitle($titleline) { if ($titleline != NULL) { echo "

$titleline

"; } } function showRankings($sorting) { global $ResultSetTotals; global $ResultSet; $ResultSet = initPilots(); if ($ResultSet && $sorting) { switch($sorting){ case "Name": usort($ResultSet, "sortByName" ); break; case "Cash": usort($ResultSet, "sortByCash" ); break; case "Time": usort($ResultSet, "sortByTime" ); break; case "Missions": usort($ResultSet, "sortByMissions" ); break; case "Kills": usort($ResultSet, "sortByKills" ); break; case "Login": usort($ResultSet, "sortByLastLogin" ); break; case "Rank": default: usort($ResultSet, "sortByRank" ); } // switch } showTitle("Sortable Pilot Listing"); printResultTable($ResultSet); echo "
"; printMenuLink(); } function showFactionDisplayForm($errMsg=NULL) { global $Pilots; global $Vaults; global $ResultSet; global $hasFactionResults; global $ResultSetTotals; // clear current Results if ($ResultSet != NULL) { $ResultSet = NULL; $ResultSetTotals = NULL; $hasFactionResults = false; session_register("hasFactionResults"); } // TAG causes trouble and is not recognized when entered in the // Form // init Pilots if needed and Vaults if needed if ($Pilots==NULL) { initPilots(); } if ($Pilots != NULL && $Vaults == NULL ) { usort($Pilots,"sortByName"); $i=1; foreach ( $Pilots as $Pilot ) { if (eregi(".*VAULT.*",strtoupper($Pilot->Name))) { $Vaults[$i++] = $Pilot; } } if ( $Vaults != NULL ) { session_register( "Vaults" ); } } // echo "Pilots:".count($Pilots)." Vaults:".count($Vaults)."
"; showTitle("Faction Overview"); if ($errMsg != NULL) { echo "

$errMsg

"; echo "
"; } echo "
"; echo "\n
"; echo "\n"; echo "\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t"; echo "\t\t\n"; echo "
Enter full Faction Tag here (e.g. [ASG]): "; if ( ($Vaults!=NULL) && (count($Vaults)>0)) { echo ""; } echo "\t\t
\n"; echo "
\n"; echo "
"; echo "
"; echo "
"; printMenuLink(); } // init FactionDisplay with Form requested Data function initFactionDisplay($faction, $vaultID=NULL) { global $Pilots; global $Vaults; global $ResultSet; global $hasFactionResults; if ($Pilots == NULL) { initPilots(); } if ( $ResultSet == NULL ) { // filter $Pilots $searchForFac = $faction; if ($vaultID > 0 && $Vaults != NULL && count($Vaults)>0 ) { $searchVault = $Vaults[$vaultID]->Pos; } $i = 1; $len = strlen($searchForFac); foreach ($Pilots as $P) { $comparison = (strlen($P->Name) >= $len)? (substr($P->Name, 0,$len)):($P->Name); // echo "compare $searchForFac <--> $comparison ($len)"."
"; if ((strcmp($searchForFac, $comparison)==0) || ($P->Pos == $searchVault)) { $ResultSet[$i++] = $P; } } if ($ResultSet != NULL && count($ResultSet)>0) { $hasFactionResults = true; session_register("hasFactionResults"); usort($ResultSet,"sortByRank"); session_register("ResultSet"); initResultSetTotals(); return true; } else { return false; } } } function showFactionResult($sorting=NULL) { global $hasFactionResults; global $ResultSet; global $ResultSetTotals; showTitle("Faction Overview"); if ($hasFactionResults) { if ($sorting) { switch($sorting){ case "Name": usort($ResultSet, "sortByName" ); break; case "Cash": usort($ResultSet, "sortByCash" ); break; case "Time": usort($ResultSet, "sortByTime" ); break; case "Missions": usort($ResultSet, "sortByMissions" ); break; case "Kills": usort($ResultSet, "sortByKills" ); break; case "Login": usort($ResultSet, "sortByLastLogin" ); break; case "Rank": default: usort($ResultSet, "sortByRank" ); } // switch } printResultTable($ResultSet); echo "
"; printTotals(); echo "
"; echo "
"; echo "
"; echo "Return to Form
"; printMenuLink(); echo "
"; } else { echo "NO MATCHING DATA FOUND

"; echo "
"; echo "Return to Form
"; printMenuLink(); echo "
"; } } function initResultSetTotals() { global $ResultSet; global $ResultSetTotals; $ResultSetTotals["Rank"] = 0; $ResultSetTotals["Money"] = 0; $ResultSetTotals["Kills"] = 0; $ResultSetTotals["Time"] = 0; $ResultSetTotals["Missions"]= 0; $ResultSetTotals["AVRank"] = 0; $ResultSetTotals["AVMoney"] = 0; $ResultSetTotals["AVKills"] = 0; $ResultSetTotals["AVTime"] = 0; $ResultSetTotals["AVMissions"]= 0; $vaultIncluded = false; if ($ResultSet!=NULL) { foreach ($ResultSet as $P) { if (!vaultIncluded && eregi("VAULT",strtoupper($P->Name))) { $vaultIncluded = true; } $ResultSetTotals["Rank"]+=$P->Rank; $ResultSetTotals["Money"]+=$P->MoneyAsNumber; $ResultSetTotals["Kills"]+=$P->KillsAsNumber; $ResultSetTotals["Time"] +=$P->TimeOnlineSecs; $ResultSetTotals["Missions"]+=$P->MissionsAsNumber; } $membercount = count($ResultSet); if ($vaultIncluded) { $membercount--; } if ($membercount>0) { $ResultSetTotals["AVRank"] = "".round ($ResultSetTotals["Rank"]/$membercount,0)." *"; $ResultSetTotals["AVMoney"] = "\$".number_format( $ResultSetTotals["Money"]/$membercount,2,'.',','); $ResultSetTotals["AVKills"] = number_format( $ResultSetTotals["Kills"]/$membercount,2,'.',','); $ResultSetTotals["AVTime"] = $ResultSetTotals["Time"]/$membercount; $h = intval($ResultSetTotals["AVTime"] / 3600); $m = (($ResultSetTotals["AVTime"]-($h*3600))/60); $s = $ResultSetTotals["AVTime"]%60; $ResultSetTotals["AVTime"]=sprintf("%dh %02dm %02ds **",$h,$m,$s); $ResultSetTotals["AVMissions"]= number_format( $ResultSetTotals["Missions"]/$membercount,2,'.',','); } else { $ResultSetTotals["AVRank"] = "No average due lack of members *"; $ResultSetTotals["AVMoney"] = "No average due lack of members"; $ResultSetTotals["AVKills"] = "No average due lack of members"; $ResultSetTotals["AVTime"] = "No average due lack of members"; $ResultSetTotals["AVMissions"]= "No average due lack of members"; } // format the values in readable Form $ResultSetTotals["Money"] = "\$".number_format($ResultSetTotals["Money"],2,'.',','); $h = intval($ResultSetTotals["Time"] / 3600); $m = (($ResultSetTotals["Time"]-($h*3600))/60); $s = $ResultSetTotals["Time"]%60; $ResultSetTotals["Time"]=sprintf("%dh %02dm %02ds",$h,$m,$s); if (!session_is_registered("ResultSetTotals")) session_register("ResultSetTotals"); } } function printTotals(){ global $ResultSetTotals; if ($ResultSetTotals != NULL && count($ResultSetTotals) > 0 ) { echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
  Totals Averages
Rank: ".$ResultSetTotals["Rank"]." ".$ResultSetTotals["AVRank"]."
Cash: ".$ResultSetTotals["Money"]." ".$ResultSetTotals["AVMoney"]."
Kills: ".$ResultSetTotals["Kills"]." ".$ResultSetTotals["AVKills"]."
Missions: ".$ResultSetTotals["Missions"]." ".$ResultSetTotals["AVMissions"]."
Time Online: ".$ResultSetTotals["Time"]." ".$ResultSetTotals["AVTime"]."
*) math. rounded value
**) fractions of seconds are not regarded
"; echo "
"; } } /** restore session variables if available */ if (session_is_registered("Pilots")) { session_register("Pilots"); } else { $Pilots=NULL; } if (session_is_registered("ResultSet")) { session_register("ResultSet"); } else { $ResultSet=NULL; } if (session_is_registered("Vaults")) { session_register("Vaults"); } else { $Vaults=NULL; } if (session_is_registered("header")) { session_register("header"); } else { $header=NULL; } if (session_is_registered("menuSelection")) { session_register("menuSelection"); } else { $menuSelection=NULL; } if (session_is_registered("hasFactionResults")) { session_register("hasFactionResults"); } else { $hasFactionResults=false; } if (session_is_registered("isCategorized")) { session_register("isCategorized"); } else { $isCategorized=false; } // ------ output ---- ?> Asgard RPG - Advanced Rankings Display

Top 250 Players showed in rankings
Main menu
Forum

"; print_r ($_GET); echo "