Parašė Lordcraft· 2008 Rugp. 13 01:08:00
#1
Reikia pagalbos nes isvis nesigaudau ant
php. vnz naudoju sita moda:
http://phpfusion.lt/infusions/mo...mod_id=189
noriu dadeti papildomu laukeliu i infusions/pinigu_sistema/servers.php kokia nors kita info ir kad ta info rodytu server liste. dar reikia kad pvz irasius ip ar web adresa rodytu ar online ar offline. P.S. man reikia deti ne cs servus.
vnz maliau as ten suda su tai failais ir galutinis rezultatas toks:
http://img120.imageshack.us/img1...fffnh8.png
rodo tik ant vieno listo ar jis on ar jis off. stai index.php ir status.php failai:
<html>
<head>
<title>csLazeris.net | serveriu sarasas</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body bgimage="bg.jpg" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" text="#FFFFFF">
<center><img src=images/theme/head.gif></center>
<?php
$starttime = microtime();
$startarray = explode(" ", $starttime);
$starttime = $startarray[1] + $startarray[0];
?>
<?php
include "configas.php";
error_log(0);
function show_server($ip, $port, $big, $blod){
include "locale.php";
$maxlongname = 70;
$maxlongnamesmall = 40;
$players = "$count_players / $maxplayers";
if($big == 1){
if (file_exists("images/".$map.".jpg")){$map_image = "<img src='images/".$map.".jpg' class='img2'>";}else{$map_image = "<img src='images/nera.jpg' class='img2'>";}
echo "<br>\n";
echo "<table class='bgbigo' width='700' align='center'>\n<tr>\n<td>\n";
echo "<table width='100%' align='center' border='0'>\n";
echo "<tr>\n";
echo "<td rowspan='7' width='160'>\n";
echo $map_image."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>\n";
echo $locale[pavadinimas];
echo "</td>\n";
echo "<td>\n";
if (strlen($server_host_name) > $maxlongname){
$server_host_namesmall = substr($server_host_name, 0, $maxlongname - 3) . "...";
}else{
$server_host_namesmall = $server_host_name;
}
echo $server_host_namesmall."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td >";
echo $locale[adresas];
echo "</td>\n";
echo "<td>\n";
echo htmlspecialchars($ip).":".htmlspecialchars($port)."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>\n";
echo $locale[zaidejai];
echo "</td\n>";
echo "<td>\n";
echo htmlspecialchars($players)."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>\n";
echo $locale[zemelapis];
echo "</td>\n";
echo "<td >\n";
echo htmlspecialchars($map)."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>\n";
echo $locale[pingas];
echo "</td>\n";
echo "<td>\n";
echo htmlspecialchars($server_ping)."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>\n";
echo $locale[protokolas];
echo "</td>\n";
echo "<td>\n";
echo htmlspecialchars($netver)."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</td>\n</tr>\n</table>\n<br>\n";
}
if($big == 0){
if (strlen($server_host_name) > $maxlongnamesmall){
$server_host_namesmall = substr($server_host_name, 0, $maxlongnamesmall - 3) . "...";
}else{
$server_host_namesmall = $server_host_name;
}
echo "<tr>\n";
echo "<td class='list_row1'>\n";
echo "<center><img src='images/theme/cstrike.gif'></center>\n";
echo "</td>\n";
echo "<td class='list_row1'>\n";
blodopen($blod);
echo htmlspecialchars($server_host_namesmall)."\n";
blodclose($blod);
echo "</td>";
echo "<td class='list_row1'>\n";
blodopen($blod);
echo htmlspecialchars($ip).":".htmlspecialchars($port)."\n";
blodclose($blod);
echo "</td>\n";
echo "<td class='list_row1'>\n";
blodopen($blod);
echo htmlspecialchars($map)."\n";
blodclose($blod);
echo "</td>\n";
echo "<td class='list_row1'>\n";
blodopen($blod);
echo "<center>";
require_once "status.php";
echo "
</center>\n";
blodclose($blod);
echo "</td>\n";
echo "<td class='list_row1'>\n";
blodopen($blod);
echo "<center>".htmlspecialchars($server_ping)."</center>\n";
blodclose($blod);
echo "</td>\n";
echo "<tr>\n";
}
}
function get_value_byte(&$data){
$temp = $data[0];
$data = substr($data, 1);
return ord($temp);
}
function get_value_string(&$data){
$temp = '';
$i = 0;
while (ord($data[$i]) != 0){
$temp .= $data[$i];
$i++;
}
$data = substr($data, $i+1);
return $temp;
}
function get_value_sint(&$data){
$temp = substr($data, 0, 2);
$data = substr($data, 2);
$array = @unpack('Sshort', $temp);
return $array['short'];
}
function get_value_lint(&$data){
$temp = substr($data, 0, 4);
$data = substr($data, 4);
$array = @unpack('Lint', $temp);
return $array['int'];
}
function get_value_float(&$data){
$temp = substr($data, 0, 4);
$data = substr($data, 4);
$array = @unpack('ffloat', $temp);
return $array['float'];
}
function microtime_float() {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
function blodopen($blod){
if($blod == "1"){
echo "<font color='#CC0000'><b>";
}}
function blodclose($blod){
if($blod == "1"){
echo "</font></b>";
}}
//Gaunam serveriu duomenis is msql ir bandom juos isvesti xD
function dbarray($query) {
$result = @mysql_fetch_assoc($query);
if (!$result) {
echo mysql_error();
return false;
} else {
return $result;
}
}
function dbcount($field,$table,$conditions="") {
$cond = ($conditions ? " WHERE ".$conditions : "");
$result = @mysql_query("SELECT Count".$field." FROM ".DB_PREFIX.$table.$cond);
if (!$result) {
echo mysql_error();
return false;
} else {
$rows = mysql_result($result, 0);
return $rows;
}
}
$db = mysql_connect($hostas, $useris, $passas) or die("<center><b>Laikinos serverio problemos 1</b></center>") or die("<center><b>Laikinos serverio problemos</b></center>");
mysql_select_db($dbas) or die("<center><b>Laikinos serverio problemos 2</b></center>");
$snddata = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"));
$goas = mysql_query("DELETE FROM ".$fusionoprefixas."money_servers WHERE `galiojaiki` < '".$snddata."'");
$serveriai1 = mysql_query("SELECT * FROM ".$fusionoprefixas."money_servers WHERE `tipas` = 1 and `galiojaiki` > ".$snddata." ORDER BY galiojaiki DESC");
if(!$serveriai1)
{
}else{
while($serverio1 = dbarray($serveriai1))
{
show_server($serverio1[serverip], $serverio1[serveroprt], "1", "0");
}
}
echo "<table cellpadding='3' cellspacing='0' class='list_table' width='700' align='center'>\n";
echo "<tr>\n<td class='list_row1'> </td>\n<td class='list_row1'><center>Hostname:</center></td>\n<td class='list_row1'><center>Ip:</center></td>\n<td class='list_row1'><center>Map:</center></td>\n<td class='list_row1'><center>Players:</center></td>\n<td class='list_row1'><center>Ping:</center></td>\n</tr>\n";
$serveriai = mysql_query("SELECT * FROM ".$fusionoprefixas."money_servers WHERE `tipas` = '0' and `galiojaiki` > ".$snddata." ORDER BY galiojaiki DESC") or die("<center><b>Laikinos serverio problemos</b</center>");
while($serverio = dbarray($serveriai))
{
show_server($serverio[serverip], $serverio[serveroprt], "0", "0");
}
mysql_close($db);
echo "</table>";
?>
<?php
$endtime = microtime();
$endarray = explode(" ", $endtime);
$endtime = $endarray[1] + $endarray[0];
$totaltime = $endtime - $starttime;
$totaltime = round($totaltime,0);
?>
</body>
</html>
status.php
<?php
require_once "index.php";
$host = $ip;
$port = $port;
function onlineIndicator($host ,$port){
$online=false;
$fp = @fsockopen($host, $port, $errno, $errstr, 1);
if($fp) {
$online=true;
}
if ($online){
return 'online';
} else {
return 'offline';
}
}
echo onlineIndicator($host,$port);
?>
Redagavo Lordcraft· 2008 Rugp. 13 18:08:44