Файл: inc/func.php
Строк: 465
<?php
###
/*
if (function_exists('ini_set'))
{
#date_default_timezone_set('europe/moscow');
ini_set('date.timezone', "Europe/Moscow");
ini_set('DirectoryIndex',index.php);
ini_set('AddDefaultCharset',utf-8);
//ini_set('session.save_path', '/home/klikior/tmp/');
ini_set('display_errors',0); // отключаем показ ошибок
ini_set('register_globals', 0); // вырубаем глобальные переменные
ini_set('session.use_cookies', 1); // используем куки для сессий
ini_set('session.auto_start', 1);
ini_set('session.use_trans_sid', 1); // используем url для передачи сессий
ini_set('session.cookie_lifetime', 0);
ini_set('mbstring.internal_encoding', 'UTF-8');
#ini_set('arg_separator.output', "&"); // разделитель переменных в url (для соответствия с xhtml)
}
// Ставим ограничение для выполнения скрипта на 60 сек
//if (function_exists('set_time_limit'))set_time_limit(60);
###
*/
function counts(){
$unique = 2;
$ip=mysql_num_rows(mysql_query("SELECT * FROM counts WHERE `ip`='$_SERVER[REMOTE_ADDR]'"));
if($ip)
{
$unique = 1;
}
mysql_query("INSERT INTO counts VALUES('0','$_SERVER[REMOTE_ADDR]','$unique')");
$h=mysql_result(mysql_query("SELECT count(*) FROM counts WHERE `unique`='2'"),0);
$hit=mysql_result(mysql_query("SELECT count(*) FROM counts WHERE `unique`>'0'"),0);
$v= "[".$h."|".$hit."]";
return $v;
}
function text_captcha($length){
$val='qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789#';
for ($i=0;$i<strlen($val);$i++){
$v[]=$val[$i];
}
shuffle($v);
$val=implode("",$v);
return substr($val,0,$length);
}
function del($mode){
return trim(htmlspecialchars($mode));
}
function is_login($login){
If (!preg_match("%^[_0-9a-zA-Zа-яА-Я -]{3,15}+$%",$login)) return false;
return true;
}
function is_password($login){
If (!preg_match("%^[0-9a-zA-Z]{3,15}$%",$login)) return false;
return true;
}
###
function shif($str)
{
global $set;
$key=$set['shif'];
$str1=md5($str);
$str2=md5($key);
return md5($key.$str1.$str2.$key);
}
###
function cookie_encrypt($str,$id=0)
{
if (function_exists('mcrypt_module_open'))
{
$td = mcrypt_module_open ('rijndael-256', '', 'ofb', '');
if (!$iv=@file_get_contents(getcwd().'/inc/shif_iv.dat'))
{
$iv=base64_encode( mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM));
file_put_contents(getcwd().'/inc/shif_iv.dat', $iv);
chmod(getcwd().'/inc/shif_iv.dat', 0777);
}
$ks = @mcrypt_enc_get_key_size ($td);
/* Создать ключ */
$key = substr (md5 ($id.@$_SERVER['HTTP_USER_AGENT']), 0, $ks);
@mcrypt_generic_init ($td, $key, base64_decode($iv));
$str = @mcrypt_generic ($td, $str);
@mcrypt_generic_deinit ($td);
@mcrypt_module_close ($td);
}
$str=base64_encode($str);
return $str;
}
function cookie_decrypt($str,$id=0)
{
$str=base64_decode($str);
if (function_exists('mcrypt_module_open'))
{
$td = mcrypt_module_open ('rijndael-256', '', 'ofb', '');
if (!$iv=@file_get_contents(getcwd().'/inc/shif_iv.dat'))
{
$iv=base64_encode( mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM));
file_put_contents(getcwd().'/inc/shif_iv.dat', $iv);
chmod(getcwd().'/inc/shif_iv.dat', 0777);
}
$ks = @mcrypt_enc_get_key_size ($td);
/* Создать ключ */
$key = substr (md5 ($id.@$_SERVER['HTTP_USER_AGENT']), 0, $ks);
@mcrypt_generic_init ($td, $key, base64_decode($iv));
$str = @mdecrypt_generic ($td, $str);
@mcrypt_generic_deinit ($td);
@mcrypt_module_close ($td);
}
return $str;
}
/*
function cookie_encrypt($str,$id=0)
{
if (function_exists('mcrypt_module_open'))
{
$td = mcrypt_module_open ('rijndael-256', '', 'ofb', '');
if (!$iv=@file_get_contents(getcwd().'/inc/shif_iv.dat'))
{
$iv=base64_encode( mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM));
file_put_contents(getcwd().'/inc/shif_iv.dat', $iv);
chmod(getcwd().'/inc/shif_iv.dat', 0777);
}
$ks = mcrypt_enc_get_key_size ($td);
// Создать ключ
$key = substr (md5 ($id.$_SERVER['HTTP_USER_AGENT']), 0, $ks);
mcrypt_generic_init ($td, $key, base64_decode($iv));
$str = mcrypt_generic ($td, $str);
mcrypt_generic_deinit ($td);
mcrypt_module_close ($td);
}
else
$str=base64_encode($str);
return $str;
}
function cookie_decrypt($str,$id=0)
{
if (function_exists('mcrypt_module_open'))
{
$td = mcrypt_module_open ('rijndael-256', '', 'ofb', '');
if (!$iv=@file_get_contents(getcwd().'/inc/shif_iv.dat'))
{
$iv=base64_encode( mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM));
file_put_contents(getcwd().'/inc/shif_iv.dat', $iv);
chmod(getcwd().'/inc/shif_iv.dat', 0777);
}
$ks = mcrypt_enc_get_key_size ($td);
// Создать ключ
$key = substr (md5 ($id.$_SERVER['HTTP_USER_AGENT']), 0, $ks);
mcrypt_generic_init ($td, $key, base64_decode($iv));
$str = mdecrypt_generic ($td, $str);
mcrypt_generic_deinit ($td);
mcrypt_module_close ($td);
}
else
$str=base64_decode($str);
return $str;
}
*/
###########
function is_id($id){
If (!is_numeric($id)) return false;
If ($id<1) return false;
If ($id>1000000) return false;
If (floor($id)!=$id) return false;
return true;
}
#############
function rexplode($sep,$which){
If (strpos($which,$sep)===false) $a[0]=$which; else $a=explode($sep,$which);
return $a;
}
function rimplode($sep,$which){
If (!is_array($which) || count($which)<=1) return $which; else return implode($sep,$which);
}
##############
function smiles($text)
{
$text=str_replace(':1:','<img src="/smile/1.gif" alt=":1:"/>',$text);
$text=str_replace(':)','<img src="/smile/1.gif" alt=":)"/>',$text);
$text=str_replace(':-)','<img src="/smile/1.gif" alt=":-)"/>',$text);
$text=str_replace(':2:','<img src="/smile/2.gif" alt=":2:"/>',$text);
$text=str_replace(':(','<img src="/smile/2.gif" alt=":("/>',$text);
$text=str_replace(':-(','<img src="/smile/2.gif" alt=":-("/>',$text);
$text=str_replace(':3:','<img src="/smile/3.gif" alt=":3:"/>',$text);
$text=str_replace('=)','<img src="/smile/3.gif" alt="=)"/>',$text);
$text=str_replace(':4:','<img src="/smile/4.gif" alt=":4:"/>',$text);
$text=str_replace(';)','<img src="/smile/4.gif" alt=";)"/>',$text);
$text=str_replace(';-)','<img src="/smile/4.gif" alt=";-)"/>',$text);
$text=str_replace(':5:','<img src="/smile/5.gif" alt=":5:"/>',$text);
$text=str_replace(':hack:','<img src="/smile/5.gif" alt=":hack:"/>',$text);
$text=str_replace(':6:','<img src="/smile/6.gif" alt=":6:"/>',$text);
$text=str_replace('.lol.','<img src="/smile/6.gif" alt=":lol:"/>',$text);
$text=str_replace(':7:','<img src="/smile/7.gif" alt=":7:"/>',$text);
$text=str_replace(':D','<img src="/smile/7.gif" alt=":D"/>',$text);
$text=str_replace(':-D','<img src="/smile/7.gif" alt=":-D"/>',$text);
$text=str_replace(':d','<img src="/smile/7.gif" alt=":d"/>',$text);
$text=str_replace(':-d','<img src="/smile/7.gif" alt=":-d"/>',$text);
$text=str_replace(':8:','<img src="/smile/8.gif" alt=":8:"/>',$text);
$text=str_replace(']:->','<img src="/smile/8.gif" alt="]:->"/>',$text);
$text=str_replace('.zloy.','<img src="/smile/8.gif" alt=":zloy:"/>',$text);
$text=str_replace(':9:','<img src="/smile/9.gif" alt=":9:"/>',$text);
$text=str_replace(':pzdc:','<img src="/smile/9.gif" alt=":pzdc:"/>',$text);
$text=str_replace(':PZDC:','<img src="/smile/9.gif" alt=":PZDC:"/>',$text);
$text=str_replace(':10:','<img src="/smile/10.gif" alt=":10:"/>',$text);
$text=str_replace(':dont_know:','<img src="/smile/10.gif" alt=":dont_know:"/>',$text);
$text=str_replace(':DONT_KNOW:','<img src="/smile/10.gif" alt=":DONT_KNOW:"/>',$text);
$text=str_replace(':11:','<img src="/smile/11.gif" alt=":11:"/>',$text);
$text=str_replace(':wall:','<img src="/smile/11.gif" alt=":wall:"/>',$text);
$text=str_replace(':WALL:','<img src="/smile/11.gif" alt=":WALL:"/>',$text);
$text=str_replace(':12:','<img src="/smile/12.gif" alt=":12:"/>',$text);
$text=str_replace('=O','<img src="/smile/12.gif" alt="=O"/>',$text);
$text=str_replace('=-O','<img src="/smile/12.gif" alt="=-O"/>',$text);
$text=str_replace(':13:','<img src="/smile/13.gif" alt=":13:"/>',$text);
$text=str_replace(':wow:','<img src="/smile/13.gif" alt=":wow:"/>',$text);
$text=str_replace(':WOW:','<img src="/smile/13.gif" alt=":WOW:"/>',$text);
$text=str_replace(':14:','<img src="/smile/14.gif" alt=":14:"/>',$text);
$text=str_replace(':dance:','<img src="/smile/14.gif" alt=":dance:"/>',$text);
$text=str_replace(':DANCE:','<img src="/smile/14.gif" alt=":DANCE:"/>',$text);
$text=str_replace(':15:','<img src="/smile/15.gif" alt=":15:"/>',$text);
$text=str_replace(':crazy:','<img src="/smile/15.gif" alt=":crazy:"/>',$text);
$text=str_replace(':CRAZY:','<img src="/smile/15.gif" alt=":CRAZY:"/>',$text);
$text=str_replace(':16:','<img src="/smile/16.gif" alt=":16:"/>',$text);
$text=str_replace('0_0','<img src="/smile/16.gif" alt="0_0"/>',$text);
$text=str_replace(':17:','<img src="/smile/17.gif" alt=":17:"/>',$text);
$text=str_replace(':scratch:','<img src="/smile/17.gif" alt=":scratch:"/>',$text);
$text=str_replace(':SCRATCH:','<img src="/smile/17.gif" alt=":SCRATCH:"/>',$text);
$text=str_replace(':18:','<img src="/smile/18.gif" alt=":18:"/>',$text);
$text=str_replace('%]','<img src="/smile/18.gif" alt="%]"/>',$text);
$text=str_replace(':19:','<img src="/smile/19.gif" alt=":19:"/>',$text);
$text=str_replace(';/','<img src="/smile/19.gif" alt=";/"/>',$text);
$text=str_replace(';-/','<img src="/smile/19.gif" alt=";-/"/>',$text);
$text=str_replace(':20:','<img src="/smile/20.gif" alt=":20:"/>',$text);
$text=str_replace(':thumbs_up:','<img src="/smile/20.gif" alt=":thumbs_up:"/>',$text);
$text=str_replace(':THUMBS_UP:','<img src="/smile/20.gif" alt=":THUMBS_UP:"/>',$text);
$text=str_replace(':21:','<img src="/smile/21.gif" alt=":21:"/>',$text);
$text=str_replace(':super:','<img src="/smile/21.gif" alt=":super:"/>',$text);
$text=str_replace(':SUPE:','<img src="/smile/21.gif" alt=":SUPER:"/>',$text);
$text=str_replace(':22:','<img src="/smile/22.gif" alt=":22:"/>',$text);
$text=str_replace(':ban:','<img src="/smile/22.gif" alt=":ban:"/>',$text);
$text=str_replace(':BAN:','<img src="/smile/22.gif" alt=":BAN:"/>',$text);
$text=str_replace(':23:','<img src="/smile/23.gif" alt=":23:"/>',$text);
$text=str_replace(':spam:','<img src="/smile/23.gif" alt=":spam:"/>',$text);
$text=str_replace(':SPAM:','<img src="/smile/23.gif" alt=":SPAM:"/>',$text);
$text=str_replace(':24:','<img src="/smile/24.gif" alt=":24:"/>',$text);
$text=str_replace(':closed:','<img src="/smile/24.gif" alt=":closed:"/>',$text);
$text=str_replace(':CLOSED:','<img src="/smile/24.gif" alt=":CLOSED:"/>',$text);
$text=str_replace(':25:','<img src="/smile/25.gif" alt=":25:"/>',$text);
$text=str_replace(':offtop:','<img src="/smile/25.gif" alt=":offtop:"/>',$text);
$text=str_replace(':OFFTOP:','<img src="/smile/25.gif" alt=":OFFTOP:"/>',$text);
$text=str_replace(':26:','<img src="/smile/26.gif" alt=":26:"/>',$text);
$text=str_replace('m/','<img src="/smile/26.gif" alt="m/"/>',$text);
$text=str_replace('M/','<img src="/smile/26.gif" alt="M/"/>',$text);
$text=str_replace(':27:','<img src="/smile/27.gif" alt=":27:"/>',$text);
$text=str_replace(':beer:','<img src="/smile/27.gif" alt="beer"/>',$text);
$text=str_replace(':BEER:','<img src="/smile/27.gif" alt=":BEER:"/>',$text);
$text=str_replace(':28:','<img src="/smile/28.gif" alt=":28:"/>',$text);
$text=str_replace(':write:','<img src="/smile/28.gif" alt=":write:"/>',$text);
$text=str_replace(':WRITE:','<img src="/smile/28.gif" alt=":WRITE:"/>',$text);
$text=str_replace(':29:','<img src="/smile/29.gif" alt=":29:"/>',$text);
$text=str_replace(':sorry:','<img src="/smile/29.gif" alt=":sorry:"/>',$text);
$text=str_replace(':SORRY:','<img src="/smile/29.gif" alt=":SORRY"/>',$text);
$text=str_replace(':30:','<img src="/smile/30.gif" alt=":30:"/>',$text);
$text=str_replace(':hi:','<img src="/smile/30.gif" alt=":hi:"/>',$text);
$text=str_replace(':HI:','<img src="/smile/30.gif" alt=":HI:"/>',$text);
return $text;
}
function smiles1($ans)
{
$ans=str_replace(':1:','<img src="/smile/1.gif" alt=":1:"/>',$ans);
$ans=str_replace(':)','<img src="/smile/1.gif" alt=":)"/>',$ans);
$ans=str_replace(':-)','<img src="/smile/1.gif" alt=":-)"/>',$ans);
$ans=str_replace(':2:','<img src="/smile/2.gif" alt=":2:"/>',$ans);
$ans=str_replace(':(','<img src="/smile/2.gif" alt=":("/>',$ans);
$ans=str_replace(':-(','<img src="/smile/2.gif" alt=":-("/>',$ans);
$ans=str_replace(':3:','<img src="/smile/3.gif" alt=":3:"/>',$ans);
$ans=str_replace('=)','<img src="/smile/3.gif" alt="=)"/>',$ans);
$ans=str_replace(':4:','<img src="/smile/4.gif" alt=":4:"/>',$ans);
$ans=str_replace(';)','<img src="/smile/4.gif" alt=";)"/>',$ans);
$ans=str_replace(';-)','<img src="/smile/4.gif" alt=";-)"/>',$ans);
$ans=str_replace(':5:','<img src="/smile/5.gif" alt=":5:"/>',$ans);
$ans=str_replace(':hack:','<img src="/smile/5.gif" alt=":hack:"/>',$ans);
$ans=str_replace(':6:','<img src="/smile/6.gif" alt=":6:"/>',$ans);
$ans=str_replace('.lol.','<img src="/smile/6.gif" alt=":lol:"/>',$ans);
$ans=str_replace(':7:','<img src="/smile/7.gif" alt=":7:"/>',$ans);
$ans=str_replace(':D','<img src="/smile/7.gif" alt=":D"/>',$ans);
$ans=str_replace(':-D','<img src="/smile/7.gif" alt=":-D"/>',$ans);
$ans=str_replace(':d','<img src="/smile/7.gif" alt=":d"/>',$ans);
$ans=str_replace(':-d','<img src="/smile/7.gif" alt=":-d"/>',$ans);
$ans=str_replace(':8:','<img src="/smile/8.gif" alt=":8:"/>',$ans);
$ans=str_replace(']:->','<img src="/smile/8.gif" alt="]:->"/>',$ans);
$ans=str_replace('.zloy.','<img src="/smile/8.gif" alt=":zloy:"/>',$ans);
$ans=str_replace(':9:','<img src="/smile/9.gif" alt=":9:"/>',$ans);
$ans=str_replace(':pzdc:','<img src="/smile/9.gif" alt=":pzdc:"/>',$ans);
$ans=str_replace(':PZDC:','<img src="/smile/9.gif" alt=":PZDC:"/>',$ans);
$ans=str_replace(':10:','<img src="/smile/10.gif" alt=":10:"/>',$ans);
$ans=str_replace(':dont_know:','<img src="/smile/10.gif" alt=":dont_know:"/>',$ans);
$ans=str_replace(':DONT_KNOW:','<img src="/smile/10.gif" alt=":DONT_KNOW:"/>',$ans);
$ans=str_replace(':11:','<img src="/smile/11.gif" alt=":11:"/>',$ans);
$ans=str_replace(':wall:','<img src="/smile/11.gif" alt=":wall:"/>',$ans);
$ans=str_replace(':WALL:','<img src="/smile/11.gif" alt=":WALL:"/>',$ans);
$ans=str_replace(':12:','<img src="/smile/12.gif" alt=":12:"/>',$ans);
$ans=str_replace('=O','<img src="/smile/12.gif" alt="=O"/>',$ans);
$ans=str_replace('=-O','<img src="/smile/12.gif" alt="=-O"/>',$ans);
$ans=str_replace(':13:','<img src="/smile/13.gif" alt=":13:"/>',$ans);
$ans=str_replace(':wow:','<img src="/smile/13.gif" alt=":wow:"/>',$ans);
$ans=str_replace(':WOW:','<img src="/smile/13.gif" alt=":WOW:"/>',$ans);
$ans=str_replace(':14:','<img src="/smile/14.gif" alt=":14:"/>',$ans);
$ans=str_replace(':dance:','<img src="/smile/14.gif" alt=":dance:"/>',$ans);
$ans=str_replace(':DANCE:','<img src="/smile/14.gif" alt=":DANCE:"/>',$ans);
$ans=str_replace(':15:','<img src="/smile/15.gif" alt=":15:"/>',$ans);
$ans=str_replace(':crazy:','<img src="/smile/15.gif" alt=":crazy:"/>',$ans);
$ans=str_replace(':CRAZY:','<img src="/smile/15.gif" alt=":CRAZY:"/>',$ans);
$ans=str_replace(':16:','<img src="/smile/16.gif" alt=":16:"/>',$ans);
$ans=str_replace('0_0','<img src="/smile/16.gif" alt="0_0"/>',$ans);
$ans=str_replace(':17:','<img src="/smile/17.gif" alt=":17:"/>',$ans);
$ans=str_replace(':scratch:','<img src="/smile/17.gif" alt=":scratch:"/>',$ans);
$ans=str_replace(':SCRATCH:','<img src="/smile/17.gif" alt=":SCRATCH:"/>',$ans);
$ans=str_replace(':18:','<img src="/smile/18.gif" alt=":18:"/>',$ans);
$ans=str_replace('%]','<img src="/smile/18.gif" alt="%]"/>',$ans);
$ans=str_replace(':19:','<img src="/smile/19.gif" alt=":19:"/>',$ans);
$ans=str_replace(';/','<img src="/smile/19.gif" alt=";/"/>',$ans);
$ans=str_replace(';-/','<img src="/smile/19.gif" alt=";-/"/>',$ans);
$ans=str_replace(':20:','<img src="/smile/20.gif" alt=":20:"/>',$ans);
$ans=str_replace(':thumbs_up:','<img src="/smile/20.gif" alt=":thumbs_up:"/>',$ans);
$ans=str_replace(':THUMBS_UP:','<img src="/smile/20.gif" alt=":THUMBS_UP:"/>',$ans);
$ans=str_replace(':21:','<img src="/smile/21.gif" alt=":21:"/>',$ans);
$ans=str_replace(':super:','<img src="/smile/21.gif" alt=":super:"/>',$ans);
$ans=str_replace(':SUPE:','<img src="/smile/21.gif" alt=":SUPER:"/>',$ans);
$ans=str_replace(':22:','<img src="/smile/22.gif" alt=":22:"/>',$ans);
$ans=str_replace(':ban:','<img src="/smile/22.gif" alt=":ban:"/>',$ans);
$ans=str_replace(':BAN:','<img src="/smile/22.gif" alt=":BAN:"/>',$ans);
$ans=str_replace(':23:','<img src="/smile/23.gif" alt=":23:"/>',$ans);
$ans=str_replace(':spam:','<img src="/smile/23.gif" alt=":spam:"/>',$ans);
$ans=str_replace(':SPAM:','<img src="/smile/23.gif" alt=":SPAM:"/>',$ans);
$ans=str_replace(':24:','<img src="/smile/24.gif" alt=":24:"/>',$ans);
$ans=str_replace(':closed:','<img src="/smile/24.gif" alt=":closed:"/>',$ans);
$ans=str_replace(':CLOSED:','<img src="/smile/24.gif" alt=":CLOSED:"/>',$ans);
$ans=str_replace(':25:','<img src="/smile/25.gif" alt=":25:"/>',$ans);
$ans=str_replace(':offtop:','<img src="/smile/25.gif" alt=":offtop:"/>',$ans);
$ans=str_replace(':OFFTOP:','<img src="/smile/25.gif" alt=":OFFTOP:"/>',$ans);
$ans=str_replace(':26:','<img src="/smile/26.gif" alt=":26:"/>',$ans);
$ans=str_replace('m/','<img src="/smile/26.gif" alt="m/"/>',$ans);
$ans=str_replace('M/','<img src="/smile/26.gif" alt="M/"/>',$ans);
$ans=str_replace(':27:','<img src="/smile/27.gif" alt=":27:"/>',$ans);
$ans=str_replace(':beer:','<img src="/smile/27.gif" alt="beer"/>',$ans);
$ans=str_replace(':BEER:','<img src="/smile/27.gif" alt=":BEER:"/>',$ans);
$ans=str_replace(':28:','<img src="/smile/28.gif" alt=":28:"/>',$ans);
$ans=str_replace(':write:','<img src="/smile/28.gif" alt=":write:"/>',$ans);
$ans=str_replace(':WRITE:','<img src="/smile/28.gif" alt=":WRITE:"/>',$ans);
$ans=str_replace(':29:','<img src="/smile/29.gif" alt=":29:"/>',$ans);
$ans=str_replace(':sorry:','<img src="/smile/29.gif" alt=":sorry:"/>',$ans);
$ans=str_replace(':SORRY:','<img src="/smile/29.gif" alt=":SORRY"/>',$ans);
$ans=str_replace(':30:','<img src="/smile/30.gif" alt=":30:"/>',$ans);
$ans=str_replace(':hi:','<img src="/smile/30.gif" alt=":hi:"/>',$ans);
$ans=str_replace(':HI:','<img src="/smile/30.gif" alt=":HI:"/>',$ans);
return $ans;
}
//Фyнкция кoнвepтaции bbcode
function bbcode($text)
{
$text=str_replace("r","<br />", $text);
$text=preg_replace('#[br/]#', '<br />', $text);
$text=preg_replace('#[b](.*?)[/b]#si', '<b>1</b>', $text);
$text=preg_replace('#[i](.*?)[/i]#si', '<i>1</i>', $text);
$text=preg_replace('#[u](.*?)[/u]#si', '<u>1</u>', $text);
$text=preg_replace('#[small](.*?)[/small]#si', '<small>1</small>', $text);
$text=preg_replace('#[big](.*?)[/big]#si', '<big>1</big>', $text);
$text=preg_replace('#[red](.*?)[/red]#si', '<span style="color:#FF0000">1</span>', $text);
$text=preg_replace('#[green](.*?)[/green]#si', '<span style="color:green">1</span>', $text);
$text=preg_replace('#[blue](.*?)[/blue]#si', '<span style="color:#0000FF">1</span>', $text);
$text=preg_replace('#[lime](.*?)[/lime]#si','<span style="color:#00FF00">1</span>',$text);
$text=preg_replace('#[white](.*?)[/white]#si','<span style="color:white">1</span>',$text);
$text=preg_replace('#[golub](.*?)[/golub]#si','<span style="color:#00FFFF">1</span>',$text);
$text=preg_replace('#[yellow](.*?)[/yellow]#is','<span style="color:yellow">1</span>',$text);
$text=preg_replace('#[url](.*?)[/url]#is','<a href="http://\1">\1</a>',$text);
$text=preg_replace('#http://([0-9a-z_][0-9a-z./?&=]*)#is','<a href="http://\1">\1</a>',$text);
return $text;
}
function sub_str($string, $length = 80, $etc = '...',
$break_words = false, $middle = false)
{
if ($length == 0)
return '';
if (mb_strlen($string, utf8) > $length) {
$length -= mb_strlen($etc, utf8);
if (!$break_words && !$middle) {
$string = mb_ereg_replace('/s+?(S+)?$/', '', mb_substr($string, 0, $length+1, utf8), utf8);
}
if(!$middle) {
return mb_substr($string, 0, $length, utf8).$etc;
} else {
return mb_substr($string, 0, $length/2, utf8) . $etc . mb_substr($string, -$length/2, utf8);
}
} else {
return $string;
}
}
##############
class click_club{
function captcha_text($length){
$symbols=symbols;
for ($i=0;$i<$length;$i++) @$text.=$symbols[mt_rand(0,strlen($symbols)-1)];
return $text;
}
function is_login($text){
global $_EREG;
If (!ereg("^[".$_EREG['login']."]{".min_login.",".lenght_login."}$",$text)) return false;
return true;
}
function is_password($text){
global $_EREG;
If (!ereg("^[".$_EREG['password']."]{".min_login.",".lenght_login."}$",$text)) return false;
return true;
}
function is_mail($text){
$len=strlen($text);
If ($len<min_mail || $len>lenght_mail || !preg_match("/^[-0-9a-z_.]+(@){1}[-0-9a-z_.]+.[a-z]{2,5}$/i",$text)) return false;
return true;
}
}
$click_club=new click_club;
?>