Просмотр файла system/xcms_func.php

Размер файла: 11.55Kb
<?php
function smiles($text){
	$text = str_replace('.0.','<img src="/files/images/smiles/0.png">',$text);
	$text = str_replace('.1.','<img src="/files/images/smiles/1.png">',$text);
	$text = str_replace('.2.','<img src="/files/images/smiles/2.png">',$text);
	$text = str_replace('.3.','<img src="/files/images/smiles/3.png">',$text);
	$text = str_replace('.4.','<img src="/files/images/smiles/4.png">',$text);
	$text = str_replace('.5.','<img src="/files/images/smiles/5.png">',$text);
	$text = str_replace('.6.','<img src="/files/images/smiles/6.png">',$text);
	$text = str_replace('.7.','<img src="/files/images/smiles/7.png">',$text);
	$text = str_replace('.8.','<img src="/files/images/smiles/8.png">',$text);
	$text = str_replace('.9.','<img src="/files/images/smiles/9.png">',$text);
	$text = str_replace('.!!.','<img src="/files/images/smiles/10.png">',$text);
	$text = str_replace('.1?.','<img src="/files/images/smiles/11.png">',$text);
	$text = str_replace('.ok.','<img src="/files/images/smiles/12.png">',$text);
	$text = str_replace('.hlop.','<img src="/files/images/smiles/13.png">',$text);
	$text = str_replace('.cool.','<img src="/files/images/smiles/14.png">',$text);
	$text = str_replace('.dog.','<img src="/files/images/smiles/15.png">',$text);
	$text = str_replace('.rus.','<img src="/files/images/smiles/16.png">',$text);
	$text = str_replace('.eng.','<img src="/files/images/smiles/17.png">',$text);
	$text = str_replace('.ukr.','<img src="/files/images/smiles/18.png">',$text);
	$text = str_replace('.diamond.','<img src="/files/images/smiles/19.png">',$text);
	$text = str_replace('.hearth1.','<img src="/files/images/smiles/20.png">',$text);
	$text = str_replace('.hearth2.','<img src="/files/images/smiles/21.png">',$text);
	$text = str_replace('.hearth3.','<img src="/files/images/smiles/22.png">',$text);
	$text = str_replace('.hearth4.','<img src="/files/images/smiles/23.png">',$text);
	$text = str_replace('.hearth5.','<img src="/files/images/smiles/24.png">',$text);
	$text = str_replace('.hearth6.','<img src="/files/images/smiles/25.png">',$text);
	$text = str_replace('.pou.','<img src="/files/images/smiles/26.png">',$text);
	$text = str_replace('.money.','<img src="/files/images/smiles/27.png">',$text);
	$text = str_replace('.+18.','<img src="/files/images/smiles/28.png">',$text);
	$text = str_replace('.refresh1.','<img src="/files/images/smiles/29.png">',$text);
	$text = str_replace('.refresh2.','<img src="/files/images/smiles/30.png">',$text);
	$text = str_replace(':)','<img src="/files/images/smiles/31.png">',$text);
	$text = str_replace('.love.','<img src="/files/images/smiles/32.png">',$text);
	$text = str_replace(':*','<img src="/files/images/smiles/33.png">',$text);
	$text = str_replace('.haha.','<img src="/files/images/smiles/34.png">',$text);
	$text = str_replace('.8D.','<img src="/files/images/smiles/35.png">',$text);
	$text = str_replace('X)','<img src="/files/images/smiles/36.png">',$text);
	$text = str_replace(':D','<img src="/files/images/smiles/37.png">',$text);
	$text = str_replace('.angel.','<img src="/files/images/smiles/38.png">',$text);
	$text = str_replace(';)','<img src="/files/images/smiles/39.png">',$text);
	$text = str_replace(':|','<img src="/files/images/smiles/40.png">',$text);
	$text = str_replace('.hm.','<img src="/files/images/smiles/41.png">',$text);
	$text = str_replace(':-/','<img src="/files/images/smiles/42.png">',$text);
	$text = str_replace('.zloj.','<img src="/files/images/smiles/43.png">',$text);
	$text = str_replace(';(','<img src="/files/images/smiles/44.png">',$text);
	$text = str_replace(':O','<img src="/files/images/smiles/45.png">',$text);
	$text = str_replace('.smushen.','<img src="/files/images/smiles/46.png">',$text);
	$text = str_replace('.zzz.','<img src="/files/images/smiles/47.png">',$text);
	$text = str_replace('.kiss.','<img src="/files/images/smiles/48.png">',$text);
	$text = str_replace('.otstoi.','<img src="/files/images/smiles/49.png">',$text);
	return $text;
}
/* Определение размера */
function formatsize($file_size){
	if($file_size >= 1073741824){$file_size = round($file_size / 1073741824 * 100) / 100 . " Гб";}
	elseif($file_size >= 1048576){$file_size = round($file_size / 1048576 * 100) / 100 . " Мб";}
	elseif($file_size >= 1024){$file_size = round($file_size / 1024 * 100) / 100 . " Кб";}
	else{$file_size = round($file_size) . " байт";}
	return $file_size;
}
/* BB КОДЫ */
function bb_code($text){
	$text = preg_replace('|\[b](.+)\[\/b]|','<b>$1</b>',$text);
	$text = preg_replace('|\[i](.+)\[\/i]|','<i>$1</i>',$text);
	$text = preg_replace('|\[u](.+)\[\/u]|','<u>$1</u>',$text);
	$text = preg_replace('|\[big](.+)\[\/big]|','<big>$1</big>',$text);
	$text = preg_replace('|\[small](.+)\[\/small]|','<small>$1</small>',$text);
	$text = preg_replace('|\[del](.+)\[\/del]|','<del>$1</del>',$text);
	$text = preg_replace('|\[quote](.+)\[\/quote]|','<div class="ads">$1</div>',$text);
	$text = preg_replace('#\[url\=http://(.*)\](.*)\[/url\]#Ui','<a href="http://'.$_SERVER['HTTP_HOST'].'/go?url=http://\\1" target="_blank">\\2</a>',$text);//для ссылок
	$text = preg_replace('|\[img](.+)\[\/img]|','<a href="$1"><img src="$1" alt="" style="height:150px;"/></a>',$text);
	$text = preg_replace('|\[color=red](.+)\[\/color]|','<font color="#dc143c">$1</font>',$text);
	$text = preg_replace('|\[music](.+)\[\/music]|','<object type="application/x-shockwave-flash" data="/ump3player.swf" height="67" width="380">
	<param name="wmode" value="transparent" /><param name="allowFullScreen" value="true" />
	<param name="allowScriptAccess" value="always" /><param name="movie" value="http://'.$_SERVER['HTTP_HOST'].'/ump3player.swf" />
	<param name="FlashVars" value="way=$1&swf=http://'.$_SERVER['HTTP_HOST'].'/ump3player.swf&w=380&h=67&&autoplay=0&q=&skin=grey&volume=100&comment=" />
	</object>',$text);
	return $text;
}

/* Функция безопасного шифрования в MD5 */
function pass($text){return md5(md5('VKSELL').md5(md5($text)));}
#------- Функция постраничной навигации
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 class="pages">';
	if($page!=1)echo'<a href="'.$link.'page='.($page-1).'"><span style="float:left;">Пред.</span></a>';else echo'<span style="float:left;">Пред.</span>';
	if($k_page>1 and $page!=$k_page)echo'<span style="float:right;"><a href="'.$link.'page='.($page+1).'">След.</a></span>';else echo'<span style="float:right;">След.</span>';
	echo'</div>';
	echo "<div class=\"pages\">Страница:\n";
	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>1 && $page+$ot<$k_page){
	if ($ot==-3 && $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==3 && $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){
	$timep= date("j M Y в H:i:s", $time);
	$time_p[0]=date("j n Y", $time);
	$time_p[1]=date("H:i", $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'];
	$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;
}
//generates
function passgen($k_simb=8, $types=3) {
	$password="";
	$small="abcdefghijklmnopqrstuvwxyz";
	$large="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	$numbers="1234567890";
	mt_srand((double)microtime()*1000000);
	for ($i=0; $i<$k_simb; $i++) {
		$type=mt_rand(1,min($types,3));
		switch ($type) {
			case 3:$password.=$large[mt_rand(0,25)];break;
			case 2:$password.=$small[mt_rand(0,25)];break;
			case 1:$password.=$numbers[mt_rand(0,9)];break;
		}
	}
	return $password;
}
$passgen=&passgen();

function checkin($str){
	if (function_exists('iconv')) {$str = iconv("UTF-8", "UTF-8", $str);}
	$str = preg_replace('/[^\P{C}\n]+/u', '', $str);
	return trim($str);
}
function protect1($str){
	$str = htmlentities(trim($str), ENT_QUOTES, 'UTF-8');
	$str = checkin($str);
	$str = htmlspecialchars($str);
	return $str;
}
function protect2($text){
	$text = strip_tags($text);
	$text = htmlspecialchars($text);
	$text = mysql_escape_string($text);
	return $text;
}
function protect($text){
	$text = trim(htmlspecialchars(($text)));
	return $text;
}
function back($text){echo'<div class="pages" style="text-align:center;"><a href="'.$text.'" style="display:block;">Назад</a></div>';return;}
function sizer($text){$text=round(filesize($text)/1000).' Кб';return $text;}
function size2($text)  {
    if ($text >= 1000000000000) {
        $text = round($text / 1099511627776, 1);
        $text = 'Тб';
    }  elseif ($text >= 1000000000) {
        $text = round($text / 1073741824, 1);
        $text ='Гб';
    } elseif ($text >= 1000000) {
        $text = round($text / 1048576, 1);
        $unit = 'Мб';
    } elseif ($text >= 1000) {
        $text = round($text / 1024, 1);
        $unit = 'Кб';
    } else {
        $unit = 'б';
        return number_format($text).' '.$unit;
    }
    return number_format($text, 1).' '.$unit;
}
function lvl($sozd, $text){
	if($text==1)$text='<span style="color:blue;">[Мод]</span> ';
	elseif($text==2)$text='<span style="color:blue;">[Мод]</span> ';
	elseif($text==3)$text='<span style="color:blue;">[Мод]</span> ';
	elseif($text==4)$text='<span style="color:blue;">[Мод]</span> ';
	elseif($text==5)$text='<span style="color:blue;">[Адм]</span> ';
	elseif($text==6)$text='<span style="color:blue;">[Ст.Адм]</span> ';
	elseif($text==0)$text='';
	if($sozd==1)$text='<span style="color:red;"><b>[Созд]</b></span> ';
	return $text;
}
function avatar($text){$text='<img src="/files/avatar/'.$text.'" alt="" style="float:left;margin-right:5px;width:28px;height:28px;"/>';return $text;}
function avatar_group_small($text){$text='<img src="/files/avatar_group/'.$text.'" alt="" style="float:left;margin-right:5px;width:28px;height:28px;"/>';return $text;}
function avatar_group($text){$text='<img src="/files/avatar_group/'.$text.'" alt="" style="float:right;height:58px;"/>';return $text;}
function image($text){$text='<img src="/files/images/'.$text.'" alt="" style="float:left;margin-right:5px;width:28px;height:28px;"/>';return $text;}
function right($text){$text='<span style="float:right;">'.$text.'</span>';return $text;}
function on($visit){if($visit>(time()-90)){$out=' <img src="/files/images/on.png" alt="*" style="width:10px;height:10px;"/>';}else{$out='';} return $out;}
?>