PHP Problem

Status
Not open for further replies.

michael9

New Member
Messages
127
Reaction score
0
Points
0
http://michaelnet.exofire.net/test.php
Can someone help me?
$services is an array with the services in them, but is not showing, an example of how it is used is:

PHP:
$services['http'] = checkService(udp, "michaelnet.exofire.net", 80);

(checkService returns true when the service opens a socket correctly)
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
Probably because you opening UDP sockets on TCP connections :)
 

michael9

New Member
Messages
127
Reaction score
0
Points
0
I don't believe so.

Here's the source of the file if it helps:

PHP:
<?php
if(!defined("udp")) define("udp","udp://");
if(!defined("tcp")) define("tcp","tcp://");
if(!defined("http")) define("http",udp);
if(!defined("NL")) define("NL","<br/>");

function checkService($type = udp, $server = "mysql.x10hosting.com", $port = 3306) {
    echo NL."------------------------------".NL."Connecting to socket on line ".__LINE__." (".$type.$server.":".$port.")".NL."------------------------------".NL;
    $fp = fsockopen($type.$server, $port, $errno, $errstr,5);
    if (!$fp) {
        echo NL."------------------------------".NL."Error opening socket on line ".__LINE__.NL."Error: ".$errstr." (#".$errno.")".NL."------------------------------".NL;
        return false;
    } else {
        echo NL."------------------------------".NL."Successfully opened socket on line ".__LINE__.NL."------------------------------".NL;
        $fp = fclose($fp);
        return true;
    }
}

$services = array();
$services['mysql'] = checkService(udp, "mysql.x10hosting.com", 3306); // MySQL
$services['http'] = checkService(udp, "michaelnet.exofire.net", 80); // HTTP
$services['https'] = checkService(udp, "michaelnet.exofire.net", 443); // HTTPS
$services['ftp'] = checkService(udp, "michaelnet.exofire.net", 21); // FTP
$services['ssh'] = checkService(udp, "michaelnet.exofire.net", 22); // SSH
$services['dns'] = checkService(udp, "michaelnet.exofire.net", 53); // DNS
$services['pop3'] = checkService(udp, "michaelnet.exofire.net", 110); // POP3
$services['smtp'] = checkService(udp, "michaelnet.exofire.net", 25); // SMTP

function echoStatus() {
    echo NL.'----------------------print_r($services);------------------------------'.NL;
    print_r($services);
    echo NL."----------------------------------------------------".NL;
    echo "Services status:".NL;
    if($services['mysql']) {
        echo "MySQL: Online".NL;
    } else {
        echo "MySQL: Offline".NL;
    }
    if($services['http']) {
        echo "HTTP: Online".NL;
    } else {
        echo "HTTP: Offline".NL;
    }
    if($services['https']) {
        echo "HTTPS: Online".NL;
    } else {
        echo "HTTPS: Offline".NL;
    }
    if($services['dns']) {
        echo "DNS: Online".NL;
    } else {
        echo "DNS: Offline".NL;
    }
    if($services['pop3']) {
        echo "POP3: Online".NL;
    } else {
        echo "POP3: Offline".NL;
    }
    if($services['smtp']) {
        echo "SMTP: Online".NL;
    } else {
        echo "SMTP: Offline".NL;
    }
    if($services['ssh']) {
        echo "SSH: Online".NL;
    } else {
        echo "SSH: Offline".NL;
    }
    if($services['ftp']) {
        echo "FTP: Online".NL;
    } else {
        echo "FTP: Offline".NL;
    }
}

echoStatus();        
die(NL."--------------------------------".NL."End of script at line ".__LINE__.NL."--------------------------------".NL);
?>
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
PHP:
$fp = fsockopen($server, $port, $errno, $errstr,5);
 

michael9

New Member
Messages
127
Reaction score
0
Points
0
Doesn't seem to fix anything, and now SMTP is seen as offline. :dunno:
Edit:
I've fixed it by passing the array as a variable into the function rather than reading a global.

Lock this topic please.
 
Last edited:
Status
Not open for further replies.
Top