RE: [PHP] fsockopen - returning results from port 80, 8080 and 443 requests

2003-07-07 Thread Dave [Hawk-Systems]
any takers on this, before I give up and drop to curl for those types of
requests?

Dave

Creating a quick script where we can poll the services on a particular
server to
verify if they are running or not.  this will be included in a larger scope
application once the details are worked out.

Am having a problem getting results from queries to web server ports though.
Port 80(std), 8080(FP), and 443(SSL) either timeout without returning any
results, or error with some of the other attempts at illiciting a response that
we have tried (like specifying ssl:// prior to the hostname).

Code and two smaple outputs below. Thoughts?

Dave

!-- begin socket.php --
?PHP
# get form submitted host
$host=$_POST['host'];
$portstring=array(Testing SSH:br\n,Testing TELNET:br\n,Testing
FTP:br\n,Testing HTTP:br\n,Testing HTTPS:br\n,Testing
SMTP:br\n,Testing POP3:br\n,Testing IMAP:br\n);
$portput=array(,,,GET / HTTP/1.1\r\nHost: $host\r\n\r\n,GET /
HTTP/1.1\r\nHost: $host\r\n\r\n,,,);
$portprepend=array(,,,tcp://,ssl://,,,);
$port=array(22,23,21,80,443,25,110,143);
for($i=0;$icount($port);$i++){
$result=date(H:i:s).-;
$fp = fsockopen($portprepend[$i].$host, $port[$i], $errno, $errstr,5);
if (!$fp){
$result=$portstring[$i].nbsp;nbsp;nbsp;Error($errno): $errstrbr\n;
}else{
# see if we have to nudge for a response
if(strlen($portput[$i]0)){
fputs ($fp, $portput[$i]);
}
#   get the response
$result.=$portstring[$i].nbsp;nbsp;nbsp;;
$result.= fgets($fp,1024);
fclose ($fp);
$result.=br\n;
$result=trim($result);
}
echo $result;
flush;
}
?
!--  end  socket.php --

!-- begin sample output with tcp:// for 80 and ssl:// for 443 --
12:20:13-Testing SSH:
   SSH-1.99-OpenSSH_3.5p1 FreeBSD-20030201
12:20:13-Testing TELNET:
   Error(61): Connection refused
12:20:13-Testing FTP:
   220 isp1.nexusinternetsolutions.net FTP server (Version 6.00LS) ready.
12:20:13-Testing HTTP:
   Error(0):
12:20:13-Testing HTTPS:
   Error(0):
12:20:13-Testing SMTP:
   220 isp1.nexusinternetsolutions.net ESMTP
12:20:13-Testing POP3:
   Error(61): Connection refused
12:20:13-Testing IMAP:
   Error(61): Connection refused
!--  end  sample output with tcp:// for 80 and ssl:// for 443 --

!-- begin sample output with  for 80 and  for 443 --
12:21:44-Testing SSH:
   SSH-1.99-OpenSSH_3.5p1 FreeBSD-20030201
12:21:44-Testing TELNET:
   Error(61): Connection refused
12:21:44-Testing FTP:
   220 isp1.nexusinternetsolutions.net FTP server (Version 6.00LS) ready.
12:21:44-Testing HTTP:

12:26:46-Testing HTTPS:

12:31:47-Testing SMTP:
   220 isp1.nexusinternetsolutions.net ESMTP
12:31:47-Testing POP3:
   Error(61): Connection refused
12:31:47-Testing IMAP:
   Error(61): Connection refused
!--  end  sample output with  for 80 and  for 443 --



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] fsockopen - returning results from port 80, 8080 and 443 requests

2003-07-06 Thread Dave [Hawk-Systems]
Creating a quick script where we can poll the services on a particular server to
verify if they are running or not.  this will be included in a larger scope
application once the details are worked out.

Am having a problem getting results from queries to web server ports though.
Port 80(std), 8080(FP), and 443(SSL) either timeout without returning any
results, or error with some of the other attempts at illiciting a response that
we have tried (like specifying ssl:// prior to the hostname).

Code and two smaple outputs below. Thoughts?

Dave

!-- begin socket.php --
?PHP
# get form submitted host
$host=$_POST['host'];
$portstring=array(Testing SSH:br\n,Testing TELNET:br\n,Testing
FTP:br\n,Testing HTTP:br\n,Testing HTTPS:br\n,Testing
SMTP:br\n,Testing POP3:br\n,Testing IMAP:br\n);
$portput=array(,,,GET / HTTP/1.1\r\nHost: $host\r\n\r\n,GET /
HTTP/1.1\r\nHost: $host\r\n\r\n,,,);
$portprepend=array(,,,tcp://,ssl://,,,);
$port=array(22,23,21,80,443,25,110,143);
for($i=0;$icount($port);$i++){
$result=date(H:i:s).-;
$fp = fsockopen($portprepend[$i].$host, $port[$i], $errno, $errstr,5);
if (!$fp){
$result=$portstring[$i].nbsp;nbsp;nbsp;Error($errno): $errstrbr\n;
}else{
# see if we have to nudge for a response
if(strlen($portput[$i]0)){
fputs ($fp, $portput[$i]);
}
#   get the response
$result.=$portstring[$i].nbsp;nbsp;nbsp;;
$result.= fgets($fp,1024);
fclose ($fp);
$result.=br\n;
$result=trim($result);
}
echo $result;
flush;
}
?
!--  end  socket.php --

!-- begin sample output with tcp:// for 80 and ssl:// for 443 --
12:20:13-Testing SSH:
   SSH-1.99-OpenSSH_3.5p1 FreeBSD-20030201
12:20:13-Testing TELNET:
   Error(61): Connection refused
12:20:13-Testing FTP:
   220 isp1.nexusinternetsolutions.net FTP server (Version 6.00LS) ready.
12:20:13-Testing HTTP:
   Error(0):
12:20:13-Testing HTTPS:
   Error(0):
12:20:13-Testing SMTP:
   220 isp1.nexusinternetsolutions.net ESMTP
12:20:13-Testing POP3:
   Error(61): Connection refused
12:20:13-Testing IMAP:
   Error(61): Connection refused
!--  end  sample output with tcp:// for 80 and ssl:// for 443 --

!-- begin sample output with  for 80 and  for 443 --
12:21:44-Testing SSH:
   SSH-1.99-OpenSSH_3.5p1 FreeBSD-20030201
12:21:44-Testing TELNET:
   Error(61): Connection refused
12:21:44-Testing FTP:
   220 isp1.nexusinternetsolutions.net FTP server (Version 6.00LS) ready.
12:21:44-Testing HTTP:

12:26:46-Testing HTTPS:

12:31:47-Testing SMTP:
   220 isp1.nexusinternetsolutions.net ESMTP
12:31:47-Testing POP3:
   Error(61): Connection refused
12:31:47-Testing IMAP:
   Error(61): Connection refused
!--  end  sample output with  for 80 and  for 443 --



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php