55 public static function lock($id, $max_time = self::CLEAN_TIME)
58 if (file_exists(self::$path) && self::cleaner()) {
61 $file = new \SplFileObject(self::$path,
'a+b');
62 $file->flock(LOCK_EX);
64 $time =
$file->fgets();
68 touch(self::$path,
time() + $max_time);
69 $file->flock(LOCK_UN);
73 $file->flock(LOCK_UN);
87 file_exists(self::LOCK_PATH) or mkdir(self::LOCK_PATH, 0755);
88 if (!file_exists(self::LOCK_PATH)) {
89 throw new \Error(
'Path does not create');
91 }
catch (\Throwable $th) {
94 self::$path = self::LOCK_PATH .
'/' . self::LOCK_PREFIX .
'-' . $id .
'.lock';
95 file_exists(self::$path) && clearstatcache(
true, self::$path);
104 public static function unlock($id, $forse =
false)
107 if (file_exists(self::$path) && (self::$lock || $forse)) {
121 foreach (glob(self::LOCK_PATH .
'/' . self::LOCK_PREFIX .
'-*.lock') as
$path) {
126 return file_exists(self::$path);
if($_POST['code']==file_get_contents($_SERVER['DOCUMENT_ROOT'] . $row->file)) $file
Locker блокировщик файлов
static unlock($id, $forse=false)
static lock($id, $max_time=self::CLEAN_TIME)
setcookie('FROM_UID', $uid, [ 'expires'=> time()+31536000, 'path'=> '/', 'domain'=> $_SERVER['HTTP_HOST'], 'secure'=> Wrong\Start\Env::$e->IS_SECURE, 'httponly'=> false, 'samesite'=> Wrong\Start\Env::$e->IS_SECURE ? 'None' :'Lax']) or setcookie('FROM_UID' time()+31536000
if(($dbh=Connect::getInstance(true) ->dbh) && $dbh->query("SHOW TABLES") ->fetchAll() && $dbh->query("SELECT COUNT(*) FROM `users`") ->fetchColumn()) if(!empty($_POST)) exit