Hello!
There is a code. Block in CMS system. Shows server status and players online. I need to add how many acconts and sharacters are at server. Can you help please?
There is a code. Block in CMS system. Shows server status and players online. I need to add how many acconts and sharacters are at server. Can you help please?
Code:
<?php
////Server Status//////
error_reporting(0);
$IP = array(
"Login Server: " => "127.0.0.1:2106",
" Game Server: " => "127.0.0.1:7777",
); while(list($ServerName,$Host)=each($IP)) {
list($IPAddress,$Port)=explode(":",$Host);
$content .=($ServerName);
if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5)) {
$content .=("<font color='green'>On-line </font><br>");
fclose($fp);
}
else {
$content .= ("<font color='red'>Off-line </font><br>");
}
}
////Players online//////
$dbhost="localhost"; ////Mysql Server
$dbname="l2jdb"; //// Base name
$dbuser="root"; //// Base user
$dbpass="password"; //// Base pass
$msc=MYSQL_CONNECT($dbhost,$dbuser,$dbpass) or die ("Ошибка БД");
MYSQL_SELECT_DB($dbname) or die ("BD Error");
$get_config_data="SELECT online FROM characters WHERE online>0";
$config_data=MYSQL_QUERY($get_config_data);
$config['num_online']=mysql_num_rows($config_data);
$content .= " Игроков онлайн ";
$content .= ("<font color='green'>".$config['num_online']."</font>");
MYSQL_CLOSE($msc);
?>