Файл: _core/_class/cache_user.php
Строк: 40
<?php
# mark core v1.0
# author Drk in
# date 24.10.19
# class cache user
class cache_user {
public static function get($ID) # get
{
$file = cache."_user/{$ID}.data";
$cache = @file_get_contents($file);
return unserialize($cache);
}
public static function save($ID) # save
{
$file = cache."_user/{$ID}.data";
$cache = DB :: $dbh -> queryFetch("SELECT * FROM user WHERE id = ? LIMIT 1;", array($ID));
$cache = serialize($cache);
@file_put_contents($file, $cache);
}
public static function check($ID) # check
{
$file = cache."_user/{$ID}.data";
if(!file_exists($file)):
self::save($ID);
endif;
return self::get($ID);
}
public static function ch($ID) # check file
{
$file = cache."_user/{$ID}.data";
if(file_exists($file)):
return true;
else:
return false;
endif;
}
public static function time($ID) # time aut
{
$file = cache."_user/{$ID}.data";
if(@filemtime($file) < time() - 30):
DB :: $dbh -> query("UPDATE user SET data_aut = ?, ip = ?, ua = ? WHERE id = ? LIMIT 1;", array(time(),ip,ua,$ID));
self::save($ID);
endif;
}
public static function online() # online user
{
$file = cache."_user/online.data";
if(@filemtime($file) < time() - 30):
$cache = DB :: $dbh -> querySingle("SELECT count(id) FROM user WHERE data_aut > ?;", array(time()-600));
@file_put_contents($file, $cache);
else:
$cache = @file_get_contents($file);
endif;
return $cache;
}
}
?>