Forum Moderators: coopster

Message Too Old, No Replies

Checking remote server for availablity

         

Giljorak

3:53 pm on Nov 6, 2003 (gmt 0)

10+ Year Member



I have some images and downloadable files that I keep on my ISP's server in my personal webspace. I do this to save bandwidth on my DSL line into my home server here at the house. The ISP is going through a bunch of network reconfigs. At times when trying to retrieve these images and files they are not available. No problem I have them hosted on my home server as well. I have them duplicated so I don't get a bunch of emails from upset people saying they couldn't download my scripts. I am checking the availability of the remote server with the following code:


error_reporting(0);
$there = include('isp.server/~myaccount/bummer.txt');
if ($there){
$url="isp.server/~myaccount/";
}else{
$url="";
}
This is a 1x20 default labeled command window. Right-click on image and select save as to download.
<a href="<?php print $url;?>path/file1.xml">
<img src="<?php print $url;?>images/imageoffile1.png" /></a>

The bummer.txt file is an empty text file that resides on the remote server.
This works just fine. I am just wondering is there a better way to do this?

Thanks,
Tim

coopster

1:40 am on Nov 7, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Better way to do what, Giljorak? I'm not sure folks understand your request. You'll have to explain or give a bit more detail if you could please.

Giljorak

2:57 am on Nov 7, 2003 (gmt 0)

10+ Year Member



Sorry,
By availability I mean am I able to retrieve a requested file(s) from the remote server.
This is the command I am using to check the availability of my files on the remote server:


$there = include('isp.server/~myaccount/bummer.txt');

If the remote server is available the variable $there will contain the contents of bummer.txt which in this case is nothing as bummer.txt is blank. However $there is not NULL so I can then set the variable $url to the remote server.

If the remote server is unavailable the varible $there will be NULL and I'll know to set the $url variable to my local server.

What I am asking is there a better way to check for the availability of a requested file(s) on the remote server?

I hope that clears it up.
Thanks

NickCoons

4:21 am on Nov 7, 2003 (gmt 0)

10+ Year Member



Giljorak,

<I am just wondering is there a better way to do this?>

Are you having any issues using this method? It looks like it would work sufficiently. I'm not sure why you'd be interested in changing it.

As far as availability goes, it depends on the reason the images may not be available. If the consistent problem is that your ISP's server is down, or their network connection goes down, then this method would be just fine.

On the other hand, if they are having file system problems whereas some files are available and others are not, then proving that bummer.txt is available doesn't prove that the requested image is also. The way to do that would be to include the image instead. The problem, of course, is that it doesn't help with the bandwidth issue you're looking to avoid in the first place :-).

I would assume the former (that your ISP's network is having issues), so either the entire server is available or it's not. Therefore, I believe your current method to be just fine.