Reputation: 8101
I have a MySQL database with some URLs in it. One URL per row. Each URL has my script on it. What I am wanting to do, is check if the file is still there via a PHP script. Not check if it 404'd, but rather check if it has been modified or replaced. Is this possible? If so, how would it be accomplished?
I was thinking making the remote file echo some string, and having the local file check the page for that string, but that seems a little inefficient and sloppy.
EDIT: The remote files don't output any data to the remote users, they trigger internal scripts, so remote users would only see a white page. (The checking script would only see this as well)
Upvotes: 1
Views: 565
Reputation: 31300
You may also be able to use stat
on a remote file and check the mtime
record.
Upvotes: 0
Reputation: 1361
just use
md5_file('http://path.to/file');
and store the hash for checking later
Upvotes: 1
Reputation: 4427
Well you can ask to the file to send his md5 under certain conditions, for example:
if($_GET['md5hash']==true)
{
echo md5($_SERVER['SCRIPT_FILENAME']);
}
You can easily understand if your script is changed by receiving his md5 or receiving something different by his md5, but i don't know what is the score for you.
Upvotes: 1
Reputation: 154533
MD5()
or SHA1()
hash.There are other ways (such as the Last-Modified
HTTP header), but they don't work with all servers.
Upvotes: 3