Код
<?php
require ('include/sesiune.php');
require ('config.php');
require ('functions.php');
require('_drawrating.php');
echo '
<script type="text/javascript" language="javascript" src="include/js/behavior.js"></script>
<script type="text/javascript" language="javascript" src="include/js/rating.js"></script>
<link rel="stylesheet" type="text/css" href="include/css/rating.css" />
';
$conexiune = mysql_connect($_mysql_host, $_mysql_user, $_mysql_password) or die("Nu ma pot conecta la MySQL!");
mysql_select_db($_mysql_db, $conexiune) or die("Nu gasesc baza de date");
if(!isset($_GET['actiune'])) $_GET['actiune'] = '';
switch($_GET['actiune'])
{
case '':
echo '<center><font size="1" face="Verdana" color="#4682B4"><b>Accesul direct la aceasta pagina nu este permis !</b></font></center>';
break;
case 'status':
$dbs = "SELECT * FROM `active_hubs` WHERE id='".$_GET['id']."'";
$rezultat = mysql_query($dbs);
while($rand = mysql_fetch_array($rezultat))
{
//variabile pinger
$address = $rand['address'];
$port = $rand['port'];
$id = $rand['id'];
$u_max = $rand['nr_useri_max'];
$data = date('Y-m-d H:i:s');
$sharesize = 26091318358521; // octeti
$email = 'maloy@krasno.ru';
$description = 'Krasno-City';
$useri = 0;
//variabile calcul timp
$timeoutseconds = 3600;
$timestamp = time();
$timeout = $timestamp-$timeoutseconds;
if ($fp=@fsockopen($address,$port,$ERROR_NO,$ERROR_STR,(float)0.5))
{
fclose($fp);
if ($rand['last'] < $timeout)
{
mysql_query('UPDATE `active_hubs` SET last = "'.$timestamp.'" WHERE id = "'.$id.'"');
function executa($sock, $str) {
socket_send($sock, $str.'|', strlen($str) + 1, NULL);
}
function lock2key($_LOCK) {
$lockLength = strlen ($_LOCK);
$h = ord($_LOCK{0}) ^ ord( $_LOCK{ $lockLength - 1} ) ^ ord( $_LOCK{ $lockLength - 2} ) ^ 5;
while ($h > 255) {$h = $h - 256;}
$h = (($h<<4) & 240) | (($h>>4) & 15);
$a = $h;
if ($a == '126' || // '~'
$a == '124' || // '|'
$a == '96' || // '`'
$a == '36' || // '$'
$a == '5' || // '^E'
$a == '0') // NUL
{
$LockToKey = "/%DCN";
if ($a < 100)
$LockToKey .="0";
if ($a < 10)
$LockToKey .="0";
$LockToKey .= $a;
$LockToKey .= "%/";
} else {
$LockToKey = chr ($a);
}
for ($j = 1; $j < strlen($_LOCK); $j++) {
$h = ord($_LOCK{$j}) ^ ord($_LOCK{$j-1});
while ($h > 255) {$h = $h - 256;}
$h = (($h<<4) & 240) | (($h>>4) & 15);
$a = $h;
if ($a == '126' || // '~'
$a == '124' || // '|'
$a == '96' || // '`'
$a == '36' || // '$'
$a == '5' || // '^E'
$a == '0') // NUL
{
$LockToKey .= "/%DCN";
if ($a < 100)
$LockToKey .="0";
if ($a < 10)
$LockToKey .="0";
$LockToKey .= $a;
$LockToKey .= "%/";
} else {
$LockToKey .= chr ($a);
}
}
return $LockToKey;
}
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!socket_connect($socket, gethostbyname($address), $port)) {
echo 'Eroare : '.socket_strerror(socket_last_error());
return;
}
while ($buffer = socket_read($socket, 2048, PHP_BINARY_READ)) {
// echo "$buffer \n\r <br>";
$linie = explode('|', $buffer);
for ($i = 0; $i < sizeof($linie); ++$i) {
$user = explode(' ', $linie[$i]);
switch($user[0]) {
case '$BadPass':
echo "Parola incorecta<br>\r\n";
break;
case '$GetPass':
executa($socket, '$MyPass '.$pass);
break;
case '$ForceMove':
echo "<center>Server busy (incercati peste cateva min.)...</center><br>\r\n";
die;
break;
case '$Hello':
if ($user[1] == $nick) {
executa($socket, '$Version 1,0091');
executa($socket, '$GetNickList');
executa($socket, '$MyINFO $ALL '.$nick.' '.$description.'<++ V:0.674,M:A,H:1/0/1,S:20>$ $LAN(T3).$'.$email.'$'.$sharesize.'$');
}
break;
case '$Lock':
executa($socket, '$Supports UserCommand NoGetINFO NoHello UserIP2 TTHSearch ');
executa($socket, '$Key '.lock2key($user[1]));
executa($socket, '$ValidateNick '.$nick);
break;
case '$MyINFO':
if ($user[2] == $nick) {
break 3;
}
$useri = $useri + 1;
break;
case '$OpList':
/*
$opi = explode('$$', $user[1]);
echo "Operatori pe hub:\n\r <br>";
while (list($cheie, $valoare) = each($opi)) {
$culoare = rand(111111,999999);
echo "<font color=\"$culoare\">$valoare</font>";
echo "<br>\r\n";
}
echo "<hr>";
*/
break;
}
}
}
socket_close($socket);
mysql_query('UPDATE `active_hubs` SET nr_useri = "'.$useri.'" WHERE id = "'.$id.'"');
if ($useri > $u_max)
{
mysql_query('UPDATE `active_hubs` SET nr_useri_max = "'.$useri.'" WHERE id = "'.$id.'"');
}
}
else
{
$useri = $rand['nr_useri'];
}
?>
<center>
Пользователей онлайн: <?=$useri?><br>
Максимум посетителей онлайн: <?=$rand['nr_useri_max']?><br>
Статус хаба: <span class="online"><b>Online</b></span>
<br>
<?php echo rating_bar(''.$id.'',''); ?>
<br>
</center>
<?
}
else
{
?>
<center>
Пользователей онлайн: <?=$rand['nr_useri']?><br>
Максимум посетителей онлайн: <?=$rand['nr_useri_max']?><br>
Статус хаба: <span class="offline"><i>Offline</i></span>
<br>
<?php echo rating_bar(''.$id.'',''); ?>
<br>
</center>
<?
}
}
break;
}
mysql_close($conexiune)
?>
<br>
<center><input type="button" value="Закрыть" onclick="closeMessage()"></center>