Файл: func.php
Строк: 65
<?php
function bbcode($text){
//$text=htmlspecialchars($text);
//$text=htmlspecialchars($text);
//конвертация кодов в теги регулярными выражениями
// ББ коды
$bbcode = array(
'/[url](.+)[/url]/isU'=>'<a href="$1">$1</a>',
'/[url=(.+)](.+)[/url]/isU'=>'<a href="$1">$2</a>',
'/[img](.+)[/img]/isU'=>'<img src="$1" alt="img" />',
'/[img=(.+)](.+)[/img]/isU'=>'<img src="$1" alt="$2" />',
'/[i](.+)[/i]/isU'=>'<em>$1</em>',
'/[b](.+)[/b]/isU'=>'<strong>$1</strong>',
'/[u](.+)[/u]/isU'=>'<span style="text-decoration:underline">$1</span>',
'/[big](.+)[/big]/isU'=>'<big>$1</big>',
'/[small](.+)[/small]/isU'=>'<small>$1</small>',
'/[code](.+)[/code]/isU'=>'<code>$1</code>',
'/[red](.+)[/red]/isU'=>'<font color="#ff0000">$1</font>',
'/[yellow](.+)[/yellow]/isU'=>'<font color="#ffff22">$1</font>',
'/[green](.+)[/green]/isU'=>'<font color="#00bb00">$1</font>',
'/[blue](.+)[/blue]/isU'=>'<font color="#0000bb">$1</font>'
);
$text=stripslashes($text);
$text=str_replace("n",'<br />',$text);
return preg_replace(array_keys($bbcode),array_values($bbcode),$text);
//$text=str_replace("n",'<br />',$text);
}
     function clear($text){
     $a = array("'",'@','`','~','!','"','№','#','$',';','%','^',':','&','?','*','=','+',"\","|","/",",");
     $b = array('','','','','','','','','','','','','','','','','','','','','','');
     $text=str_replace($a,$b,$text);
     return $text;
     }
function vivod($text){
$text=stripslashes(htmlspecialchars($text));
return $text;
    }
function trans($text){
$a = array('_','YA','Ya','ya','yee','YO','yo','Yo','ZH','zh','Zh','Z','z','CH','ch','Ch','SH','sh','Sh','YE','ye','Ye','YU','yu','Yu','JA','ja','Ja','A','a','B','b','V','v','G','g','D','d','E','e','I','i','J','j','K','k','L','l','M','m','N','n','O','o','P','p','R','r','S','s','T','t','U','u','F','f','H','h','W','w','x','q','Y','y','C','c','!','\');
$b = array(' ','Я','Я','я','ые','Ё','ё','Ё','Ж','ж','Ж','З','з','Ч','ч','Ч','Ш','ш','Ш','Э','э','Э','Ю','ю','Ю','Я','я','Я','А','а','Б','б','В','в','Г','г','Д','д','Е','е','И','и','Й','й','К','к','Л','л','М','м','Н','н','О','о','П','п','Р','р','С','с','Т','т','У','у','Ф','ф','Х','х','Щ','щ','ъ','ь','Ы','ы','Ц','ц','','');
$text=str_replace($a,$b,$text);
return $text;
}
function retrans($text){
$a = array('_','YA','Ya','ya','yee','YO','yo','Yo','ZH','zh','Zh','Z','z','CH','ch','Ch','SH','sh','Sh','YE','ye','Ye','YU','yu','Yu','JA','ja','Ja','A','a','B','b','V','v','G','g','D','d','E','e','I','i','J','j','K','k','L','l','M','m','N','n','O','o','P','p','R','r','S','s','T','t','U','u','F','f','H','h','W','w','x','q','Y','y','C','c','!');
$b = array(' ','Я','Я','я','ые','Ё','ё','Ё','Ж','ж','Ж','З','з','Ч','ч','Ч','Ш','ш','Ш','Э','э','Э','Ю','ю','Ю','Я','я','Я','А','а','Б','б','В','в','Г','г','Д','д','Е','е','И','и','Й','й','К','к','Л','л','М','м','Н','н','О','о','П','п','Р','р','С','с','Т','т','У','у','Ф','ф','Х','х','Щ','щ','ъ','ь','Ы','ы','Ц','ц','');
$text=str_replace($b,$a,$text);
return $text;
}
$filesdir = array(
"1"=>"pictures",
"2"=>"games",
"3"=>"apps",
"4"=>"wallpaper"
);
$filesdirname = array(
"1"=>"Картинки",
"2"=>"Игры",
"3"=>"Приложения",
"4"=>"Живые обои"
);
 function RemoveDir($path)
{
    if(file_exists($path) && is_dir($path))
    {
        $dirHandle = opendir($path);
        while (false !== ($file = readdir($dirHandle)))
        {
            if ($file!='.' && $file!='..')// исключаем папки с назварием '.' и '..'
            {
                $tmpPath=$path.'/'.$file;
                chmod($tmpPath, 0777);
                if (is_dir($tmpPath))
                  {  // если папка
                    RemoveDir($tmpPath);
                   }
                  else
                  {
                      if(file_exists($tmpPath))
                    {
                        // удаляем файл
                          unlink($tmpPath);
                    }
                  }
            }
        }
        closedir($dirHandle);
        // удаляем текущую папку
        if(file_exists($path))
        {
            rmdir($path);
        }
    }
    else
    {
        echo "Удаляемой папки не существует или это файл!";
    }
}
function getRealIpAddr()
{
  if (!empty($_SERVER['HTTP_CLIENT_IP']))
  {
    $ip=$_SERVER['HTTP_CLIENT_IP'];
  }
  elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
  {
    $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  }
  else
  {
    $ip=$_SERVER['REMOTE_ADDR'];
  }
  return $ip;
}
function avtexit()
{
unset ($_SESSION['id']);
unset ($_SESSION['ip']);
unset ($_SESSION['login']);
}
   function gen_cod($num)
{
    //симвлы из которых генерируется пароль
    $kod=array(
    'a','b','c','d','e',
    'f','g','h','i','j',
    'k','l','m','n','o',
    'p','q','r','s','t',
    'u','v','w','x','y','z',
    'A','B','C','D','E',
    'F','G','H','I','J',
    'K','L','M','N','O',
    'P','Q','R','S','T',
    'U','V','W','X','Y','Z',
    '0','1','2','3','4','5',
    '6','7','8','9'
    );
    $ko='';
    for($i=1; $i<=$num; $i++)
    {
        $ko.=$kod[array_rand($kod)];
    }
    return $ko;
}
?>