<?php
/**
* @name Cleaner - class that cleans chars transmited via an url
* @author hide@address.com
*/
class Cleaner
{
// cleans as per RFC 1808 as well strips any html and php tags
// returns UTF-8 into lowercase
function clean_rfc1808($str)
{
// rfc http://www.ietf.org/rfc/rfc1808.txt
$national = array("{" , "}" , "|" , "\\" , "^" , "~" , "[" , "]" , "`");
$extra = array("!", "*", "'", "(", ")", ",");
$bad_chars = array_merge($national, $extra);
// clean bad chars
$clean = trim(str_replace($bad_chars, "", strip_tags($str)));
// strip white spaces
$clean = preg_replace('/\s+/','',$clean);
return mb_strtolower($clean, 'UTF-8');
}
// wrapper to htmlspecialchars using ENT_QUOTES
function html_chars($str)
{
return htmlspecialchars($str, ENT_QUOTES);
}
// wrapper to htmlspecialchars using ENT_QUOTES
function html_chars_decode($str)
{
return htmlspecialchars_decode($str, ENT_QUOTES);
}
}