Comparing file creating dates...
| From: | Ryan S | Date: | Sat, 22 Mar 2008 16:01:44 +0000 |
| Subject: | Comparing file creating dates... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-271978@lists.php.net to get a copy of this message | ||
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)
{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