Вход Регистрация
Файл: adultscript-2.0.3-pro/files/libraries/framework/file.php
Строк: 51
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VFile
{
    public static function 
ext($file)
    {
        return 
strtolower(substr($filestrrpos($file'.')+1));
    }
    
    public static function 
name($file)
    {
        return 
basename($file);
    }
    
    public static function 
strip_ext($file)
    {
        return 
substr($file0strrpos($file'.'));
    }
    
    public static function 
exists($file)
    {
        return (bool) (
file_exists($file) && is_file($file) && is_readable($file));
    }
    
    public static function 
safe($file$clean true)
    {
        if (
strpos($file"") !== false) {
            throw new 
Exception('A file (path or name) cannot contain NUL bytes.');
        }

        
$parts explode('/'$file);
        
$level 0;
        foreach (
$parts as $part) {
            if (
'..' === $part) {
                --
$level;
            } elseif (
'.' !== $part) {
                ++
$level;
            }
    
            if (
$level 0) {
                throw new 
Exception(sprintf('Looks like you try to use a file outside of configured directories (%s).'$path));
            }
        }
        
        if (
$clean) {
            
$regex  = (utf8_is_ascii($file)) ? '/[^A-Za-z0-9 -_.]+/' '/[^pLpNpZs-_.]+/u';
            
$file   preg_replace($regex''$file);
        }
    
        return 
$file;
    }
    
    public static function 
read($file)
    {
        return 
file_get_contents($file);
    }
    
    public static function 
write($file$data$append=false)
    {
        if (
$append !== false) {
            return (bool) 
file_put_contents($file$dataFILE_APPEND LOCK_EX);
        } else {
            return (bool) 
file_put_contents($file$dataLOCK_EX);
        }
    }
    
    public static function 
delete($file)
    {
        if (
file_exists($file) && is_file($file)) {
            
unlink($file);
        }
    }
}
?>
Онлайн: 0
Реклама