[PHP] fsockopen with ADH cipher

2010-08-20 Thread Dave Cundiff
Hello,

I've scoured the net and it appears I may be out of luck.

Is it possible to change the cipher fsockopen uses for SSL? I have a
remote socket that uses ADH which I can connect to fine with the
openssl client.

CONNECTED(0003)
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 298 bytes and written 201 bytes
---
New, TLSv1/SSLv3, Cipher is ADH-AES256-SHA
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol  : TLSv1
Cipher: ADH-AES256-SHA
Session-ID: 2163F431CC23523B8F156F6C2E806F3CA23B7F9149E92A2E3F80FEE420F72E4F
Session-ID-ctx:
Master-Key:
ECC5BB2D5B2F76B6D6F332FCEE294C21B0FFAF3C93322F2CD82FF9AFAFC6B6DD3EA371F0F1ADA09FB00B046BC1DB1D59
Key-Arg   : None
Krb5 Principal: None
Start Time: 1282349024
Timeout   : 300 (sec)
Verify return code: 0 (ok)
---


However, my simple PHP script fails.

?
$fd = fsockopen(tls://host.domain.com,5666);
?

[r...@host ~]# php ssltest.php
PHP Warning:  fsockopen(): SSL operation failed with code 1. OpenSSL
Error messages:
error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake
failure in /root/ssltest.php on line 2
PHP Warning:  fsockopen(): Failed to enable crypto in
/root/ssltest.php on line 2
PHP Warning:  fsockopen(): unable to connect to
tls://host.domain.com:5666 (Unknown error) in /root/ssltest.php on
line 2

I had to specify ADH on the cipher list for OpenSSL to be able to make
the connection but cannot find a way to do so for fsockopen. Can a
cipher even be specified?

Thanks,
-- 
Dave Cundiff
System Administrator
A2Hosting, Inc
http://www.a2hosting.com

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



Re: [PHP] fsockopen in phpmailer and tls

2008-09-07 Thread Larry Brown
On Sat, 2008-09-06 at 14:53 -0400, Robert Cummings wrote:
 On Sat, 2008-09-06 at 14:38 -0400, Larry Brown wrote:
  On Sat, 2008-09-06 at 14:06 -0400, Robert Cummings wrote: 
   On Sat, 2008-09-06 at 14:02 -0400, Larry Brown wrote:
   
OK.  So I broke down and re-created my mail server due to its age.  I
am
now running the latest sendmail and it is still failing.  The message
in
the sendmail log is 

...remoteMachineIP] did not issue MAIL/EXPN/VRFY/ETRN during
connection to MTA

A little research is leading me to believe the client (php client
script) opened the socket but didn't send anything.  Now the
certificate
that I'm using for the server is a self signed certificate.  Evolution
asked if I wanted to accept the certificate when I first connected and
I
did.  After which it worked fine.  Is there a setting I must enable to
accept unknown certificates when a site is first connected to?

Any other ideas?
   
   Sounds like an email client issue and most likely may differ for each
   and every one of them.
   
   Cheers,
   Rob.
   -- 
  
  
  I am the email client.  In this case which is what I'm trying to figure
  out.  The script fails with the original string I posted:
  
  PHP Warning:  fsockopen(): SSL operation failed with code 1. OpenSSL
  Error messages:
  error:1408F10B:SSL routines:func(143):reason(267)
  in /opt/scriptsMain/include/class.smtp.php on line 122
  
I'm using the smtpmailer class and it is trying to execute fsockopen.
  So to simplify troubleshooting I used the following code:
  
  if(fsockopen(tls://serverName,25,$errno,$errstr, 30))
  {
  echo Made it!\n;
  }
  else
  {
  echo Nope!\n;
  echo $errno.\n;
  echo $errstr.\n;
  }
  
  I get the above warning from PHP and $errno has 0 as a value and there
  is $errstr is empty.
  
  PHP is v5.2.6 and phpinfo shows that ssl and tls support are both
  compiled in.
 
 Ah, I see, I misunderstood when you mentioned Evolution. Sorry, I can't
 really help you, you're in foreign territory to me :/
 
 Cheers,
 Rob.

For posterity and to thank Robert...

I have determined that the mechanism in PHP does not allow you to
specify tls for a connection that initially starts off as a clear text
connection.  When you set up sendmail to use tls for smtp auth it allows
a connecting client to send connection details specifying tls at which
point it will start talking tls.  PHP expects the connection to be
dedicated tls.  So if you specify in sendmail to use a separate port for
tls and you point PHP to that port it works like a champ.

Thanks to Robert for at least giving it a shot.  Hopefully this will be
helpful to the next poor soul...

Larry



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



Re: [PHP] fsockopen in phpmailer and tls

2008-09-06 Thread Larry Brown
On Fri, 2008-09-05 at 00:58 -0400, Robert Cummings wrote:
 On Thu, 2008-09-04 at 23:20 -0400, Larry Brown wrote:
  I am having a ball of a time trying to figure this one out... If anyone
  has dealt with this before I'd love to get some morsels of wisdom from
  you...
  
  I am trying to connect to a postfix server I have set up remotely using
  smtp auth with tls.  The postfix appears to be configured correctly at
  this point.  I can telnet to port 25 and it will list tls as an option
  as the howto describes it should.  I try to connect from php and get:
  
  PHP Warning:  fsockopen(): SSL operation failed with code 1. OpenSSL
  Error messages:
  error:1408F10B:SSL routines:func(143):reason(267)
  in /opt/scriptsMain/include/class.smtp.php on line 122
  
  I've googled this and someone seems very knowledgeable about it yet
  describes the solution in a way that a mere mortal like myself can't
  follow.  He states in part:
  
  Look at the error message:
  error:1408F10B:SSL routines:func(143):reason(267)
  
  Take the reason code (267) and determine the error:
  grep 267 /usr/include/openssl/ssl.h
  /usr/include/openssl/ssl.h:#define SSL_R_WRONG_VERSION_NUMBER   
  267
  
  Now google for SSL_R_WRONG_VERSION_NUMBER...
  
  ...So in your server method configuration you must put:
SSL_CTX *ctx = SSL_CTX_new (SSLv23_server_method())
  to correctely analyse the first client_hello message
  instead of 
SSL_CTX *ctx = SSL_CTX_new (SSLv3_server_method())
  which i suppose you did
  
  So is he talking about modifying the source code in postfix and 
  rebuilding it?  Have any of you guys dealt with this?...
  
  By the way, when I started out I had a typo in the postfix 
  config for the path to the certificates for ssl and was getting 
  the same error message.  It wasn't until I saw in the postfix 
  mail log that it couldn't read the cert.  So that was fixed but 
  I continue to get the same message which I'm now thinking might 
  be a red herring.
 
 Possibly a complete waste of your time... but maybe you need to
 configure this setting:
 
 smtp_tls_mandatory_protocols
 
 http://www.postfix.org/postconf.5.html
 
 Cheers,
 Rob.
 -- 


OK.  So I broke down and re-created my mail server due to its age.  I am
now running the latest sendmail and it is still failing.  The message in
the sendmail log is 

...remoteMachineIP] did not issue MAIL/EXPN/VRFY/ETRN during
connection to MTA

A little research is leading me to believe the client (php client
script) opened the socket but didn't send anything.  Now the certificate
that I'm using for the server is a self signed certificate.  Evolution
asked if I wanted to accept the certificate when I first connected and I
did.  After which it worked fine.  Is there a setting I must enable to
accept unknown certificates when a site is first connected to?

Any other ideas?


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



Re: [PHP] fsockopen in phpmailer and tls

2008-09-06 Thread Robert Cummings
On Sat, 2008-09-06 at 14:02 -0400, Larry Brown wrote:

 OK.  So I broke down and re-created my mail server due to its age.  I
 am
 now running the latest sendmail and it is still failing.  The message
 in
 the sendmail log is 
 
 ...remoteMachineIP] did not issue MAIL/EXPN/VRFY/ETRN during
 connection to MTA
 
 A little research is leading me to believe the client (php client
 script) opened the socket but didn't send anything.  Now the
 certificate
 that I'm using for the server is a self signed certificate.  Evolution
 asked if I wanted to accept the certificate when I first connected and
 I
 did.  After which it worked fine.  Is there a setting I must enable to
 accept unknown certificates when a site is first connected to?
 
 Any other ideas?

Sounds like an email client issue and most likely may differ for each
and every one of them.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] fsockopen in phpmailer and tls

2008-09-06 Thread Larry Brown
On Sat, 2008-09-06 at 14:06 -0400, Robert Cummings wrote: 
 On Sat, 2008-09-06 at 14:02 -0400, Larry Brown wrote:
 
  OK.  So I broke down and re-created my mail server due to its age.  I
  am
  now running the latest sendmail and it is still failing.  The message
  in
  the sendmail log is 
  
  ...remoteMachineIP] did not issue MAIL/EXPN/VRFY/ETRN during
  connection to MTA
  
  A little research is leading me to believe the client (php client
  script) opened the socket but didn't send anything.  Now the
  certificate
  that I'm using for the server is a self signed certificate.  Evolution
  asked if I wanted to accept the certificate when I first connected and
  I
  did.  After which it worked fine.  Is there a setting I must enable to
  accept unknown certificates when a site is first connected to?
  
  Any other ideas?
 
 Sounds like an email client issue and most likely may differ for each
 and every one of them.
 
 Cheers,
 Rob.
 -- 


I am the email client.  In this case which is what I'm trying to figure
out.  The script fails with the original string I posted:

PHP Warning:  fsockopen(): SSL operation failed with code 1. OpenSSL
Error messages:
error:1408F10B:SSL routines:func(143):reason(267)
in /opt/scriptsMain/include/class.smtp.php on line 122

  I'm using the smtpmailer class and it is trying to execute fsockopen.
So to simplify troubleshooting I used the following code:

if(fsockopen(tls://serverName,25,$errno,$errstr, 30))
{
echo Made it!\n;
}
else
{
echo Nope!\n;
echo $errno.\n;
echo $errstr.\n;
}

I get the above warning from PHP and $errno has 0 as a value and there
is $errstr is empty.

PHP is v5.2.6 and phpinfo shows that ssl and tls support are both
compiled in.


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



Re: [PHP] fsockopen in phpmailer and tls

2008-09-06 Thread Robert Cummings
On Sat, 2008-09-06 at 14:38 -0400, Larry Brown wrote:
 On Sat, 2008-09-06 at 14:06 -0400, Robert Cummings wrote: 
  On Sat, 2008-09-06 at 14:02 -0400, Larry Brown wrote:
  
   OK.  So I broke down and re-created my mail server due to its age.  I
   am
   now running the latest sendmail and it is still failing.  The message
   in
   the sendmail log is 
   
   ...remoteMachineIP] did not issue MAIL/EXPN/VRFY/ETRN during
   connection to MTA
   
   A little research is leading me to believe the client (php client
   script) opened the socket but didn't send anything.  Now the
   certificate
   that I'm using for the server is a self signed certificate.  Evolution
   asked if I wanted to accept the certificate when I first connected and
   I
   did.  After which it worked fine.  Is there a setting I must enable to
   accept unknown certificates when a site is first connected to?
   
   Any other ideas?
  
  Sounds like an email client issue and most likely may differ for each
  and every one of them.
  
  Cheers,
  Rob.
  -- 
 
 
 I am the email client.  In this case which is what I'm trying to figure
 out.  The script fails with the original string I posted:
 
 PHP Warning:  fsockopen(): SSL operation failed with code 1. OpenSSL
 Error messages:
 error:1408F10B:SSL routines:func(143):reason(267)
 in /opt/scriptsMain/include/class.smtp.php on line 122
 
   I'm using the smtpmailer class and it is trying to execute fsockopen.
 So to simplify troubleshooting I used the following code:
 
 if(fsockopen(tls://serverName,25,$errno,$errstr, 30))
 {
   echo Made it!\n;
 }
 else
 {
   echo Nope!\n;
   echo $errno.\n;
   echo $errstr.\n;
 }
 
 I get the above warning from PHP and $errno has 0 as a value and there
 is $errstr is empty.
 
 PHP is v5.2.6 and phpinfo shows that ssl and tls support are both
 compiled in.

Ah, I see, I misunderstood when you mentioned Evolution. Sorry, I can't
really help you, you're in foreign territory to me :/

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



[PHP] fsockopen in phpmailer and tls

2008-09-04 Thread Larry Brown
I am having a ball of a time trying to figure this one out... If anyone
has dealt with this before I'd love to get some morsels of wisdom from
you...

I am trying to connect to a postfix server I have set up remotely using
smtp auth with tls.  The postfix appears to be configured correctly at
this point.  I can telnet to port 25 and it will list tls as an option
as the howto describes it should.  I try to connect from php and get:

PHP Warning:  fsockopen(): SSL operation failed with code 1. OpenSSL
Error messages:
error:1408F10B:SSL routines:func(143):reason(267)
in /opt/scriptsMain/include/class.smtp.php on line 122

I've googled this and someone seems very knowledgeable about it yet
describes the solution in a way that a mere mortal like myself can't
follow.  He states in part:

Look at the error message:
error:1408F10B:SSL routines:func(143):reason(267)

Take the reason code (267) and determine the error:
grep 267 /usr/include/openssl/ssl.h
/usr/include/openssl/ssl.h:#define SSL_R_WRONG_VERSION_NUMBER   
267

Now google for SSL_R_WRONG_VERSION_NUMBER...

...So in your server method configuration you must put:
  SSL_CTX *ctx = SSL_CTX_new (SSLv23_server_method())
to correctely analyse the first client_hello message
instead of 
  SSL_CTX *ctx = SSL_CTX_new (SSLv3_server_method())
which i suppose you did

So is he talking about modifying the source code in postfix and 
rebuilding it?  Have any of you guys dealt with this?...

By the way, when I started out I had a typo in the postfix 
config for the path to the certificates for ssl and was getting 
the same error message.  It wasn't until I saw in the postfix 
mail log that it couldn't read the cert.  So that was fixed but 
I continue to get the same message which I'm now thinking might 
be a red herring.


-- 
Larry Brown [EMAIL PROTECTED]


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



Re: [PHP] fsockopen in phpmailer and tls

2008-09-04 Thread Robert Cummings
On Thu, 2008-09-04 at 23:20 -0400, Larry Brown wrote:
 I am having a ball of a time trying to figure this one out... If anyone
 has dealt with this before I'd love to get some morsels of wisdom from
 you...
 
 I am trying to connect to a postfix server I have set up remotely using
 smtp auth with tls.  The postfix appears to be configured correctly at
 this point.  I can telnet to port 25 and it will list tls as an option
 as the howto describes it should.  I try to connect from php and get:
 
 PHP Warning:  fsockopen(): SSL operation failed with code 1. OpenSSL
 Error messages:
 error:1408F10B:SSL routines:func(143):reason(267)
 in /opt/scriptsMain/include/class.smtp.php on line 122
 
 I've googled this and someone seems very knowledgeable about it yet
 describes the solution in a way that a mere mortal like myself can't
 follow.  He states in part:
 
 Look at the error message:
 error:1408F10B:SSL routines:func(143):reason(267)
 
 Take the reason code (267) and determine the error:
 grep 267 /usr/include/openssl/ssl.h
 /usr/include/openssl/ssl.h:#define SSL_R_WRONG_VERSION_NUMBER   
 267
 
 Now google for SSL_R_WRONG_VERSION_NUMBER...
 
 ...So in your server method configuration you must put:
   SSL_CTX *ctx = SSL_CTX_new (SSLv23_server_method())
 to correctely analyse the first client_hello message
 instead of 
   SSL_CTX *ctx = SSL_CTX_new (SSLv3_server_method())
 which i suppose you did
 
 So is he talking about modifying the source code in postfix and 
 rebuilding it?  Have any of you guys dealt with this?...
 
 By the way, when I started out I had a typo in the postfix 
 config for the path to the certificates for ssl and was getting 
 the same error message.  It wasn't until I saw in the postfix 
 mail log that it couldn't read the cert.  So that was fixed but 
 I continue to get the same message which I'm now thinking might 
 be a red herring.

Possibly a complete waste of your time... but maybe you need to
configure this setting:

smtp_tls_mandatory_protocols

http://www.postfix.org/postconf.5.html

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



[PHP] fsockopen Fread and fget issue

2008-06-05 Thread Ross King II
When I do the following it grabs the response (And using a packet sniffer I
can see the server responds quick). If I only call fread  one time it will
read and return the page to the server. If I read a second batch after the
eof it hangs for 30 seconds.

 

 

All I want to do is send a raw POST and get the response that can be up to
500K or as little as 450 bytes of XML.

 


PHP Version 5.2.1

 


System 

Linux lamp 2.6.20-16-server #2 SMP Tue Feb 12 05:48:21 UTC 2008 i686 


Build Date 

Nov 28 2007 23:00:22 


Server API 

Apache 2.0 Handler 

 

 

$fp = fsockopen($host, $port, $errno, $errstr, 30);

if (!$fp) {

echo $errstr ($errno)br /\n;

} else {

 

fwrite($fp, SOAP_Call(Email_AddWithFields ,$Parms));

 

while (!feof($fp)) {

$x .= fread($fp, 16000);

}

fclose($fp);

}





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



Re: [PHP] fsockopen + fputs

2008-05-18 Thread Stut

On 16 May 2008, at 00:04, debussy007 wrote:
I use fsockopen and fputs to call a distant URL, but I have the  
following

error :
The requested URL /registration/test was not found on this server.

This is my code:

$req =
'username=' . $usr . 'password=' . $pass .
'date_of_birth=' . $year . - . $month . - . $day .
'email=' . $email . 'country=' . $country;


You should be using urlencode on these variables, otherwise you could  
end up truncating the data.



$fp = fsockopen(www.example.com, 80, $errno, $errstr, 30);
if (!$fp) {
  echo $errstr ($errno)br\n;
} else {
$header = POST /registration/test HTTP/1.0\r\n;
$header .= Content-Type: application/x-www-form-urlencoded\r\n;
$header .= Content-Length:  . strlen($req) . \r\n\r\n;
fputs ($fp, $header . $req);

  while (!feof($fp)) {
echo fgets($fp, 1024);
  }
  fclose($fp);
}

However the path www.example.com/registration/test exists


By which I assume you mean it works in a browser. If not, make sure  
it works in a browser first.



so why does it says it cannot find the requested url ?


You probably need a Host header to direct the request to the right  
website. If you're going to be making manual HTTP requests I suggest  
you use Firebug or similar to examine the requests your browser is  
making. Even better read the HTTP spec, but I tend to be realistic in  
my expectations. Alternatively I'd recommend looking at using the Curl  
extension.


-Stut

--
http://stut.net/

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



Re: [PHP] fsockopen + fputs

2008-05-16 Thread Per Jessen
debussy007 wrote:

 However the path www.example.com/registration/test exists
 so why does it says it cannot find the requested url ?
 
 Any idea ? Thank you for any help !!

Take a look at the accesslog on www.example.com - that'll tell you
what's happening.


/Per Jessen, Zürich


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



Re: [PHP] fsockopen + fputs

2008-05-16 Thread Nathan Rixham

debussy007 wrote:

Hello,

I use fsockopen and fputs to call a distant URL, but I have the following
error : 
The requested URL /registration/test was not found on this server.


This is my code:

$req = 
	'username=' . $usr . 'password=' . $pass . 
	'date_of_birth=' . $year . - . $month . - . $day . 
	'email=' . $email . 'country=' . $country;


$fp = fsockopen(www.example.com, 80, $errno, $errstr, 30);
if (!$fp) {
echo $errstr ($errno)br\n;
} else {
$header = POST /registration/test HTTP/1.0\r\n;
$header .= Content-Type: application/x-www-form-urlencoded\r\n;
$header .= Content-Length:  . strlen($req) . \r\n\r\n;
fputs ($fp, $header . $req);

while (!feof($fp)) {
echo fgets($fp, 1024);
}
fclose($fp);
}

However the path www.example.com/registration/test exists
so why does it says it cannot find the requested url ?

Any idea ? Thank you for any help !!


try changing to
POST /registration/test/ HTTP/1.0\r\n

note the trailing slash on test
also if that fails try http/1.1

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



[PHP] fsockopen + fputs

2008-05-15 Thread debussy007

Hello,

I use fsockopen and fputs to call a distant URL, but I have the following
error : 
The requested URL /registration/test was not found on this server.

This is my code:

$req = 
'username=' . $usr . 'password=' . $pass . 
'date_of_birth=' . $year . - . $month . - . $day . 
'email=' . $email . 'country=' . $country;

$fp = fsockopen(www.example.com, 80, $errno, $errstr, 30);
if (!$fp) {
echo $errstr ($errno)br\n;
} else {
$header = POST /registration/test HTTP/1.0\r\n;
$header .= Content-Type: application/x-www-form-urlencoded\r\n;
$header .= Content-Length:  . strlen($req) . \r\n\r\n;
fputs ($fp, $header . $req);

while (!feof($fp)) {
echo fgets($fp, 1024);
}
fclose($fp);
}

However the path www.example.com/registration/test exists
so why does it says it cannot find the requested url ?

Any idea ? Thank you for any help !!
-- 
View this message in context: 
http://www.nabble.com/fsockopen-%2B-fputs-tp17264395p17264395.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



[PHP] fsockopen on ssl://

2008-05-13 Thread bob pilly

Hi all

I have tried researching this issue but havent come up with any solution so im 
hoping someone has seen it before and can help. I have the following test 
script that uses fsockopen to connect to a https site, get the contents and 
outputs it.

?php
$host = www.microsoft.com;
$path = /;
$fh = fsockopen(ssl://.$host, 443, $errno, $errstr, 5);//opens url for 
reading with a timeout of 2 seconds

if (!$fh){
echo FAIL: $errno $errstr ;
}
else{
$out = GET $path HTTP/1.1\r\n;
$out .= Host: $host\r\n;
$out .= Connection: Close\r\n;
$out .= \r\n;
fwrite($fh, $out);
stream_set_timeout($fh,2);
$info = stream_get_meta_data($fh);
if($info['timed_out']){
echo TIMEOUT\n;
}
else{
$haystack = ;
while (!feof($fh)) {
$haystack.= fgets($fh, 4096);
}
}
print $haystack;
fclose($fh);
}
?

if i run this script using php -f test.php it works fine. However if i try and 
run this on my loca apache server i get the following error:

Warning:  fsockopen() [function.fsockopen]:unable to connect to 
ssl://www.microsoft.com:443 (A connection attemptfailed because the connected 
party did not properly respond after aperiod of time, or established connection 
failed because connected hosthas failed to respond.) in C:\Program Files\Apache 
Software Foundation\Apache2.2\htdocs\test.php on line 4
FAIL: 10060 A connection attempt failed because the connected party didnot 
properly respond after a period of time, or established connectionfailed 
because connected host has failed to respond.

As you can see from that error i am using windows and apache 2.2. My php 
version is 5.25. I have Registered Stream Socket Transports tcp, udp, ssl, 
sslv3, sslv2, tlsin my config.

Thanks for any help in advance and it is greatly appreciated, this problem is 
driving me nuts!!

Cheers

Bob








  __
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html

[PHP] fsockopen on ssl://

2008-05-13 Thread bob pilly
Hi all

I have tried researching this issue but havent come up with any solution so im 
hoping someone has seen it before and can help. I have the following test 
script that uses fsockopen to connect to a https site, get the contents and 
outputs it.

?php
$host = www.microsoft.com;
$path = /;
$fh = fsockopen(ssl://.$host, 443, $errno, $errstr, 5);//opens url for 
reading with a timeout of 2 seconds

if (!$fh){
echo FAIL: $errno $errstr ;
}
else{
$out = GET $path HTTP/1.1\r\n;
$out .= Host: $host\r\n;
$out .= Connection: Close\r\n;
$out .= \r\n;
fwrite($fh, $out);
stream_set_timeout($fh,2);
$info = stream_get_meta_data($fh);
if($info['timed_out']){
echo TIMEOUT\n;
}
else{
$haystack = ;
while (!feof($fh)) {
$haystack.= fgets($fh, 4096);
}
}
print $haystack;
fclose($fh);
}
?

if i run this script using php -f test.php it works fine. However if i try and 
run this on my loca apache server i get the following error:

Warning:  fsockopen() [function.fsockopen]:unable to connect to 
ssl://www.microsoft.com:443 (A connection attemptfailed because the connected 
party did not properly respond after aperiod of time, or established connection 
failed because connected hosthas failed to respond.) in C:\Program Files\Apache 
Software Foundation\Apache2.2\htdocs\test.php on line 4
FAIL: 10060 A connection attempt failed because the connected party didnot 
properly respond after a period of time, or established connectionfailed 
because connected host has failed to respond.

As you can see from that error i am using windows and apache 2.2. My php 
version is 5.25. I have Registered Stream Socket Transports tcp, udp, ssl, 
sslv3, sslv2, tlsin my config.

Thanks for any help in advance and it is greatly appreciated, this problem is 
driving me nuts!!

Cheers

Bob




  __
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html

[PHP] PHP fsockopen with the UNIX abstract namespace

2008-02-13 Thread @4u
Hi,

I have a problem with fsockopen in connection with the UNIX abstract
namespace.

To open a UNIX socket in the abstract namespace I have to add a nul byte
in front of the path.

Unfortunately PHP returns
fsockopen() [function.fsockopen]: unable to connect to unix://:0
(Connection refused)

for unix://\x00/tmp/dbus-whatever which is a bit strange because I
expected at least the error message fsockopen() [function.fsockopen]:
unable to connect to unix://[NUL byte]/tmp/dbus-whatever:0 (Connection
refused)

Is this a known issue or do I have to set something in the php.ini?

I would appreciate any ideas how to debug this issue.

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



Re: [PHP] PHP fsockopen with the UNIX abstract namespace

2008-02-13 Thread Jochem Maas

@4u schreef:

Hi,

I have a problem with fsockopen in connection with the UNIX abstract
namespace.

To open a UNIX socket in the abstract namespace I have to add a nul byte
in front of the path.

Unfortunately PHP returns
fsockopen() [function.fsockopen]: unable to connect to unix://:0
(Connection refused)

for unix://\x00/tmp/dbus-whatever which is a bit strange because I
expected at least the error message fsockopen() [function.fsockopen]:
unable to connect to unix://[NUL byte]/tmp/dbus-whatever:0 (Connection
refused)


your problem might be version related, but php does have a C level function
php_stream_sock_open_unix() explicitly for the issue of the NUL byte
(the NUL byte is seen as the end of a string, unless the string handling
is binary safe - if I got the lingo correct).

my first guess would be to use socket_create() in combination with
socket_connect() instead of fsockopen() and see if that does the trick.




Is this a known issue or do I have to set something in the php.ini?

I would appreciate any ideas how to debug this issue.



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



Re: [PHP] PHP fsockopen with the UNIX abstract namespace

2008-02-13 Thread @4u
Hi,

thanks for your help - unfortunately it doesn't help.

With stream_socket_client () I get the message unable to connect to
unix://\0/tmp/hald-local/dbus-ZniNmvr5O0 (Connection refused) in
/root/dbus_session.php on line 272 which is at least better, because it
shows the full path.

I verified it with

PHP 5.1.2 (cli) (built: Jul 17 2007 17:32:48)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

(It's a Debian based machine)

and

PHP 5.2.5-pl1-gentoo (cli) (built: Dec 29 2007 11:46:44)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with eAccelerator v0.9.5.1, Copyright (c) 2004-2006 eAccelerator, by
eAccelerator

(Gentoo)

socket_create and socket_connect produces the following error:

Warning: socket_connect() [function.socket-connect]: unable to connect
[22]: Invalid argument in ...

again verified on both systems and definitely with the right arguments -
 the socket resource and a [NUL]/tmp/path string as written in the PHP
manual.

Are their other solutions or known problems? If not, I will maybe post
it as a bug - but wanted to make sure that it's not my fault.

Jochem Maas schrieb:
 @4u schreef:
 Hi,

 I have a problem with fsockopen in connection with the UNIX abstract
 namespace.

 To open a UNIX socket in the abstract namespace I have to add a nul byte
 in front of the path.

 Unfortunately PHP returns
 fsockopen() [function.fsockopen]: unable to connect to unix://:0
 (Connection refused)

 for unix://\x00/tmp/dbus-whatever which is a bit strange because I
 expected at least the error message fsockopen() [function.fsockopen]:
 unable to connect to unix://[NUL byte]/tmp/dbus-whatever:0 (Connection
 refused)
 
 your problem might be version related, but php does have a C level function
 php_stream_sock_open_unix() explicitly for the issue of the NUL byte
 (the NUL byte is seen as the end of a string, unless the string handling
 is binary safe - if I got the lingo correct).
 
 my first guess would be to use socket_create() in combination with
 socket_connect() instead of fsockopen() and see if that does the trick.
 
 

 Is this a known issue or do I have to set something in the php.ini?

 I would appreciate any ideas how to debug this issue.


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



Re: [PHP] PHP fsockopen with the UNIX abstract namespace

2008-02-13 Thread Jochem Maas

@4u schreef:

Hi,

thanks for your help - unfortunately it doesn't help.

With stream_socket_client () I get the message unable to connect to
unix://\0/tmp/hald-local/dbus-ZniNmvr5O0 (Connection refused) in
/root/dbus_session.php on line 272 which is at least better, because it
shows the full path.


is the connection refused a permissions thing here? can you
verify that it's possible to connect?

you might consider attaching php to gdb and seeing where things
go wrong, if the socket itself is fine and usable and your sure
then a bug report is in order, no?

maybe someone smarter cares to comment.



I verified it with

PHP 5.1.2 (cli) (built: Jul 17 2007 17:32:48)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

(It's a Debian based machine)

and

PHP 5.2.5-pl1-gentoo (cli) (built: Dec 29 2007 11:46:44)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with eAccelerator v0.9.5.1, Copyright (c) 2004-2006 eAccelerator, by
eAccelerator

(Gentoo)

socket_create and socket_connect produces the following error:

Warning: socket_connect() [function.socket-connect]: unable to connect
[22]: Invalid argument in ...

again verified on both systems and definitely with the right arguments -
 the socket resource and a [NUL]/tmp/path string as written in the PHP
manual.

Are their other solutions or known problems? If not, I will maybe post
it as a bug - but wanted to make sure that it's not my fault.

Jochem Maas schrieb:

@4u schreef:

Hi,

I have a problem with fsockopen in connection with the UNIX abstract
namespace.

To open a UNIX socket in the abstract namespace I have to add a nul byte
in front of the path.

Unfortunately PHP returns
fsockopen() [function.fsockopen]: unable to connect to unix://:0
(Connection refused)

for unix://\x00/tmp/dbus-whatever which is a bit strange because I
expected at least the error message fsockopen() [function.fsockopen]:
unable to connect to unix://[NUL byte]/tmp/dbus-whatever:0 (Connection
refused)

your problem might be version related, but php does have a C level function
php_stream_sock_open_unix() explicitly for the issue of the NUL byte
(the NUL byte is seen as the end of a string, unless the string handling
is binary safe - if I got the lingo correct).

my first guess would be to use socket_create() in combination with
socket_connect() instead of fsockopen() and see if that does the trick.



Is this a known issue or do I have to set something in the php.ini?

I would appreciate any ideas how to debug this issue.





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



Re: [PHP] PHP fsockopen with the UNIX abstract namespace

2008-02-13 Thread @4u
Hi again,

Jochem Maas schrieb:
 @4u schreef:
[snip]
 is the connection refused a permissions thing here? can you
 verify that it's possible to connect?

I'm not sure but I don't think so. 1.) we speak about D-BUS and 2.) its
owner and root should always be able to connect to it. Especially the
socket_create test seems interesting - removing the NUL byte results in
this snipplet to work - adding it again results in an invalid argument.

 you might consider attaching php to gdb and seeing where things
 go wrong, if the socket itself is fine and usable and your sure
 then a bug report is in order, no?

Looks like I'll do that (trying gdb) and post a bug report.

 maybe someone smarter cares to comment.

Once more thanks for your help :) I wasn't sure if it was me or PHP -
but with the socket_* function tests it looks like it's something wrong
with PHP and the NUL byte.

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



Re: [PHP] fsockopen problems

2007-06-22 Thread Tijnema

On 6/22/07, Ray [EMAIL PROTECTED] wrote:

hello,
I'm having some problems with fsockopen and was hopping for some help.
I try to connect to a host via fsockopen and I get getaddrinfo failed
errors, but if I try fsockopen with google, everything works.

sample test code
  $fp=fsockopen('apps.subname.domain.com/xml_2.4/xml.php',80,$errno,
$errstr);
   var_dump($errno);
   var_dump($errstr);
   $fp=fsockopen(000.00.00.000/xml_2.4/xml.php,80,$errno, $errstr);
   var_dump($errno);
   var_dump($errstr);
   $fp=fsockopen('www.google.ca',80,$errno, $errstr);
   var_dump($errno);
   var_dump($errstr);

(sorry for sanitizing, not my choice.)
I can ping the host from the server, and going to this site in a browser gives
the expected output.

Warning: fsockopen() [function.fsockopen]: php_network_getaddresses:
getaddrinfo failed: hostname nor servname provided, or not known
in /usr/local/www/apache22/data/index.php on line 119

Warning: fsockopen() [function.fsockopen]: unable to connect to
apps.subname.domain.com/xml_2.4/xml.php:80 (Unknown error)
in /usr/local/www/apache22/data/index.php on line 119
int(0) string(0) 

[note no error for google. should be here]

Warning: fsockopen() [function.fsockopen]: php_network_getaddresses:
getaddrinfo failed: hostname nor servname provided, or not known
in /usr/local/www/apache22/data/index.php on line 122

Warning: fsockopen() [function.fsockopen]: unable to connect to
000.00.00.000/xml_2.4/xml.php:80 (Unknown error)
in /usr/local/www/apache22/data/index.php on line 122
int(0) string(0)  int(0) string(0) 



With fsockopen you connect to a host, not to the host with full path...
This would work fine:
$fp=fsockopen('apps.subname.domain.com',80,$errno,
$errstr);
  var_dump($errno);
  var_dump($errstr);
Now you probably want to get that file, so you should do a fwrite:
fwrite($fp,GET /xml_2.4/xml.php HTTP/1.1\r\nHost:
apps.subname.domain.com\r\n\r\n);
*note: All above should be on one single line
Then, after you made a request, you can get the data with fread:
$data = fread($fp,102400); // 100KB of data max
This returns the page, including the headers!
If you only want data, you're better off using file_get_contents
function, like this:
$data = file_get_contents('apps.subname.domain.com/xml_2.4/xml.php);

Hope this helps ;)

Tijnema


--
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] fsockopen problems

2007-06-22 Thread Ray
On Friday 22 June 2007 10:59 am, Tijnema wrote:
 On 6/22/07, Ray [EMAIL PROTECTED] wrote:
  hello,
  I'm having some problems with fsockopen and was hopping for some help.
  I try to connect to a host via fsockopen and I get getaddrinfo failed
  errors, but if I try fsockopen with google, everything works.
 
  sample test code
$fp=fsockopen('apps.subname.domain.com/xml_2.4/xml.php',80,$errno,
  $errstr);
 var_dump($errno);
 var_dump($errstr);
 $fp=fsockopen(000.00.00.000/xml_2.4/xml.php,80,$errno, $errstr);
 var_dump($errno);
 var_dump($errstr);
 $fp=fsockopen('www.google.ca',80,$errno, $errstr);
 var_dump($errno);
 var_dump($errstr);
 
  (sorry for sanitizing, not my choice.)
  I can ping the host from the server, and going to this site in a browser
  gives the expected output.
 
  Warning: fsockopen() [function.fsockopen]: php_network_getaddresses:
  getaddrinfo failed: hostname nor servname provided, or not known
  in /usr/local/www/apache22/data/index.php on line 119
 
  Warning: fsockopen() [function.fsockopen]: unable to connect to
  apps.subname.domain.com/xml_2.4/xml.php:80 (Unknown error)
  in /usr/local/www/apache22/data/index.php on line 119
  int(0) string(0) 
 
  [note no error for google. should be here]
 
  Warning: fsockopen() [function.fsockopen]: php_network_getaddresses:
  getaddrinfo failed: hostname nor servname provided, or not known
  in /usr/local/www/apache22/data/index.php on line 122
 
  Warning: fsockopen() [function.fsockopen]: unable to connect to
  000.00.00.000/xml_2.4/xml.php:80 (Unknown error)
  in /usr/local/www/apache22/data/index.php on line 122
  int(0) string(0)  int(0) string(0) 

 With fsockopen you connect to a host, not to the host with full path...
 This would work fine:
 $fp=fsockopen('apps.subname.domain.com',80,$errno,
 $errstr);
var_dump($errno);
var_dump($errstr);
 Now you probably want to get that file, so you should do a fwrite:
 fwrite($fp,GET /xml_2.4/xml.php HTTP/1.1\r\nHost:
 apps.subname.domain.com\r\n\r\n);
 *note: All above should be on one single line
 Then, after you made a request, you can get the data with fread:
 $data = fread($fp,102400); // 100KB of data max
 This returns the page, including the headers!
 If you only want data, you're better off using file_get_contents
 function, like this:
 $data = file_get_contents('apps.subname.domain.com/xml_2.4/xml.php);

 Hope this helps ;)

 Tijnema

Thanks, that does help. Thats exactly what I was looking for.
Ray

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



[PHP] fsockopen problems

2007-06-22 Thread Ray
hello,
I'm having some problems with fsockopen and was hopping for some help.
I try to connect to a host via fsockopen and I get getaddrinfo failed 
errors, but if I try fsockopen with google, everything works.

sample test code
   $fp=fsockopen('apps.subname.domain.com/xml_2.4/xml.php',80,$errno, 
$errstr);
var_dump($errno);
var_dump($errstr);
$fp=fsockopen(000.00.00.000/xml_2.4/xml.php,80,$errno, $errstr);
var_dump($errno);
var_dump($errstr);
$fp=fsockopen('www.google.ca',80,$errno, $errstr);
var_dump($errno);
var_dump($errstr);
 
(sorry for sanitizing, not my choice.)
I can ping the host from the server, and going to this site in a browser gives 
the expected output.
 
Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: 
getaddrinfo failed: hostname nor servname provided, or not known 
in /usr/local/www/apache22/data/index.php on line 119

Warning: fsockopen() [function.fsockopen]: unable to connect to 
apps.subname.domain.com/xml_2.4/xml.php:80 (Unknown error) 
in /usr/local/www/apache22/data/index.php on line 119
int(0) string(0) 

[note no error for google. should be here]

Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: 
getaddrinfo failed: hostname nor servname provided, or not known 
in /usr/local/www/apache22/data/index.php on line 122

Warning: fsockopen() [function.fsockopen]: unable to connect to 
000.00.00.000/xml_2.4/xml.php:80 (Unknown error) 
in /usr/local/www/apache22/data/index.php on line 122
int(0) string(0)  int(0) string(0) 

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



[PHP] fsockopen with proxy?

2007-06-07 Thread Tijnema

Hi,


What I want is to send a complete HTTP request, including special
headers, to another server over a HTTP proxy. Is this possible with
PHP?
I've seen the manual, and it doesn't say anything about proxy. I've
checked the comments on the fsockopen page, and there's a comment
about it for using ICQ status request through proxy, but it seems not
what i need.

Tijnema

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



[PHP] fsockopen - how can I specify the local/source port

2007-04-18 Thread Matt
Hello,

I am experimenting with the fsockopen function to send custom UDP packets. 
What I would like to do is to be able to nominate the LOCAL port that my UDP 
packet originates from. What happens currently is that when I execute my 
code below I get a random port 1023 allocated. What I want to be able to do 
is to fix the port to one that I specify.

The code below works and I can see my packet being sent out to destination 
port 7077.  The 192.168.2.10 server is also watching for the source port of 
incoming traffic and will only respond if the source port is also 7077.

?php
$fp = fsockopen(udp://192.168.2.10, 7077, $errno, $errstr);
if (!$fp) {
echo ERROR: $errno - $errstrbr /\n;
} else {
fwrite($fp, Test\n);
echo fread($fp, 26);
fclose($fp);
}
?

Any ideas how I can achieve this?

Thanks,
Matt 

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



Re: [PHP] fsockopen - how can I specify the local/source port

2007-04-18 Thread Richard Lynch
On Wed, April 18, 2007 5:48 am, Matt wrote:
 I am experimenting with the fsockopen function to send custom UDP
 packets.
 What I would like to do is to be able to nominate the LOCAL port that
 my UDP
 packet originates from. What happens currently is that when I execute
 my
 code below I get a random port 1023 allocated. What I want to be able
 to do
 is to fix the port to one that I specify.

 The code below works and I can see my packet being sent out to
 destination
 port 7077.  The 192.168.2.10 server is also watching for the source
 port of
 incoming traffic and will only respond if the source port is also
 7077.

 ?php
 $fp = fsockopen(udp://192.168.2.10, 7077, $errno, $errstr);
 if (!$fp) {
 echo ERROR: $errno - $errstrbr /\n;
 } else {
 fwrite($fp, Test\n);
 echo fread($fp, 26);
 fclose($fp);
 }
 ?

 Any ideas how I can achieve this?

I believe you can only get what you want by dropping down to the lower
level socket stuff:
http://php.net/sockets

There may be some new-fangled streams stuff that also does it, with
prettier code...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] fsockopen error messages

2006-11-06 Thread Philip Thompson

Hi.

I have not dealt much with fsockopen, but after looking at many  
examples, I'm not finding the answers I need. fsockopen is not  
returning anything and I'm trying to find out what the issue is. The  
error messages are not provided and I'm not sure what's going on.  
Help please!


?
$fp = fsockopen($host, $port, $errno, $errstr);

if (!$fp) {
echo fsock NOT opened!br/;
echo Error: $errstr ($errno)br /\n;
}
?

Thanks,
~Philip

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



Re: [PHP] fsockopen error messages

2006-11-06 Thread Richard Lynch
Depending on your php.ini settings, it may be set up to wait FOREVER
for a socket to open...

What $host?
What $port?

Is it public? Private?

Is there any authentication scheme in place?

We've got nothing to work with here to help you...

On Mon, November 6, 2006 2:58 pm, Philip Thompson wrote:
 Hi.

 I have not dealt much with fsockopen, but after looking at many
 examples, I'm not finding the answers I need. fsockopen is not
 returning anything and I'm trying to find out what the issue is. The
 error messages are not provided and I'm not sure what's going on.
 Help please!

 ?
 $fp = fsockopen($host, $port, $errno, $errstr);

 if (!$fp) {
  echo fsock NOT opened!br/;
  echo Error: $errstr ($errno)br /\n;
 }
 ?

 Thanks,
 ~Philip

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




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] fsockopen error messages

2006-11-06 Thread Philip Thompson
Ok, since my last post, I have slapped myself on the wrist. I made a  
newbie mistake. The function that I send the host, port, etc to was  
in the wrong order from an older version of the function I had. So...  
the port was MSIE... instead of 80. Way to go me! =\


Thanks Richard.

~Philip


On Nov 6, 2006, at 3:12 PM, Richard Lynch wrote:


Depending on your php.ini settings, it may be set up to wait FOREVER
for a socket to open...

What $host?
What $port?

Is it public? Private?

Is there any authentication scheme in place?

We've got nothing to work with here to help you...

On Mon, November 6, 2006 2:58 pm, Philip Thompson wrote:

Hi.

I have not dealt much with fsockopen, but after looking at many
examples, I'm not finding the answers I need. fsockopen is not
returning anything and I'm trying to find out what the issue is. The
error messages are not provided and I'm not sure what's going on.
Help please!

?
$fp = fsockopen($host, $port, $errno, $errstr);

if (!$fp) {
 echo fsock NOT opened!br/;
 echo Error: $errstr ($errno)br /\n;
}
?

Thanks,
~Philip


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



[PHP] fsockopen, openssl error

2006-01-20 Thread James Benson
Im running into the followng error when trying to use fsockopen with the 
openssl extension,




Warning: fsockopen(): php_stream_sock_ssl_activate_with_method: failed 
to create an SSL context


Warning: fsockopen(): failed to activate SSL mode 1

Socket Error: Operation now in progress




Anyone have any clues as to what this may be or why its happening?

Perhaps a compile problem, anyway, I probably will try 4.4.0 because ive 
not made any changes to the script for a few months but have upgraded to 
4.4.2 recently then get this error, very suspicious i think?




James

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



Re: [PHP] fsockopen, openssl error

2006-01-20 Thread Richard Lynch
On Fri, January 20, 2006 7:38 am, James Benson wrote:
 Im running into the followng error when trying to use fsockopen with
 the
 openssl extension,



 Warning: fsockopen(): php_stream_sock_ssl_activate_with_method: failed
 to create an SSL context

 Warning: fsockopen(): failed to activate SSL mode 1

 Socket Error: Operation now in progress




 Anyone have any clues as to what this may be or why its happening?

 Perhaps a compile problem, anyway, I probably will try 4.4.0 because
 ive
 not made any changes to the script for a few months but have upgraded
 to
 4.4.2 recently then get this error, very suspicious i think?

Didja remember to include OpenSSL when you compiled PHP 4.4.2???

Check your phpinfo() and see if it's in there.

If it ain't, you ain't gonna be able to build an SSL context, cuz you
ain't got SSL in your PHP to start with...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Fsockopen error

2005-11-02 Thread Terence



Robert Prentice wrote:

snip

$reply = http_post(https://www.safetrustprocessing.com;, 80, / 


Isnt https supposed to run on port 443? (or other than 80) Just a guess


xml_order_processing.php, array(myXml = $xml));
function http_post ($server, $port, $url, $vars) {


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



Re: [PHP] Fsockopen error

2005-11-02 Thread Jochem Maas

Terence wrote:



Robert Prentice wrote:

snip

$reply = http_post(https://www.safetrustprocessing.com;, 80, / 



Isnt https supposed to run on port 443? (or other than 80) Just a guess


that is the default, but any port is allowed technically ... although putting
port 80 under SSL is probably going to cause you a headache sometime/somewhere.




xml_order_processing.php, array(myXml = $xml));
function http_post ($server, $port, $url, $vars) {





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



Re: [PHP] Fsockopen error

2005-11-02 Thread Robert Prentice

Even if i change it back to 443 i still get the error.

Robert

On Nov 2, 2005, at 9:54 AM, Jochem Maas wrote:


Terence wrote:


Robert Prentice wrote:
snip


$reply = http_post(https://www.safetrustprocessing.com;, 80, /

Isnt https supposed to run on port 443? (or other than 80) Just a  
guess




that is the default, but any port is allowed technically ...  
although putting
port 80 under SSL is probably going to cause you a headache  
sometime/somewhere.




xml_order_processing.php, array(myXml = $xml));
function http_post ($server, $port, $url, $vars) {



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




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



Re: [PHP] Fsockopen error

2005-11-02 Thread Jochem Maas

Robert Prentice wrote:

Even if i change it back to 443 i still get the error.


take another look at your initail error message... it indicates
a problem related to the machines nameserver/dns setting (specifically
IPv6).

I'm willing to bet it's nothing to do with php - your OS seems to at fault.
note that you never mention anything about what version of software you
are using or even what platform you are running on... I'll just assume
linux and the prerequisite knowledge:

does this work for you?:

wget -d -v --delete-after https://www.safetrustprocessing.com



Robert

On Nov 2, 2005, at 9:54 AM, Jochem Maas wrote:


Terence wrote:


Robert Prentice wrote:
snip


$reply = http_post(https://www.safetrustprocessing.com;, 80, /


Isnt https supposed to run on port 443? (or other than 80) Just a  guess



that is the default, but any port is allowed technically ...  although 
putting
port 80 under SSL is probably going to cause you a headache  
sometime/somewhere.




xml_order_processing.php, array(myXml = $xml));
function http_post ($server, $port, $url, $vars) {



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






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



Re: [PHP] Fsockopen error

2005-11-02 Thread Robert Prentice

I get this error:

wget -d -v --delete-after https://www.safetrustprocessing.com
Setting --verbose (verbose) to 1
Setting --delete-after (deleteafter) to 1
DEBUG output created by Wget 1.10.1 (Red Hat modified) on linux-gnu.

--17:15:16--  https://www.safetrustprocessing.com/
   = `index.html'
Resolving www.safetrustprocessing.com... 209.200.128.119
Caching www.safetrustprocessing.com = 209.200.128.119
Connecting to www.safetrustprocessing.com|209.200.128.119|:443...  
connected.

Created socket 3.
Releasing 0x081fb188 (new refcount 1).
Initiating SSL handshake.
Handshake successful; connected socket 3 to SSL handle 0x08210a50
certificate:
  subject: /C=US/O=www.safetrustprocessing.com/OU=https:// 
services.choicepoint.net/get.jsp?GT91812388/OU=See www.geotrust.com/ 
resources/cps (c)04/OU=Domain Control Validated - QuickSSL(R)/ 
CN=www.safetrustprocessing.com
  issuer:  /C=US/O=Equifax Secure Inc./CN=Equifax Secure Global  
eBusiness CA-1
ERROR: Certificate verification error for  
www.safetrustprocessing.com: unable to get local issuer certificate
To connect to www.safetrustprocessing.com insecurely, use `--no-check- 
certificate'.

Closed 3/SSL 0x8210a50
Unable to establish SSL connection.


On Nov 2, 2005, at 11:18 AM, Jochem Maas wrote:


Robert Prentice wrote:


Even if i change it back to 443 i still get the error.



take another look at your initail error message... it indicates
a problem related to the machines nameserver/dns setting (specifically
IPv6).

I'm willing to bet it's nothing to do with php - your OS seems to  
at fault.
note that you never mention anything about what version of software  
you

are using or even what platform you are running on... I'll just assume
linux and the prerequisite knowledge:

does this work for you?:

wget -d -v --delete-after https://www.safetrustprocessing.com



Robert
On Nov 2, 2005, at 9:54 AM, Jochem Maas wrote:


Terence wrote:



Robert Prentice wrote:
snip



$reply = http_post(https://www.safetrustprocessing.com;, 80, /


Isnt https supposed to run on port 443? (or other than 80) Just  
a  guess





that is the default, but any port is allowed technically ...   
although putting
port 80 under SSL is probably going to cause you a headache   
sometime/somewhere.





xml_order_processing.php, array(myXml = $xml));
function http_post ($server, $port, $url, $vars) {




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





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




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



Re: [PHP] Fsockopen error

2005-11-02 Thread Jochem Maas

still no info on what your version of php etc.
but that output gives the impression it may not be the OS after all...

are you able to recompile php? (using the --no-ipv6 flag or whatever it 
mentioned
in the original php error message you posted).

I have no idea how 'invalid' certificates are handled when connecting
to an SSL enabled port ... maybe that's what really causing the problem

have you confirmed that grabbing stuff over normal http does work?...

// something like...
$er = http_post(http://www.php.net;, 80, / );

Robert Prentice wrote:

I get this error:

wget -d -v --delete-after https://www.safetrustprocessing.com
Setting --verbose (verbose) to 1
Setting --delete-after (deleteafter) to 1
DEBUG output created by Wget 1.10.1 (Red Hat modified) on linux-gnu.

--17:15:16--  https://www.safetrustprocessing.com/
   = `index.html'
Resolving www.safetrustprocessing.com... 209.200.128.119
Caching www.safetrustprocessing.com = 209.200.128.119
Connecting to www.safetrustprocessing.com|209.200.128.119|:443...  
connected.

Created socket 3.
Releasing 0x081fb188 (new refcount 1).
Initiating SSL handshake.
Handshake successful; connected socket 3 to SSL handle 0x08210a50
certificate:
  subject: /C=US/O=www.safetrustprocessing.com/OU=https:// 
services.choicepoint.net/get.jsp?GT91812388/OU=See www.geotrust.com/ 
resources/cps (c)04/OU=Domain Control Validated - QuickSSL(R)/ 
CN=www.safetrustprocessing.com
  issuer:  /C=US/O=Equifax Secure Inc./CN=Equifax Secure Global  
eBusiness CA-1
ERROR: Certificate verification error for  www.safetrustprocessing.com: 
unable to get local issuer certificate
To connect to www.safetrustprocessing.com insecurely, use `--no-check- 
certificate'.

Closed 3/SSL 0x8210a50
Unable to establish SSL connection.


On Nov 2, 2005, at 11:18 AM, Jochem Maas wrote:


Robert Prentice wrote:


Even if i change it back to 443 i still get the error.



take another look at your initail error message... it indicates
a problem related to the machines nameserver/dns setting (specifically
IPv6).

I'm willing to bet it's nothing to do with php - your OS seems to  at 
fault.

note that you never mention anything about what version of software  you
are using or even what platform you are running on... I'll just assume
linux and the prerequisite knowledge:

does this work for you?:

wget -d -v --delete-after https://www.safetrustprocessing.com



Robert
On Nov 2, 2005, at 9:54 AM, Jochem Maas wrote:


Terence wrote:



Robert Prentice wrote:
snip



$reply = http_post(https://www.safetrustprocessing.com;, 80, /


Isnt https supposed to run on port 443? (or other than 80) Just  a  
guess





that is the default, but any port is allowed technically ...   
although putting
port 80 under SSL is probably going to cause you a headache   
sometime/somewhere.





xml_order_processing.php, array(myXml = $xml));
function http_post ($server, $port, $url, $vars) {




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





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






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



[PHP] Fsockopen error

2005-11-01 Thread Robert Prentice
I am attempting to connect to a remote server using fsockopen to post  
data to a php file. Here is the error i get:


Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed:  
Name or service not known (is your IPV6 configuration correct? If  
this error happens all the time, try reconfiguring PHP using -- 
disable-ipv6 option to configure) in /home/customerservice/docs/ 
admin_ahmed/test.php on line 37


Here is the code i am using:


$reply = http_post(https://www.safetrustprocessing.com;, 80, / 
xml_order_processing.php, array(myXml = $xml));

function http_post ($server, $port, $url, $vars) {
$user_agent = Mozilla/4.0 (compatible; MSIE 5.5; Windows 98);
$urlencoded = ;
while (list($key,$value) = each($vars))
$urlencoded.= urlencode($key) . = . urlencode($value) . ;
$urlencoded = substr($urlencoded,0,-1);

$content_length = strlen($urlencoded);

$headers = POST $url HTTP/1.1
Accept: */*
Accept-Language: en-au
Content-Type: application/x-www-form-urlencoded
User-Agent: $user_agent
Host: $server
Connection: Keep-Alive
Cache-Control: no-cache
Content-Length: $content_length
;

$fp = fsockopen($server, $port, $errno, $errstr);
if (!$fp) {
return false;
}

fputs($fp, $headers);
fputs($fp, $urlencoded);

$ret = ;
while (!feof($fp))
$ret.= fgets($fp, 1024);

fclose($fp);

return $ret;
}


Any ideas on the problem?

Robert

Re: [PHP] fsockopen and session_start

2005-03-08 Thread Pedro Garre
*This message was transferred with a trial version of CommuniGate(tm) Pro*

It works now. Thanks Jason.

I had never realized that once $_SESSION is set, and if you are not going to 
modify it, the session could be closed. It does not seem a good programming 
practice, thou.

On Tuesday 08 March 2005 05:15, Jason Wong wrote:
 *This message was transferred with a trial version of CommuniGate(tm) Pro*

 On Monday 07 March 2005 22:02, Pedro Garre wrote:
  I am using fsockopen to simulate a POST to another page (test_post.php)
  within the same server.

 It's not clear how exactly you're executing your code. I suspect that you
 haven't closed the session before doing your simulated POST. Your order
 of execution should be something like:

   start session
   assign values to session
   close session
   do the simulated POST

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



[PHP] fsockopen and session_start

2005-03-07 Thread Pedro Garre
*This message was transferred with a trial version of CommuniGate(tm) Pro*

Hi,

I am using fsockopen to simulate a POST to another page (test_post.php) within 
the same server.

Data sent to the socket is:
  POST $uri HTTP/1.1\r\n.
  Host: $host\n. User-Agent: mandapost\r\n.
  Cookie: .session_name().=. session_id().\r\n.
  Content-Type: application/x-www-form-urlencoded\r\n.
  Content-Length: $contentlength\r\n.
  Connection: close\r\n\r\n.
  $my_post_variables\r\n;

$_SESSION is used to hold some variables.

test_post.php is:
?php
session_start();
echo User.$_SESSION[user];
...


The problem is that session_start creates a new session instead of using the 
session_id indicated in the cookie.

A user comment in the online PHP manual says:
Just for info, session_start() blocks if another PHP using the same session 
is still running in background. It seems it's waiting the other PHP to 
finish... and sometimes it can be a problem. Create 2 different sessions by 
setting 2 different names : session_name() solve the problem.

The above comment seems correct and PHP hangs until some time-out or something 
occurs. The previous session is not started anyway.
I tried to change the name with use session_name, to change the ID with 
session_regenerate_id, also some tests with session_id, ...
I also tried to send data to the sockect using PHPSESSID and $_COOKIE instead 
of session_name and session_id.

This is my current code:
?php
$previous_name = session_name(MASIVO);
//sessionid($previous_name);

session_start();
//session_regenerate_id();

echo ##.$previous_name.##.$_COOKIE[$previous_name].##; // (1)
echo User.$_SESSION[user];

(1) It is correct: ##PHPSESSID##09a169b69eccbf2dd49407c5d4cc84aa##

And this is what the socket returns:
HTTP/1.1 200 OK Date: Mon, 07 Mar 2005 13:43:51 GMT Server: Apache/1.3.28 
(Unix) PHP/4.3.3 mod_ssl/2.8.15 OpenSSL/0.9.7c X-Powered-By: PHP/4.3.3 
Set-Cookie: MASIVO=79241c1fb5309b6487f689eb30c65caa; path=/ Expires: Thu, 19 
Nov 1981 08:52:00 GMT Cache-Control: private, max-age=10800, pre-check=10800 
Last-Modified: Mon, 7 Mar 2005 13:38:57 GMT Connection: close 
Transfer-Encoding: chunked Content-Type: text/html c7 
##PHPSESSID##09a169b69eccbf2dd49407c5d4cc84aa##
Notice: Undefined index: user in ... etzetera

I am running out of ideas. Could anyboy help ?

Thanks,

Pedro.

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



Re: [PHP] fsockopen and session_start

2005-03-07 Thread Jason Wong
On Monday 07 March 2005 22:02, Pedro Garre wrote:

 I am using fsockopen to simulate a POST to another page (test_post.php)
 within the same server.

It's not clear how exactly you're executing your code. I suspect that you 
haven't closed the session before doing your simulated POST. Your order 
of execution should be something like:

  start session
  assign values to session
  close session
  do the simulated POST

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] fsockopen: fetching url

2005-02-13 Thread Bostjan Skufca @ domenca.com
HTTP 1.0 does not support virtual hosts.


B.




On Friday 11 February 2005 18:04, [EMAIL PROTECTED] wrote:
 I'm using code below to fetch content from the url.
 This code was worked properly on two servers I tested but it want worked on
 the
 designated one,  so after getting error message I figure it out it may
 be php.ini settings limitation
 ---
- The server encountered an internal
 error or misconfiguration and was unable to complete your request.
 Additionally, a 404 Not Found error was encountered while trying to use an
 ErrorDocument to handle the request.
 ---
-


 So here's the settings I found as possible reason for limitation on code
 execution.
 ---
- disable_functions: readfile, system,
 passthru, shell_exec, shell_exec, system, execreadfile, system, passthru,
 shell_exec, shell_exec, system, exec
 ---
- Does anybody hava any tip how to
 workarround on this?


 CODE
 ---
- function fetchURL( $url ) {
$url_parsed = parse_url($url);
$host = isset($url_parsed[host]) ? $url_parsed[host]: ;
$port = isset($url_parsed[port]) ? $url_parsed[port]: 0;
if ($port==0)
$port = 80;
$path = $url_parsed[path];

$query = isset($url_parsed[query]) ? $url_parsed[query]: ;

if ($query != )
$path .= ? . $query;

$out = GET $path HTTP/1.0\r\nHost: $host\r\n\r\n;

$fp = fsockopen($host, $port, $errno, $errstr, 30);

fwrite($fp, $out);
$body = false;
$in = ;
while (!feof($fp)) {
$s = fgets($fp, 1024);
if ( $body )
$in .= $s;
if ( $s == \r\n )
$body = true;
}

fclose($fp);

return $in;
 }
 ---
-

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



[PHP] fsockopen: fetching url

2005-02-11 Thread branimir . topic

I'm using code below to fetch content from the url.
This code was worked properly on two servers I tested but it want worked on
the
designated one,  so after getting error message I figure it out it may
be php.ini settings limitation

The server encountered an internal error or misconfiguration and was
unable to complete your request.
Additionally, a 404 Not Found error was encountered while trying to use an
ErrorDocument to handle the request.



So here's the settings I found as possible reason for limitation on code
execution.

disable_functions: readfile, system, passthru, shell_exec, shell_exec,
system, execreadfile, system, passthru, shell_exec, shell_exec, system,
exec

Does anybody hava any tip how to workarround on this?


CODE

function fetchURL( $url ) {
   $url_parsed = parse_url($url);
   $host = isset($url_parsed[host]) ? $url_parsed[host]: ;
   $port = isset($url_parsed[port]) ? $url_parsed[port]: 0;
   if ($port==0)
   $port = 80;
   $path = $url_parsed[path];

   $query = isset($url_parsed[query]) ? $url_parsed[query]: ;

   if ($query != )
   $path .= ? . $query;

   $out = GET $path HTTP/1.0\r\nHost: $host\r\n\r\n;

   $fp = fsockopen($host, $port, $errno, $errstr, 30);

   fwrite($fp, $out);
   $body = false;
   $in = ;
   while (!feof($fp)) {
   $s = fgets($fp, 1024);
   if ( $body )
   $in .= $s;
   if ( $s == \r\n )
   $body = true;
   }

   fclose($fp);

   return $in;
}


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



Re: [PHP] fsockopen: fetching url

2005-02-11 Thread Richard Lynch
[EMAIL PROTECTED] wrote:

 I'm using code below to fetch content from the url.
 This code was worked properly on two servers I tested but it want worked
 on
 the
 designated one,  so after getting error message I figure it out it may
 be php.ini settings limitation
 
 The server encountered an internal error or misconfiguration and was
 unable to complete your request.
 Additionally, a 404 Not Found error was encountered while trying to use
 an
 ErrorDocument to handle the request.

Do *ANY* PHP scripts work on that server?

?php phpinfo();?

is a good example to try.




 So here's the settings I found as possible reason for limitation on code
 execution.
 
 disable_functions: readfile, system, passthru, shell_exec, shell_exec,
 system, execreadfile, system, passthru, shell_exec, shell_exec, system,
 exec

Are you using any of those functions?...

I don't see them in your code.


 Does anybody hava any tip how to workarround on this?


 CODE
 
 function fetchURL( $url ) {
$url_parsed = parse_url($url);
$host = isset($url_parsed[host]) ? $url_parsed[host]: ;
$port = isset($url_parsed[port]) ? $url_parsed[port]: 0;
if ($port==0)
$port = 80;
$path = $url_parsed[path];

$query = isset($url_parsed[query]) ? $url_parsed[query]: ;

if ($query != )
$path .= ? . $query;

$out = GET $path HTTP/1.0\r\nHost: $host\r\n\r\n;

$fp = fsockopen($host, $port, $errno, $errstr, 30);

fwrite($fp, $out);
$body = false;
$in = ;
while (!feof($fp)) {
$s = fgets($fp, 1024);
if ( $body )
$in .= $s;
if ( $s == \r\n )
$body = true;
}

fclose($fp);

return $in;
 }


-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] fsockopen

2005-02-02 Thread Bostjan Skufca @ domenca.com
Last two examples are fine as connection is obviously established, it is the  
communication with server that is causig an error. Read http protocol 
documentation.

You do not want such a degree of control over communication you can just use
file_get_contents($url);
where $url is 
http(s)://your.domain.net/dir/file... - standard url


regards,
Bostjan




On Tuesday 01 February 2005 18:17, pete M wrote:
 am not having a lot of success with opening a socket to a secure domain
 (php 4.3.8 - apache - openSSL)

 $fp = fsockopen($url , 443 ,$errno, $errstr, 30);

 have tried the following $urls

 ---
 $url = 'domain.net';

 Bad Request
 Your browser sent a request that this server could not understand.

 Reason: You're speaking plain HTTP to an SSL-enabled server port.
 Instead use the HTTPS scheme to access this URL, please.

 --
 $url = 'https://domain.net';

 Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name
 or service not known

 --
 $url = 'ssl://domain.net';

 Bad Request
 Your browser sent a request that this server could not understand.

 Client sent malformed Host header

 ---
 $url = 'tls://domain.net';

 Bad Request
 Your browser sent a request that this server could not understand.

 Client sent malformed Host header


 Am I missing the obvious as I cannot thing of any other options ;-((

 tia
 pete

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



[PHP] fsockopen

2005-02-01 Thread pete M
am not having a lot of success with opening a socket to a secure domain 
(php 4.3.8 - apache - openSSL)

$fp = fsockopen($url , 443 ,$errno, $errstr, 30);
have tried the following $urls
---
$url = 'domain.net';
Bad Request
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.
--
$url = 'https://domain.net';
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name 
or service not known

--
$url = 'ssl://domain.net';
Bad Request
Your browser sent a request that this server could not understand.
Client sent malformed Host header
---
$url = 'tls://domain.net';
Bad Request
Your browser sent a request that this server could not understand.
Client sent malformed Host header
Am I missing the obvious as I cannot thing of any other options ;-((
tia
pete
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fsockopen

2005-02-01 Thread Richard Lynch
pete M wrote:
 am not having a lot of success with opening a socket to a secure domain
 (php 4.3.8 - apache - openSSL)

 $fp = fsockopen($url , 443 ,$errno, $errstr, 30);

You would need to do S much work to get this going, generating
complementary two-way encryption keys...

Just use curl:

http://php.net/curl

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] fsockopen to own server

2004-12-22 Thread Doc
Thanks for your (and everyone else's) help so far.

I've given up on this. Got another one off the web which uses pop3 and
mail() to achieve the same thing.

Thanks anyway
Dave

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



Re: [PHP] fsockopen to own server

2004-12-20 Thread Doc
On Thu, 16 Dec 2004 10:02:02 -0800, Richard Lynch wrote:

 Doc wrote:
 I'm having a problem with fsockopen and was wondering has anyone ever
 noticed a case where it will work from machine1 (dev machine) to machine2.
 But when the was placed onto machine2 it wouldn't work connecting to it's
 own ip address;

 when connecting via telnet it returns:

  Escape character is '^]'.
 * OK [CAPABILITY IMAP4REV1 LOGIN-REFERRALS AUTH=LOGIN]
 serverip IMAP4rev1 2003.339-cpanel at Wed, 15 Dec 2004
 19:33:27 + (GMT)
 
 You *ARE* getting this when telnetting from/to the same machine, right?...

Yes. the same machine.

 so I don't think it's the firewall. the error it returns is No such file
 or directory. So it seems that when it connects (which it does without
 failing), the file seems to be deleted, as the file the variable refers to
 doesn't exist on the fs either.

 if(($s = fsockopen($id[sockname], 0, $errno, $errstr)) === FALSE)

 $id[sockname] is in the format /tmp/filename with the filename changing
 based on a random value and there are no files with that format in /tmp
 
 Despite the user contributed note on
 http://php.net/manual/en/transports.unix.php
 I'm wondering if you shouldn't use the unix:// bit -- and try udg:// as
 well, if that doesn't work.

Tried both without any success.

 Finally, if there are no files with that format in /tmp, how will this
 work?  Or is that how unix socket streams are supposed to work?  I'm
 ignorant in this area...  But it seems to me that if you try to open a
 file that's not there, you SHOULD get FALSE back. :-)

I'm as ignorant as you :) this is an ex-coworkers code. From
what I can tell from the file should be there from when it connects
initially (as that's the way it is when it's on the dev machine) but
they're not although there is no failure to connect, which suggests to me
that the file is deleted.

 it always returns false for some reason on this server.
 
 And what, if anything, are in $errno and $errstr?
 
 You've put them in there, you might as well use them :-)

$errno 2
$errstr No such file or directory

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



Re: [PHP] fsockopen to own server

2004-12-20 Thread Doc
On Thu, 16 Dec 2004 23:37:36 +0600, Raditha Dissanayake wrote:

 
 Escape character is '^]'.
* OK [CAPABILITY IMAP4REV1 LOGIN-REFERRALS AUTH=LOGIN]
serverip IMAP4rev1 2003.339-cpanel at Wed, 15 Dec 2004
19:33:27 + (GMT)

so I don't think it's the firewall. 

 usually a good idea to disable firewalls when having trouble with socket 
 code.

Tried that. didn't make any difference.

if(($s = fsockopen($id[sockname], 0, $errno, $errstr)) === FALSE)

$id[sockname] is in the format /tmp/filename with the filename changing
based on a random value and there are no files with that format in /tmp 

it always returns false for some reason on this server.
  

 not sure what you are trying to do but it sounds like you are using unix 
 domain sockets where you should be using tcp. That's why it might work 
 on one machine (where web and imap are both installed) and not on the 
 other where you only have the web server but the imap server is remote.

This is actually the opposite of what is happening. It will work on the
remote server but not the local one. I've tried using unix:// and it made
no difference.

Any other suggestions?

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



Re: [PHP] fsockopen to own server

2004-12-20 Thread Richard Lynch
Doc wrote:
 not sure what you are trying to do but it sounds like you are using unix
 domain sockets where you should be using tcp. That's why it might work
 on one machine (where web and imap are both installed) and not on the
 other where you only have the web server but the imap server is remote.

 This is actually the opposite of what is happening. It will work on the
 remote server but not the local one. I've tried using unix:// and it made
 no difference.

 Any other suggestions?

WILD GUESS ALERT!

What you got in /etc/hosts.allow and /etc/hosts.deny?...

Or any kind of other anti-bad-guy technology?...

Does it work if you use 127.0.0.1 for the IP/URL?
How about the actual IP of the machine?
localhost?

Just throwing out random things to try that might lead you somewhere.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] fsockopen to own server

2004-12-20 Thread Doc
On Mon, 20 Dec 2004 07:51:46 -0800, Richard Lynch wrote:
 
 WILD GUESS ALERT!
 
 What you got in /etc/hosts.allow and /etc/hosts.deny?...

nothing in there other than default install comments.
 
 Or any kind of other anti-bad-guy technology?...

nope.

 Does it work if you use 127.0.0.1 for the IP/URL?
 How about the actual IP of the machine?
 localhost?

d) none of the above :)
 
 Just throwing out random things to try that might lead you somewhere.

much appreciated. I'm willing to sacrifice young lambs at this stage.

Cheers
Doc

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



Re: [PHP] fsockopen to own server

2004-12-20 Thread Richard Lynch
Doc wrote:
 On Mon, 20 Dec 2004 07:51:46 -0800, Richard Lynch wrote:

 WILD GUESS ALERT!

 What you got in /etc/hosts.allow and /etc/hosts.deny?...

 nothing in there other than default install comments.

 Or any kind of other anti-bad-guy technology?...

 nope.

 Does it work if you use 127.0.0.1 for the IP/URL?
 How about the actual IP of the machine?
 localhost?

 d) none of the above :)

 Just throwing out random things to try that might lead you somewhere.

 much appreciated. I'm willing to sacrifice young lambs at this stage.

Okay, pull out ethereal and netstat -a to see what connections are being
tried/attempted/whatever.

Maybe even tcpdump to see what is going back and forth.

If all else fails, here's a TOTAL HACK:

Write a PHP script on some other server that connects back to the first
server and opens the socket and does whatever you need it to do.

Now have your script connect to the other server and use its sockets to do
what you need.

This is clearly *NOT* a Good Idea for a long-term solution, but could get
you past this hump long enough to survive, and maybe even make you realize
just why the same-machine system doesn't work.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] fsockopen to own server

2004-12-16 Thread Doc
Hello.

I'm having a problem with fsockopen and was wondering has anyone ever
noticed a case where it will work from machine1 (dev machine) to machine2.
But when the was placed onto machine2 it wouldn't work connecting to it's
own ip address; 

when connecting via telnet it returns:

 Escape character is '^]'.
* OK [CAPABILITY IMAP4REV1 LOGIN-REFERRALS AUTH=LOGIN]
serverip IMAP4rev1 2003.339-cpanel at Wed, 15 Dec 2004
19:33:27 + (GMT)

so I don't think it's the firewall. the error it returns is No such file
or directory. So it seems that when it connects (which it does without
failing), the file seems to be deleted, as the file the variable refers to
doesn't exist on the fs either.

if(($s = fsockopen($id[sockname], 0, $errno, $errstr)) === FALSE)

$id[sockname] is in the format /tmp/filename with the filename changing
based on a random value and there are no files with that format in /tmp 

it always returns false for some reason on this server.

Thanks in advance for your help.
Dave

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



Re: [PHP] fsockopen to own server

2004-12-16 Thread Raditha Dissanayake
Doc wrote:
Hello.
I'm having a problem with fsockopen and was wondering has anyone ever
noticed a case where it will work from machine1 (dev machine) to machine2.
 

happens all the time :-)
But when the was placed onto machine2 it wouldn't work connecting to it's
own ip address; 

when connecting via telnet it returns:
Escape character is '^]'.
* OK [CAPABILITY IMAP4REV1 LOGIN-REFERRALS AUTH=LOGIN]
serverip IMAP4rev1 2003.339-cpanel at Wed, 15 Dec 2004
19:33:27 + (GMT)
so I don't think it's the firewall. 

usually a good idea to disable firewalls when having trouble with socket 
code.

the error it returns is No such file
or directory. So it seems that when it connects (which it does without
failing), the file seems to be deleted, as the file the variable refers to
doesn't exist on the fs either.
if(($s = fsockopen($id[sockname], 0, $errno, $errstr)) === FALSE)
$id[sockname] is in the format /tmp/filename with the filename changing
based on a random value and there are no files with that format in /tmp 

it always returns false for some reason on this server.
 

not sure what you are trying to do but it sounds like you are using unix 
domain sockets where you should be using tcp. That's why it might work 
on one machine (where web and imap are both installed) and not on the 
other where you only have the web server but the imap server is remote.

--
Raditha Dissanayake.
--
http://www.radinks.com/print/card-designer/ | Card Designer Applet
http://www.radinks.com/upload/  | Drag and Drop Upload 

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


Re: [PHP] fsockopen to own server

2004-12-16 Thread Richard Lynch
Doc wrote:
 I'm having a problem with fsockopen and was wondering has anyone ever
 noticed a case where it will work from machine1 (dev machine) to machine2.
 But when the was placed onto machine2 it wouldn't work connecting to it's
 own ip address;

 when connecting via telnet it returns:

  Escape character is '^]'.
 * OK [CAPABILITY IMAP4REV1 LOGIN-REFERRALS AUTH=LOGIN]
 serverip IMAP4rev1 2003.339-cpanel at Wed, 15 Dec 2004
 19:33:27 + (GMT)

You *ARE* getting this when telnetting from/to the same machine, right?...

 so I don't think it's the firewall. the error it returns is No such file
 or directory. So it seems that when it connects (which it does without
 failing), the file seems to be deleted, as the file the variable refers to
 doesn't exist on the fs either.

 if(($s = fsockopen($id[sockname], 0, $errno, $errstr)) === FALSE)

 $id[sockname] is in the format /tmp/filename with the filename changing
 based on a random value and there are no files with that format in /tmp

Despite the user contributed note on
http://php.net/manual/en/transports.unix.php
I'm wondering if you shouldn't use the unix:// bit -- and try udg:// as
well, if that doesn't work.

Finally, if there are no files with that format in /tmp, how will this
work?  Or is that how unix socket streams are supposed to work?  I'm
ignorant in this area...  But it seems to me that if you try to open a
file that's not there, you SHOULD get FALSE back. :-)

 it always returns false for some reason on this server.

And what, if anything, are in $errno and $errstr?

You've put them in there, you might as well use them :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] fsockopen https problem

2004-12-13 Thread Richard Lynch
Maycon de Oliveira wrote:
 Hi, i have problem in my script, this error is Permission Danied (13)

 ?

 $host = 193.132.139.36;

 $port = 443;

 $path = /gatekeeper/ink/quexry.asp; //or .dll, etc. for authnet, etc.

 $fp = fsockopen(https://.$host, $port, $errno, $errstr, $timeout = 10);

You can't just open up a socket on port 443 to a secure server and start
sending/getting data.

The whole point of SSL is that you need to provide a half of an SSH
key-pair, and get half of their key-pair, then you each generate a
key-pair from your secret half key-pairs, and then you swap those so you
each know the other has the secret half of the key-pair they gave you,
then you can send a new unique key-pair to encrypt/decrypt the data, and
then you can start sending the username/password back and forth safely to
be logged in, and then you can kiss each other...

You could, in theory, develop all of the code to implement this protocol
for yourself and use fsockopen as you are.

But it would be *WAY* mo' betta to just use this:

http://php.net/curl

Have fun.

PS Keep all the urlencode stuff you have -- That's all good.  Just the
fsockopen bit needs to change.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] fsockopen https problem

2004-12-10 Thread Maycon de Oliveira
Hi, i have problem in my script, this error is Permission Danied (13)

 

 

 

?

$host = 193.132.139.36;

$port = 443;

$path = /gatekeeper/ink/quexry.asp; //or .dll, etc. for authnet, etc.

 

//you will need to setup an array of fields to post with

//then create the post string

$formdata = array (

 type = full,

 originator = 33,

 urn = 2528,

 surname = appleton,

 submit = submit

);

//build the post string

  foreach($formdata AS $key = $val){

   $poststring .= urlencode($key) . = . urlencode($val) . ;

  }

// strip off trailing ampersand

$poststring = substr($poststring, 0, -1);

 

$fp = fsockopen(https://.$host, $port, $errno, $errstr, $timeout = 10);

 

if(!$fp){

 //error tell us

 

 echo $errstr ($errno)\n;

 

}else{

 

  //send the server request

  fputs($fp, POST $path HTTP/1.1\r\n);

  fputs($fp, Host: $host\r\n);

  fputs($fp, Content-type: application/x-www-form-urlencoded\r\n);

  fputs($fp, Content-length: .strlen($poststring).\r\n);

  fputs($fp, Connection: close\r\n\r\n);

  fputs($fp, $poststring . \r\n\r\n);

 

  //loop through the response from the server

  while(!feof($fp)) {

   echo fgets($fp, 4096);

  }

  //close fp - we are done with it

  fclose($fp);

}

?



[PHP] fsockopen() throwing errors

2004-05-28 Thread Phil Ewington - 43 Plc
Hi All,

How can I stop fsockopen() throwing an error and killing my script when it
cannot connect?

I have tried the following:

$this-_Socket = fsockopen($s_server, $this-_Port, $i_errno, $s_errstr,
$this-_Timeout);
if (!$this-_Socket)
{
... code to handle connection failure
}

and ...

if (!$this-_Socket = fsockopen($s_server, $this-_Port, $i_errno,
$s_errstr, $this-_Timeout))
{
... code to handle connection failure
}

I have also tried prefixing fsockopen() with @ but when it fails to connect
it kills my script by throwing an error. Any advise here will be much
appreciated as this code is mission critical.

TIA

- Phil.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 22/05/2004

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



[PHP] fsockopen connection error on IIS

2004-03-31 Thread Michael Egan
Hello all,

I'm working with somebody using IIS (honest - it's not me) to try and develop some web 
services whereby a site hosted on IIS is able to access data using a nusoap client 
with a nusoap server set up on a linux/apache server. I can do this satisfactorily 
from another linux/apache server but my colleague is having problems doing this from 
IIS.

The main problem seems to be that fsockopen isn't working from their system. We have 
tried running the following script:

?php
$fp = fsockopen(www.thehostname.com, 80, $errno, $errstr, 30);

if (!$fp) 

{
   echo $errstr ($errno)br /\n;
} 

else 

{

   echo Success;

}
? 

But the following error is returned:

Warning: fsockopen(): unable to connect to www.thehostname.com:80 in 
C:\Inetpub\wwwroot\webservice\fsocktest.php on line 2
A connection attempt failed because the connected party did not properly respond after 
a period of time, or established connection failed because connected host has failed 
to respond. (10060)

I've searched through a few mailing list archives and the only thing I came across was 
the suggestion that the client server is not allowing outgoing connections. Is there 
any way of testing this or indeed any other suggestions as to what might be going 
wrong.

I confess I feel I'm on extremely thin ice with this - I'm not overly familiar with 
nusoap and have no familiarity whatsoever with IIS. Any general pointers would be 
extremely welcome.

Regards,

Michael Egan

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



RE: [PHP] fsockopen connection error on IIS[Scanned]

2004-03-31 Thread Michael Egan
Problem solved. It seems there was a proxy server involved which was screwing things 
up.

Regards,

Michael Egan

 -Original Message-
 From: Michael Egan 
 Sent: 31 March 2004 14:20
 To: PHP General (E-mail)
 Subject: [PHP] fsockopen connection error on IIS[Scanned]
 
 
 Hello all,
 
 I'm working with somebody using IIS (honest - it's not me) to 
 try and develop some web services whereby a site hosted on 
 IIS is able to access data using a nusoap client with a 
 nusoap server set up on a linux/apache server. I can do this 
 satisfactorily from another linux/apache server but my 
 colleague is having problems doing this from IIS.
 
 The main problem seems to be that fsockopen isn't working 
 from their system. We have tried running the following script:
 
 ?php
 $fp = fsockopen(www.thehostname.com, 80, $errno, $errstr, 30);
 
 if (!$fp) 
 
 {
echo $errstr ($errno)br /\n;
 } 
 
 else 
 
 {
 
echo Success;
 
 }
 ? 
 
 But the following error is returned:
 
 Warning: fsockopen(): unable to connect to 
 www.thehostname.com:80 in 
 C:\Inetpub\wwwroot\webservice\fsocktest.php on line 2
 A connection attempt failed because the connected party did 
 not properly respond after a period of time, or established 
 connection failed because connected host has failed to 
 respond. (10060)
 
 I've searched through a few mailing list archives and the 
 only thing I came across was the suggestion that the client 
 server is not allowing outgoing connections. Is there any way 
 of testing this or indeed any other suggestions as to what 
 might be going wrong.
 
 I confess I feel I'm on extremely thin ice with this - I'm 
 not overly familiar with nusoap and have no familiarity 
 whatsoever with IIS. Any general pointers would be extremely welcome.
 
 Regards,
 
 Michael Egan
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



[PHP] fsockopen and HTTP 1.1 Problem

2004-03-25 Thread Mooki
I am using these to get the code of a page that is listed in the code 
below. I am using the example code of fsockopen on php.net as reference. 
I can get the response header but i have a problem with the CHUNKs.

the Code :

$header = ;
$response = ;
	
	if (!($fp = fsockopen (myplanetside.station.sony.com, 80, $errno, 
$errstr,30)))
		exit($errstr);
	else {
	echo bin drin ;
	
		echo Bin richtig;
		fputs ($fp, GET /outfit.jsp?outfitId=6607worldId=21 HTTP/1.1 \r\n);
  		fputs ($fp, Host: myplanetside.station.sony.com\r\n);
   		fputs ($fp, Connection: close\r\n);
  		fputs ($fp, Accept-Encoding: gzip\r\n);
  		fputs ($fp, Accept: 
application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\n);
 		fputs ($fp, Accept-Language: en-us,en;q=0.5\r\n);
   		fputs ($fp, Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n);
   		fputs ($fp, Accept-Language: en-us,en;q=0.5\r\n\r\n);
		
		
		do $header.=fread($fp,1); while (!preg_match('/\\r\\n\\r\\n$/',$header));
		
			

   // check for chunked encoding
   if (preg_match('/Transfer\\-Encoding:\\s+chunked\\r\\n/',$header)){
   echo bin in der IF alls TRUE;
 do {
 $byte = ;
 $chunk_size=;
 do {
		 	// Here should be the the Problem
			// I get endles query so to say.
   $chunk_size.=$byte;
   $byte=fread($fp,1);
 } while ($byte!=\\r);  // till we match the CR
 fread($fp, 1);// also drop off the LF
 $chunk_size=hexdec($chunk_size); // convert to real number
 $response.=fread($fp,$chunk_size);
 fread($fp,2);  // ditch the CRLF that trails the chunk
 } while ($chunk_size);   // till we reach the 0 length chunk 
(end marker)
	}//end if
   else {
 // check for specified content length
 if 
(preg_match('/Content\\-Length:\\s+([0-9]*)\\r\\n/',$header,$matches)) {
 $response=fread($fp,$matches[1]);
 } else {
 // not a nice way to do it (may also result in extra CRLF 
which trails the real content???)
 while (!feof($fp)) $response .= fread($fp, 4096);
 }
   }
   // close connection
   fclose($fp);
}

// do something useful with the response
print($header);
print($response);
hope someone can help me ...

P.S. : Sorry for the bad eng.

mfG Munir

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


Re: [PHP] fsockopen and HTTP 1.1 Problem

2004-03-25 Thread Richard Davey
Hello Mooki,

Thursday, March 25, 2004, 12:26:27 PM, you wrote:

M I am using these to get the code of a page that is listed in the code
M below. I am using the example code of fsockopen on php.net as reference.
M I can get the response header but i have a problem with the CHUNKs.

You could save yourself a whole load of headaches by getting the free
class file Snoopy, that will do exactly what you want (and a lot
more)

http://snoopy.sourceforge.com

Then your code would just look like this:

?php
include Snoopy.class.php;
$snoopy = new Snoopy;
$submit_url = http://myplanetside.station.sony.com/outfit.jsp;;
$submit_vars[outfitId] = 6607;
$submit_vars[worldId] = 21;
$snoopy-submit($submit_url,$submit_vars);
?

Then the whole page is stored in $snoop-results, the headers in
$snoopy-headers, etc etc. Lots of variations, see the doc files.

:)

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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



Re: [PHP] fsockopen and HTTP 1.1 Problem

2004-03-25 Thread Chris Shiflett
--- Mooki [EMAIL PROTECTED] wrote:
 I am using these to get the code of a page that is listed in the code 
 below. I am using the example code of fsockopen on php.net as
 reference.
 
 I can get the response header but i have a problem with the CHUNKs.

I can show you how to deal with chunked responses, but I think this is
unnecessary.

You can open a remote URL just as if it were a local file if
allow_url_fopen is enabled:

$handle = fopen('http://example.org/', 'r');
...

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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



Re: [PHP] fsockopen to spit out the HTTP's Location...

2004-03-23 Thread Scott Fletcher
In plain english, can't use the header(Location: ), so have to use the
fsockopen() instead.  Just that header() is not allowed, don't ask me why.
Just couldn't get the browser perform the HTTP LOCATION event.  It does work
when using fsockopen() for HTTP POST or GET as stated in the
http://us2.php.net/manual/en/function.fsockopen.php with the user's comment.
What could be more difficult than this?

--snip--
$host = 192.168.0.2;
$port = 443;
$url_str = ssl://www.whatever.com?str1=truestr2=falsestr3=true;

$fp = fsockopen(ssl://.$host, $port, $errno, $errstr, $timeout = 30);

if(!$fp){
  echo $errstr ($errno)\n;
}else{
  //send out to the browser.
  fputs($fp, Location: .$url_str.\r\n);

  fclose($fp);
}

FletchSOD

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



Re: [PHP] fsockopen to spit out the HTTP's Location...

2004-03-23 Thread Scott Fletcher
In plain english, can't use the header(Location: ), so have to use the
fsockopen() instead.  Just that header() is not allowed, don't ask me why.
Just couldn't get the browser perform the HTTP LOCATION event.  It does work
when using fsockopen() for HTTP POST or GET as stated in the
http://us2.php.net/manual/en/function.fsockopen.php with the user's comment.
What could be more difficult than this?

--snip--
$host = 192.168.0.2;
$port = 443;
$url_str = ssl://www.whatever.com?str1=truestr2=falsestr3=true;

$fp = fsockopen(ssl://.$host, $port, $errno, $errstr, $timeout = 30);

if(!$fp){
  echo $errstr ($errno)\n;
}else{
  //send out to the browser.
  fputs($fp, Location: .$url_str.\r\n);

  fclose($fp);
}

FletchSOD

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



Re: [PHP] fsockopen to spit out the HTTP's Location...

2004-03-23 Thread Michal Migurski
In plain english, can't use the header(Location: ), so have to use
the fsockopen() instead.  Just that header() is not allowed, don't ask me
why. Just couldn't get the browser perform the HTTP LOCATION event.
--snip--
$host = 192.168.0.2;
$port = 443;
$url_str = ssl://www.whatever.com?str1=truestr2=falsestr3=true;

$fp = fsockopen(ssl://.$host, $port, $errno, $errstr, $timeout = 30);
--snip--
  //send out to the browser.
  fputs($fp, Location: .$url_str.\r\n);

That won't get sent to the browser, it will get sent to 192.168.0.2, which
is (I guess) some machine behind your router. You can't initiate a TCP
connection -- what fsockopen does -- with the client's machine.

I'll ask even though you said not to - Why doesn't header() work?

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] fsockopen to spit out the HTTP's Location...

2004-03-23 Thread Chris Shiflett
--- Scott Fletcher [EMAIL PROTECTED] wrote:
 In plain english, can't use the header(Location: ), so have to
 use the fsockopen() instead. Just that header() is not allowed, don't
 ask me why.

I'm asking anyway. :-)

You cannot (thank goodness) connect to a remote client with fsockopen(),
so you can probably save yourself some trouble by forgetting this whole
approach. You need to focus on why header() is not working for you,
because this is the way to send HTTP headers to the client.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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



Re: [PHP] fsockopen to spit out the HTTP's Location...

2004-03-23 Thread Scott Fletcher
Boy!  Everyone here is itching for an answer!!!  :-)  Sigh!  Well, I guess
all web browsers suck at it by the way!!  Michal Migurski from other posting
had explained that fsockopen() do the TCP stuff or the Transport Layer.  So,
no wonder fsockopen() can't get to the Network layer, like the IP Address
stuff.  I'll think of a workaround to the header() instead.  I don't want to
use cURL because it take more time.  And finally, for those of you who are
dying to know the answer to why I can't use the header().  It's the 3rd
party coding that contain the code,

--snip--
if(headers_sent())
$this-Error('  ');
--snip--

FletchSOD

Chris Shiflett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 --- Scott Fletcher [EMAIL PROTECTED] wrote:
  In plain english, can't use the header(Location: ), so have to
  use the fsockopen() instead. Just that header() is not allowed, don't
  ask me why.

 I'm asking anyway. :-)

 You cannot (thank goodness) connect to a remote client with fsockopen(),
 so you can probably save yourself some trouble by forgetting this whole
 approach. You need to focus on why header() is not working for you,
 because this is the way to send HTTP headers to the client.

 Chris

 =
 Chris Shiflett - http://shiflett.org/

 PHP Security - O'Reilly
  Coming Fall 2004
 HTTP Developer's Handbook - Sams
  http://httphandbook.org/
 PHP Community Site
  http://phpcommunity.org/

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



Re: [PHP] fsockopen to spit out the HTTP's Location...

2004-03-23 Thread Scott Fletcher
See the reply to the Chris Shiflett's reply...

Michal Migurski [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 In plain english, can't use the header(Location: ), so have to use
 the fsockopen() instead.  Just that header() is not allowed, don't ask me
 why. Just couldn't get the browser perform the HTTP LOCATION event.
 --snip--
 $host = 192.168.0.2;
 $port = 443;
 $url_str = ssl://www.whatever.com?str1=truestr2=falsestr3=true;
 
 $fp = fsockopen(ssl://.$host, $port, $errno, $errstr, $timeout = 30);
 --snip--
   //send out to the browser.
   fputs($fp, Location: .$url_str.\r\n);

 That won't get sent to the browser, it will get sent to 192.168.0.2, which
 is (I guess) some machine behind your router. You can't initiate a TCP
 connection -- what fsockopen does -- with the client's machine.

 I'll ask even though you said not to - Why doesn't header() work?

 -
 michal migurski- contact info and pgp key:
 sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] fsockopen to spit out the HTTP's Location...

2004-03-23 Thread Michal Migurski
And finally, for those of you who are dying to know the answer to why I
can't use the header().  It's the 3rd party coding that contain the code,

--snip--
if(headers_sent())
$this-Error('  ');
--snip--

Why not delete that part of the 3rd party code then? Or send your Location
header before you call it? Curl won't help you here, for the same reasons
that fsockopen won't work.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] fsockopen to spit out the HTTP's Location...

2004-03-23 Thread Chris Shiflett
--- Scott Fletcher [EMAIL PROTECTED] wrote:
 Sigh!  Well, I guess all web browsers suck at it by the way!

Suck at what exactly?

 Michal Migurski from other posting had explained that fsockopen()
 do the TCP stuff or the Transport Layer. So, no wonder fsockopen()
 can't get to the Network layer, like the IP Address stuff.

What do you consider to be the network layer? This figure might be helpful
to you:

http://shiflett.org/images/18fig06.jpg

 I don't want to use cURL because it take more time.

A better reason is that it also cannot make a connection to a remote
client.

 And finally, for those of you who are dying to know the answer to
 why I can't use the header(). It's the 3rd party coding that contain
 the code,
 
 --snip--
 if(headers_sent())
 $this-Error('  ');
 --snip--

Yeah, this is why everyone was interested - you're wrong. :-)

That code will throw an error is headers have already been sent. Headers
are sent as soon as output begins, so you can either set all of your
headers prior to any output or use output buffering with ob_start().

So, use header().

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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



Re: [PHP] fsockopen to spit out the HTTP's Location...

2004-03-23 Thread Scott Fletcher
  Sigh!  Well, I guess all web browsers suck at it by the way!
 Suck at what exactly?
Not suck at receiving the HTTP commands from the webserver but suck at not
receiving the HTTP commands from the PHP.  :-)  I understand how the
browser/webserver communication work so no wonder why it doesn't work.  Kind
of make you jealous of the flash player that are both client and server side
on the web-browser

 What do you consider to be the network layer? This figure might be helpful
 to you: http://shiflett.org/images/18fig06.jpg

Application -- Web Browser/Web Server
Presentation -- HTTP/HTTPS/SSL and language (HTML/JavaScript, etc).
Session -- Browser-Server connection, etc.
Transport -- Port 80/Port 443, packet transfer control, etc.
Network -- IP Address/Internet/Router
Data Link -- Network card driver/binding
Physical -- Media stuffs (Network cable, wireless, etc).

 Yeah, this is why everyone was interested - you're wrong. :-)
Me wrong?  Really!  :-)

 That code will throw an error is headers have already been sent. Headers
 are sent as soon as output begins, so you can either set all of your
 headers prior to any output or use output buffering with ob_start().

 So, use header().
Yea, working on it  Wish can make the 3rd party software come after the
header()..

FletchSOD

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



Re: [PHP] fsockopen to spit out the HTTP's Location...

2004-03-23 Thread Scott Fletcher
 Why not delete that part of the 3rd party code then? Or send your Location
 header before you call it? Curl won't help you here, for the same reasons
 that fsockopen won't work.
Not sure about deleting the part of the 3rd party code though, I had thought
about it alot and I had been itching for it.  Can't say that I would
remember this 2 months from now with the upgrading parting.  Location
header, it wouldn't hurt to move it around in the script.

FletchSOD

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



Re: [PHP] fsockopen to spit out the HTTP's Location...

2004-03-23 Thread Chris Shiflett
--- Scott Fletcher [EMAIL PROTECTED] wrote:
 Application -- Web Browser/Web Server
 Presentation -- HTTP/HTTPS/SSL and language (HTML/JavaScript, etc).
 Session -- Browser-Server connection, etc.
 Transport -- Port 80/Port 443, packet transfer control, etc.
 Network -- IP Address/Internet/Router
 Data Link -- Network card driver/binding
 Physical -- Media stuffs (Network cable, wireless, etc).

In this case, fsockopen() basically handles everything from the Transport
layer down, and whatever you write needs to handle everything from the
Session layer up.

  So, use header().

 Yea, working on it  Wish can make the 3rd party software come after
 the header()..

You don't have to. All you have to do is make sure no output comes before
your 3rd party software. If you can't avoid this, you can put ob_start()
at the very top, and PHP will buffer the output for you, so that headers
aren't sent until the script terminates. Whatever works best for you.

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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



[PHP] fsockopen to spit out the HTTP's Location...

2004-03-22 Thread Scott Fletcher
Hi!

I haven't found the right wording to spit out the HTTP scripts to the
web browser through the fsockopen.  In this case, the Location: 
script.  I can not use the php header() function because of the FPDF strict
checking.  (Freeware PDF).  All I did was to create a PDF and put it on the
webserver with nothing being outputted but FPDF have no way of knowing this
and think I'm spitting out the PDF data because I'm using hte Location:
, so I'm using fsockopen() instead.   For now, when I tried to spit out
the Location:  from fsockopen(), nothing happen.  So, what exactly
should the HTTP script be??

Thanks,
 FletchSOD

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



Re: [PHP] fsockopen to spit out the HTTP's Location...

2004-03-22 Thread Chris Shiflett
--- Scott Fletcher [EMAIL PROTECTED] wrote:
 I haven't found the right wording to spit out the HTTP scripts to
 the web browser through the fsockopen.

I feel certain that I can help you, but unfortunately I can't seem to
understand your question at all. Please understand that I'm not trying to
criticize your question, but there are some things that confuse me.

For example, HTTP is a protocol, and I must assume that you mean HTTP
headers (rather than scripts). More importantly, unless you really know
what you're doing and have a very specific environment, there is no way
you can connect to the user using fsockopen().

 In this case, the Location:  script. I can not use the php
 header() function because of the FPDF strict checking.

Can you explain this? Why can you not use header()? I think your
assumption is wrong.

I can't erally make out the rest of your message, but I think that if you
can explain these statements, the rest might make more sense.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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



[PHP] fsockopen() errors.

2004-03-08 Thread Phil Ewington - 43 Plc
Hi All,

Can anyone tell me the best way to avoid errors using fsockopen(). I have
tried wrapping the function call in a conditional statement, and have also
tried calling the function and then testing the return.

Example 1:
$sckHandle = fsockopen($server, 25, $errNo, $errString);
if ($sckHandle)
{
code here...
}


Example 2:
if ($sckHandle = fsockopen($server, 25, $errNo, $errString))
{
code here...
}

both give this error on failing to connect to a given server:

fsockopen(): unable to connect to mx3.hotmail.com:25

I was under the impression that example 2 would not trigger an error if
fsockopen() failed. Any help will be greatly appreciated.

Phil.

---
Phil Ewington - Technical Director

43 Plc - Ashdale House
35 Broad Street, Wokingham
Berkshire RG40 1AU

T: +44 (0)1189 789 500
F: +44 (0)1189 784 994
E: mailto:[EMAIL PROTECTED]
W: www.soyouthink.com

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



Re: [PHP] fsockopen() errors.

2004-03-08 Thread Miguel J. Jiménez
Is it an error or a warning? If it is a warning you can try use @  
before fsockopen() to avoid echoing warning messages [EMAIL PROTECTED](...)].

--

Miguel J. Jiménez
ISOTROL, S.A. (Área de Internet)
Avda. Innovación nº1, 3ª - 41020 Sevilla (ESPAÑA)
[EMAIL PROTECTED]
TLFNO. 955036800 ext. 111
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] fsockopen() errors.

2004-03-08 Thread Phil Ewington - 43 Plc
Hi Miguel,

I am giving it a test at the moment, thanks.

-- Phil.


 -Original Message-
 From: Miguel J. Jiménez [mailto:[EMAIL PROTECTED]
 Sent: 08 March 2004 12:29
 To: Phil Ewington - 43 Plc
 Cc: PHP
 Subject: Re: [PHP] fsockopen() errors.


 Is it an error or a warning? If it is a warning you can try use @
 before fsockopen() to avoid echoing warning messages [EMAIL PROTECTED](...)].

 --

 Miguel J. Jiménez
 ISOTROL, S.A. (Área de Internet)
 Avda. Innovación nº1, 3ª - 41020 Sevilla (ESPAÑA)
 [EMAIL PROTECTED]
 TLFNO. 955036800 ext. 111

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


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



RE: [PHP] fsockopen() errors.

2004-03-08 Thread Phil Ewington - 43 Plc
Hmm, added @ to fsockopen() function, still happens, can anyone shed any
light on this?

TIA

Phil.



 -Original Message-
 From: Phil Ewington - 43 Plc [mailto:[EMAIL PROTECTED]
 Sent: 08 March 2004 12:57
 To: Miguel J. Jiménez
 Cc: PHP
 Subject: RE: [PHP] fsockopen() errors.


 Hi Miguel,

 I am giving it a test at the moment, thanks.

 -- Phil.


  -Original Message-
  From: Miguel J. Jiménez [mailto:[EMAIL PROTECTED]
  Sent: 08 March 2004 12:29
  To: Phil Ewington - 43 Plc
  Cc: PHP
  Subject: Re: [PHP] fsockopen() errors.
 
 
  Is it an error or a warning? If it is a warning you can try use @
  before fsockopen() to avoid echoing warning messages [EMAIL PROTECTED](...)].
 
  --
 
  Miguel J. Jiménez
  ISOTROL, S.A. (Área de Internet)
  Avda. Innovación nº1, 3ª - 41020 Sevilla (ESPAÑA)
  [EMAIL PROTECTED]
  TLFNO. 955036800 ext. 111
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 

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


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



[PHP] fsockopen failed with permission denied error...

2004-02-19 Thread Scott Fletcher
Hi Everyone!

Sample code below...

--snip--
$fp = fsockopen(www.cnn.com, 80, $errno, $errstr, 30);
--snip--

I get the error message, permission denied along with 13.  When I read the
bugs.php.net and found out that I need to add the @ to it so I did this..

--snip--
$fp = @fsockopen(www.cnn.com, 80, $errno, $errstr, 30);
--snip--

I get a different error message, it said ...

--snip--
Addr family not supported by protocol (66)
--snip--

Does anyone know what it meant and what is the workaround to it?

Thanks,
 FletchSOD

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



[PHP] fsockopen to conect to ssl sites

2004-01-03 Thread Jorge Castaneda
WHERE IS THE ERROR?
 
The  username  and  the  password  are the correct and the name of the
variables  (login  and  pass)  also  match. I tried to get data from a
secure  site but I always receive the next message instead of the page
I request:
 
We are connected with somesecuredomain.com
 
HTTP/1.1  302  Found  Date:  Fri,  02  Jan  2004  19:21:20 GMT Server:
Apache/1.3.27 (Unix) FrontPage/5.0.2.2623 PHP/4.3.2 mod_gzip/1.3.19.1a
mod_accounting/1.0   mod_fastcgi/2.4.0  mod_ssl/2.8.14  OpenSSL/0.9.7b
rus/PL30.17 X-Powered-By: PHP/4.3.2Set-Cookie:
biz=8a204f6cf271a7a81d3de70c0b250921; path=/ Expires: Thu, 01 Jan 1970
00:00:01   GMT  Cache-Control:  no-store,  no-cache,  must-revalidate,
post-check=0,  pre-check=0  Pragma: no-cache Location:
/?error=Auth+error%2C+wrong+login+or+password.login=myusername
Connection:   close   Content-Type:   text/html;  charset=windows-1251
Last-Modified: Fri, 02 Jan 2004 19:21:20 GMT
 
 
 
The script I used:
__
 
?php
 
$host= somesecuredomain.com; $page= /account/login.php;
 
 
$formdata = array (login=myusername , pass=mypassword); 
 
foreach($formdata AS $key = $val)
{ 
$poststring .= urlencode($key).=.urlencode($val).; 
} 
 
$poststring = substr($poststring, 0, -1); 
 
$request= POST $page HTTP/1.0\x0D\x0A;
$request .= HOST: $host\x0D\x0A;
$request .= Content-Type: application/x-www-form-urlencoded\x0D\x0A;
$request .= User-Agent: test client\x0D\x0A;
$request .= Accept: */*\x0D\x0A;
$request .= Content-Length: .strlen($poststring).\x0D\x0A;
$request .= Connection: close\x0D\x0A\x0D\x0A; 
$request .= $poststring .\x0D\x0A\x0D\x0A; 
 
$fp = fsockopen(ssl://.$host, 443, $errorno, $errordesc);
 
if ($fp) {print We are connected with $host;}
else
{die (I can not connect with $host: \nError: $errorno \nDescription: $errordesc);}
 
print br;
 
fputs($fp, $request);
 
while (!feof($fp))
 print  fgets($fp, 1024);
fclose($fp);
? 
 

___

Thank you in advance for any help.

Best regards,
 Jorge  mailto:[EMAIL PROTECTED]

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



[PHP] fsockopen()

2003-09-30 Thread Phil Ewington - 43 Plc
Hi All,

I am having problems with fsockopen() and wondered if anyone else has
encountered this behaviour. My problem is that when connecting to an invalid
domain I cannot trap the errors.

I have tried setting a variable then testing the value, which prints a
warning to the screen...

$sck_handle = fsockopen($hostname, $port, $errno, $errstr, $timeout);
if (!$sck_handle)
{
// socket could not be opened.
$http_statuscode = Error: . $errno . - . $errstr;
}
else
{
...
}

How can I get $errno  $errstr, are these for read/write errors rather than
socket initialisation? I need to know why the socket could not be opened so
I can give an appropriate error message.

TIA


Phil Ewington - Technical Director
--
43 Plc
35 Broad Street, Wokingham
Berkshire RG40 1AU
T: +44 (0)118 978 9500
F: +44 (0)118 978 4994
E: mailto:[EMAIL PROTECTED]
W: http://www.43plc.com

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



Re: [PHP] fsockopen()

2003-09-30 Thread Jason Wong
On Tuesday 30 September 2003 18:46, Phil Ewington - 43 Plc wrote:

 I am having problems with fsockopen() and wondered if anyone else has
 encountered this behaviour. My problem is that when connecting to an
 invalid domain I cannot trap the errors.

Have you checked that it is really an invalid domain and not simply been 
hijacked by Versign:

  http://www.techweb.com/tech/network/20030926_network

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
H. L. Mencken's Law:
Those who can -- do.
Those who can't -- teach.

Martin's Extension:
Those who cannot teach -- administrate.
*/

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



RE: [PHP] fsockopen()

2003-09-30 Thread Phil Ewington - 43 Plc
Positive, I am deliberately using invalid domains to test how to catch
errors when users misspell their domain.



-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]
Sent: 30 September 2003 12:01
To: [EMAIL PROTECTED]
Subject: Re: [PHP] fsockopen()


On Tuesday 30 September 2003 18:46, Phil Ewington - 43 Plc wrote:

 I am having problems with fsockopen() and wondered if anyone else has
 encountered this behaviour. My problem is that when connecting to an
 invalid domain I cannot trap the errors.

Have you checked that it is really an invalid domain and not simply been
hijacked by Versign:

  http://www.techweb.com/tech/network/20030926_network

--
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
H. L. Mencken's Law:
Those who can -- do.
Those who can't -- teach.

Martin's Extension:
Those who cannot teach -- administrate.
*/

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

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



Re: [PHP] fsockopen()

2003-09-30 Thread Jason Wong
On Tuesday 30 September 2003 20:39, Phil Ewington - 43 Plc wrote:
 Positive, I am deliberately using invalid domains to test how to catch
 errors when users misspell their domain.

Did you read that article (or are you aware of what it is about)?

And what invalid domains have you tried?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Life is the childhood of our immortality.
-- Goethe
*/

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



RE: [PHP] fsockopen()

2003-09-30 Thread Phil Ewington - 43 Plc
Sorry Jason, I did read the article but must have been away with the fairies
for a moment. I was testing domains that are complete rubbish but they were
all .com and .net so yes you were right and I am a complete fool ;o). Now
getting an error message 'No such file or directory' when testing on another
TLD, strange message for 'domain cannot be found', but hey life would be
boring if everyone thought along the same lines :o)


-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]
Sent: 30 September 2003 15:51
To: [EMAIL PROTECTED]
Subject: Re: [PHP] fsockopen()


On Tuesday 30 September 2003 20:39, Phil Ewington - 43 Plc wrote:
 Positive, I am deliberately using invalid domains to test how to catch
 errors when users misspell their domain.

Did you read that article (or are you aware of what it is about)?

And what invalid domains have you tried?

--
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Life is the childhood of our immortality.
-- Goethe
*/

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

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



[PHP] fsockopen server monitor

2003-09-29 Thread Cameron Metzke
Hi there,
I have been trying to make a simple monitor script using fsockopen. here it
is
--Start Code-

?php
error_reporting(0);
include 'config.php';
$domain = $_POST['domain'];
?
html
head
titlemonitor script/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
/head

body bgcolor=#00 text=#FF link=#FF vlink=#FF
alink=#FF

table width=40% border=2 cellpadding=5 cellspacing=5
bordercolor=#66 align=center
  tr
td width=50%HTTP Server :/td
td width=50%?php
// Http port connection
 $http = fsockopen($domain, $httpport, $errno, $errstr, 30);
 if (!$http)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
  tr
tdFTP Server :/td
td?php
//ftp port connection
 $ftp = fsockopen($domain, $ftpport, $errno, $errstr, 30);
 if (!$ftp)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
  tr
tdPOP Server :/td
td?php
//pop port connection
 $pop = fsockopen($domain, $popport, $errno, $errstr, 30);
 if (!$pop)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
  tr
tdIMAP Server :/td
td?php
//Imap server connection
 $imap = fsockopen($domain, $imapport, $errno, $errstr, 30);
 if (!$imap)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
  tr
tdSMTP Server :/td
td?php
//ssh port connection
 $smtp = fsockopen($domain, $smtpport, $errno, $errstr, 30);
 if (!$smtp)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
  tr
tdSSH Server :/td
td?php
//ssh port connection
 $ssh = fsockopen($domain, $sshport, $errno, $errstr, 30);
 if (!$ssh)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
  tr
tdBogus Server :/td
td?php
// bogus port
 $test = fsockopen($domain, $bogusport, $errno, $errstr, 30);
 if (!$test)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
/table

/body
/html

END CODE

all seems to work ok , except that the http and smtp ports always come up ok
even when the domain doesnt exist. I am thinking mabey it has something to
do with verisign playing with the .com names lattley?. any ideas and help
would be appreciated :)

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



[PHP] fsockopen server monitor

2003-09-29 Thread Cameron Metzke
Hi there,
I have been trying to make a simple monitor script using fsockopen. here it
is
--Start Code-

?php
error_reporting(0);
include 'config.php';
$domain = $_POST['domain'];
?
html
head
titlemonitor script/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
/head

body bgcolor=#00 text=#FF link=#FF vlink=#FF
alink=#FF

table width=40% border=2 cellpadding=5 cellspacing=5
bordercolor=#66 align=center
  tr
td width=50%HTTP Server :/td
td width=50%?php
// Http port connection
 $http = fsockopen($domain, $httpport, $errno, $errstr, 30);
 if (!$http)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
  tr
tdFTP Server :/td
td?php
//ftp port connection
 $ftp = fsockopen($domain, $ftpport, $errno, $errstr, 30);
 if (!$ftp)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
  tr
tdPOP Server :/td
td?php
//pop port connection
 $pop = fsockopen($domain, $popport, $errno, $errstr, 30);
 if (!$pop)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
  tr
tdIMAP Server :/td
td?php
//Imap server connection
 $imap = fsockopen($domain, $imapport, $errno, $errstr, 30);
 if (!$imap)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
  tr
tdSMTP Server :/td
td?php
//ssh port connection
 $smtp = fsockopen($domain, $smtpport, $errno, $errstr, 30);
 if (!$smtp)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
  tr
tdSSH Server :/td
td?php
//ssh port connection
 $ssh = fsockopen($domain, $sshport, $errno, $errstr, 30);
 if (!$ssh)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
  tr
tdBogus Server :/td
td?php
// bogus port
 $test = fsockopen($domain, $bogusport, $errno, $errstr, 30);
 if (!$test)
 {
 echo (img src=\fail.jpg\img src=\fail.jpg\img
src=\fail.jpg\);
 }

 else
 {
 echo (img src=\pass.jpg\img src=\pass.jpg\img
src=\pass.jpg\);
 }
?
/td
  /tr
/table

/body
/html

END CODE

all seems to work ok , except that the http and smtp ports always come up ok
even when the domain doesnt exist. I am thinking mabey it has something to
do with verisign playing with the .com names lattley?. any ideas and help
would be appreciated :)

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



Re: [PHP] fsockopen server monitor

2003-09-29 Thread Curt Zirzow
* Thus wrote Cameron Metzke ([EMAIL PROTECTED]):
 Hi there,
 I have been trying to make a simple monitor script using fsockopen. here it
 is
 --Start Code-
 
 ?php
 error_reporting(0);
 include 'config.php';
 $domain = $_POST['domain'];

 [... unneeded code ...]

 td width=50%?php
 // Http port connection
  $http = fsockopen($domain, $httpport, $errno, $errstr, 30);
  if (!$http)
  {

  [.. (130 lines) more unneeded  code  ..]

 
 END CODE
 
 all seems to work ok , except that the http and smtp ports always come up ok
 even when the domain doesnt exist. I am thinking mabey it has something to
 do with verisign playing with the .com names lattley?. any ideas and help
 would be appreciated :)

It seems that you've already answered your question.

rant
and playing is a rather nice term; I'd rather say something like
destroying, stealing, monopolizing, betraying, untrusting,
stupidly trying to make the 'internet' more friendly by taking
advantage of certain organizations that weren't on the ball with
the .com names.
/rant

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] fsockopen server monitor

2003-09-29 Thread Cameron Metzke
Sorry about that . Its my first post, :(
Curt Zirzow [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 * Thus wrote Cameron Metzke ([EMAIL PROTECTED]):
  Hi there,
  I have been trying to make a simple monitor script using fsockopen. here
it
  is
  --Start Code-
 
  ?php
  error_reporting(0);
  include 'config.php';
  $domain = $_POST['domain'];
 
  [... unneeded code ...]
 
  td width=50%?php
  // Http port connection
   $http = fsockopen($domain, $httpport, $errno, $errstr, 30);
   if (!$http)
   {
 
   [.. (130 lines) more unneeded  code  ..]
 
 
  END CODE
 
  all seems to work ok , except that the http and smtp ports always come
up ok
  even when the domain doesnt exist. I am thinking mabey it has something
to
  do with verisign playing with the .com names lattley?. any ideas and
help
  would be appreciated :)

 It seems that you've already answered your question.

 rant
 and playing is a rather nice term; I'd rather say something like
 destroying, stealing, monopolizing, betraying, untrusting,
 stupidly trying to make the 'internet' more friendly by taking
 advantage of certain organizations that weren't on the ball with
 the .com names.
 /rant

 Curt
 --
 I used to think I was indecisive, but now I'm not so sure.

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



[PHP] fsockopen/ssl

2003-08-14 Thread Wendy Reetz
Using php 4.3.2, apache 1.3.27, openssl .9.7b

I'm trying to open a secure connection using fsockopen(ssl://...,443...) as 
described in http://us4.php.net/manual/en/function.fsockopen.php.

I keep getting an error:  PRNG not seeded. 
OpenSSL says http://www.openssl.org/support/faq.html#USER1 says:
If the default seeding file [/dev/random or /dev/urandom] does not exist or is too 
short, the PRNG not seeded error message may occur. 
Now, both of these exist, but I'm not sure how to tell if they are too short...

has anyone used fsockopen(ssl://...) successfully?  I've read through the php site, 
apache, and openssl...but I'm not finding a solution.  Is there something that may 
have been overlooked when the 3 were compiled?  Do you need to create a certificate?

The answer may be staring me right in the face  I'm just not seeing it.Any point in 
the right direction would be appreciated.

Thanks,

Wendy


Re: [PHP] fsockopen

2003-07-22 Thread Curt Zirzow
* Thus wrote Mike Migurski ([EMAIL PROTECTED]):
  preg_match('/(!DOCTYPE.+\/html)/ms', $http_response, $html)
 
  ...puts it into $html[1]. Adjust to suit your local standards-compliance
  practices. You can also look for everything after the first instance of
  \n\n.
 
 Thats assuming that the person used the doctypehtml for the first
 item. what bout extra space, SSI, etc...
 
 SSI's wouldn't be output on port 80, and anything before the doctype is
 essentially junk anyway. Like I said, suit to taste or just pull from
 after the first \n\n -- no regexp needed in that case.

My bad, i had overlooked that ssi's get expanded before it gets to the
client.

Thanks,

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



RE: [PHP] fsockopen

2003-07-22 Thread Boaz Yahav
If you only need the HTML why don't you look up file()

http://www.weberdev.com/get_example.php3?count=729

Sincerely
 
berber
 
Visit http://www.weberdev.com/ Today!!!
To see where PHP might take you tomorrow.
Share your code : http://addexample.weberdev.com


-Original Message-
From: Doug La Farge [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 22, 2003 12:27 AM
To: [EMAIL PROTECTED]
Subject: [PHP] fsockopen


Is there a way to get fsockopen to suppress the header information it 
returns.  I have no use for the crap, have no idea how to use a regexp 
to get it out of there (nor does anyone on this list it would seem 
either).


I'd like to be able to grab a web page as it is presented to the 
browsers (as seen in view source).

HTTP/1.1 200 OK
Date: Tue, 22 Jul 2003 05:14:41 GMT
Server: Apache/1.3.27 (Unix) mod_jk/1.1.0 mod_ssl/2.8.12 OpenSSL/0.9.6g
Set-Cookie: JSESSIONID=jwjesefa81;Path=/Interface
Connection: close
Content-Type: text/html;charset=ISO-8859-1

The above crap needs to not be returned.

Any ideas?

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



RE: [PHP] fsockopen

2003-07-22 Thread Mike Migurski
Is there a way to get fsockopen to suppress the header information it
returns.  I have no use for the crap, have no idea how to use a regexp to
get it out of there (nor does anyone on this list it would seem either).

preg_match('/(!DOCTYPE.+\/html)/ms', $http_response, $html)

...puts it into $html[1]. Adjust to suit your local standards-compliance
practices. You can also look for everything after the first instance of
\n\n.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html


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



Re: [PHP] fsockopen

2003-07-22 Thread Curt Zirzow
* Thus wrote Mike Migurski ([EMAIL PROTECTED]):
 Is there a way to get fsockopen to suppress the header information it
 returns.  I have no use for the crap, have no idea how to use a regexp to
 get it out of there (nor does anyone on this list it would seem either).
 
 preg_match('/(!DOCTYPE.+\/html)/ms', $http_response, $html)
 
 ...puts it into $html[1]. Adjust to suit your local standards-compliance
 practices. You can also look for everything after the first instance of
 \n\n.

Thats assuming that the person used the doctypehtml  for the first
item. what bout extra space, SSI, etc...

Yeah I know that a proper html doc should have that doctype as the first
line, but most people dont even know what the doctype is used for if the
even know that one exists.

best to look for the first empty line, that seperates the headers and
content.

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] fsockopen

2003-07-22 Thread Mike Migurski
 preg_match('/(!DOCTYPE.+\/html)/ms', $http_response, $html)

 ...puts it into $html[1]. Adjust to suit your local standards-compliance
 practices. You can also look for everything after the first instance of
 \n\n.

Thats assuming that the person used the doctypehtml for the first
item. what bout extra space, SSI, etc...

SSI's wouldn't be output on port 80, and anything before the doctype is
essentially junk anyway. Like I said, suit to taste or just pull from
after the first \n\n -- no regexp needed in that case.

Personally, I'm using the regexp method, because I'm using the above code
in a context where the server is flakey. I need to repeat the request
immediately if PHP craps out and dies before the '/html' is output. It's
a proxy that allows for the possibility of segfaults and premature exits
and such.

looks like this if you are curious. the usleep give the server increasing
amount of chill-out time as the number of attempts is incremented:
-
do {
usleep(pow(4, $attempt));

if($fp = @fsockopen($GLOBALS['_SERVER']['HTTP_HOST'], 80, $errno, $errstr, 30)) {
fputs($fp, sprintf(GET %s?fresh=fresh HTTP/1.0\nHost: %s\nConnection: 
close\n\n,
   str_replace('proxy.php', 'view.php', 
$GLOBALS['_SERVER']['REQUEST_URI']),
   $GLOBALS['_SERVER']['HTTP_HOST']));

$html = '';
while(!feof($fp)) $html .= fgets($fp, 128);
fclose($fp);

}

} while((++$attempt = $max_tries)  !preg_match('/(!DOCTYPE.+\/html)/ms', $html, 
$matches));
-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html


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



[PHP] fsockopen

2003-07-21 Thread Doug La Farge
Is there a way to get fsockopen to suppress the header information it 
returns.  I have no use for the crap, have no idea how to use a regexp 
to get it out of there (nor does anyone on this list it would seem 
either).

I'd like to be able to grab a web page as it is presented to the 
browsers (as seen in view source).

HTTP/1.1 200 OK
Date: Tue, 22 Jul 2003 05:14:41 GMT
Server: Apache/1.3.27 (Unix) mod_jk/1.1.0 mod_ssl/2.8.12 OpenSSL/0.9.6g
Set-Cookie: JSESSIONID=jwjesefa81;Path=/Interface
Connection: close
Content-Type: text/html;charset=ISO-8859-1
The above crap needs to not be returned.

Any ideas?

Re: [PHP] fsockopen

2003-07-21 Thread Curt Zirzow
* Thus wrote Doug La Farge ([EMAIL PROTECTED]):
 Is there a way to get fsockopen to suppress the header information it 
 returns.  I have no use for the crap, have no idea how to use a regexp 
 to get it out of there (nor does anyone on this list it would seem 
 either).

I have plenty of use for the so called 'crap'. I know how to use a
regex  to strip it out of there, and your using the *wrong* function.

RTFM...
(no link provided)

 
 
 I'd like to be able to grab a web page as it is presented to the 
 browsers (as seen in view source).

That is not how it is presented to the browser. The browser presents to
you something entirely different.

 
 HTTP/1.1 200 OK
 Date: Tue, 22 Jul 2003 05:14:41 GMT
 Server: Apache/1.3.27 (Unix) mod_jk/1.1.0 mod_ssl/2.8.12 OpenSSL/0.9.6g
 Set-Cookie: JSESSIONID=jwjesefa81;Path=/Interface
 Connection: close
 Content-Type: text/html;charset=ISO-8859-1
 
 The above crap needs to not be returned.

Yes it does.

 
 Any ideas?

Of course.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



  1   2   >