Вход Регистрация
Файл: Dvig/core/func.php
Строк: 164
<?php

        defined
'xcms_pro' ) or die( 'Идите нахуй!' ) ;
        
##Файл функций###
        #фильтрация в базу
        
function checkin$str )
        {
        
// Фильтруем невидимые символы
        
$str preg_replace('/[^P{C}n]+/u'''$str);
        return 
trim($str);
        }
        
        function 
check$str )
        {
                        
$str htmlentitiestrim$str ), ENT_QUOTES'UTF-8' ) ;
                        
$str nl2br$str ) ;
                        
$str strtr$str, array(
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr10 ) => '',
                                        
chr11 ) => '',
                                        
chr12 ) => '',
                                        
chr13 ) => '',
                                        
chr14 ) => '',
                                        
chr15 ) => '',
                                        
chr16 ) => '',
                                        
chr17 ) => '',
                                        
chr18 ) => '',
                                        
chr19 ) => '',
                                        
chr20 ) => '',
                                        
chr21 ) => '',
                                        
chr22 ) => '',
                                        
chr23 ) => '',
                                        
chr24 ) => '',
                                        
chr25 ) => '',
                                        
chr26 ) => '',
                                        
chr27 ) => '',
                                        
chr28 ) => '',
                                        
chr29 ) => '',
                                        
chr30 ) => '',
                                        
chr31 ) => '' ) ) ;
                        
$str str_replace"'""&#39;"$str ) ;
                        
$str str_replace('"'''$str);
                        
$str str_replace'\', "&#92;", $str ) ;
                        $str = str_replace( "|", "I", $str ) ;
                        $str = str_replace( "||", "I", $str ) ;
                        $str = str_replace( "/\$/", "&#36;", $str ) ;
                        $str = str_replace('
+','',$str);
                        $str = str_replace('
and','',$str);
                        $str = str_replace('
%20','',$str);
                        $str = trim($str);
                        $str = mysql_real_escape_string( $str ) ;
                        return $str ;
        }
        #бб коды
        function bb( $var = '' )
        {
                        $var = preg_replace( '
#[b](.*?)[/b]#si', '<span style="font-weight: bold;">1</span>',
                                        
$var ) ;
                        
$var preg_replace'#[i](.*?)[/i]#si''<span style="font-style:italic;">1</span>',
                                        
$var ) ;
                        
$var preg_replace'#[u](.*?)[/u]#si',
                                        
'<span style="var-decoration:underline;">1</span>'$var ) ;
                        
$var preg_replace'#[s](.*?)[/s]#si',
                                        
'<span style="var-decoration: line-through;">1</span>'$var ) ;
                        
$var preg_replace'#[red](.*?)[/red]#si''<span style="color:red">1</span>',
                                        
$var ) ;
                        
$var preg_replace'#[green](.*?)[/green]#si''<span style="color:green">1</span>',
                                        
$var ) ;
                        
$var preg_replace'#[blue](.*?)[/blue]#si''<span style="color:blue">1</span>',
                                        
$var ) ;
                        
$var preg_replace'#[c](.*?)[/c]#si''<div class="quote">1</div>'$var ) ;
                        
$var preg_replace('#[url=http://(.*)](.*)[/url]#Ui','<a href="1">2</a>',$var);//для ссылок
                        
$var preg_replace('#[author](.*?)[/author]#si''<div id="razd"><span style="padding:0px 40px;">1 пишет :</span></div>',$var);
                        
$var preg_replace('#[quote](.*?)[/quote]#si''<div id="l1"><span style="padding:0px 40px;">1</span></div>',$var);
                        return 
$var ;
        }
        
# Смайлики
        
function smiles$var '' )
{
$var str_replace(':)','<img src="/img/smiles/1.gif" alt=""/>',$var);
$var str_replace(':D','<img src="/img/smiles/2.gif" alt=""/>',$var);
$var str_replace(':(','<img src="/img/smiles/3.gif" alt=""/>',$var);
$var str_replace('.молчу.','<img src="/img/smiles/4.gif" alt=""/>',$var);
$var str_replace('О.о','<img src="/img/smiles/5.gif" alt=""/>',$var);
$var str_replace('.плачу.','<img src="/img/smiles/6.gif" alt=""/>',$var);
$var str_replace('.злой.','<img src="/img/smiles/7.gif" alt=""/>',$var);
$var str_replace('.слева.','<img src="/img/smiles/8.gif" alt=""/>',$var);
$var str_replace('.кричу.','<img src="/img/smiles/9.gif" alt=""/>',$var);
$var str_replace('.запутался.','<img src="/img/smiles/10.gif" alt=""/>',$var);
$var str_replace('.хм.','<img src="/img/smiles/11.gif" alt=""/>',$var);
$var str_replace('.ого.','<img src="/img/smiles/12.gif" alt=""/>',$var);
$var str_replace('.омг.','<img src="/img/smiles/13.gif" alt=""/>',$var);
$var str_replace('.язык.','<img src="/img/smiles/14.gif" alt=""/>',$var);
$var str_replace('.устал.','<img src="/img/smiles/15.gif" alt=""/>',$var);
$var str_replace('.слежу.','<img src="/img/smiles/16.gif" alt=""/>',$var);
$var str_replace('.кент.','<img src="/img/smiles/17.gif" alt=""/>',$var);
$var str_replace('.дьявол.','<img src="/img/smiles/18.gif" alt=""/>',$var);
$var str_replace('.шок.','<img src="/img/smiles/19.gif" alt=""/>',$var);
$var str_replace('.умный.','<img src="/img/smiles/20.gif" alt=""/>',$var);
$var str_replace('.извини.','<img src="/img/smiles/21.gif" alt=""/>',$var);
$var str_replace('.веселый.','<img src="/img/smiles/22.gif" alt=""/>',$var);
$var str_replace('.шта.','<img src="/img/smiles/wta.png" width="40" height="40" />',$var);
$var str_replace('.фуу.','<img src="/img/smiles/23.gif" width="40" height="30" />',$var);
$var str_replace('.рожа.','<img src="/img/smiles/24.gif" width="40" height="30" />',$var);
$var str_replace('.лол.','<img src="/img/smiles/25.gif" width="40" height="30" />',$var);
$var str_replace('.алон.','<img src="/img/smiles/26.gif" width="40" height="30" />',$var);
$var str_replace('.покерфейс.','<img src="/img/smiles/27.gif" width="40" height="30" />',$var);
$var str_replace('.зачто.','<img src="/img/smiles/28.gif" width="40" height="30" />',$var);
$var str_replace('.удивлен.','<img src="/img/smiles/29.gif" width="40" height="30" />',$var);
$var str_replace('.зол.','<img src="/img/smiles/30.gif" width="40" height="30" />',$var);
$var str_replace('.мужик.','<img src="/img/smiles/31.gif" width="40" height="30" />',$var);
$var str_replace('.минь.','<img src="/img/smiles/32.gif" width="40" height="30" />',$var);
$var str_replace('.тружусь.','<img src="/img/smiles/33.gif" width="40" height="30" />',$var);
$var str_replace('.солгал.','<img src="/img/smiles/34.gif" width="40" height="30" />',$var);
$var str_replace('.нет.','<img src="/img/smiles/35.gif" width="40" height="30" />',$var);
$var str_replace('.что.','<img src="/img/smiles/36.gif" width="40" height="30" />',$var);
$var str_replace('.счастлив.','<img src="/img/smiles/37.gif" width="40" height="30" />',$var);
$var str_replace('.успех.','<img src="/img/smiles/38.gif" width="40" height="30" />',$var);
$var str_replace('.грусть.','<img src="/img/smiles/39.gif" width="40" height="30" />',$var);
$var str_replace('.удивляюсь.','<img src="/img/smiles/40.gif" alt=""/>',$var);
$var str_replace('.цензура.','<img src="/img/smiles/41.gif" alt=""/>',$var);
$var str_replace('.вшоке.','<img src="/img/smiles/42.gif" alt=""/>',$var);
$var str_replace('.конь.','<img src="/img/smiles/43.gif" alt=""/>',$var);
$var str_replace('.олень.','<img src="/img/smiles/44.gif" alt=""/>',$var);
$var str_replace('.олень2.','<img src="/img/smiles/45.gif" alt=""/>',$var);
$var str_replace('.олень3.','<img src="/img/smiles/46.gif" alt=""/>',$var);
$var str_replace('.сердце.','<img src="/img/smiles/47.gif" alt=""/>',$var);
$var str_replace('.фен.','<img src="/img/smiles/48.gif" alt=""/>',$var);
$var str_replace('.приветвсем.','<img src="/img/smiles/49.gif" alt=""/>',$var);
$var str_replace('.стыд.','<img src="/img/smiles/50.gif" alt=""/>',$var);
$var str_replace('.зло.','<img src="/img/smiles/51.gif" alt=""/>',$var);
$var str_replace('.бабу.','<img src="/img/smiles/52.gif" alt=""/>',$var);
$var str_replace('.бананы.','<img src="/img/smiles/53.gif" alt=""/>',$var);
$var str_replace('.закрыто.','<img src="/img/smiles/54.gif" alt=""/>',$var);
$var str_replace('.хулиган.','<img src="/img/smiles/55.gif" alt=""/>',$var);
$var str_replace('.новыйгод.','<img src="/img/smiles/56.gif" alt=""/>',$var);
$var str_replace('.фак.','<img src="/img/smiles/57.gif" alt=""/>',$var);
$var str_replace('.член.','<img src="/img/smiles/58.gif" alt=""/>',$var);
$var str_replace('.дура.','<img src="/img/smiles/59.gif" alt=""/>',$var);
return 
$var ;}
        
#определение расширения
        
function type$name )
        {
                        
$f1 strrpos$name"." ) ;
                        
$f2 substr$name$f1 1999 ) ;
                        
$fname strtolower$f2 ) ;
                        return 
$fname ;
        }
        
#вывод с базы фильтр
        
function checkout$str$br 0$tags )
        {
                        
$str htmlentities$strENT_QUOTES'UTF-8' ) ;
                        if ( 
$br == $str nl2br$str ) ;
                        elseif ( 
$br == $str str_replace"rn"' '$str ) ;
                        if ( 
$tags == $str bb$str ) ;
                        elseif ( 
$tags == $str notags$str ) ;
                        
$str strtr$str, array(
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr) => '',
                                        
chr10 ) => '',
                                        
chr11 ) => '',
                                        
chr12 ) => '',
                                        
chr13 ) => '',
                                        
chr14 ) => '',
                                        
chr15 ) => '',
                                        
chr16 ) => '',
                                        
chr17 ) => '',
                                        
chr18 ) => '',
                                        
chr19 ) => '',
                                        
chr20 ) => '',
                                        
chr21 ) => '',
                                        
chr22 ) => '',
                                        
chr23 ) => '',
                                        
chr24 ) => '',
                                        
chr25 ) => '',
                                        
chr26 ) => '',
                                        
chr27 ) => '',
                                        
chr28 ) => '',
                                        
chr29 ) => '',
                                        
chr30 ) => '',
                                        
chr31 ) => '' ) ) ;
                        return 
$str ;
        }

        
#транслит
        
function translit$var )
        {
                        
$replace = array(
                                        
'Є' => 'EH',
                                        
'І' => 'I',
                                        
'і' => 'i',
                                        
'№' => 'No',
                                        
'є' => 'eh',
                                        
'А' => 'A',
                                        
'Б' => 'B',
                                        
'В' => 'V',
                                        
'Г' => 'G',
                                        
'Д' => 'D',
                                        
'Е' => 'E',
                                        
'Ё' => 'JO',
                                        
'Ж' => 'ZH',
                                        
'З' => 'Z',
                                        
'И' => 'I',
                                        
'Й' => 'Y',
                                        
'К' => 'K',
                                        
'Л' => 'L',
                                        
'М' => 'M',
                                        
'Н' => 'N',
                                        
'О' => 'O',
                                        
'П' => 'P',
                                        
'Р' => 'R',
                                        
'С' => 'S',
                                        
'Т' => 'T',
                                        
'У' => 'U',
                                        
'Ф' => 'F',
                                        
'Х' => 'H',
                                        
'Ц' => 'C',
                                        
'Ч' => 'CH',
                                        
'Ш' => 'SH',
                                        
'Щ' => 'SHH',
                                        
'Ъ' => '',
                                        
'Ы' => 'Y',
                                        
'Ь' => '',
                                        
'Э' => 'EH',
                                        
'Ю' => 'YU',
                                        
'Я' => 'YA',
                                        
'а' => 'a',
                                        
'б' => 'b',
                                        
'в' => 'v',
                                        
'г' => 'g',
                                        
'д' => 'd',
                                        
'е' => 'e',
                                        
'ё' => 'jo',
                                        
'ж' => 'zh',
                                        
'з' => 'z',
                                        
'и' => 'i',
                                        
'й' => 'y',
                                        
'к' => 'k',
                                        
'л' => 'l',
                                        
'м' => 'm',
                                        
'н' => 'n',
                                        
'о' => 'o',
                                        
'п' => 'p',
                                        
'р' => 'r',
                                        
'с' => 's',
                                        
'т' => 't',
                                        
'у' => 'u',
                                        
'ф' => 'f',
                                        
'х' => 'h',
                                        
'ц' => 'c',
                                        
'ч' => 'ch',
                                        
'ш' => 'sh',
                                        
'щ' => 'shh',
                                        
'ъ' => '',
                                        
'ы' => 'y',
                                        
'ь' => '',
                                        
'э' => 'eh',
                                        
'ю' => 'yu',
                                        
'я' => 'ya',
                                        
'>' => '_',
                                        
'<' => '_',
                                        
'/' => '_',
                                        
'—' => '-',
                                        
                                        
'A' => 'А',
                                        
'B' => 'Б',
                                        
'V' => 'В',
                                        
'G' => 'Г',
                                        
'D' => 'Д',
                                        
'E' => 'Е',
                                        
'E' => 'Ё',
                                        
'ZH' => 'Ж',
                                        
'Z' => 'З',
                                        
'I' => 'И',
                                        
'Y' => 'Й',
                                        
'K' => 'К',
                                        
'L' => 'Л',
                                        
'M' => 'М',
                                        
'N' => 'Н',
                                        
'O' => 'О',
                                        
'P' => 'П',
                                        
'R' => 'Р',
                                        
'S' => 'С',
                                        
'T' => 'Т',
                                        
'U' => 'У',
                                        
'F' => 'Ф',
                                        
'H' => 'Х',
                                        
'C' => 'Ц',
                                        
'CH' => 'Ч',
                                        
'SH' => 'Ш',
                                        
'SHH' => 'Щ',
                                        
'Y' => 'Ы',
                                        
'EH' => 'Э',
                                        
'YU' => 'Ю',
                                        
'YA' => 'Я',
                                        
'a' => 'а',
                                        
'b' => 'б',
                                        
'v' => 'в',
                                        
'g' => 'г',
                                        
'd' => 'д',
                                        
'e' => 'е',
                                        
'jo' => 'ё',
                                        
'zh' => 'ж',
                                        
'z' => 'з',
                                        
'i' => 'и',
                                        
'y' => 'й',
                                        
'k' => 'к',
                                        
'l' => 'л',
                                        
'm' => 'м',
                                        
'n' => 'н',
                                        
'o' => 'о',
                                        
'p' => 'п',
                                        
'r' => 'р',
                                        
's' => 'с',
                                        
't' => 'т',
                                        
'u' => 'у',
                                        
'f' => 'ф',
                                        
'h' => 'х',
                                        
'c' => 'ц',
                                        
'ch' => 'ч',
                                        
'sh' => 'ш',
                                        
'shh' => 'щ',
                                        
'y' => 'у',
                                        
'eh' => 'э',
                                        
'yu' => 'ю',
                                        
'ya' => 'я',
                                        
'>' => '_',
                                        
'<' => '_',
                                        
'/' => '_',
                                        
'—' => '-'                                        ) ;

                        
$var strtr$var$replace ) ;

                        return 
preg_replace"#s+#""_"$var ) ;
        }
        
#вывод пользователя

        
function userlist$uid )
        {
                        global 
$host$level;

                        
$luser mysql_fetch_assocmysql_query"SELECT * FROM `users` WHERE `id` = '$uid' LIMIT 1" ) ) ;
                        
$pol $luser['pol'] ;
                        
$name check$luser['login'] ) ;
                        
$on time() - $luser['time'] ;
                        if ( 
$on <= 300 )
                        {
                                        
#поставить иконку онлайн
                                        
$on '<img src="/img/online.png"/>' ;
                        }
                        else
                        {
                                        
#поставить иконку офлайн
                                        
$on '<img src="/img/offline.png"/>' ;
                        }
                        
$stat $luser['status'] ;

                        echo 
'<div class="userlist"><table>
<tr>
    <td><img src="' 
$host '/avatar/small/' $luser['id'] . '.png" /></td>
    <td></td>
    <td><strong><a href="' 
$host '/' $luser['id'] . '">' $name .
                                        
'</a></strong><br /><font color="green">' .
                                        
$on '</font></td></tr>
</table></div>' 
;
    }

        
#$file файл который конвертим
        #$size размер конечного файла
        #$news имя и путь конечного файла
        
function limage$file$size$news )
        {

                        
$source imagecreatefromjpeg$file ) ;
                        list( 
$width$height ) = getimagesize$file ) ;
                        
$thumbs imagecreatetruecolor$size$size ) ;
                        if ( 
$width $height && $width $size )
                        {
                                        
imagecopyresampled$thumbs$source00, ( ( $width $height ) / ), 0$size,
                                                        
$size$height$height ) ;
                        }
                        elseif ( 
$height $width && $height $size )
                        {
                                        
imagecopyresampled$thumbs$source000, ( ( $height $width ) / ), $size,
                                                        
$size$width$width ) ;
                        }
                        elseif ( 
$height == $width && $height $size )
                        {
                                        
imagecopyresampled$thumbs$source0000$size$size$width$width ) ;
                        }
                        else
                        {
                                        
$thumbs $source ;
                        }

                        
imagejpeg$thumbs$news100 ) ;
                        
imagedestroy$thumbs ) ;
        }

        
#копирайт на фотку
        
function watermark$file$watermark )
        {
                        if ( empty( 
$file ) | empty( $watermark ) ) return false ;
                        
$wh getimagesize$watermark ) ;
                        
$fh getimagesize$file ) ;
                        
$rwatermark imagecreatefrompng$watermark ) ; //Иногда может понадобиться наложить прозрачный png, тогда заменяем функцию на imagecreatefrompng
                        
$rfile imagecreatefromjpeg$file ) ;
                        
imagecopy$rfile$rwatermark$fh[0] - $wh[0], $fh[1] - $wh[1], 00$wh[0],
                                        
$wh[1] ) ;
                        
imagejpeg$rfile$file'100' ) ;
                        
imagedestroy$rwatermark ) ;
                        
imagedestroy$rfile ) ;
                        return 
true ;
        }
        
//watermark('1.jpg', '2.jpg'); //Теперь 1.jpg в нижнем правом углу обляпался 2.jpg
function page($k_page=1){ // Выдает текущую страницу
$page=1;
if (isset(
$_GET['page'])){
if (
$_GET['page']=='end')$page=intval($k_page);elseif(is_numeric($_GET['page'])) $page=intval($_GET['page']);}
if (
$page<1)$page=1;
if (
$page>$k_page)$page=$k_page;
return 
$page;}
function 
k_page($k_post=0,$k_p_str=10){ // Высчитывает количество страниц
if ($k_post!=0){$v_pages=ceil($k_post/$k_p_str);return $v_pages;}
else return 
1;}
function 
str($link='?',$k_page=1,$page=1){ // Вывод номеров страниц (только на первый взгляд кажется сложно ;))
if ($page<1)$page=1;
echo 
"<div id="pagez">";
echo 
" ";
if (
$page!=1)echo "<a href="".$link."page=1">1</a>";else echo "<b>1</b>";
for (
$ot=-3$ot<=3$ot++){
if (
$page+$ot>&& $page+$ot<$k_page){
if (
$ot==-&& $page+$ot>2)echo " ..";
if (
$ot!=0)echo " <a href="".$link."page=".($page+$ot)."">".($page+$ot)."</a>";else echo " <b>".($page+$ot)."</b>";
if (
$ot==&& $page+$ot<$k_page-1)echo " ..";}}
if (
$page!=$k_page)echo " <a href="".$link."page=end">$k_page</a>";elseif ($k_page>1)echo " <b>$k_page</b>";
echo 
"</div>n";
}

        
/* Функция отображения времени */
function clock($time)
{
global 
$users;
$timezone = (!$users) ? : ($users['sdvig']*3600);
$time $time+$timezone;
$timepdate("j M Y в H:i:s"$time);
$time_p[0]=date("j n Y"$time);
$time_p[1]=date("H:i:s"$time);
if (
$time_p[0]==date("j n Y"time()))$timep='Сегодня в '.$time_p['1'];
if (
$time_p[0]==date("j n Y"time()-86400))$timep='Вчера в '.$time_p['1'];
if (
$time_p[0]==date("j n Y"time()-172800))$timep='Позовчера в '.$time_p['1'];
if (
$time_p[0]==date("j n Y"time()-259200))$timep='3 Дня назад в '.$time_p['1'];
if (
$time_p[0]==date("j n Y"time()-604800))$timep='Неделю назад в '.$time_p['1'];
if (
$time_p[0]==date("j n Y"time()-1209600))$timep='2 Недели назад в '.$time_p['1'];
if (
$time_p[0]==date("j n Y"time()-2592000))$timep='Месяц назад в '.$time_p['1'];
$months_eng = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
$months_rus = array('Января','Февраля','Марта','Апреля','Мая','Июня','Июля','Августа','Сентября','Октября','Ноября','Декабря');
$timep str_replace($months_eng,$months_rus,$timep);
return 
$timep;
}
        
/* Функция отображения времени */
function clockchat($time)
{
global 
$users;
$timezone = (!$users) ? : ($users['sdvig']*3600);
$time $time+$timezone;
$timepdate("j M Y в H:i:s"$time);
$time_p[0]=date("j n Y"$time);
$time_p[1]=date("H:i:s"$time);
if (
$time_p[0]==date("j n Y"time()))$timep=$time_p['1'];
$months_eng = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
$months_rus = array('Января','Февраля','Марта','Апреля','Мая','Июня','Июля','Августа','Сентября','Октября','Ноября','Декабря');
$timep str_replace($months_eng,$months_rus,$timep);
return 
$timep;
}

function 
protect($var){return trim(mysql_real_escape_string($var));}

?>
Онлайн: 2
Реклама