Файл: BlogExl_v_3/system/functions/func.php
Строк: 88
<?
list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;
function elite($var){
if ($var['level'] == 0){ $return = 'Блоггер';
}elseif ($var['level'] == 1){
$return = 'Модератор';
}elseif ($var['level'] == 2){ $return = 'Администратор';}
return $return;
}
function times($var) {
if ($var == NULL) $var = time();
$full_time = date('d.m.Y в H:i', $var);
$date = date('d.m.Y', $var);
$time = date('H:i', $var);
if ($date == date('d.m.Y')) $full_time = date('Сегодня в H:i', $var);
if ($date == date('d.m.Y', time()-60*60*24)) $full_time = date('Вчера в H:i', $var);
return $full_time;
}
function smiles($str) {
global $dbs;
$smiles = $dbs->query("SELECT * FROM `smiles`");
while($a = $smiles->fetch_assoc()){
$str = str_replace($a['name'], '<img src="/files/smiles/'.$a['file'].'" alt="'.$a['name'].'"/>', $str);
}
return $str;
}
$home = 'http://'.$_SERVER['HTTP_HOST'].'';
function code($var){
$var = preg_replace('#[php](.+?)[/php]#e', 'highlight_code("1")', $var);
$var = preg_replace('#[b](.*?)[/b]#si', '<b>1</b>', $var);
$var = preg_replace('#[cit](.+?)[/cit]#is', '<div class="cit">\1</div>', $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', '<s>1</s>', $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( "#[center](.+?)[/center]#is", "<center>\1</center>", $var);
$var = preg_replace('#[url=(http://.+)](.+)[/url]#i','<a href="1">2</a>',$var);
$var = preg_replace( "~\[img](.+?)[/img]~", "<img src="".$home."/system/resize.php?image=\1" alt="Изображение" /></a>", $var);
$var = preg_replace( "#(^|[n ])([w]+?://[w#$%&~/.-;:=,?@[]+]*)#is", "\1<a href="\2" target="_blank">\2</a>", $var);
$var = preg_replace( "#(^|[n ])((www|ftp).[w#$%&~/.-;:=,?@[]+]*)#is", "\1<a href="http://\2" target="_blank">\2</a>", $var);
return $var;
}
function head($title){
global $user,$set;
$t=microtime(1);
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>'.$set['name'].' | '.$title.'</title>
<meta name="description" content="'.$set['description'].'"/>
<meta name="keywords" content="'.$set['keywords'].'"/>
<link rel="stylesheet" href="'.(empty($user['style'])?'/design/css.css':$user['style']).'" type="text/css" />
</head>
<body><div
class="verh"><img src="'.$set['logo'].'"
alt="logo"/></div>';
}
function info(){
global $user, $dbs;
if(isset($user)){
$k = $dbs->query("SELECT * FROM `mail` WHERE `komu` = '$user[id]' AND `read` = '0'")->num_rows;
if($k>0){echo'<div class="post2"><a href="/my/mail.php?in">Сообщение</a> (+'.$k.')</div>';}
$op = $dbs->query("SELECT * FROM `action` WHERE `id_us` = '$user[id]' AND `read` = '0'")->num_rows;
if($op>0){echo'<div class="post2"><a href="/my/ops.php">Оповещение</a> (+'.$op.')</div>';}
}
}
function foot(){
global $dbs,$set,$headtime,$time;
list($msec, $sec) = explode(chr(32), microtime());
$tgen=round(($sec + $msec) - $headtime, 3);
echo '<div class="niz"><input type="button" value="Назад" onClick="history.go(-1);" /></a><a href="/"><input type="button" value="Главная"/></a><br/><a href="/index.php">(c) '.$set['copy'].'</a><br/>Ген.: '.$tgen.'</div>';
echo '</body></html>';
}
function footer(){
global $dbs,$set,$headtime,$time;
list($msec, $sec) = explode(chr(32), microtime());
$tgen=round(($sec + $msec) - $headtime, 3);
echo '<div class="niz"><a href="/index.php">(c) '.$set['copy'].'</a><br/>Ген.: '.$tgen.'</div>';
echo '</body></html>';
}
function page($param){
global $page,$total;
if ($page != 1) $pervpage = '<a href="'.$param.'page1"><<</a>
<a href="'.$param.'page'.($page-1).'"><</a> ';
if ($page != $total) $nextpage = ' <a href="'.$param.'page'.($page+1).'">></a>
<a href="'.$param.'page'.$total.'">>></a>';
if($page - 2 > 0) $page2left = ' <a href="'.$param.'page'. ($page - 2) .'">'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = '<a href="'.$param.'page'. ($page - 1) .'">'. ($page - 1) .'</a> | ';
if($page + 2 <= $total) $page2right = ' | <a href="'.$param.'page'. ($page + 2) .'">'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href="'.$param.'page'. ($page + 1) .'">'. ($page + 1) .'</a>';
echo '<div class="pod_razd">Стр. '.$pervpage.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$nextpage.'</div>';
}
function str($param){
global $page,$total;
if ($page != 1) $pervpage = '<a href="'.$param.'page=1"><<</a>
<a href="'.$param.'page='.($page-1).'"><</a> ';
if ($page != $total) $nextpage = ' <a href="'.$param.'page='.($page+1).'">></a>
<a href="'.$param.'page='.$total.'">>></a>';
if($page - 2 > 0) $page2left = ' <a href="'.$param.'page='. ($page - 2) .'">'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = '<a href="'.$param.'page='. ($page - 1) .'">'. ($page - 1) .'</a> | ';
if($page + 2 <= $total) $page2right = ' | <a href="'.$param.'page='. ($page + 2) .'">'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href="'.$param.'page='. ($page + 1) .'">'. ($page + 1) .'</a>';
echo '<div class="pod_razd">Стр. '.$pervpage.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$nextpage.'</div>';
}
?>