you may need to use filemtime() and not filectime();
Jim Lucas wrote:
Ryan S wrote:
Hey all,
Heres what i am trying to do:
When someone sends a message from my site, i take their ip address and
make a file with their ip address in a directory called
"hash-directory", the file looks like this: 169.34.534.243.txt
I want to make sure they cant send too many messages because of the
potential to spam, so I want to limit them to sending a message every
X number of minutes... heres what i have written (its not working for
some damn reason)
############# Start PHP file ################
if(isset($_SERVER['REMOTE_ADDR']))
{$rem_address=$_SERVER['REMOTE_ADDR'];}
$directory_with_files="hash-directory/";
$threshold = strtotime('-2 minutes');
echo "File created on: <b>".$rem_address .".txt - ". date("F d Y
H:i:s.", filectime($directory_with_files.$rem_address.".txt"))."
".$file_time_details[0]."</b><br><br>";
if (file_exists($directory_with_files.$rem_address.".txt")) {
if
(getdate(filectime($directory_with_files.$rem_address.".txt")) <
$threshold)
From the manual
This returns a timestamp
int strtotime ( string $time [, int $now ] )
This returns an hash array with all the date/time info in it.
array getdate ([ int $timestamp ] )
You are trying to compare two things that are completely different.
Get rid of the getdate() function. All you need is the filectime()
call, it returns a unix timestamp.
{echo "<b>Please wait more than 1 minute before
posting.</b><br>";}
else{echo "<b>Enough time has elapsed.</b><br>";}
}
############# END PHP file ################
Where am I going wrong?
Thanks!
Ryan
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
____________________________________________________________________________________
Looking for last minute shopping deals? Find them fast with Yahoo!
Search.
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php