adrian.s85 Posted June 7, 2009 Share Posted June 7, 2009 Hi everybody,I have a problem with the filemtime() function on my website, I use it to display a "last modified on dd.mm.yyyy" string in the footer of every page.The code I use is the following and it works for every page except for one: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/main_template.dwt" codeOutsideHTMLIsLocked="false" --><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><!-- InstanceBeginEditable name="doctitle" --><title>Round the World</title><!-- InstanceEndEditable --><link href="../resources/style4.css" rel="stylesheet" type="text/css" /><!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --></head><body><center><div id="header"> <div class="name">name</div> <ul id="menu"> <li><a href="../home.php">HOME</a></li> <li><a href="../software.php">SOFTWARE</a> <ul class="menu_list"> <li><a href="../software/eth_sms.php">ETH SMS</a></li> <li><a href="../software/red_theme.php">RED THEME</a></li> <li><a href="../software/xudoku.php">XUDOKU</a></li> </ul> </li> <li><a href="../gallery.php">GALLERY</a> <ul class="menu_list"> <li><a href="world_gallery.php">WORLD</a></li> </ul> </li> <li><a href="../cv.php">CURRICULUM</a></li> <li class="contact"><a href="../contact_form.php">CONTACT</a></li> </ul></div><div class="page"><!-- InstanceBeginEditable name="title" --> <div class="title">ROUND THE WORLD</div> <!-- InstanceEndEditable --> <table width="100%" style="border:none"> <tr> <td valign="top"><!-- InstanceBeginEditable name="body" --><center> <table class="gallery"><?php $pict = $_GET['pict']; if(!$pict) { //visualize entire gallery $dir = chdir("world_images"); $pictures = glob("*.jpg"); $rows = ceil(count($pictures)/3); //shuffle($pictures); sort($pictures, SORT_NUMERIC); for ($i = 0; $i < $rows; $i++) { ?> <tr> <?php for ($j = 0; $j < 3; $j++) { ?> <td> <?php if (current($pictures)) { echo("<a href='world_gallery.php?pict=" . current($pictures) . "'><img class='image' border='0' alt='' src='world_thumbnails/" . current($pictures) . "' /></a>"); $a = next($pictures); } ?> </td> <?php } ?> </tr> <?php } } else { //visualize given picture ?> <tr> <td> <img class="image2" alt="" src="world_images/<?php echo $pict; ?>" /> </td> </tr> <?php }?> </table> </center><!-- InstanceEndEditable --> </td> <td valign="top"><!-- InstanceBeginEditable name="index" --><?php if (!$pict) { ?> <div class="index"> <p class="title">description</p> <p class="text">This is a selection of some of the pictures I took during my trips around the world. Please enjoy.</p> <a class="h1" href="../gallery.php">back to index</a> </div> <?php } else { $dir = chdir("world_images"); $pictures = glob("*.jpg"); $tot = count($pictures); sort($pictures, SORT_NUMERIC); //find prev and next $key = array_search($pict,$pictures); $prev2 = ($key + $tot - 2) % $tot; $prev1 = ($key + $tot - 1) % $tot; $next1 = ($key + 1) % $tot; $next2 = ($key + 2) % $tot; ?> <div class="index"> <p class="title">navigation</p> <a class="h1" href="world_gallery.php">↑ back to gallery</a> <br /> <br /> <a href='world_gallery.php?pict=<?php echo $pictures[$prev2] . "'>" . "<img class='thumb0' src='world_thumbnails/" . $pictures[$prev2] . "' alt='" . $pictures[$prev2] . "' />"; ?></a> <br /> <a href='world_gallery.php?pict=<?php echo $pictures[$prev1] . "'>" . "<img class='thumb1' src='world_thumbnails/" . $pictures[$prev1] . "' alt='" . $pictures[$prev1] . "' />"; ?></a> <br /> <a href='world_gallery.php?pict=<?php echo $pictures[$key] . "'>" . "<img class='thumb2' src='world_thumbnails/" . $pictures[$key] . "' alt='" . $pictures[$key] . "' />"; ?></a> <br /> <a href='world_gallery.php?pict=<?php echo $pictures[$next1] . "'>" . "<img class='thumb1' src='world_thumbnails/" . $pictures[$next1] . "' alt='" . $pictures[$next1] . "' />"; ?></a> <br /> <a href='world_gallery.php?pict=<?php echo $pictures[$next2] . "'>" . "<img class='thumb0' src='world_thumbnails/" . $pictures[$next2] . "' alt='" . $pictures[$next2] . "' />"; ?></a> </div> <?php }?><!-- InstanceEndEditable --> </td> </tr> </table><br /><div class="footer">© 2009 - designed by <a class="footer" href="../contact_form.php">my name</a> - <?php $file = basename($_SERVER["PHP_SELF"]); echo "page last modified on " . date("d.m.Y",filemtime($file));?></div></div></center></body><!-- InstanceEnd --></html> Link to comment Share on other sites More sharing options...
justsomeguy Posted June 8, 2009 Share Posted June 8, 2009 Check this instead:http://www.php.net/manual/en/function.getlastmod.php Link to comment Share on other sites More sharing options...
adrian.s85 Posted June 10, 2009 Author Share Posted June 10, 2009 thanks a lot! i never saw this function!getlastmod() does work. It works on every page.but i still don't understand the strange error that i was getting with filemtime().anyway, thanks for the help! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.