Файл: you/_system/functions.php
Строк: 95
<?
###################################################
# BY MAKSAMKA (Mr.MAX) ICQ 154-26-36 #
# Поиск видео > API v3 Youtube #
# Версия сборки V.1.1 продолжение будет #
###################################################
/* фильтрация цифр */
function num($var){
return abs(intval($var));
}
/* фильтрация прочего */
function filtr($var){
return htmlspecialchars(trim($var));
}
function out($var)
{
return htmlspecialchars(stripslashes($var));
}
function clear() {
if (file_exists(dirname(__FILE__).'/../logs/cache/')) {
foreach (glob(dirname(__FILE__).'/../logs/cache/*') as $file) {
unlink($file);
}
}
}
function tm($youtube_time){
$start = new DateTime('@0');
$start->add(new DateInterval($youtube_time));
return $start->format('H:i:s');
}
function yotube($url,$name,$times){
if ($times) {
$cache_file = dirname(__FILE__).'/../logs/cache/' . $name;
if (time() - @filemtime($cache_file) >= $times) {
$buf = file_get_contents($url);
if ($buf) file_put_contents($cache_file, $buf);
}
if (empty($buf)) {
$buf = file_get_contents($cache_file);
}
}else{
$buf = file_get_contents($url);
}
return json_decode($buf);
}
function slv($str,$msg1,$msg2,$msg3) {
$str = (int)$str;
$str1 = abs($str) % 100;
$str2 = $str % 10;
if ($str1 > 10 && $str1 < 20) return $str .' '. $msg3;
if ($str2 > 1 && $str2 < 5) return $str .' '. $msg2;
if ($str2 == 1) return $str .' '. $msg1;
return $str .' '. $msg3;
}
function times($times=NULL){
$time = time();
$today = date("j M Y", $time);
$today = date("j M Y", $time);
$yesterday = date("j M Y", strtotime("-1 day"));
$timesp=date("j M Y H:i", $times);
$timesp = str_replace($today, 'Сегодня', $timesp);
$timesp = str_replace($yesterday, 'Вчера', $timesp);
$timesp = strtr($timesp, array ("Jan" => "Янв","Feb" => "Фев","Mar" => "Марта","May" => "Мая","Apr" => "Апр","Jun" => "Июня","Jul" => "Июля","Aug" => "Авг","Sep" => "Сент","Oct" => "Окт","Nov" => "Ноября","Dec" => "Дек",));
return $timesp;
}
function times2($string) {
$day=floor($string/86400);
$hours=floor(($string/3600)-$day*24);
$min=floor(($string-$hours*3600-$day*86400)/60);
$sec=$string-($min*60+$hours*3600+$day*86400);
if($day > 0) $day2 = $day.' дней';
if($hours > 0 ) $hours2 = $hours.' часов';
if($min > 0 ) $min2 = $min.' минут';
if($sec > 0 ) $sec2 = $sec.' секунд';
return $day2.' '.$hours2.' '.$min2.' '.$sec2;
}
function navigator($page,$cnt,$url){
if($page > $cnt){ die(header('Location: '.$url.''.$cnt.''));}
$cnt=num($cnt);
if (!empty($cnt)){
if ($page-3 > 0){$a='<a href="'.$url.'1"><<<</a> ...';}
if ($page-2 > 0){$b='<a href="'.$url.''.($page-2).'">'.($page-2).'</a>';}
if ($page-1 > 0){$c='<a href="'.$url.''.($page-1).'">'.($page-1).'</a>';}
if ($page+1 <= $cnt){$d='<a href="'.$url.''.($page+1).'">'.($page+1).'</a>';}
if ($page+2 <= $cnt){$e='<a href="'.$url.''.($page+2).'">'.($page+2).'</a>';}
if ($page+3 <= $cnt){$f='... <a href="'.$url.''.$cnt.'">>>></a>';}
echo '<div class="pages"> '.$a.' '.$b.' '.$c.' <span class="chosenpage">'.$page.'</span> '.$d.' '.$e.' '.$f.'</div>';
}
}
$page=num($_GET['page']);
if (!isset($_GET['page']) ? $page=1 : false);
function kol($ca,$page,$cop){
$cp = ceil($ca/$cop);
if(isset($page) && is_numeric($page)){
if($page>$cp) $page = $cp;
if($page<1) $page = 1;
}else{
$page = 1;
}
return array(num($page*$cop-$cop),num(ceil($ca/$cop)));
}
function delete($times){
if ($times) {
$cache_del = dirname(__FILE__).'/../logs/delete/data.dat';
if (time() - @filemtime($cache_del) >= $times) {
file_put_contents($cache_del, date("H:i:s"));
clear();
}
}
}
?>