<?php
defined('_CMEX_') or die('Error. You don`t have permision to access.');
class Filter {
public function num($var) {
$var = abs(intval($var));
return $var;
}
public function txt($var) {
$var = trim($var);
$var = htmlspecialchars($var, ENT_QUOTES, 'UTF-8');
$var = strtr($var, array(chr(0)=> '', chr(1)=> '', chr(2)=> '', chr(3)=> '', chr(4)=> '', chr(5)=> '', chr(6)=> '', chr(7)=> '', chr(8)=> '', chr(9)=> '', chr(10)=> '', chr(11)=> '', chr(12)=> '', chr(13)=> '', chr(14)=> '', chr(15)=> '', chr(16)=> '', chr(17)=> '', chr(18)=> '', chr(19)=> '', chr(20)=> '', chr(21)=> '', chr(22)=> '', chr(23)=> '', chr(24)=> '', chr(25)=> '', chr(26)=> '', chr(27)=> '', chr(28)=> '', chr(29)=> '', chr(30)=> '', chr(31)=> ''));
$var = str_replace("\00", "", $var);
$var = str_replace('\\', '&#92;', $var);
$var = str_replace('\'', '&#39;', $var);
$var = str_replace('$', '$$', $var);
$var = addcslashes($var, '_%');
return $var;
}
public function url($var) {
$url = array('http', 'www.', 'ftp', '.com', '.ru', '.us', '.org', '.net', '.tk', '.biz', '.ws', '.kz', '.su', '.mobi', '.in', '.ua');
$var = str_replace($url, '', $var);
return $var;
}
public function in($var) {
$var = trim($var);
$var = htmlspecialchars($var, ENT_QUOTES, 'UTF-8');
$var = mysql_real_escape_string($var);
return $var;
}
public function sql($var) {
$var = $this->in($var);
$var = $this->url($var);
return $var;
}
public function usql($var) {
$var = $this->in($var);
return $var;
}
public function bbcode($var) {
$vars = array('/\[red\](.+)\[\/red\]/isU' => '<font style="color:#ff0000; font-weight: bold;">$1</font>',
'/\[yellow\](.+)\[\/yellow\]/isU' => '<font style="color:#ffff22; font-weight: bold;">$1</font>',
'/\[green\](.+)\[\/green\]/isU' => '<font style="color:#00bb00; font-weight: bold;">$1</font>',
'/\[blue\](.+)\[\/blue\]/isU' => '<font style="color:#0000bb; font-weight: bold;">$1</font>');
$var = preg_replace(array_keys($vars), array_values($vars), $var);
return $var;
}
public function view($var) {
$var = nl2br($this->bbcode($var));
return $var;
}
}
?>