Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

fsockopen error in server status

Asked Modified Viewed 3,009 times
S
sobe
S
sobe 10
  • Member, joined since
  • Contributed 56 posts on the community forums.
  • Started 12 threads in the forums
  • Started this discussions
asked
Member

The basic rundown is, I'm rather limited in my PHP knowledge, but I know enough to get by. I'm learning, and I thought this code would be ok, but apparently it IS.... UNTIL a server is offline, then PFusion complains about server timeout with fsockopen. Here is the error in the errorlog:

Quote

gsp_panel/gsp_panel.php
fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: unable to connect to 204.2.139.20:80 (Connection timed out) Line: 21




This is the entirety of the panel I've made thus far:

<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright © 2002 - 2011 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: gsp_panel.php
| CVS Version: 1.00
| Author: Chris "sobe" Johnson
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) { die("Access Denied"); }
function serverstatus($server, $port) {
    $up = @fsockopen($server, $port, $errno, $errstr, 1);
   
    if(!$up) {

                return "<font color=\"red\">Offline</font>";
            } else{

                return "<font color=\"green\">Online</font>";
            }

        fclose($up);
}


openside("Server Status");


$nagastatus = serverstatus("173.245.92.162", 4514);
echo "<div><p style='float: left'>Naga </p><p style='float: right'> " . $nagastatus;
echo "</p></div>";
$loginstatus = serverstatus("173.245.92.120", 4500);
echo "<br /><div style='clear: both;'><p style='float: left'>Login </p><p style='float: right'>" . $loginstatus;
echo "</p></div>";
$patchstatus = serverstatus("204.2.139.20", 80);
echo "<br /><div style='clear: both;'><p style='float: left'>Patch </p><p style='float: right'>" . $patchstatus;
echo "</p></div>";


closeside();

// opentable("Center panel");
// closetable();
?>



With the knowledge I have I tried to make it as simple as I could, and it WORKS, I'm just trying to find a reason for that errorlog when fclose is already in place in the script.

Merged on Aug 27 2011 at 22:45:46:
If anyone has any ideas, feel free to post, for the time being I've simply disabled all error reporting in PHPFusion.
Edited by sobe on 28-08-2011 17:12,
0 replies

2 posts

P
PolarFox
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums
answered
Veteran Member

try to use

Quote

try( fsockopen() )
catch( /*something wrong?*/ )

http://php.net/manual/en/language.exc...ptions.php

need more help with this?
0 replies
S
sobe
S
sobe 10
  • Member, joined since
  • Contributed 56 posts on the community forums.
  • Started 12 threads in the forums
  • Started this discussions
answered
Member

Uhohs, new PHP instructions to learn :P But yes this has been an interesting help, it will cease the script after the exception if there is an error. Just need to tinker a bit to get the desired result methinks, thank you PolarFox :)
0 replies

Category Forum

Panels and Infusions

Labels

None yet

Statistics

  • Views 0 views
  • Posts 2 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

S
S
sobe 10
  • Member, joined since
  • Contributed 56 posts on the community forums.
  • Started 12 threads in the forums
  • Started this discussions
P
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet