Made a test code once. It gets data from a server and tells every data back during each gamemode.
Code: Select all
<html>
<head>
<script>
<!--
/*
Auto Refresh Page with Time script
By JavaScript Kit (javascriptkit.com)
Over 200+ free scripts here!
*/
//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="0:03"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function beginrefresh(){
if (!document.images)
return
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
else
curtime=cursec+" seconds left until page refresh!"
window.status=curtime
setTimeout("beginrefresh()",1000)
}
}
window.onload=beginrefresh
//-->
</script>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<title>Intense Mania Stats</title>
<?php
/**
* IMS - IntenseManiaStats
*
* -- IMS Webpage --
* @name IMS Testindex.php
* @date 13-03-2011
* @version r001
* @website ims.tmrankings.com
* @package IMS
*
* @author Willem "W1lla" van den Munckhof <w1llaopgezwolle@gmail.com>
*
* @copyright 2010 - 2011
*
* ---------------------------------------------------------------------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
* You are allowed to change things of use this in other projects, as
* long as you leave the information at the top (name, date, version,
* website, package, author, copyright) and publish the code under
* the GNU General Public License version 3.
* ---------------------------------------------------------------------
*/
$version = 0.1;
$ip="localhost"; //IP address of server
$port=5225; //Port for remote access
$user= "SuperAdmin"; // SuperAdmin Login
$pass= "SuperAdmin"; // SuperAdmin Password
require("includes/GbxRemote.inc.php"); // required for connection with server.
require("includes/tmfcolorparser.inc.php"); //colorparser for tracks, nicknames etc.
$client = new IXR_Client_Gbx;
$colors= new TMFColorParser;
if (!$client->InitWithIp($ip,$port)) {
echo'An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage();
}
if (!$client->query("Authenticate", $user, $pass)) {
print "login failed !<br/>";
}
if($client->query('GetStatus')) {
$Status = $client->getResponse();
}
if($client->query('GetPlayerList', 300, 0)){ //used to show all player nicknames..
$players = $client->getResponse();
$CurrentPlayerCount=0;
$playersinput = array();
foreach ($players as $pls) {
$playersinput[$CurrentPlayerCount] = $colors->toHTML($pls['NickName']);
$CurrentPlayerCount++;
}
}
if($client->query('GetServerOptions')) { //used for the current max state of players.
$ServerOptions = $client->getResponse();
$servername=$ServerOptions['Name'];
$MaxPLayers=$ServerOptions['CurrentMaxPlayers'];
$pl=0;
foreach ($players as $player) {
$pl++;
}
}
if($client->query('GetCurrentChallengeInfo')) { //used for current track.
$CurrentChallengeInfo = $client->getResponse();
$trackname=$CurrentChallengeInfo['Name'];
}
if($client->query('GetCurrentGameInfo')) { // used for current gamemode.
$GetCurrentGameInfo=$client->getResponse();
$GameMode=$GetCurrentGameInfo["GameMode"];
}
if($client->query('GetNextChallengeInfo')) { // used for next track.
$GetNextChallengeInfo=$client->getResponse();
$nexttrackname=$GetNextChallengeInfo['Name'];
}
if ($client->query('GetLadderServerLimits')) { // used for serverlimits.
$GetLadderServerLimits=$client->getResponse();
$ladderMin = $GetLadderServerLimits['LadderServerLimitMin'];
$ladderMax = $GetLadderServerLimits['LadderServerLimitMax'];
}
if ($client->query('GetMainServerPlayerInfo')) { // used for serverlogin.
$GetMainServerPlayerInfo = $client->getResponse();
$serverlogin = $GetMainServerPlayerInfo['Login'];
}
if ($client->query('GetCurrentGameInfo', 1)) { //used for CurrentGameinfos
$currentgameinfo = $client->getResponse();
$RoundsPointsLimit = $currentgameinfo['RoundsPointsLimitNewRules'];
$CupPointsLimit = $currentgameinfo['CupPointsLimit'];
}
//Formating Game Mod
switch($GameMode){
case 0:
$GameMode="Rounds";
Break;
case 1:
$GameMode="Time Attack";
Break;
case 2:
$GameMode="Team";
Break;
case 3:
$GameMode="Laps";
Break;
case 4:
$GameMode="Stunts";
Break;
case 5:
$GameMode="Cup";
Break;
}
if ($client->query('GetCurrentRanking', 300, 0)) { // used for CurrentRanking tested in Rounds....
$currentranking = $client->getResponse();
foreach ($currentranking as $playersplay) {
$playerlogin = $playersplay['Login'];
$playernickname = $playersplay['NickName'];
$score = $playersplay['Score'];
$Rank = $playersplay['Rank'];
$playerBest = $playersplay['BestTime'];
$MWTime = $playerBest;
$minutes = floor($MWTime/(1000*60));
$seconds = floor(($MWTime-$minutes*60*1000)/1000);
$mseconds = substr($MWTime,strlen($MWTime)-3,2);
$time=sprintf("%02d:%02d.%02d", $minutes, $seconds, $mseconds);
if ($time=="-1:59.01") {
$time="No time made";
$Rank="---";
}
}
}
?>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo 'Current Gamemode: '.$GameMode.'' ?></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo 'Current Track being played: '.$colors->toHTML($trackname).'' ?></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo 'Next Track being played: '.$colors->toHTML($nexttrackname).'' ?></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Players: $pl/$MaxPLayers" ?></font></div></td>
</tr>
<br>
<?php if ($pl == 1){?>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Playerlist:<br><br>".implode('<br><br>', $playersinput)."" ?></font></div></td>
</tr>
<br>
<?php } ?>
<?php if ($GameMode === "Team"){
?>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Team:".$colors->toHTML($playernickname)."" ?><br></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "PlayerBestTime: $time" ?></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Score: $score" ?></font></div></td>
</tr>
<br>
<?php
}
?>
<?php if ($GameMode === "Time Attack"){
?>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Playernickname:".$colors->toHTML($playernickname)."" ?><br></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Playerlogin:".$playerlogin."" ?><br></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "PlayerBestTime: $time" ?></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Score: $score" ?></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Rank: $Rank" ?></font></div></td>
</tr>
<br>
<br>
<?php
}
?>
<br><?php if ($GameMode === "Rounds"){?>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "RoundpointsLimit: $RoundsPointsLimit" ?></font></div></td>
</tr>
<br>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Playernickname:".$colors->toHTML($playernickname)."" ?><br></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Playerlogin:".$playerlogin."" ?><br></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "PlayerBestTime: $time" ?></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Score: $score" ?></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Rank: $Rank" ?></font></div></td>
</tr>
<br>
<br>
<?php } ?>
<br><?php if ($GameMode === "Cup"){?>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "CuppointsLimit: $CupPointsLimit" ?></font></div></td>
</tr>
<br>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Playernickname:".$colors->toHTML($playernickname)."" ?><br></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Playerlogin:".$playerlogin."" ?><br></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "PlayerBestTime: $time" ?></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Score: $score" ?></font></div></td>
</tr>
<br>
<tr bgcolor="#000000">
<td height="25" colspan="5"> <div align="center"><font color="#000000"><?php echo "Rank: $Rank" ?></font></div></td>
</tr>
<br>
<br>
<?php } ?>
<?php
echo "<center>Intense Mania Stats $version. All rights reserved.<br /></center>";
echo '</head>
<body style="background:#BBBBBB; font-family:Arial, sans-serif">';
?>
Copy paste it in a new file and save it as .php extension file.