Open sidebar
<?php $genericLockFile = './' . $_SERVER['PHP_SELF'] . explode('.', $argv) . '.lock'; if ($genericLock = fopen($genericLockFile, "w")) { // create the lock if (flock($genericLock, LOCK_EX | LOCK_NB)) { echo "***************\n Creating lock for this script...\n ***************\n"; } else { die("Lock exists for this file. Stopping script..\n"); } } else { die("Script requires a lock but could not be created!\n"); } // release the lock if this script is executed register_shutdown_function(function() use ($genericLock) { echo "***************\n Releasing lock for this script...\n ***************\n"; flock($genericLock, LOCK_UN); fclose($genericLock); }, $genericLockFile);
Close sidebar
Back
Please note that all pasted data is publicly available.
X (fomerly Twitter)
GitHub
Use setting
Back
Please note that all pasted data is publicly available.
X (fomerly Twitter)
GitHub
Use setting