PHP Code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
class Wordfilter {
private $hotels = array(
'habbo',
'bobbaz',
'jabbu',
'jebbu',
'jabbo',
'fobba',
'kuggo',
'yebbo',
'huggo',
'holows',
'ficken',
'penis',
'ibabbo',
'livehotel',
'cabbo',
'hubbu',
'hubbo',
'hobbu',
'hobbo',
'hobba',
'wubbu',
'titanhotel',
'hubba',
'retrohotelcc',
'habbor',
'xebbo',
'kibbu',
'rabbo',
'cybersex',
'sperma',
'kibbo',
'vubba',
'hebbo',
'lemonhotel'
);
private $removeKeys = array(
'+',
' ',
'|',
'ȶ',
'/',
'\'',
'"',
'*',
'~',
'\\',
'.',
'-',
';',
'<',
'>',
'_',
'$',
'#',
'¦',
'´',
'`',
'^',
'}',
'{',
']',
'[',
',',
'!',
'$',
'bz',
'mn',
'li',
'st'
);
private $utfKeywords = array(
'û' => 'u',
'ú' => 'u',
'ù' => 'u',
'â' => 'a',
'á' => 'a',
'à' => 'a',
'@' => 'a',
'ô' => 'o',
'ó' => 'o',
'ò' => 'o',
'ê' => 'e',
'é' => 'e',
'è' => 'e',
'4' => 'a',
'0' => 'o',
'$' => 's',
'€' => 'e',
'3' => 'e',
'â' => 'a',
'é' => 'e'
);
public function addUtf($utf, $norm) {
$this->utfKeywords[$utf] = $norm;
}
public function addRemoveKey($key) {
$this->removeKeys[] = $key;
}
public function addHotel($hotel) {
$this->hotels[] = $hotel;
}
public function checkText($text) {
$this->convertUtf();
$text = explode(' ', $text);
$final = '';
foreach($text as $word) {
$filter = str_ireplace($this->removeKeys, '', (str_ireplace($this->toChange16, $this->toChange8, (stripslashes(htmlentities($word, ENT_COMPAT, 'utf-8'))))));
$this->convertHotels();
if(isset($this->toHotels[strtolower($filter)])) {
$cWord = '';
for($i = 0; $i <= strlen($filter); ++$i) {
$cWord .= '*';
}
$final .= $cWord . ' ';
} else {
$final .= $filter . ' ';
}
}
return $final;
}
private function convertUtf() {
$this->toChange16 = array();
$this->toChange8 = array();
foreach($this->utfKeywords as $_16 => $_8) {
$this->toChange16[] = $_16;
$this->toChange8[] = $_8;
}
}
public function convertHotels() {
$this->toHotels = array();
foreach($this->hotels as $hotel) {
$this->toHotels[$hotel] = $hotel;
}
}
public function isSuspiciousWord($word) {
$this->convertUtf();
$this->convertHotels();
$filter = str_ireplace($this->removeKeys, '', (str_ireplace($this->toChange16, $this->toChange8, (stripslashes(htmlentities($word, ENT_COMPAT, 'utf-8'))))));
return (isset($this->toHotels[strtolower($filter)]));
}
public function getHotelname($hotel) {
$this->convertUtf();
$this->convertHotels();
$filter = str_ireplace($this->removeKeys, '', (str_ireplace($this->toChange16, $this->toChange8, (stripslashes(htmlentities($hotel, ENT_COMPAT, 'utf-8'))))));
return (isset($this->toHotels[strtolower($filter)])) ? $this->toHotels[strtolower($filter)] : false;
}
}
$wordfilter = new Wordfilter();
if(isset($_POST['check']) && (!empty($_POST['check']))) {
$text = explode(' ', $_POST['check']);
foreach($text as $word) {
if($wordfilter->isSuspiciousWord($word)) {
echo '<span style="color: red; font-weight: bold">'.$word.'('.$wordfilter->getHotelname($word).')</span> ';
} else {
echo $word . ' ';
}
}
}
?>
<form method="post">
<input type="text" name="check"><input type="submit">
</form>
Have a nice *day*, dudes!