[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Модератор форума: MaZaФФaka  
Форум » Perfect World » Графика и Web дизайн » [MySQL] Статус сервера
[MySQL] Статус сервера
FrenkДата: Воскресенье, 02.06.2013, 22:11 | Сообщение # 1
NyaFrenk*
Группа: Администраторы
Сообщений: 37
Репутация: 4
Статус:
Красивенький статус сервера)))


Код
// конфиги
$config = array
(
'host' => 'localhost',
'user' => 'root',
'pass' => 'password',
'name' => 'pw',
'ip' => '127.0.0.1',
'port' => '29000',
'maxon' => '1000',
);
// коннект
$link = mysql_connect($config['host'], $config['user'], $config['pass']);
mysql_select_db($config['name'], $link);
// статус
$fp = @fsockopen($config['ip'], $config['port'], $errno, $errstr, 1);
if($fp >= 1)
{$status = '<font color="7FFF00">Online</font>';}
else
{$status = '<font color=red>Offline</font>';}
// кол-во в сети
$online = mysql_query("select count(*) from point where zoneid='1'");
$on = mysql_fetch_row($online);
$on[0] = $on[0];
// кол-во gm в сети
$query = mysql_query("select userid from auth where rid = '0'");
$count = 0;
$off_count = 0;
while($o2 = mysql_fetch_array($query))
{
$online = mysql_query("select * from point where uid='".$o2[0]."'and zoneid='1'");
$o = mysql_fetch_row($online);
$query2 = mysql_query("select name from users where id = '".$o2[0]."'");
while($o3 = mysql_fetch_array($query2))
{
if ($o[3] == 1)
{
$count++;
}
else
{
$off_count++;
}
}
}
// нагрузка на сервер
$a1=$on[0]/$config['maxon'];
$b2=$a1 * 100;
$numeric=$b2;
$numeric=round($numeric);
if($numeric < 25){$numeric= "<font color='#7FFF00'>{$numeric}%</font>";}
if($numeric < 50 and $numeric > 25){$numeric = "<font color='#FFFF00'>{$numeric}%</font>";}
if($numeric < 75 and $numeric > 50){$numeric = "<font color='#FFA500'>{$numeric}%</font>";}
if($numeric < 100 and $numeric > 75){$numeric = "<font color='#FF0000'>{$numeric}%</font>";}
// кол-во акков
$result = mysql_query("select count(1) from users");
$d = mysql_fetch_array($result);
$akkov = "{$d[0]}";
// вывод на страницу
echo <<<html
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<b>Сервер: $status<br/>
Кол-во в сети: $on[0]<br/>
Кол-во GM в сети: $count<br/>
Сервер нагружен на: $numeric<br/>
Аккаунтов на сервере: $akkov<br/>
html;
?>
Установка:

Меняем 127.0.0.1 на Ип сервера.
Меняем password на свой пароль от базы

Помог!? ставим +сики )
 
Форум » Perfect World » Графика и Web дизайн » [MySQL] Статус сервера
  • Страница 1 из 1
  • 1
Поиск: