FireDrake Posted November 9, 2007 Share Posted November 9, 2007 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> Quote Link to comment Share on other sites More sharing options...
MadTechie Posted November 10, 2007 Share Posted November 10, 2007 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> Quote Link to comment Share on other sites More sharing options...
FireDrake Posted November 10, 2007 Author Share Posted November 10, 2007 that one still doesn't work, but I found the problem.. It could not connect to any port, because the variable was wrong.. it was RS_port, not rs_port That was a stupid mistake, but ye thanks anyway =) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.