|
Posted by Pedro Graca on 01/21/06 01:17
Steel wrote:
>
> <?php
> clearstatcache();
> $FileName = 'sem.txt';
> $origtime = getdate(filemtime($FileName));
>
> //these following date are they of some type?
> $Today=strtotime("now");
> $Modifile=filemtime($FileName);
Yes. Now it's ok to compare them. They're both UNIX timestamps.
But I'd do it /just/ a little differently. You're calling the function
filemtime() twice but you may remove one of those calls with some
reordering of the lines.
$FileName = 'sem.txt'; ### repeated to mark changes
$Modifile = filemtime($FileName);
$origtime = getdate($Modifile);
$Today = strtotime("now"); ### repeated to mark changes
> if ($Today>$Modifile)
> {
> $newtime = mktime(2, 0, 0, $origtime['mon'],
> 1+$origtime['mday'],$origtime['year']);
> touch($FileName, $newtime);
So, if you do this shortly before midnight, the new file time will be
set to "expire" in a little more than two hours. If you don't mind about
such a short time, that's ok :-)
> if ($handle = opendir('./cgi-bin/sessions')) {
>
> while (false !== ($file = readdir($handle))) {
> if ($file != "." && $file != "..")
> {unlink("./cgi-bin/sessions/" . $file);}
> }
You need to work on your indenting :-)
> closedir($handle);
> }
> }
> ?>
>
> Now work?
Looks like it should. I didn't test it.
--
If you're posting through Google read <http://cfaj.freeshell.org/google>
Navigation:
[Reply to this message]
|