w README napisane jest tak:
Kod: Zaznacz cały
These scripts can be used to parse and display information stored in etpub's
xpsave.cfg format.
You will need to edit xpsave_table.php to replace $GLOBALS["XPSAVE_CFG"] with
the full path to your xpsave.cfg file (or set $GLOBALS["XPSAVE_CFG"]).
xpsave_table.php
This is the script that should be run (or included) to draw the
table containing xpsave.cfg data
xpsave.php
This is a file that is included by xpsave_table.php. It contains
functions nececessary for parsing the xpsave.cfg file.
Kod: Zaznacz cały
<?php
function xpsave_readconfig(
$cfg = "/home/et/.etwolf/etpub/xpsave.cfg",
$sort = "win")
{
if(!is_readable($cfg))
return array();
$file = file($cfg);
while(list($lnum,$line) = each($file)) {
$line = trim($line);
if($line == "[xpsave]") {
while(trim($line) != "") {
list($lnum,$line) = each($file);
if(trim($line) == "")
continue;
$lparts = explode("=", $line);
if(@count($lparts) < 2) {
?>
<!--
xpsave_readconfig: parse error
on line <?php echo $lnum;?> near
<?php echo htmlspecialchars($line);?>
-->
<?php
continue;
}
$p = trim(array_shift($lparts));
$n = implode("", $lparts);
$xpsave[$p] = trim($n);
}
// tjw: old versions of xpsave lacked name
if($xpsave["name"] == "")
continue;
if(!isset($xpsave["killrating"]))
$xpsave["killrating"] = 1600;
if(!isset($xpsave["rating"]))
$xpsave["rating"] = "0.000000";
if(!isset($xpsave["rating_variance"]))
$xpsave["rating_variance"] = "1.0";
$xpsave["rating_variance"] = sqrt($xpsave["rating_variance"]);
$xpsave["kd"] = 1.0 / (1.0 + exp(-($xpsave["killrating"]-1600)/400.0));
$xpsave["kd"] /= 1.0 - $xpsave["kd"];
$xpsave["win"] = 1.0 / (1.0 + exp(-$xpsave["rating"]/sqrt(1.0+3*($xpsave["rating_variance"]*$xpsave["rating_variance"]*20)/(pi()*pi()))));
$xpsave["win"] = sprintf("%.3f",$xpsave["win"]);
$xpsave["kd"] = sprintf("%.3f",$xpsave["kd"]);
$xpsaves[$xpsave["guid"]] = $xpsave;
unset($xpsave);
}
}
if(!is_array($xpsaves))
return array();
if($sort == "name") {
$sort_ord = SORT_ASC;
$sort_type = SORT_STRING;
}
else {
$sort_ord = SORT_DESC;
$sort_type = SORT_NUMERIC;
}
while (list(,$v) = each($xpsaves))
$sort_ary[] = strtolower($v[$sort]);
reset($xpsaves);
array_multisort($sort_ary, $sort_type, $sort_ord, $xpsaves);
return $xpsaves;
}
?>
plik do zmiany (xpsave_table.php):
Kod: Zaznacz cały
<?php
require_once("../globals.php");
require_once("xpsave.php");
if(!isset($_REQUEST["xpsave_sort"]))
$_REQUEST["xpsave_sort"] = "win";
?>
<table border = 1>
<tr>
<?php
$fields = array(
"name" => "Name",
"win" => "PR Win %",
"kd" => "KR K/D",
//"lower_rating" => "Range",
//"player_rating" => "Player Rating",
//"player_rating_variance" => "Player Rating Deviation",
//"killrating" => "Kill Rating",
//"playerrating" => "Player Rating",
//"skill[0]" => "Battle Sense",
//"skill[1]" => "Engineering",
//"skill[2]" => "First Aid",
//"skill[3]" => "Signals",
//"skill[4]" => "Light Weapons",
//"skill[5]" => "Heavy Weapons",
//"skill[6]" => "Covert Ops",
"time" => "Last Seen"
);
?>
<TD>Rank</TD>
<?php
while(list($k,$v) = each($fields)) {
?>
<TD><?php
if($_REQUEST["xpsave_sort"] != $k) {
?>
<a href="<?php $_SERVER["PHP_SELF"];?>?xpsave_sort=<?php
echo urlencode($k);?>">
<b><?php echo $v;?></b></a>
<?php
}
else {
?>
<b><?php echo $v;?></b>
<?php
}
?>
</td>
<?php
}
reset($fields);
?>
</td>
</tr>
<?php
$xpsaves = xpsave_readconfig($GLOBALS["XPSAVE_CFG"], $_REQUEST["xpsave_sort"]);
$rank = 0;
while(list($guid,$x) = each($xpsaves)) {
$rank++;
?>
<tr>
<td>
<?php
echo $rank;
?></td>
<?php
while(list($k,$v) = each($fields)) {
if($x[$k] == "") {
switch($k) {
case "killrating":
$x[$k] = 1600;
case "rating":
$x[$k] = 0;
break;
case "rating_variance":
$x[$k] = 1.0;
break;
case "name":
$x[$k] = "";
break;
default:
$x[$k] = 0;
break;
}
}
if($k == "time") {
$x[$k] = date("Y-m-d H:i", $x[$k]);
} else if($k == "name") {
$x[$k] = preg_replace("/\^(.{1})/","",$x[$k]);
}
$x[$k] = htmlspecialchars($x[$k]);
?>
<td><?php
echo ($x[$k] == "") ? " " : $x[$k];
?></td>
<?php
}
reset($fields);
?>
</tr>
<?php
}
?>
</table>
$fields = array(
"name" => "Name",
"win" => "PR Win %",
"kd" => "KR K/D",
//"lower_rating" => "Range",
//"player_rating" => "Player Rating",
//"player_rating_variance" => "Player Rating Deviation",
//"killrating" => "Kill Rating",
//"playerrating" => "Player Rating",
//"skill[0]" => "Battle Sense",
//"skill[1]" => "Engineering",
//"skill[2]" => "First Aid",
//"skill[3]" => "Signals",
//"skill[4]" => "Light Weapons",
//"skill[5]" => "Heavy Weapons",
//"skill[6]" => "Covert Ops",
"time" => "Last Seen"
);
?>
<TD>Rank</TD>
<?php
while(list($k,$v) = each($fields)) {
?>
<TD><?php
if($_REQUEST["xpsave_sort"] != $k) {
?>
<a href="<?php $_SERVER["PHP_SELF"];?>?xpsave_sort=<?php
echo urlencode($k);?>">
<b><?php echo $v;?></b></a>
<?php
}
else {
?>
<b><?php echo $v;?></b>
<?php
}
?>
</td>
<?php
}
reset($fields);
?>
</td>
</tr>
<?php
$xpsaves = xpsave_readconfig($GLOBALS["XPSAVE_CFG"], $_REQUEST["xpsave_sort"]);
$rank = 0;
while(list($guid,$x) = each($xpsaves)) {
$rank++;
?>
<tr>
<td>
<?php
echo $rank;
?></td>
<?php
while(list($k,$v) = each($fields)) {
if($x[$k] == "") {
switch($k) {
case "killrating":
$x[$k] = 1600;
case "rating":
$x[$k] = 0;
break;
case "rating_variance":
$x[$k] = 1.0;
break;
case "name":
$x[$k] = "";
break;
default:
$x[$k] = 0;
break;
}
}
if($k == "time") {
$x[$k] = date("Y-m-d H:i", $x[$k]);
} else if($k == "name") {
$x[$k] = preg_replace("/\^(.{1})/","",$x[$k]);
}
$x[$k] = htmlspecialchars($x[$k]);
?>
<td><?php
echo ($x[$k] == "") ? " " : $x[$k];
?></td>
<?php
}
reset($fields);
?>
</tr>
<?php
}
?>
</table>
sciezka do pliku xpsave.cfg:
Kod: Zaznacz cały
http://templars-clan.cba.pl/xpsave.cfg"