Файл: OldBlog by Axer/blog/inc/function.php
Строк: 90
<?
///Фильтруем текст////////////////////////////////////////////
function mht($text){
$text=mysql_real_escape_string(htmlspecialchars(trim($text)));
return $text;
}
//////////////////////////////////////////////////////////////
///Фильтруем числа////////////////////////////////////////////
function intag($int){
$int = abs(intval(trim($int)));
return $int;
}
//////////////////////////////////////////////////////////////
function mail_send($to, $subject, $message)
{
$from=$otvet['email'];
$headers = "Content-type: text/html; charset=utf-8 rn";
$headers .= "From: Robot $fromrn";
$headers .= "Bcc: ".$otvet['http']."rn";
return mail($to, $subject, $message, $headers);
}
//Устанавливаем статус админа//////////////////////////////////
function status($m){
$times=time();
$status=mysql_query("UPDATE settings SET status='$m',tstatus='$times'");
}
////узнаем формат файла///////
function format($type){
if ($type=='rar') {$typ='rar';}
elseif ($type=='zip') {$typ='zip';}
elseif ($type=='mp3') {$typ='mp3';}
elseif ($type=='wav') {$typ='wav';}
elseif ($type=='mid') {$typ='mid';}
elseif ($type=='avi') {$typ='avi';}
elseif ($type=='mp4') {$typ='mp4';}
elseif ($type=='flv') {$typ='flv';}
elseif ($type=='wmv') {$typ='wmv';}
elseif ($type=='mpeg') {$typ='mpeg';}
elseif ($type=='3gp') {$typ='3gp';}
elseif ($type=='txt') {$typ='txt';}
elseif ($type=='docx' || $type=='doc') {$typ='word';}
elseif ($type=='xls') {$typ='excel';}
elseif ($type=='ppt' || $type=='pptx') {$typ='powerpoint';}
elseif ($type=='png') {$typ='png';}
elseif ($type=='gif') {$typ='gif';}
elseif ($type=='jpg' || $type=='jpeg') {$typ='jpg';}
elseif ($type=='wav') {$typ='wav';}
elseif ($type=='') {$typ='no';}
else {$typ='no';}
return $typ;
}
////////////////////////////////
///выбираем картинку формата файла///
function imgpic($type){
if ($type=='rar' || $type=='zip') {$img='<img src="formats/archives.png"></img>';}
elseif ($type=='mp3' ||$type=='wav' || $type=='mid') {$img='<img src="formats/audio.png"></img>';}
elseif ($type=='avi' || $type=='mp4' || $type=='flv' || $type=='wmv' || $type=='mpeg' || $type=='3gp') {$img='<img src="formats/video.png"></img>';}
elseif ($type=='txt') {$img='<img src="formats/txt.png"></img>';}
elseif ($type=='docx' || $type=='doc') {$img='<img src="formats/word.png"></img>';}
elseif ($type=='xls' || $type=='xlsx') {$img='<img src="formats/excels.png"></img>';}
elseif ($type=='ppt' || $type=='pptx') {$img='<img src="formats/powerpoint.png"></img>';}
elseif ($type=='png' || $type=='PNG' || $type=='pneg' || $type=='gif' || $type=='jpg' || $type=='jpeg') {$img='<img src="formats/img.png"></img>';}
elseif ($type=='') {$img='<img src="formats/no.png"></img>';}
else {$img='<img src="formats/no.png"></img>';}
return $img;
}
/////////////////////////////////////
function bbcode($var = '')
{
$var = strip_tags($var);
$var = preg_replace('#[br]#si', '<br/>', $var);
$var = preg_replace('#[b](.*?)[/b]#si', '<b>1</b>', $var);
$var = preg_replace('#[img](.*?)[/img]#si', '<a href="1" title="Нажмите для масштабирования"><img src="1" width="100" height="100" alt="Картинка"/></a>', $var);
$var = preg_replace('#[i](.*?)[/i]#si', '<i>1</i>', $var);
$var = preg_replace('#[u](.*?)[/u]#si', '<u>1</u>', $var);
$var = preg_replace('#[s](.*?)[/s]#si', '<strike>1</strike>', $var);
$var = preg_replace('#[red](.*?)[/red]#si', '<font color="#ff7900">1</font>', $var);
$var = preg_replace('#[green](.*?)[/green]#si', '<font color="#00FF00">1</font>', $var);
$var = preg_replace('#[blue](.*?)[/blue]#si', '<font color="#0000FF">1</font>', $var);
$var = preg_replace('#[black](.*?)[/black]#si', '<font color="#FFF">1</font>', $var);
$var = preg_replace('#[video](.*?)[/video]#si', '<div id="mediaplayer">JW Player goes here</div>
<script type="text/javascript" src="jwplayer.js"></script>
<script type="text/javascript">
jwplayer("mediaplayer").setup({
flashplayer: "player.swf",
file: "1",
image: "preview.jpg"
});
</script>', $var);
$var = preg_replace('#[url=(.*?)](.*?)[/url]#si', '<a href="1">2</a>', $var);
return $var;
}
function html2bbcode($var = '')
{
$var = ereg_replace("<br/>", "[br]", $var);
$var = preg_replace('#<span style="font-size: 20px">(.*?)</span>#si', '<strong>1</strong>', $var);
$var = preg_replace('#<a href="(.*?)" title="Нажмите для масштабирования"><img src="(.*?)" width="50" height="50" alt="Картинка"/></a>#si', '[img]1[/img]', $var);
$var = preg_replace('#<i>(.*?)</i>#si', '<em>1</em>', $var);
$var = preg_replace('#<u>(.*?)</u>#si', '<span style="text-decoration:underline;">1</span>', $var);
$var = preg_replace('#<strike>(.*?)</strike>#si', '[s]1[/s]', $var);
$var = preg_replace('#<font color="#ff7900">(.*?)</font>#si', '<span style="color:#ff0000;">1</span>', $var);
$var = preg_replace('#<font color="#00FF00">(.*?)</font>#si', '<span style="color:#00bb00;">1</span>', $var);
$var = preg_replace('#<font color="#0000FF">(.*?)</font>#si', '<span style="color:#0000bb;">1</span>', $var);
$var = preg_replace('#<a href="(.*?)">(.*?)</a>#si', '[url=1]2[/url]', $var);
return $var;
}
?>