Sighed Posted November 23, 2012 Posted November 23, 2012 This PHP is for Hint's hAuthD (http://www.hauthd.org) Enjoy. <?php class ServerStatus { private $ip, $port, $interval, $timeout; public function __construct($ip = '127.0.0.1', $port = 2106, $interval = 30, $timeout = 1) { $this->ip = $ip; $this->port = $port; $this->interval = $interval; $this->timeout = $timeout; } public function GetStatusFromAuth() { $status = array(); $f = @fsockopen($this->ip, $this->port, $errno, $errstr, $this->timeout); if ($f) { do { $sec = floor($this->timeout); $msec = ($this->timeout - $sec) * 1000; socket_set_timeout($f, $sec, $msec); $buf = fread($f, 2); if (strlen($buf) != 2) break; $a = unpack('vsize', $buf); $size = $a['size'] - 2; if ($size < 1) break; $buf = fread($f, $size); if (strlen($buf) != $size) break; fwrite($f, "\x03\x00\xFE", 3); $buf = fread($f, 2); if (strlen($buf) != 2) break; $a = unpack('vsize', $buf); $size = $a['size'] - 2; if ($size < 1) break; $buf = fread($f, $size); if (strlen($buf) != $size) break; if (ord($buf[0]) != 0xFE) break; if (strlen($buf) < 3) break; $amount = ord($buf[1]) + ord($buf[2]) * 256; $buf = substr($buf, 3); if (strlen($buf) != $amount * 4) break; $a = unpack('v' . ($amount * 2), $buf); for ($i = 0; $i < $amount; $i++) $status[$a[$i * 2 + 1]] = $a[$i * 2 + 2]; } while (false); fclose ($f); } return $status; } public function GetStatus() { $fn = dirname(__FILE__) . '/status.txt'; $status = array(); fclose(fopen($fn, 'a+b')); $f = @fopen($fn, 'r+b'); if ($f) { flock($f, LOCK_EX); $cache = unserialize(fread($f, 1024)); $status = @$cache['status']; $time = @$cache['time']; if (!IsSet($status) || !IsSet($time)) { $status = array(); $time = 0; } if (time() - $time > $this->interval) { $new = $this->GetStatusFromAuth(); foreach ($status as $id => $value) { $c = &$status[$id]; $c['on'] = false; $c['cur'] = 0; } foreach ($new as $id => $value) { if (!IsSet($status[$id])) $status[$id] = array('on' => false, 'cur' => 0, 'max' => 0); $c = &$status[$id]; $c['on'] = true; $c['cur'] = $new[$id]; if ($c['cur'] > $c['max']) $c['max'] = $c['cur']; } $cache = array('status' => $status, 'time' => time()); $s = serialize($cache); rewind($f); ftruncate($f, 0); fwrite($f, $s, strlen($s)); } fclose($f); } return $status; } public function GetText($id, $online, $offline) { $status = $this->GetStatus(); if (IsSet($status[$id])) $c = &$status[$id]; else $c = array('on' => false, 'cur' => 0, 'max' => 0); $res = str_replace(array('%c', '%m'), array($c['cur'], $c['max']), $c['on'] ? $online : $offline); return $res; } } $status = new ServerStatus('127.0.0.1'); $online = 'Status: <b><font color="#00AA00">ONLINE</font></b> | Players: <b>%c</b> | Record: <b>%m</b>'; $offline = 'Status: <b><font color="#FF0000">OFFLINE</font></b> | Players: <b>%c</b> | Record: <b>%m</b>'; echo $status->GetText(1, $online, $offline); //1 - ServerID ?>
lordvenancio Posted November 25, 2012 Posted November 25, 2012 Is Server Status? For see in web page?
Sighed Posted May 15, 2014 Author Posted May 15, 2014 and it is possible to make this script cheat online? What do you mean by cheat online ? You mean fake the online amount of people ?
Sighed Posted May 22, 2014 Author Posted May 22, 2014 Sighed you have script for online players? That scripts does both things. But it requires to use hAuthD.
n0bo Posted May 26, 2014 Posted May 26, 2014 What do you mean by cheat online ? You mean fake the online amount of people ?yes, can I do that would including online was multiplied 5 times for example yes, can I do that would including online was multiplied 5 times for example?
Paradise Posted May 27, 2014 Posted May 27, 2014 Go inside hAuthD.ini [Online] Multiplier = 1,0 UserCount = 5 Interval = 30
n0bo Posted May 27, 2014 Posted May 27, 2014 Go inside hAuthD.ini [Online] Multiplier = 1,0 UserCount = 5 Interval = 30 thank you
madn3ss Posted July 1, 2014 Posted July 1, 2014 working on localhost but when I copy it to webpage ftp it shows offline 0 player, what do I need to do?
xeL Posted July 1, 2014 Posted July 1, 2014 working on localhost but when I copy it to webpage ftp it shows offline 0 player, what do I need to do? make sure your web host has mssql extenstion and you added the right ip/user/pas.
Silla.Impulse Posted July 1, 2014 Posted July 1, 2014 make sure your web host has mssql extenstion and you added the right ip/user/pas. And this, sometimes will be a problem as we already know :D
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now