Created
January 3, 2012 14:36
-
-
Save whazor/1555118 to your computer and use it in GitHub Desktop.
Filelock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file = dirname( __FILE__ ).'/lock.txt'; | |
$lock = file_exists($file); | |
if($lock) $lock = file_get_contents($file); | |
if($lock && $lock != 'unlocked' && ((time() - $lock) < 120)) | |
die('Het scriptje is al bezig! Wacht '.(120 - (time() - $lock)).'s.'); | |
else file_put_contents($file, time()); | |
echo 'ZWARE OPERATIE'; | |
file_put_contents('lock.txt', 'unlocked'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment