Файл: mob-lave.ru/core/function/site.php
Строк: 133
<?php
// ----------- вывод ошибок ----------- //
function err(){
global $err;
if (isset($err)){
if (is_array($err)){
foreach ($err as $key=>$value) {
echo "<div class='err'>$value</div>n";
}
}
else
echo "<div class='err'>$err</div>n";
}
}
function msg($msg){
echo '<div class="msg">'.$msg.'</div>';
}
function rekl($rekl) {
global $system, $time;
// Низ всех страниц
if($rekl == 2){
$q = mysql_query("SELECT * FROM `$system[perfix]_rekl` WHERE `gde` = '2' && `time_out` > '$time' ORDER BY rand() LIMIT 3");
while($post = mysql_fetch_assoc($q)) {
echo '<img src="http://favicon.yandex.net/favicon/'.htmlspecialchars($post['link']).'" /> <a href="http://'.htmlspecialchars($post['link']).'">'.htmlspecialchars($post['title']).'</a><br />';
}
}
}
// ------------ Время ----------- //
function vremja($time=NULL){
global $user;
if ($time==NULL)$time=time();
if (isset($user))$time=$time+$user['timesdvig']*60*60;
$timep="".date("j M Y в H:i", $time)."";
$time_p[0]=date("j n Y", $time);
$time_p[1]=date("H:i", $time);
if ($time_p[0]==date("j n Y"))$timep=date("H:i:s", $time);
if (isset($user)){
if ($time_p[0]==date("j n Y", time()+$user['timesdvig']*60*60))$timep=date("H:i:s", $time);
if ($time_p[0]==date("j n Y", time()-60*60*(24-$user['timesdvig'])))$timep="Вчера в $time_p[1]";}
else{
if ($time_p[0]==date("j n Y"))$timep=date("H:i:s", $time);
if ($time_p[0]==date("j n Y", time()-60*60*24))$timep="Вчера в $time_p[1]";}
$timep=str_replace("Jan","Янв",$timep);
$timep=str_replace("Feb","Фев",$timep);
$timep=str_replace("Mar","Марта",$timep);
$timep=str_replace("May","Мая",$timep);
$timep=str_replace("Apr","Апр",$timep);
$timep=str_replace("Jun","Июня",$timep);
$timep=str_replace("Jul","Июля",$timep);
$timep=str_replace("Aug","Авг",$timep);
$timep=str_replace("Sep","Сент",$timep);
$timep=str_replace("Oct","Окт",$timep);
$timep=str_replace("Nov","Ноября",$timep);
$timep=str_replace("Dec","Дек",$timep);
return $timep;
}
// -------- Редирект ---------- //
function loc($location) {
if (headers_sent())
die('<sсriрt type="text/jаvаsсriрt">document.location.href = "'.$location.'";</sсriрt>');
else
die(header('Location: '.$location));
}
// ------------- Навигация ---------- //
function page($k_page=1){ // Выдает текущую страницу
$page=1;
if (isset($_GET['page'])){
if ($_GET['page']=='end')$page=num($k_page);elseif(is_numeric($_GET['page'])) $page=num($_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 '<form method="get" action="'.$link.'">';
if ($page>1)echo "<a href='".$link."page=".($page-1)."'>← Предыдущая</a>n";
if ($page<$k_page)echo ($page>1?"":NULL)."<a href='".$link."page=".($page+1)."'>Следующая →</a>n";
echo '<br/>';
if ($page!=1)echo "<span class='page'><a href='".$link."page=1'> 1 </a></span>n";
else echo "<span class='str'> 1 </span>n";
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 "<span class='page'><a href='".$link."page=".($page+$ot)."'> ".($page+$ot)." </a></span>n";
else echo "<span class='str'> ".($page+$ot)." </span> ";
if ($ot==3 && $page+$ot<$k_page-1)echo " ..";
}
}
if ($page!=$k_page)echo "<span class='page'><a href='".$link."page=end'> $k_page </a></span>n";
elseif ($k_page>1)echo "<span class='str'> $k_page </span>n";
echo '<input name="page" size="3" maxlength="5" value=""/>
<input type="submit" value="Перейти" />';
echo '</form>';
}
// --------------- Вап/веб ------------- //
function mobile($id){
global $system;
$id_user = mysql_fetch_assoc(mysql_query("SELECT `user_agent` FROM `$system[perfix]_users` WHERE `id` = '$id'"));
$user_agent = text($id_user['user_agent']);
$ipod = strpos($user_agent,"iPod");
$iphone = strpos($user_agent,"iPhone");
$android = strpos($user_agent,"Android");
$symb = strpos($user_agent,"Symbian");
$winphone = strpos($user_agent,"WindowsPhone");
$wp7 = strpos($user_agent,"WP7");
$wp8 = strpos($user_agent,"WP8");
$operam = strpos($user_agent,"Opera M");
$palm = strpos($user_agent,"webOS");
$berry = strpos($user_agent,"BlackBerry");
$mobile = strpos($user_agent,"Mobile");
$htc = strpos($user_agent,"HTC_");
$fennec = strpos($user_agent,"Fennec/");
if ($ipod || $iphone || $android || $symb || $winphone || $wp7 || $wp8 || $operam || $palm || $berry || $mobile || $htc || $fennec)
{
return true;
}
else
{
return false;
}
}
?>