Kann hier jemand den Sourcecode für eine funktionierende bf2tracker.php posten ?
Hat sich erledigt.
Wen es interessiert, hier eine funktionierende Bf2Tracker.php
Ich hoffe, das ist OK so, da ich auch nicht so komform in PHP bin und auch nicht weis, ob Topolino das überhaupt gestattet, dass ich es hier reinstelle.
Wenn es nicht erwünscht wird, bitte löschen !
<?php
/*
***********************************
* Copyright (c) 2006, honklords.de*
***********************************
*/
defined ('main') or die ( 'no direct access' );
$title = $allgAr['title'].' :: Battlefield 2 Tracker';
$hmenu = '<a href="?bf2_tracker">BF2-Tracker</a>';
$design = new design ( $title , $hmenu );
$design->header();
$clanid = "26051"; //Clan ID from Battlefield 2 Tracker
function startTag($parser, $name, $attrs) {
global $stack;
$tag=array("name"=>$name,"attrs"=>$attrs);
array_push($stack,$tag);
}
function cdata($parser, $cdata) {
global $stack;
$stack[count($stack)-1]['cdata'] .= $cdata;
}
function endTag($parser, $name) {
global $stack;
$stack[count($stack)-2]['children'][] = $stack[count($stack)-1];
array_pop($stack);
}
function aSortBySecondIndex($multiArray, $secondIndex, $dir) {
while (list($firstIndex, ) = each($multiArray))
$indexMap[$firstIndex] = $multiArray[$firstIndex][$secondIndex];
if ($dir==0)
asort($indexMap);
else
arsort($indexMap);
while (list($firstIndex, ) = each($indexMap))
if (is_numeric($firstIndex))
$sortedArray[] = $multiArray[$firstIndex];
else $sortedArray[$firstIndex] = $multiArray[$firstIndex];
return $sortedArray;
}
$stack = array();
$claninfo = array();
$clanstats = array();
$playerstats = array();
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startTag", "endTag");
xml_set_character_data_handler($xml_parser, "cdata");
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://battletracker.com/clanfeed/bf2/'.$clanid.'/claninfo.xml');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$xmllink = curl_exec($ch);
curl_close($ch);
$data = xml_parse($xml_parser,$xmllink);
if(!$data) die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
xml_parser_free($xml_parser);
// Get Data
// Get Clan Profile Data
for($i = 0; $i < sizeof($stack[0][children][0][children]); $i++) {
$valname=$stack[0][children][0][children][$i][name];
$claninfo[$valname]=$stack[0][children][0][children][$i][cdata];
}
for($i = 0; $i < sizeof($stack[0][children][1][children]); $i++) {
$valname=$stack[0][children][1][children][$i][name];
$clanstats[$valname]=$stack[0][children][1][children][$i][cdata];
}
$clan_count = $claninfo['CLANCOUNTRY'];
$clan_matches = $clanstats['MATCHES'];
$clan_wins = $clanstats['WINS'];
$clan_loss = $clanstats['LOSS'];
$clan_score = $clanstats['SCORE'];
$clan_kills = $clanstats['KILLS'];
$clan_deaths = $clanstats['DEATHS'];
$clan_kdr = $clanstats['KDRATIO'];
$clan_kdr = ($clan_kdr < 1) ? '<font color="#FF0000">'.$clan_kdr.'</font>' : '<font color="#00FF00">'.$clan_kdr.'</font>';
$clan_kdr = ($clan_kdr <= 2) ? '<font color="#0000FF">'.$clan_kdr.'</font>' : $clan_kdr;
echo '<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td><b>'.$title.'</b></td>
</tr>
</table>';
if ($clan_count == ""){
echo '<br><br><table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center">keine Daten oder offline</td>
</tr>
</table>';
}else {
echo '<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td height="20"><br></td>
</tr>
</table>';
echo '<table width="200" cellpadding="2" cellspacing="1" border="0" class="border">';
echo '<tr class="Chead"><td colspan="2"><b>Clanstats:</b></td></tr>';
echo '<tr><td class="Cmite">Clancountry:</td>
<td class="Cnorm" align="center"><img src="include/images/tracker/flags/'.$clan_count.'.jpg" width="16" height="12" border="0"></td></tr>';
echo '<tr><td class="Cmite">Durchschnitts Matches:</td>
<td class="Cnorm" align="right">'.$clan_matches.'</td></tr>';
echo '<tr><td class="Cmite">Durchschnitts Wins:</td>
<td class="Cnorm" align="right">'.$clan_wins.'</td></tr>';
echo '<tr><td class="Cmite">Durchschnitts Loss:</td>
<td class="Cnorm" align="right">'.$clan_loss.'</td></tr>';
echo '<tr><td class="Cmite">Durchschnitts Score:</td>
<td class="Cnorm" align="right">'.$clan_score.'</td></tr>';
echo '<tr><td class="Cmite">Durchschnitts Death:</td>
<td class="Cnorm" align="right">'.$clan_deaths.'</td></tr>';
echo '<tr><td class="Cmite">Durchschnitts Kills:</td>
<td class="Cnorm" align="right">'.$clan_kills.'</td></tr>';
echo '<tr><td class="Cmite">Durchschnitts K/D:</td>
<td class="Cnorm" align="right">'.$clan_kdr.'</td></tr>';
echo '</table>';
// Get Player Data
for($i = 0; $i < sizeof($stack[0][children][2][children]); $i++) {
for($x = 0; $x < sizeof($stack[0][children][2][children][$i][children]); $x++) {
$valname=$stack[0][children][2][children][$i][children][$x][name];
$value=$stack[0][children][2][children][$i][children][$x][cdata];
if($valname=="PLAYERID") $pid=$value;
$playerstats[$pid][$valname]=$value;
}
}
echo '<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td height="20"><br></td>
</tr>
</table>';
echo '<table width="100%" cellpadding="2" cellspacing="1" class="border">';
echo '<tr class="Chead"><td colspan="11"><b>Playerstats:</b></td></tr>';
echo '<tr class="Cmite">';
echo '<td align="center" width="16"><b>RA</b></td>';
echo '<td align="center" width="16"><b>CO</b></td>';
echo '<td align="center"><b>Player</b></td>';
echo '<td align="center"><b>Match</b></td>';
echo '<td align="center"><b>Wins</b></td>';
echo '<td align="center"><b>Loss</b></td>';
echo '<td align="center"><b>Score</b></td>';
echo '<td align="center"><b>Kills</b></td>';
echo '<td align="center"><b>Deaths</b></td>';
echo '<td align="center"><b>K/D</b></td>';
echo '<td align="center"><b>Status</b></td></tr>';
switch ($sort) {
case 1:
$playerstats_sorted=aSortBySecondIndex($playerstats, 'PLAYERSTATUS', $dir);
break;
case 2:
$playerstats_sorted=aSortBySecondIndex($playerstats, 'PLAYERNAME', $dir);
break;
case 3:
$playerstats_sorted=aSortBySecondIndex($playerstats, 'PLAYERRANK', $dir);
break;
case 4:
$playerstats_sorted=aSortBySecondIndex($playerstats, 'PLAYERMATCHES', $dir);
break;
case 5:
$playerstats_sorted=aSortBySecondIndex($playerstats, 'PLAYERWINS', $dir);
break;
case 6:
$playerstats_sorted=aSortBySecondIndex($playerstats, 'PLAYERLOSS', $dir);
break;
case 7:
$playerstats_sorted=aSortBySecondIndex($playerstats, 'PLAYERGLOBALSCORE', $dir);
break;
case 8:
$playerstats_sorted=aSortBySecondIndex($playerstats, 'PLAYERKILLS', $dir);
break;
default:
$playerstats_sorted=aSortBySecondIndex($playerstats, 'PLAYERRANK', 1);
}
foreach($playerstats_sorted as $key => $value) {
$playerrank = $playerstats_sorted[$key][PLAYERRANK];
$playerflag = $playerstats_sorted[$key][PLAYERCOUNTRY];
$playername=$playerstats_sorted[$key][PLAYERNAME];
$playerurl = $playerstats_sorted[$key][PLAYERSTATSURL];
$playermatches = $playerstats_sorted[$key][PLAYERMATCHES];
$playerwins = $playerstats_sorted[$key][PLAYERWINS];
$playerloss = $playerstats_sorted[$key][PLAYERLOSS];
$playerscore = $playerstats_sorted[$key][PLAYERGLOBALSCORE];
$playerkills = $playerstats_sorted[$key][PLAYERKILLS];
$playerdeaths = $playerstats_sorted[$key][PLAYERDEATHS];
$playerkdr = @round($playerstats_sorted[$key][PLAYERKILLS]/$playerstats_sorted[$key][PLAYERDEATHS], 2);
$status = ($playerstats_sorted[$key]['PLAYERSTATUS']=="1") ? '<img src="include/images/tracker/online.gif" alt="online" />' : '<img src="include/images/tracker/offline.gif" alt="offline" />';
$playerkdr = ($playerkdr < 1) ? '<font color="#FF0000">'.$playerkdr.'</font>' : '<font color="#00FF00">'.$playerkdr.'</font>';
$playerkdr = ($playerkdr <= 2) ? '<font color="#0000FF">'.$playerkdr.'</font>' : $playerkdr;
echo '<tr class="Cnorm">';
echo '<td valign="middle" width="16"><img src="include/images/tracker/ranks/'.$playerrank.'.gif" border="0"></td>';
echo '<td valign="middle" width="16"><img src="include/images/tracker/flags/'.$playerflag.'.jpg" width="16" height="12" border="0"></td>';
echo '<td align="left"><a href="'.$playerurl.'" target="_blank">'.$playername.'</a></td>';
echo '<td align="center">'.$playermatches.'</td>';
echo '<td align="center">'.$playerwins.'</td>';
echo '<td align="center">'.$playerloss.'</td>';
echo '<td align="center">'.$playerscore.'</td>';
echo '<td align="center">'.$playerkills.'</td>';
echo '<td align="center">'.$playerdeaths.'</td>';
echo '<td align="center">'.$playerkdr.'</td>';
echo '<td align="right">'.$status.'</td>';
echo '</tr>';
}
echo '</table>';
echo '<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><br><b>RA</b> = Playerrank || <b>CO</b> = Country || <b>K/D</b> = Fragrate (K/D Ratio)<br>Click the player name to get more detailed stats @ bf2tracker.com</td>
</tr>
</table>';
}
$design->footer();
?>
Zuletzt modifiziert von Caporal Maine am 20.10.2009 - 16:07:23