Вход Регистрация
Файл: adultscript-2.0.3-pro/files/libraries/framework/filter.php
Строк: 53
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VFilter
{
    protected 
$cfg = array();
    public function 
__construct()
    {
        
$this->cfg = VF::cfg('library.filter');
    }
    
    public function 
getDriver()
    {
        
VF::load('framework.filter.'.$this->cfg['driver']);
        
$filter_class = 'VFilter_'.$this->cfg['driver'];
        
        return 
$filter = new $filter_class();
    }
    
    public function 
get($var, $type='STRING', $source='POST')
    {
        
$type        = strtoupper($type);
        
$source        = strtoupper($source);
        
        switch (
$source) {
            case 
'POST':
                
$source    = $_POST;
                break;
            case 
'GET':
                
$source    = $_GET;
                break;
            case 
'SERVER':
                
$source    = $_SERVER;
                break;
            case 
'COOKIE':
                
$source    = $_COOKIE;
                break;
            case 
'FILES':
                
$source    = $_FILES;
                break;
            case 
'ENV':
                
$source    = $_ENV;
                break;
            default:
                throw new 
VException('Application Error! Invalid filter source!');
        }
        
        
$input        = (isset($source[$var])) ? trim($source[$var]) : NULL;
        if (
$input === NULL) {
            if (
$type == 'STRING' OR $type == 'RAW') {
                return 
NULL;
            }
            
            if (
$type == 'BOOL') {
                return 
FALSE;
            }
            
            return 
0;
        }
        
        switch (
$type) {
            case 
'INT':
            case 
'INTEGER':
                
$input     = (int) $input;
                break;
            case 
'FLOAT':
            case 
'DOUBLE':
                
$input     = (float) $input;
                break;
            case 
'BOOL':
            case 
'BOOLEAN':
                
$input     = (bool) $input;
            case 
'STRING':
                
$input    = $this->clean($input);
                break;
            case 
'RAW':
                return 
$input;
            default:
                
$input     = $this->clean($input);
                break;
        }
        
        return 
$input;
    }
    
    protected function 
__decode($input)
    {
        
$trans_tbl     = get_html_translation_table(HTML_ENTITIES);
        foreach(
$trans_tbl as $k => $v) {
            
$ttr[$v] = utf8_encode($k);
        }
        
$input         = strtr($input, $ttr);
        
$input         = preg_replace('/&#(d+);/me', "chr(\1)", $input);
        
$input         = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\1)", $input);
        
        return 
$input;
    }
}
?>
Онлайн: 2
Реклама