View file NuclearCMS_v.1.0.0/system/functions.php

File size: 4.36Kb
<?php

#----------------------------------------- Шифруем Cookies -----------------------------------------#
$key = "4569hhhhhf8dj4st6823rgh/iq56"; // ключ для расшифрования
function hard_encode($text,$key){
$length=strlen($text);
$output="";
$collision=array(2,4);
	for($i=0; $i<strlen($key); $i++){
	$collision[0]+=ord($key[$i]);
	$collision[1]+=ord($key[$i]);
	}
$collision[0]=($collision[0]%27)+10;
$collision[1]=(int)($collision[1]/strlen($key));
$collision[1]=($collision[1]%32)+3;
($collision[0]==$collision[1]) ? $collision[1]-- : $collision[0];
$separator=chr(65+(int)($collision[0]/2));
	for($i=0; $i<$length; $i++){
	$mod_collision=$i*$collision[1];
	$output.=base_convert(ord($text[$i])+$mod_collision,$collision[0],$collision[1]).$separator;
	$separator=chr(65+$mod_collision%20);
	}
return $output;
}

function hard_decode($text,$key){
$length=strlen($text);
$output="";
$collision=array(2,4);
	for($i=0; $i<strlen($key); $i++){
	$collision[0]+=ord($key[$i]);
	$collision[1]+=ord($key[$i]);
	}
$collision[0]=($collision[0]%27)+10;
$collision[1]=(int)($collision[1]/strlen($key));
$collision[1]=($collision[1]%32)+3;
($collision[0]==$collision[1]) ? $collision[1]-- : $collision[0];
$separator=chr(65+(int)($collision[0]/2));
$rec="";
$symbols=0;
	for($i=0; $i<$length; $i++){
		if($text[$i]!=$separator){
		$rec.=$text[$i];
		} else {	
		$mod_collision=$symbols*$collision[1];
		$output.=chr(base_convert($rec,$collision[1],$collision[0])-$mod_collision);
		$separator=chr(65+$mod_collision%20);
		$rec="";
		$symbols++;
		}
	}
	
return $output;
}
#---------------------------------------Строковые функции---------------------------------------#
//Функция вырезания опасных знаков
function check($a) { 
$a=str_replace("\0","",$a);
$a=str_replace("%","&#37;",$a);
$a=str_replace("^","&#94;",$a);
$a=str_replace("$","&#36;",$a);
$a=htmlspecialchars(stripslashes($a));
$a=trim($a); return($a);
}
//Функция вырезания мата
function antimat($a) { 
$a=strtr($a,array("сука"=>"****", "падла"=>"*****", "мразь"=>"*****", "уебище"=>"******", "ублюдок"=>"*******", "хуйло"=>"*****", "даун"=>"****", "чмо"=>"***", "гандон"=>"******", "тварь"=>"*****", "сучара"=>"******", "хуй"=>"***", "пизда"=>"*****", "блядь"=>"*****", "пидор"=>"*****", "пидар"=>"*****", "ебать"=>"*****", "сцука"=>"*****", "дурак"=>"*****", "дура"=>"****", "идиот"=>"*****", "лошара"=>"******", "целка"=>"*****", "педик"=>"*****", "пиздец"=>"******", "жопа"=>"****","лол"=>"***","ламер"=>"*****")); return $a;
}
//Функция вставки BB-кода
function bbcode($message){ 
$message = preg_replace('#\[code\](.*?)\[/code\]#ie', 'highlight_code("\1")', $message); 
$message = preg_replace('#\[big\](.*?)\[/big\]#si', '<big>\1</big>', $message);
$message = preg_replace('#\[b\](.*?)\[/b\]#si', '<b>\1</b>', $message);
$message = preg_replace('#\[i\](.*?)\[/i\]#si', '<i>\1</i>', $message);
$message = preg_replace('#\[u\](.*?)\[/u\]#si', '<u>\1</u>', $message);
$message = preg_replace('#\[small\](.*?)\[/small\]#si', '<small>\1</small>', $message);
$message = preg_replace('#\[red\](.*?)\[/red\]#si', '<font color="#FF0000">\1</font>', $message);
$message = preg_replace('#\[green\](.*?)\[/green\]#si', '<font color="#00FF00">\1</font>', $message);
$message = preg_replace('#\[blue\](.*?)\[/blue\]#si', '<font color="#0000FF">\1</font>', $message);
$message = preg_replace('#\[yellow\](.*?)\[/yellow\]#si', '<font color="#FFFF00">\1</font>', $message);
$message = preg_replace('#\[quote\](.*?)\[/quote\]#si', '<q>\1</q>', $message);
$message = preg_replace('#\[del\](.*?)\[/del\]#si', '<del>\1</del>', $message);
$message = preg_replace_callback('~\\[url=(http://.+?)\\](.+?)\\[/url\\]|(http://(www.)?[0-9a-z\.-]+\.[a-z]{2,6}[0-9a-z/\?\.\~&amp;_=/%-:#]*)~', 'url_replace', $message); 
return $message; 
}
//Функция вставки эмоций
function emoc($message){
$message = str_replace('::0', '[Без эмоций]', $message);
$message = str_replace('::1', '[Радостно]', $message);
$message = str_replace('::2', '[Печально]', $message);
$message = str_replace('::3', '[Удивленно]', $message);
return $message; 
}


?>