Skip to content

Instantly share code, notes, and snippets.

@whazor
Created January 3, 2012 14:36
Show Gist options
  • Save whazor/1555118 to your computer and use it in GitHub Desktop.
Save whazor/1555118 to your computer and use it in GitHub Desktop.
Filelock
<?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