Script

Show Script

Showing code for: moddate_demo.irev

Back

<?rev
   -- Standard header -------------------------------
   put "Troz : : On-Rev" into tHeader
   include "../../includes/header.irev"
   
   include "../../includes/menu.irev"
   --------------------------------------------------
?>

<?rev include "includes/scriptlink.irev" ?>
<h1>Modification date demo</h1>

I have written a moddate include file which returns 
   the modification date of the current file. <br />
Here is what it returns for this page: <br />

<?rev
   include "includes/moddate.irev"
?>

<p>To implement this in your own pages, get the
<a href="showscript.irev?showscript=includes/moddate.irev">
script of the moddate.irev file</a>, make a moddate.irev file, <br />
change it to use your local time zone, save it in your includes folder, 
and use it as follows:

<code><pre>
&lt;?rev
   include "includes/moddate.irev"
?&gt;
</pre></code>

<p>
This works by looking at the $_SERVER["PATH_TRANSLATED"] parameter, which for this page is:
<p>
<code><pre>
$_SERVER["PATH_TRANSLATED"]:   <?rev put $_SERVER["PATH_TRANSLATED"] ?>
</pre></code>

<p>The shell command: <code>ls -l "<?rev put $_SERVER["PATH_TRANSLATED"]?>"</code>
lists the details for the specified file.

<?rev
   put $_SERVER["PATH_TRANSLATED"] into tPath
   put shell("ls -l " & quote & tPath & quote) into tListing
   put line 1 of tListing into tFileData
   put "<code><pre>" & tFileData & "</pre></code>"   
?>

<p>And the modification date is extracted from that line, 
   and can then be formatted in any way you wish, <br />
remembering that sometimes the time will be shown and sometimes the year:

<?rev
   delete word 1 to 5 of tFileData
   replace tPath with empty in tFileData
   put "<code><pre>" & tab & tFileData & "</pre></code>"   
?>

<p>For checking purposes, here is the data for every irev file in my samples folder:

<?rev
-- put $_SERVER["PATH_TRANSLATED"] into tFolder
put shell("ls -l ../samples") into tListing
filter tListing with "*.irev"
replace cr with "<br />" in tListing
put "<code><pre>" & tListing & "</pre></code>"   
?>


<?rev
   -- Standard footer -------------------------------
   include "includes/showIncludes.irev"
   include "../../includes/footer.irev"
   --------------------------------------------------
?>