Jump to content

fsockopen and proxy


Eiolon

Recommended Posts

I am using a server status script and it works fine but when I put it on a server that is behind a proxy I can't get it to work.  Can anyone help me configure it so it gets through the proxy?  Thanks!

 

<?php
//Page Variables 
    $online='<td style="background-color:#00FF00; padding:5px;">Online</td>'; 
    $offline='<td style="background-color:#FF0000; padding:5px;">Offline</td>'; 
//Functions 
    function servercheck($server,$port){ 
        //Check that the port value is not empty 
        if(empty($port)){ 
            $port=80; 
        } 
        //Check that the server value is not empty 
        if(empty($server)){ 
            $server='localhost'; 
        } 
        //Connection 
	global $proxy, $proxyport;
        $fp=@fsockopen($server, $port, $errno, $errstr, 1); 
            //Check if connection is present 
            if($fp){ 
                //Return Alive 
                return 1; 
            } else{ 
                //Return Dead 
                return 0; 
            } 
        //Close Connection 
        fclose($fp); 
    } 
//Ports and Services to check 
$services=array( 
    'HTTP' => array('domainhere.com' => 80), 
'SMTP' => array('domainhere.com' =>  25),
); 
?> 
<table> 
<?php 
//Check All Services 
foreach($services as $name => $server){ 
?> 
    <tr> 
    <td><?php echo $name; ?></td> 
<?php 
    foreach($server as $host => $port){ 
        if(servercheck($host,$port)){ echo $online; }else{ echo $offline; } 
    } 
?> 
    </tr> 
<?php 
} 
?> 
</table> 

Link to comment
Share on other sites

It looks like we can't edit our own posts so I am reposting the code:

 

<?php
//Page Variables 
    $online='<td style="background-color:#00FF00; padding:5px;">Online</td>'; 
    $offline='<td style="background-color:#FF0000; padding:5px;">Offline</td>'; 
//Functions 
    function servercheck($server,$port){ 
        //Check that the port value is not empty 
        if(empty($port)){ 
            $port=80; 
        } 
        //Check that the server value is not empty 
        if(empty($server)){ 
            $server='localhost'; 
        } 
        //Connection 
        $fp=@fsockopen($server, $port, $errno, $errstr, 1); 
            //Check if connection is present 
            if($fp){ 
                //Return Alive 
                return 1; 
            } else{ 
                //Return Dead 
                return 0; 
            } 
        //Close Connection 
        fclose($fp); 
    } 
//Ports and Services to check 
$services=array( 
    'HTTP' => array('domainhere.com' => 80), 
    'SMTP' => array('domainhere.com' =>  25),
); 
?> 
<table> 
<?php 
//Check All Services 
foreach($services as $name => $server){ 
?> 
    <tr> 
    <td><?php echo $name; ?></td> 
<?php 
    foreach($server as $host => $port){ 
        if(servercheck($host,$port)){ echo $online; }else{ echo $offline; } 
    } 
?> 
    </tr> 
<?php 
} 
?> 
</table> 

Link to comment
Share on other sites

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.