www.tswn.com | www.bf2online.com | aquaria.tswn.com | www.bf2142online.org
if (isset($_GET['type'])){
$type = $_GET['type'];
if($type != "png" && $type != "gif" && $type != "jpg" && $type != "jpeg"){
$type = "jpg"; }
}else{
$type = "jpg";
}
//#########################################################################################################################################//
header("Expires: ".date("D, d M Y H:i:s",time()+$cachetime)." GMT");
//#########################################################################################################################################//
header('Content-Control: cache');
if ($type == "jpg" || $type == "jpeg"){
header("Content-type: image/jpeg"); // expire in 6 hours; );
imagejpeg($image_out,"",$jpeg_quality);
}elseif ($type == "gif"){
header("Content-type: image/gif"); // expire in 6 hours; );
imagegif($image_out);
}else{
header('Content-Type: image/png'); // expire in 6 hours;
imagepng($image_out);
}
header("Content-Length: " . ob_get_length());
//header("Content-type: image/png");
function xml2array($text) {
$reg_exp = '/<(.*?)>(.*?)</\1>/s';
preg_match_all($reg_exp, $text, $match);
foreach ($match[1] as $key=>$val) {
if ( preg_match($reg_exp, $match[2][$key]) ) {
$array[$val][] = xml2array($match[2][$key]);
} else {
$array[$val] = $match[2][$key];
}
}
return $array;
}
//handy dandy little function for making the string centered, and making it fit.
function imagestringcentered ($img,$font,$xoffset,$cy,$text,$color) {
while (strlen($text) * imagefontwidth($font) > imagesx($img)-$xoffset) {
if ($font > 1) { $font--; }
else { break; }
}
imagestring($img,$font,(imagesx($img)-$xoffset) / 2 - strlen($text) * imagefontwidth($font) / 2 + $xoffset,$cy,$text,$color);
}
//Map converter
function mapconverter($mapnumber) {
$mapname[0] = "Kubra Dam";
$mapname[1] = "Mashtuur City";
$mapname[2] = "Operation Clean Sweep";
$mapname[3] = "Zatar Wetlands";
$mapname[4] = "Strike at Karkand";
$mapname[5] = "Sharqi Peninsula";
$mapname[6] = "Gulf of Oman";
$mapname[100] = "Daqing Oilfields";
$mapname[101] = "Dalian Plant";
$mapname[102] = "Dragon Valley";
$mapname[103] = "FuShe Pass";
$mapname[104] = "Wake Island";
$mapname[105] = "Songhua Stalemate";
//Special Forces Maps
$mapname[300] = "Devil's Perch (BF2SF)";
$mapname[301] = "The Iron Gator (BF2SF)";
$mapname[302] = "Night Flight (BF2SF)";
$mapname[303] = "Warlord (BF2SF)";
$mapname[304] = "Leviathan (BF2SF)";
$mapname[305] = "Mass Destruction (BF2SF)";
$mapname[306] = "Surge (BF2SF)";
$mapname[307] = "Ghost Town (BF2SF)";
//Euro Forces Maps (EF)
$mapname[10] = "Operation Smoke Screen (EF)";
$mapname[11] = "The Great Wall of China (EF)";
$mapname[110] = "Tabara Quarry (EF)";
//Armoured Fury Maps (AF)
/*
# US Theatre
"midnight_sun" : "200",
"operationroadrage" : "201",
"operationharvest" : "202",
*/
$mapname[200] = "Midnight Sun (AF)";
$mapname[201] = "Operation Road Rage (AF)";
$mapname[202] = "Operation Harvest (AF)";
return $mapname[$mapnumber];
}
//Kit converter
function kitconverter($kitnumber) {
$kitname[0] = "Anti-Tank";
$kitname[1] = "Assault";
$kitname[2] = "Engineer";
$kitname[3] = "Medic";
$kitname[4] = "Spec-Ops";
$kitname[5] = "Support";
$kitname[6] = "Sniper";
return $kitname[$kitnumber];
}
//Vehicle Converter
function vehicleconverter($vehiclenumber) {
$vehiclename[0] = "Tank";
$vehiclename[1] = "Plane";
$vehiclename[2] = "Air Defense";
$vehiclename[3] = "Helicopter";
$vehiclename[4] = "Transport";
$vehiclename[5] = "Artillery";
$vehiclename[6] = "Ground Defense";
return $vehiclename[$vehiclenumber];
}
//Weapon Converter
function weaponconverter($weaponnumber) {
$weaponname[0] = "Assault Rifles";
$weaponname[1] = "Grenade Launchers";
$weaponname[2] = "Carbines";
$weaponname[3] = "Light Machine Guns";
$weaponname[4] = "Sniper Rifles";
$weaponname[5] = "Pistols";
$weaponname[6] = "Rockets";
$weaponname[7] = "Submachine Guns";
$weaponname[8] = "Shotguns";
$weaponname[9] = "Knife";
$weaponname[10] = "Defibrillator";
$weaponname[11] = "Explosives";
$weaponname[12] = "Hand Grenade";
$weaponname[13] = "Tear Gas";
return $weaponname[$weaponnumber];
}
$pid = $_GET["id"];
$mode = $_GET["image"];
$theme = $_GET["theme"];
if ($mode == "") {
$mode = $defaultmode;
}
if ($pid == "") {
/*$error = "No PID Specified";
$mode = "error";
include("themes/baseline/theme.php");
exit;*/
$pid = $defaultpid; //Player ID
}
if ($AllowedPID[0] != "any") {
if (!in_array($pid, $AllowedPID)) {
$error = "PID $pid Not Authorized";
$mode = "error";
include("themes/baseline/theme.php");
exit;
}
}
$cachefilename = $statdir.$pid.".xml";
if ((!file_exists($cachefilename)) || ((time() - filemtime($cachefilename)) > $cachetime)) {
//$filename = "http://bf2web.gamespy.com/ASP/getplayerinfo.aspx?weapon=".$weaponnumbers."&kit=".$kitnumbers."&map=".$mapnumbers."&army=".
//$filename = "http://bf2web.gamespy.com/ASP/getplayerinfo.aspx?pid=".$pid."&info=per*,cmb*,twsc,cpcp,cacp,dfcp,kila,heal,rviv,rsup,rpar,tgte,dkas,dsab,cdsc,rank,cmsc,kick,kill,deth,suic,ospm,klpm,klpr,dtpr,bksk,wdsk,bbrs,tcdr,ban,dtpm,lbtl,osaa,vrk,tsql,tsqm,tlwf,mvks,vmks,mvn*,vmr*,fkit,fmap,fveh,fwea,wtm-,wkl-,wdt-,wac-,wkd-,vtm-,vkl-,vdt-,vkd-,vkr-,atm-,awn-,alo-,abr-,ktm-,kkl-,kdt-,kkd-";
//$armynumbers."&vehicle=".$vehiclenumbers."&pid=".$pid."&info=".$infotoget.",rank";
//ini_set("user_agent","GameSpyHTTP/1.0");
//$fp = @fopen ($filename, "r");
################################################################# CURL MODIFICATION ###########################################################
$ch = curl_init();
$header[]="User-Agent: GameSpyHTTP/1.0rn";
//$header[]="Connection: closern";
curl_setopt($ch, CURLOPT_URL, "http://bf2web.gamespy.com/ASP/getplayerinfo.aspx?pid=".$pid."&info=per*,cmb*,twsc,cpcp,cacp,dfcp,kila,heal,rviv,rsup,rpar,tgte,dkas,dsab,cdsc,rank,cmsc,kick,kill,deth,suic,ospm,klpm,klpr,dtpr,bksk,wdsk,bbrs,tcdr,ban,dtpm,lbtl,osaa,vrk,tsql,tsqm,tlwf,mvks,vmks,mvn*,vmr*,fkit,fmap,fveh,fwea,wtm-,wkl-,wdt-,wac-,wkd-,vtm-,vkl-,vdt-,vkd-,vkr-,atm-,awn-,alo-,abr-,ktm-,kkl-,kdt-,kkd-
");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
$fp=curl_exec($ch);
curl_close ($fp);
################################################################# CURL MODIFICATION ##########################################################
if (!$fp) {
//Old Error Handler left incase someone wants it to do this instead of just reading the cache
/*$error = "BF2 Stats Site Down.";
$mode = error;
include("themes/baseline/theme.php");
exit;
*/
if (!file_exists($cachefilename)) {
$error = "BF2Web Down and no cache file exists.";
$mode = error;
include("themes/".$theme."/theme.php");
exit;
}
//read the cache for the stats
$xmlfile = @fopen($cachefilename, "r");
if (!$xmlfile) {
$error = "Error Reading $cachefilename";
$mode = "error";
include("themes/".$theme."/theme.php");
exit;
}
while(!feof($xmlfile)) {
$xmldoc .= fread($xmlfile,4096);
}
fclose($xmlfile);
$thestats = xml2array($xmldoc);
//end code for reading stat cache
$namedstats = $thestats['stats'][0]['info'][0];
$namedawards = $thestats['stats'][0]['awards'][0];
$namedleader = $thestats['stats'][0]['leaderboard'][0];
$namedunlocks = $thestats['stats'][0]['unlocks'][0];
$namedmaps = $thestats['stats'][0]['maps'][0];
//end code for reading stat cache
} else {
$_xml ="<?xml version="1.0"?>rn <stats>rn <info>rn";
//while (($fp)) {
//$content = fgets( $fp, 4096 );
//$content=preg_split("/n/",$fp);
############################################ CURL MODIFICATION FOR WHILE STATEMENT ######################
$content = array($fp);
$content = explode("t", $fp);
## array test
//$statnames = print_r(array_values($content));
############################################ CURL MODIFICATION FOR WHILE STATEMENT ######################
//echo $statnames;
//get names
if (ereg("Et107", $content) == true ) {
$error = "Error Invalid PID";
$mode = "error";
include("themes/".$theme."/theme.php");
exit;
}
if (ereg("Htpid", $content) == true ) {
$statnames = $content; //load up the names of the stats so that they can be used for the naming of the array
}
//real stats
//start the first part of the xml file
if (ereg($pid, $content) == true ) {
$stats = $content; //make the array with the stats
//it goes to one less than the count becuase the last one is one i added since the last one always gets messed up for some reason
//it also skips the first one because that is H (not a stat) from using explode it just picks this one up
for($i = 1; $i<count($stats)-1; $i++ ) {
$namedstats[$statnames[$i]] = "$stats[$i]"; //add the stat into a named array so its more easily configured.
//begin xml generation code
$_xml .="t ".$statnames[$i].">" . $stats[$i] . "</".$statnames[$i].">rn";
}
}
//}
$_xml .=" </info>rn <awards>rn";
}
//award part
//$awardfilename = "http://bf2web.gamespy.com/ASP/getawardsinfo.aspx?pid=".$pid;
//$afp = @fopen ($awardfilename, "r");
################################################################# CURL MODIFICATION ###########################################################
$ch = curl_init();
//$header[]="User-Agent: GameSpyHTTP/1.0rn";
//$header[]="Connection: closern";
curl_setopt($ch, CURLOPT_URL, "http://bf2web.gamespy.com/ASP/getawardsinfo.aspx?pid=".$pid);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
$afp=curl_exec($ch);
curl_close ($afp);
################################################################# CURL MODIFICATION ##########################################################
if (!$afp) {
} else {
//while (!feof ($afp)) {
//$content = fgets( $afp, 4096 );
############################################ CURL MODIFICATION FOR WHILE STATEMENT ######################
$content = array();
$content = explode("t", $afp);
############################################ CURL MODIFICATION FOR WHILE STATEMENT ######################
if (ereg("Dt([0-9]{7})t([0-9]*)", $content, $awards)) {
//echo "1:".$awards[1]." 2:".$awards[2]."n";
$namedawards[$awards[1]] = $awards[2]; //add the stat into a named array so its more easily configured.
//begin xml generation code
$_xml .="t <".$awards[1].">" . $awards[2] . "</".$awards[1].">rn";
}
}
//}
$_xml .=" </awards>rn <maps>rn";
######################################################################################################################################
//maps part
//$mapfilename = "http://bf2web.gamespy.com/ASP/getplayerinfo.aspx?pid=".$pid."&info=mtm-,mwn-,mls-";
//$mfp = @fopen ($mapfilename, "r");
################################################################# CURL MODIFICATION ###########################################################
$ch = curl_init();
//$header[]="User-Agent: GameSpyHTTP/1.0rn";
//$header[]="Connection: closern";
curl_setopt($ch, CURLOPT_URL, "http://bf2web.gamespy.com/ASP/getplayerinfo.aspx?pid=".$pid."&info=mtm-,mwn-,mls-");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
$mfp=curl_exec($ch);
curl_close($mfp);
################################################################# CURL MODIFICATION ##########################################################
//while (!feof ($mfp)) {
//$mapcontent = fgets( $mfp, 4096 );
############################################ CURL MODIFICATION FOR WHILE STATEMENT ######################
$mapcontent = array();
$mapcontent = explode("t",$mfp);
############################################ CURL MODIFICATION FOR WHILE STATEMENT ######################
//get names
if (ereg("Et107", $mapcontent) == true ) {
$error = "Error Invalid PID";
$mode = "error";
include("themes/".$theme."/theme.php");
exit;
}
if (ereg("Htpid", $mapcontent) == true ) {
$mapnames = $mapcontent; //load up the names of the stats so that they can be used for the naming of the array
}
//real stats
//start the first part of the xml file
if (ereg($pid, $mapcontent) == true ) {
$mapstats = $mapcontent; //make the array with the stats
//it goes to one less than the count becuase the last one is one a added since the last one always gets messed up for some reason
//it also skips the first one because that is H (not a stat) from using explode it just picks this one up
for($a = 1; $a<count($mapstats)-1; $a++ ) {
$namedmaps[$mapnames[$a]] = "$mapstats[$a]"; //add the stat into a named array so its more easily configured.
//begin xml generation code
$_xml .="t ".$mapnames[$a].">" . $mapstats[$a] . "</".$mapnames[$a].">rn";
}
}
//}
$_xml .=" </maps>rn <unlocks>rn";
##############################################################################################################################
//Unlocks part
//$unlocksfilename = "http://bf2web.gamespy.com/ASP/getunlocksinfo.aspx?pid=".$pid;
//$ufp = @fopen ($unlocksfilename, "r");
################################################################# CURL MODIFICATION ###########################################################
$ch = curl_init();
//$header[]="User-Agent: GameSpyHTTP/1.0rn";
//$header[]="Connection: closern";
curl_setopt($ch, CURLOPT_URL, "http://bf2web.gamespy.com/ASP/getunlocksinfo.aspx?pid=".$pid);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
$ufp=curl_exec($ch);
curl_close ($ufp);
################################################################# CURL MODIFICATION ##########################################################
if (!$ufp) {
} else {
//while (!feof ($ufp)) {
//$content = fgets( $ufp, 4096 );
############################################ CURL MODIFICATION FOR WHILE STATEMENT ######################
$content = array();
$content = explode("t", $ufp);
############################################ CURL MODIFICATION FOR WHILE STATEMENT ######################
if (ereg("Dt([0-9]{2}|[0-9]{3})t([ns])", $content, $unlocks)) {
$namedunlocks[$unlocks[1]] = $unlocks[2]; //add the stat into a named array so its more easily configured.
//begin xml generation code
$_xml .="t <".$unlocks[1].">" . $unlocks[2] . "</".$unlocks[1].">rn";
}
}
//}
$_xml .=" </unlocks>rn <leaderboard>rn";
//end awards
//leaderboard part
//$leaderfilename = "http://bf2web.gamespy.com/ASP/getleaderboard.aspx?pid=".$pid."&type=score&id=overall";
//$lfp = @fopen ($leaderfilename, "r");
################################################################# CURL MODIFICATION ###########################################################
$ch = curl_init();
//$header[]="User-Agent: GameSpyHTTP/1.0rn";
//$header[]="Connection: closern";
curl_setopt($ch, CURLOPT_URL, "http://bf2web.gamespy.com/ASP/getleaderboard.aspx?pid=".$pid."&type=score&id=overall");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
$lfp=curl_exec($ch);
curl_close ($lfp);
################################################################# CURL MODIFICATION ##########################################################
if (!$lfp) {
} else {
//while (!feof ($lfp)) {
//$content = fgets( $lfp, 4096 );
############################################ CURL MODIFICATION FOR WHILE STATEMENT ######################
$content = array();
$content = explode("t", $lfp);
############################################ CURL MODIFICATION FOR WHILE STATEMENT ######################
if (ereg("Htntpid", $content) == true ) {
$leadernames = $content; //load up the names of the stats so that they can be used for the naming of the array
}
//real stats
//start the first part of the xml file
if (ereg($pid, $content) == true ) {
$leader = $content; //make the array with the stats
//it also skips the first one because that is H (not a stat) from using explode it just picks this one up
for($i = 1; $i<count($leader); $i++ ) {
if ($i == (count($leader)-1)) {
//this gets rid of the line break the last one has
$leader[$i] = str_replace("n", "", $leader[$i]);
$leadernames[$i] = str_replace("n", "", $leadernames[$i]);
}
$namedleader[$leadernames[$i]] = "$leader[$i]"; //add the stat into a named array so its more easily configured.
//begin xml generation code
$_xml .="t ".$leadernames[$i].">" . $leader[$i] . "</".$leadernames[$i].">rn";
}
}
}
//}
//end leaderboard
$_xml .=" </leaderboard>rn </stats>rn</xml>";
$xmlcachefile = @fopen($cachefilename, "w");
if (!$xmlcachefile) {
$error = "Error Opening $cachefilename for writing";
$mode = "error";
include("themes/".$theme."/theme.php");
exit;
}
if(fwrite($xmlcachefile, $_xml) === False) {
$error = "Error Writing $cachefilename";
$mode = "error";
include("themes/".$theme."/theme.php");
exit;
}
fclose($xmlcachefile);
} else {
//read the cache for the stats
$xmlfile = @fopen($cachefilename, "r");
if (!$xmlfile) {
$error = "Error Reading $cachefilename";
$mode = "error";
include("themes/".$theme."/theme.php");
exit;
}
while(!feof($xmlfile)) {
$xmldoc .= fread($xmlfile,4096);
}
fclose($xmlfile);
$thestats = xml2array($xmldoc);
//end code for reading stat cache
$namedstats = $thestats['stats'][0]['info'][0];
$namedawards = $thestats['stats'][0]['awards'][0];
$namedleader = $thestats['stats'][0]['leaderboard'][0];
$namedunlocks = $thestats['stats'][0]['unlocks'][0];
$namedmaps = $thestats['stats'][0]['maps'][0];
}