Файл: _core/_class/cache_size.php
Строк: 25
<?php
# mark core v1.0
# author Drk in
# date 24.10.19
# class cache size
class cache_size {
public static function get($ID,$lvl) # get
{
$file = cache."_size/{$ID}.data";
$cache = @file_get_contents($file);
return unserialize($cache);
}
public static function save($ID,$lvl) # save
{
$file = cache."_size/{$ID}.data";
$size = DB :: $dbh -> queryFetch("SELECT sum(size*cn) FROM itm,inv WHERE itm.id = inv.thing AND inv.user = {$ID} AND hide = 0");
$size_max = $lvl * 10;
$cache = ['size' => ($size['sum(size*cn)'] == null || $size['sum(size*cn)'] < 0 ? 0 :$size['sum(size*cn)']), 'max' => $size_max];
$cache = serialize($cache);
@file_put_contents($file, $cache);
}
public static function check($ID,$lvl) # check
{
$file = cache."_size/{$ID}.data";
if(!file_exists($file)):
self::save($ID,$lvl);
endif;
return self::get($ID,$lvl);
}
}
?>