You could try something like this:
<?php
$file = fopen ("http://www.bla.com/bla.htm", "r");
if (!$file)
{
echo "<img src=\"red.gif\" height=\"10\" width=\"10\">";
}
else
{
echo "<img src=\"green.gif\" height=\"10\" width=\"10\">";
}
?>
You could try something like this:
<?php
$file = fopen ("http://www.bla.com/bla.htm", "r");
if (!$file)
{
echo "<img src=\"red.gif\" height=\"10\" width=\"10\">";
}
else
{
echo "<img src=\"green.gif\" height=\"10\" width=\"10\">";
}
?>
Originally posted by batman
You could try something like this:
<?php $file = fopen ("http://www.bla.com/bla.htm", "r"); if (!$file)
{ echo "<img src=\"red.gif\" height=\"10\" width=\"10\">"; } else { echo "<img src=\"green.gif\" height=\"10\" width=\"10\">"; } ?>[/B]
It doesn't works.
I always get green picture even if the file not exists.
Here is my code:
<?php
$file = fopen ("http://free.x3.hu/bighed/valami.zip", "r");
if (!$file)
{
echo "<img src=\"status_red.gif\" height=\"20\" width=\"20\">";
}
else
{
echo "<img src=\"status_green.gif\" height=\"20\" width=\"20\">";
}
?>
Something else?
<?php
$file = "http://free.x3.hu/bighed/valami.zip";
$fp = fsockopen ($file, 80);
if (!$fp)
{
echo "<img src=\"status_red.gif\" height=\"20\" width=\"20\">";
}
else
{
echo "<img src=\"status_green.gif\" height=\"20\" width=\"20\">";
}
?>
Try that,
I got this error message:
Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: gethostbyname failed in C:\www\bighed\bighed_temp\ping\file.php on line 3
Warning: fsockopen() [function.fsockopen]: unable to connect to http://free.x3.hu/bighed/valami.zip:80 in C:\www\bighed\bighed_temp\ping\file.php on line 3
The first parameter of fsockopen() is the domain isn't it?
But how can I put in the file name?
<?php
$file = "http://free.x3.hu/bighed/valami.zip";
$fp = fsockopen ($file, 2082);
if (!$fp)
{
echo "<img src=\"status_red.gif\" height=\"20\" width=\"20\">";
}
else
{
echo "<img src=\"status_green.gif\" height=\"20\" width=\"20\">";
}
?>
Just keep changing the # after the $file till it works. I am not sure what socket number it is.
And where can I watch this number?
It's different on all server or not?
Not sure. Try the code I posted above and see if it works with the number 2082.
It isn't working. :mad:
I think that the problem is not the socket number...
I wrote a script which tries the socket numbers and I tried the first 11000 numbers!
So it's not good..
A question: Is this url correct??? http://free.x3.hu/bighed/valami.zip:2654
So the socket number comes behind the file name?
Anything else?
Yes the socket number comes after. yes the url is correct. No, I don't have any more ideas. sorry about that.
OK, no problem!
But I discowared why I get always green picture!!!
If the file doesn't exists, I get the 404 error which is always exist, so I always get the green pic.
Yes, forgot about that. I used to have a way around this, but forgot how. LOL If I remember, I'll tell you.
hmm..
Hi!
Thanx for the script, but the problem is the same:
I always get the "File found" message, because of the 404 error.
yeah, I thought I had it working then, now it's not, strange but true
ok, try this, from my system this is working;
hope it works for you
<?php
$file = "http://free.x3.hu/bighed/index.html";
$fp = fopen($file,"r");
$getid = substr($fp,strlen($fp)-1);
if( (integer)$getid==2 )
{
print "Could not open file or file does not exist";
}
else {
print "File Found $file";
}
fclose($fp);
?>
btw - make sure that allow_url_fopen is set to [On] on the server that your using, it probably won't work for all servers dependant upon the setting but On is the default setting.
but again, hope it helps!
It's much better and it's working!
Thank you Xoid!
My homepage is on a free server, and fopen disabled
But the script is good...
hmm... are you sure that file_exists() doesn't work? I've tried fsockopen but it doesn't work either.
apart from the solution I posted I don't really know what else to try, sorry