how to ‘implode’ a URL ?? – PHP

  php

Q(Question):

hi,

using PHP 4.3.3 and Apache (ADVX) 2.0.47 and i want to get the contents of
my SETI stats site :

$personal = implode("",
@file("http://setiathome.ssl.berkeley.edu/fcgi-bin/fcgi?email=$email&cmd=user_stats_new"));

which gives me this :

Warning: implode(): Bad arguments. in
/home/rob/www/php/phpMySetiStats/download.php on line 4

what am i doing wrong ? i used this code a couple of months back on somewhat
older versions of PHP/Apache in Windows2000 and it worked … ??

A(Answer):

"Rob" <un*****@anonymous.net> wrote in message
news:vt************@corp.supernews.com…

hi,

using PHP 4.3.3 and Apache (ADVX) 2.0.47 and i want to get the contents of
my SETI stats site :

$personal = implode("",
@file("http://setiathome.ssl.berkeley.edu/fcgi-bin/fcgi?email=$email&cmd=use
r_stats_new"));
which gives me this :

Warning: implode(): Bad arguments. in
/home/rob/www/php/phpMySetiStats/download.php on line 4

what am i doing wrong ? i used this code a couple of months back on
somewhat older versions of PHP/Apache in Windows2000 and it worked … ??

Or

you could just read it from

$SETI_DIRECTORY/user_info.sah
……
nresults=8505

A(Answer):

On Wed, 17 Dec 2003 00:03:19 +0100, Rob <un*****@anonymous.net> wrote:

using PHP 4.3.3 and Apache (ADVX) 2.0.47 and i want to get the contents of
my SETI stats site :

$personal = implode("",
@file("http://setiathome.ssl.berkeley.edu/fcgi-bin/fcgi?email=$email&cmd=user_stats_new"));

which gives me this :

Warning: implode(): Bad arguments. in
/home/rob/www/php/phpMySetiStats/download.php on line 4

what am i doing wrong ? i used this code a couple of months back on somewhat
older versions of PHP/Apache in Windows2000 and it worked … ??

You’ve suppressed warnings with @, and you’re using the return value from
file() directly. So there’s two easy places you can help yourself:

(a) Remove the @, and look at any warning produced.
(b) Execute the file() separately and use var_dump to examine what it returns.

Read the manual page, and what file() can return: http://uk2.php.net/file
Which of the two possible return types could give a problem with implode()?

And anyway – if you’re on 4.3, you may as well use file_get_contents().


Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

A(Answer):

Andy Hassall wrote:

You’ve suppressed warnings with @, and you’re using the return value from
file() directly.

ah, ok … now i get this (e-mail edited!) :

Warning: file(): php_network_getaddresses: getaddrinfo failed: Temporary
failure in name resolution in /home/rob/www/php/phpMySetiStats/download.php
on line 7

Warning: file(http://…@<my email>&cmd=user_stats_new): failed to open
stream: Resource temporarily unavailable in
/home/rob/www/php/phpMySetiStats/download.php on line 7

but using the URL directly from Mozilla gives me the stats page, so it is
there and available.
And anyway – if you’re on 4.3, you may as well use file_get_contents().

ok.
btw ; in this case it gives the same error :

Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed:
Temporary failure in name resolution in
/home/rob/www/php/phpMySetiStats/download.php on line 8

so there’s probably something wrong with the way i supply the URL …
i’ll keep trying 😉

A(Answer):

Rob wrote:

Andy Hassall wrote:

You’ve suppressed warnings with @, and you’re using the return value from
file() directly.

ah, ok … now i get this (e-mail edited!) :

Warning: file(): php_network_getaddresses: getaddrinfo failed: Temporary
failure in name resolution in /home/rob/www/php/phpMySetiStats/download.php
on line 7

Warning: file(http://…@<my email>&cmd=user_stats_new): failed to open
stream: Resource temporarily unavailable in
/home/rob/www/php/phpMySetiStats/download.php on line 7

but using the URL directly from Mozilla gives me the stats page, so it is
there and available.

And anyway – if you’re on 4.3, you may as well use file_get_contents().

ok.
btw ; in this case it gives the same error :

Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed:
Temporary failure in name resolution in
/home/rob/www/php/phpMySetiStats/download.php on line 8

so there’s probably something wrong with the way i supply the URL …
i’ll keep trying 😉

You may want to urlencode() the $email address. If that doesn’t work, maybe the
site uses a redirect or something? If so try fsockopen().

Regards,
Shawn

Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com

A(Answer):

Use a sniffer/packet capture, type the url into a browser, and watch
the header info, this could help you debug.

as was said, you may need to use a socket, then supply a cookie or
useragent or something.

There was a time when I had a page accessing an https document on
wellsfargos website, and then they restricted access to specific user
agents (netscape and ie only) so i used a socket and wrote the agent
header.
Mike Bradley
http://gzen.myhq.info — free online php tools

A(Answer):

Ok, me again

I wrote a small utility that you can use, if you using a windows 2000,
or xp (i have not tested on others)

This little program will let you watch the header exchage between your
browser and your server.

You just tell your browser to use a proxy/sock server at
127.0.0.1:8080 and your ready to go (be sure to remove the proxy/sock
setting from your browser when your done with the program or you will
be wondering why you cant surf)

You can find it here: http://gzen.myhq.info/sockview.php

Mike Bradley
http://gzen.myhq.info — free online php tools

LEAVE A COMMENT