Jump to content

Recommended Posts

Someone asked me to make a status page for RuneScape.. I agreed with that, but when I fill in the form I made, nothing happens. It won't even give me the time out. Please help me ::)

The top one works, but the bottom one wont give me any succes. I think i did something wrong with the variables..

 

<html>
<head>
<title>
RuneScape World Stutus
</title>
</head>
<body bgcolor=black text=white>
<?php
class RuneScape_World_Status
{
    var $services = array();
    var $timeout = 4;
    var $types = array('tcp', 'udp');

function add_RS_world($name, $ip, $port, $type = 'tcp', $world_status = false, $errno = '', $errstr = '')
	{
		$this->services[$name] = array(
                                    'ip'         => $ip,
                                    'port'         => $port,
                                    'type'         => $type,
                                    'status'     => $status,
                                    'errno'        => $errno,
                                    'errstr'    => $errstr
                                );
	}
function set_world_status($name, $world_status = false)
	{
		return $this->services[$name]['world_status'] = $world_status;
	}
function get($name)
	{
		if(in_array($this->services[$name]['type'], $this->types))
			{
				$fp = @fsockopen(
                            "{$this->services[$name]['type']}://{$this->services[$name]['ip']}",
                            $this->services[$name]['port'],
                            $this->services[$name]['errno'],
                            $this->services[$name]['errstr'],
                            $this->timeout
                    );
				if($fp)
					{
						$this->set_world_status($name, true);
					}
				else
					{
						$this->set_world_status($name);
					}
				return $this->services[$name]['world_status'];
			}
	}	
    function check()
	{
		foreach($this->services as $service => $value)
		{
			$this->get($service);
		}
	}
    function world_status($name)
	{
		return $this->services[$name]['world_status'];
	}
    function debug($var)
	{
		echo '<pre>';
		print_r($var);
		echo '</pre>';
	}
    function total_services()
	{
		return count($this->services);
	}
function service($name)
	{
		return $this->services[$name];
	}
}
?>
<center>
<br /><br /><br />
<form name='RSform' method='POST'><table><tr><td>
Name of the world: <td><input type='text' name='name' /><tr><td>
Link to the world: <td><input type='text' name='worldlink' value='http://' /><tr><td>
IP of the world: <td><input type='text' name='worldip' /><tr><td>
Port of RuneScape: <td><input type='text' name='port' value='43594' /> (43594 or 43595)<tr><td></table>
<input type='submit' name='submit' value='check status'>
</form>
</center>
<?php
if (isset ($_POST['submit']))
{
$RS_name = ($_POST['name']);
$RS_world_link = ($_POST['worldlink']);
$RS_world_ip = ($_POST['worldip']);
$RS_port = ($_POST['port']);


$world_status = new RuneScape_World_Status();
$world_status->add_RS_world('RuneScape', '64.90.181.244', '80');
$world_status->add_RS_world(''.$RS_name.'', ''.$RS_world_ip.'', ''.$rs_port.'');
$world_status->check();

echo "<br /><br /><br /><br /><center>RuneScape is: ";
echo ($world_status->world_status('RuneScape')) ? '<a href=\'http://www.runescape.com/\'><font color=green><b>Online!</b></font></a>' : '<font color=red><b>Offline!</b></font>';
echo "<br /><br /><br /><br />".$RS_name." is: ";
echo ($world_status->world_status($RS_name)) ? '<a href='.$RS_world_link.'><font color=green><b>Online!</b></font></a>' : '<a href='.$RS_world_link.'><font color=red><b>Offline!</b></font></a>';
}
?> 
</center>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/76691-solved-online-offline-server-status-form/
Share on other sites

try this

 

<html>
<head>
<title>
RuneScape World Stutus
</title>
</head>
<body bgcolor=black text=white>
<?php
class RuneScape_World_Status
{
    public $services = array();
    public $timeout = 30;
    public $types = array('tcp', 'udp');

function add_RS_world($name, $ip, $port, $type = 'tcp', $world_status = false, $errno = '', $errstr = '')
	{
		$this->services[$name] = array(
                                    'ip'         => $ip,
                                    'port'         => $port,
                                    'type'         => $type,
                                    'status'     => $world_status,
                                    'errno'        => $errno,
                                    'errstr'    => $errstr
                                );
	}
function set_world_status($name, $world_status = false)
	{
		return $this->services[$name]['world_status'] = $world_status;
	}
function get($name)
	{
		if(in_array($this->services[$name]['type'], $this->types))
			{
				$fp = fsockopen(
                            "{$this->services[$name]['type']}://{$this->services[$name]['ip']}",
                            $this->services[$name]['port'],
                            $this->services[$name]['errno'],
                            $this->services[$name]['errstr'],
                            $this->timeout
                    );
				if($fp)
					{
						$this->set_world_status($name, true);
					}
				else
					{
						$this->set_world_status($name);
					}
				return $this->services[$name]['world_status'];
			}
	}	
    function check()
	{
		foreach($this->services as $service => $value)
		{
			$this->get($service);
		}
	}
    function world_status($name)
	{
		return $this->services[$name]['world_status'];
	}
    function debug($var)
	{
		echo '<pre>';
		print_r($var);
		echo '</pre>';
	}
    function total_services()
	{
		return count($this->services);
	}
function service($name)
	{
		return $this->services[$name];
	}
}
?>
<center>
<br /><br /><br />
<form name='RSform' method='POST'><table><tr><td>
Name of the world: <td><input type='text' name='name' /><tr><td>
Link to the world: <td><input type='text' name='worldlink' value='http://' /><tr><td>
IP of the world: <td><input type='text' name='worldip' /><tr><td>
Port of RuneScape: <td><input type='text' name='port' value='43594' /> (43594 or 43595)<tr><td></table>
<input type='submit' name='submit' value='check status'>
</form>
</center>
<?php
if(isset($_POST['submit']))
{
$RS_name = ($_POST['name']);
$RS_world_link = ($_POST['worldlink']);
$RS_world_ip = ($_POST['worldip']);
$RS_port = ($_POST['port']);
$world_status = new RuneScape_World_Status();
$world_status->add_RS_world('RuneScape', '64.90.181.244', '80');
$world_status->add_RS_world($RS_name, $RS_world_ip, $rs_port);
$world_status->check();

echo "<br /><br /><br /><br /><center>RuneScape is: ";
echo ($world_status->world_status('RuneScape')) ? '<a href=\'http://www.runescape.com/\'><font color=green><b>Online!</b></font></a>' : '<font color=red><b>Offline!</b></font>';
echo "<br /><br /><br /><br />".$RS_name." is: ";
echo ($world_status->world_status($RS_name)) ? '<a href='.$RS_world_link.'><font color=green><b>Online!</b></font></a>' : '<a href='.$RS_world_link.'><font color=red><b>Offline!</b></font></a>';
}
?> 
</center>
</body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.