Ich wollte die Mani-Stats auf meiner HP integrieren, schaffe es aber leider nicht ohne Hilfe!
Hier werden keine Daten angezeigt:
externer Link
Verlinke ich direkt funktioniert es:
externer Link
Ich stell mal einfach den Code hier herein, hoffe es kann mir jemand helfen.
Eigentlich sind nur die letzten paar Zeilen wichtig, da ich im Augenblick die Datei direkt wom Webspace aufrufe.
<?php
/********************************************************************
MANI ADMIN PLUGIN STATS READER
v2.1
Copyright (c) 2005 Josef Ohnheiser, All Rights Reserved
! This script has been created and released under !
! the GNU GPL and is free to use and redistribute !
! only if this copyright statement is not removed !
Author: TutatiS (2t4t!$TM) - Josef Ohnheiser
admin@fraghunter.net
externer Link
FragHunter.Net :: Counter-Strike & Half-Life 2 portal
========================================================
File for get mani_ranks.txt from FTP server and parse
for showing player stats on web page.
========================================================
INSTALLATION & SETTINGS:
Set FTP section if use FTP for downloaded mani_ranks.txt
on to webserver. When dont use FTP, set only $ftp['use']
to false (not true).
Paths are ok (plugin use default paths), sets only local
file name and number of showing plaers.
Error messages in czech language, message's are:
1. Error on MySQL connect
2. Error in MySQL query
3. Error on connection to FTP
4. Error on login to FTP
5. Error on get file mani_ranks.txt
Bad CHars - chars in bad format (UTF charset)
For correctly showing chars, must UTF chars added to first
array (name $bad) and correct chars to second array ($good)
Format are:
$bad = array('1','2','3'....);
$good = array('1a','2a','3a'....);
and 1 change to 1a, 2 change to 2a etc....
Create manistats.dat file on your web server and set him
CHMOD 666 - file must by enabled for writing if use FTP
========================================================
MYSQL table data structure:
CREATE TABLE `manistats` (
`stats_uid` int(11) unsigned NOT NULL auto_increment,
`stats_nick` varchar(30) default NULL,
`stats_steamid` varchar(20) default NULL,
`stats_kills` int(11) NOT NULL default '0',
`stats_deaths` int(11) NOT NULL default '0',
`stats_suicides` int(11) NOT NULL default '0',
`stats_hs` int(11) NOT NULL default '0',
`stats_hsperc` varchar(4) NOT NULL default '0',
`stats_kdratio` varchar(5) NOT NULL default '0',
`stats_modify` timestamp(14) NOT NULL,
`stats_make` timestamp(14) NOT NULL default '00000000000000',
PRIMARY KEY (`stats_uid`)
) TYPE=MyISAM ;
********************************************************************/
// Disable showing system (php) error messages (only messages in SCRIPT MESSAGES section)
error_reporting(0);
// FTP settings for get mani_ranks.txt over FTP
$ftp['server'] = ""; //serverIP ohne port
$ftp['login'] = ""; // FTP user login name
$ftp['passwd'] = ""; // FTP user password
$ftp['use'] = false; // USE FTP for get stats file? (true = yes, false = no)
// MySQL Settings
$sql['host'] = ""; // MySQL host
$sql['login'] = ""; // MySQL login name
$sql['password'] = ""; // MySQL password
$sql['db'] = ""; // name of MySQL database
$sql['table'] = "mani_stats"; // name of MySQL table
$sql['use'] = false; // USE MySQL databse for storage stats? (true = yes, false = no)
$sql['sortby'] = 7; // sort output from DB (1-nick,2-kills,3-deaths,4-suicides,5-hs,6-hs%,7-k/d ratio)
// Path's and file name settings
$cfg['serverpath'] = "/css/cstrike/cfg/mani_admin_plugin/"; // default server path
$cfg['serverfile'] = "mani_ranks.txt"; // Mani Admin Plugin stats file
$cfg['localfile'] = "serrverstats.dat"; // Stats file on your web server
$cfg['playerlimit'] = "200"; // How players are view on webpage
$cfg['minstyle'] = "color: green; font-weight: bold"; // style for highlight min values
$cfg['maxstyle'] = "color: red; font-weight: bold"; // style for highlight max values
// Script Messages
define("SQLCONERROR", "Can't connect to database ");
define("SQLBADQUERY", "Chyba pøi zpracování dotazù v databázi");
define("FTPCONERROR", "Can't connect to FTP server");
define("FTPLOGERROR", "Can't login to FTP server");
define("FTPFILEERROR", "Can't download file");
define("COPYRIGHT", "<hr style='height: 1px'>Mani Admin Plugin Stats Reader v 2.0 © 2005 <a href='externer Link</a>");
// parse unreadable chars to normal format
$bad = array('â"¢'); // unreadable chars
$good = array('TM'); // normal format for web output
// FUNCTIONS
function parsestats($file) {
global $cfg, $sql, $bad, $good;
if ($sql['use'] == true) {
$sqlconnect = mysql_connect($sql['host'], $sql['login'], $sql['password']) or die(SQLCONERROR);
mysql_select_db($sql['db'], $sqlconnect);
}
$content = file($file);
$i = 0;
foreach ($content AS $k => $v) {
list($pos,$nick,$steamid,$kills,$deaths,$suicides,$hs,$ratio) = explode("> <", $v);
$hsp = sprintf("%01.1f", $hs/($kills/100));
$ratio = str_replace(">", "", $ratio);
for ($ii=0; $ii<=count($bad); $ii++) {
$nick = str_replace($bad[$ii], $good[$ii], $nick);
} // end for
if ($sql['use'] == true && $steamid != "") { // save to database
$res = mysql_query("SELECT stats_steamid FROM ".$sql['table']." WHERE stats_steamid = '".$steamid."'");
if (!$res) echo SQLBADQUERY;
if (mysql_num_rows($res) > 0) {
$res = mysql_query("UPDATE ".$sql['table']." SET
stats_nick='".$nick."',
stats_kills='".$kills."',
stats_deaths='".$deaths."',
stats_suicides='".$suicides."',
stats_hs='".$hs."',
stats_hsperc='".$hsp."',
stats_kdratio='".$ratio."'
WHERE stats_steamid='".$steamid."'
");
if (!$res) echo SQLBADQUERY;
} else {
$res = mysql_query("INSERT INTO ".$sql['table']."
(stats_nick,stats_steamid,stats_kills,stats_deaths,stats_suicides,stats_hs,stats_hsperc,stats_kdratio,stats_make)
VALUES
('".$nick."','".$steamid."','".$kills."','".$deaths."','".$suicides."','".$hs."','".$hsp."','".$ratio."',NOW())
");
if (!$res) echo SQLBADQUERY;
} // end if
} // end if
if ($i != 0 && $i <= $cfg['playerlimit']) {
if ($sql['use'] == false) {
$return .= "<tr><td><strong>".$i.".</strong></td><td><IMG SRC='gamer.gif'>".$nick."</td><td style='text-align: center'>".$kills."</td><td style='text-align: center'>".$deaths."</td><td style='text-align: center'>".$hs."</td><td style='text-align: center'>".$hsp."</td><td style='text-align: center'>".$ratio."</td></tr>";
}
} // end if
$i++;
}
if ($sql['use'] == true) {
$res = mysql_query("SELECT max(stats_kills) AS maxkills,min(stats_deaths) AS mindeaths,max(stats_hs) AS maxhs,max(stats_hsperc) AS maxhsperc FROM ".$sql['table']." LIMIT 0,".$cfg['playerlimit']." ");
$res = mysql_fetch_array($res);
$maxkills = $res['maxkills'];
$mindeaths = $res['mindeaths'];
$maxhs = $res['maxhs'];
$maxhsperc = $res['maxhsperc'];
$sort = array('','stats_nick','stats_kills','stats_deaths','stats_suicides','stats_hs','stats_hsperc','stats_kdratio');
$res = mysql_query("SELECT * FROM ".$sql['table']." ORDER BY ".$sort[$sql['sortby']]." DESC LIMIT 0,".$cfg['playerlimit']." ");
if ($res) {
$i = 1;
while ($result = mysql_fetch_array($res)) {
$return .= "<tr><td><strong>".$i.".</strong></td><td>".$result['stats_nick']."</td><td style='text-align: center'>".($maxkills==$result['stats_kills']?"<span style='".$cfg['maxstyle']."'>":"").$result['stats_kills'].($maxkills==$result['stats_kills']?"</span>":"")."</td><td style='text-align: center'>".($mindeaths==$result['stats_deaths']?"<span style='".$cfg['minstyle']."'>":"").$result['stats_deaths'].($mindeaths==$result['stats_deaths']?"</span>":"")."</td><td style='text-align: center'>".($maxhs==$result['stats_hs']?"<span style='".$cfg['maxstyle']."'>":"").$result['stats_hs'].($maxhs==$result['stats_hs']?"</span>":"")."</td><td style='text-align: center'>".($maxhsperc==$result['stats_hsperc']?"<span style='".$cfg['maxstyle']."'>":"").$result['stats_hsperc'].($maxhsperc==$result['stats_hsperc']?"</span>":"")."</td><td style='text-align: center'>".$result['stats_kdratio']."</td></tr>";
$i++;
}
} else {
echo SQLBADQUERY;
echo mysql_error();
}
}
return $return;
}
function showstats($data) {
global $sql;
$return .= "<table border='1' cellpadding='0' cellspacing='0' width='100%'>n";
$return .= "<tr><td>Pos</td><td><FONT COLOR='black'>Nick</FONT></td><td style='text-align: center'><FONT COLOR='black'>Kills</FONT></td><td style='text-align: center'><FONT COLOR='black'>Deaths</FONT></td><td style='text-align: center'><FONT COLOR='Olive'>Headshot</FONT></td><td style='text-align: center'><FONT COLOR='Olive'>Headshot %</FONT></td><td style='text-align: center'><FONT COLOR='black'>K/D Ratio</FONT></td></tr>n";
$return .= $data."n";
$return .= "</table>n";
$return .= "<div style='text-align: center'>".COPYRIGHT."</div>n";
return $return;
}
// FUNCTIONS END
if ($ftp['use'] == true) {
// FTP connection and get mani_ranks.txt
$connection = ftp_connect($ftp['server'], 21);
if($connection) {
if (ftp_login($connection, $ftp['login'], $ftp['passwd'])) {
if (ftp_get($connection, $cfg['localfile'], $cfg['serverpath'].$cfg['serverfile'], FTP_BINARY)) {
$datafromfile = parsestats($cfg['localfile']);
echo showstats($datafromfile);
} else {
echo FTPFILEERROR;
}
} else {
echo FTPLOGERROR;
}
} else {
echo FTPCONERROR;
}
ftp_close($connection);
} else {
// read file from local server
$datafromfile = parsestats($cfg['localfile']);
echo showstats($datafromfile);
} // end if
?>
Zuletzt geändert von Gemma am 04.06.2005 - 22:53
Zuletzt geändert von Gemma am 04.06.2005 - 23:15
Zuletzt geändert von Gemma am 04.06.2005 - 23:16