Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return last date modified of file held on remote server.

Status
Not open for further replies.

monkey64

Technical User
Joined
Apr 27, 2008
Messages
69
Location
GB
I have 2 webservers.
Webserver #1 has a file index.php, and I would like to know the last date modified property of the file. Using this code, it is quite simple:

Code:
<?
$filename = 'index.php';
if (file_exists($filename)) {
    $a =  date ("F d Y", filemtime($filename));
	echo $a;
}
?>

Works locally, BUT
From Webserver #2, I need to return the last date modified property of the index.php file held on Webserver #1. Is it possible?
 
if the two webservers on the same subnet and the relevant ports are open then they can just attach as network shares.
otherwise you could write an applet on the webserver1 that listens as a soap service (or similar) and returns the filemodified time in return for a properly formed request.
or perhaps ssh using the relevant php extension (ssh2).
or maybe use the ftp extensions to php

 
Thanks jpadie.
I think I overcomplicated this...
The easiest way to do this, would be to run the above script on Webserver#1, and simply read the html source of the page from Webserver#2, to give the date modified.

Something like this:

Code:
$handle = @fopen("mywebserver.com/page.php", "rt");
$source_code = fread($handle,9000);

Thanks anyway.
 
yup - that was option 2 from my list above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top