php curl retrieve modification date of .php file -
i've been struggling hours , can't seem find myself answer.
i'm making script retrieve modification dates of several files on external servers. since i'm using curl retrieving these data, in case show data of files need request accept .php file..
little script of use..
function modified($url){ $curl = curl_init($url); curl_setopt($curl, curlopt_nobody, true); curl_setopt($curl, curlopt_url, $url); curl_setopt($curl, curlopt_returntransfer, true); curl_setopt($curl, curlopt_filetime, true); $result = curl_exec($curl); $timestamp = curl_getinfo($curl, curlinfo_filetime); if ($timestamp != -1): echo date("y-m-d h:i:s", $timestamp); else: echo 'no timestamp found'; endif; } echo modified('http://myurl.com/');
am doing wrong or retrieving .php files in case out of possibility.
what trying not possible.
a way around write php file, able check filemtime
of given php file on server.
filemtime.php
<?php // requested file name $filename = isset($_get['filename']) ? $_get['filename'] : ''; // return result if (file_exists($filename)) { echo filemtime($filename); } else { echo 0; } ?>
then usage this:
<?php // load last time index.php modified on server $filemtime = intval(file_get_contents('http://yourdomain.com/filemtime.php?filename=index.php')); // parse result echo 'index.php modified on '. date('d/m/y h:i:s a', $filemtime); ?>
Comments
Post a Comment