<?php
# класс конфиг кэша
# author Drk
class cache {
public static function index() # index
{
global $config;
$file = cache."_tag/index.json";
if(@filemtime($file) < time() - $config['cache_time']):
$get = curl::get($config['url'],'3ajka');
preg_match_all('#<a href="/video/(.*).html">(.*)src="(.*)"(.*)title="(.*)"(.*)duration">(.*)</span>#sU', $get, $video);
$cache ='{"video":[';
for($i = 0; $i<count($video[1]); $i++):
$arr = [
'href' => $video[1][$i],
'src' => $video[3][$i],
'title' => $video[5][$i],
'duration' => $video[7][$i]
];
$cache .= '{"href":"'.$arr['href'].'","src":"'.$arr['src'].'","title":"'.$arr['title'].'","duration":"'.$arr['duration'].'"},';
endfor;
$cache .= '{}],"tag":[';
preg_match_all('#<a class="linksss" href="/cat/(.*).html" title="(.*)">(.*)<span class="count2">(.*)</span></a>#sU', $get, $tag);
for($i = 0; $i<count($tag[1]); $i++):
$arr = [
'href' => $tag[1][$i],
'title' => $tag[2][$i],
'name' => $tag[3][$i],
'cn' => $tag[4][$i]
];
$cache .= '{"href":"'.$arr['href'].'","name":"'.$arr['name'].'","title":"'.$arr['title'].'","cn":"'.$arr['cn'].'"},';
endfor;
$cache .= '{}]}';
@file_put_contents($file, $cache);
endif;
return json_decode(@file_get_contents($file));
}
public static function tag($id) # tag
{
global $config;
$search = ['/','?','\ ',':','*','<','>','"','|'];
$tag = system::trim($id,$search,'_');
$file = cache."_tag/{$tag}.json";
if(@filemtime($file) < time() - $config['cache_time']):
$get = curl::get($config['url'].$id,'3ajka');
preg_match('#<title>(.*)</title>#sU', $get, $title);
preg_match('#<meta name="description" content="(.*)"#sU', $get, $description);
preg_match('#<h1 class="heads">(.*)</h1>#sU', $get, $tl);
$cache ='{"meta":[{"title":"'.system::br(system::trim($title[1],'zajka.org',domain)).'","tl":"'.system::br($tl[1]).'","description":"'. system::br($description[1]).'","keywords":"'. system::br($description[1]).'"}],';
preg_match_all('#<a href="/video/(.*).html">(.*)src="(.*)"(.*)title="(.*)"(.*)duration">(.*)</span>#sU', $get, $video);
$cache .='"video":[';
for($i = 0; $i<count($video[1]); $i++):
$arr = [
'href' => $video[1][$i],
'src' => $video[3][$i],
'title' => system::br($video[5][$i]),
'duration' => $video[7][$i]
];
$cache .= '{"href":"'.$arr['href'].'","src":"'.$arr['src'].'","title":"'.$arr['title'].'","duration":"'.$arr['duration'].'"},';
endfor;
preg_match('#<div class="pages">(.*)</div>#sU', $get, $page);
preg_match('#<span>(.*)</span>#sU', $page[1], $page_to);
$cache .= '{}],"page_to":[{"name":"'.$page_to[1].'"}],"page_all":[';
preg_match_all('#href="/cat/(.*)/(.*)"(.*)>(.*)</a>#sU', $page[1], $page_all);
for($i = 0; $i<count($page_all[1]); $i++):
$arr = [
'href' => $page_all[2][$i],
'name' => $page_all[4][$i]
];
$cache .= '{"href":"'.$arr['href'].'","name":"'.$arr['name'].'"},';
endfor;
$cache .= '{}]}';
@file_put_contents($file, $cache);
endif;
return json_decode(@file_get_contents($file));
}
public static function watch($id) # watch
{
global $config;
$search = ['/','?','\ ',':','*','<','>','"','|'];
$watch = system::trim($id,$search,'_');
$file = cache."_watch/{$watch}.json";
if(@filemtime($file) < time() - $config['cache_time']):
$get = curl::get($config['url'].$id,'3ajka');
preg_match('#<title>(.*)</title>#sU', $get, $title);
preg_match('#<h1 class="heads">(.*)</h1>#sU', $get, $tl);
preg_match('#<meta name="description" content="(.*)"#sU', $get, $description);
$cache ='{"meta":[{"title":"'.system::br(system::trim($title[1],'zajka.org',domain)).'","tl":"'.system::br($tl[1]).'","description":"'. system::br($description[1]).'","keywords":"'. system::br($description[1]).'"}],';
preg_match('#poster="(.*)"#sU', $get, $src);
preg_match('#<source src="(.*)"#sU', $get, $href);
preg_match('#</div><div class="main">(.*)</div>#sU', $get, $mess);
preg_match('#<div class="main">Добавлено: (.*)<br/>Длительность: (.*)<br/>#sU', $get, $dul);
preg_match('#<a class="knopka"(.*)href="(.*)"(.*)>(.*)</a>#sU', $get, $download);
$search_mess = ['Скачать','порно','(',')'];
$arr = [
'href' => $href[1],
'src' => $src[1],
'mess' => system::br($mess[1]),
'time' => $dul[1],
'duration' => $dul[2],
'd_href' => $download[2],
'd_name' => system::trim($download[4],$search_mess)
];
$cache .='"video":[{"href":"'.$arr['href'].'","src":"'.$arr['src'].'","mess":"'.$arr['mess'].'","time":"'.$arr['time'].'","duration":"'.$arr['duration'].'","d_href":"'.$arr['d_href'].'","d_name":"'.$arr['d_name'].'"}],';
preg_match_all('#<a itemprop="url" rel="tag" href="/cat/(.*).html"(.*)itemprop="title">(.*)</span>#sU', $get, $tag);
$cache .='"tag":[';
for($i = 0; $i<count($tag[1]); $i++):
$arr = [
'href' => $tag[1][$i],
'name' => $tag[3][$i]
];
$cache .= '{"href":"'.$arr['href'].'","name":"'.$arr['name'].'"},';
endfor;
$cache .= '{}],"video_sel":[';
preg_match_all('#<div class="tumb">(.*)href="/video/(.*).html"(.*)<span>(.*)</span>(.*)src="(.*)"(.*)duration">(.*)</span>#sU', $get, $video);
for($i = 0; $i<count($video[1]); $i++):
$arr = [
'href' => $video[2][$i],
'src' => $video[6][$i],
'title' => system::br($video[4][$i]),
'duration' => $video[8][$i]
];
$cache .= '{"href":"'.$arr['href'].'","src":"'.$arr['src'].'","title":"'.$arr['title'].'","duration":"'.$arr['duration'].'"},';
endfor;
$cache .= '{}]}';
@file_put_contents($file, $cache);
endif;
return json_decode(@file_get_contents($file));
}
public static function mod($id,$pach) # mod
{
global $config;
$search = ['/','?','\ ',':','*','<','>','"','|'];
$tag = system::trim($id,$search,'_');
$file = cache."_mod/{$tag}.json";
if(@filemtime($file) < time() - $config['cache_time']):
$get = curl::get($config['url'].$id,'3ajka');
preg_match('#<title>(.*)</title>#sU', $get, $title);
preg_match('#<meta name="description" content="(.*)"#sU', $get, $description);
preg_match('#<h1 class="heads">(.*)</h1>#sU', $get, $tl);
$cache ='{"meta":[{"title":"'.system::br(system::trim($title[1],'zajka.org',domain)).'","tl":"'.system::br($tl[1]).'","description":"'. system::br($description[1]).'","keywords":"'. system::br($description[1]).'"}],';
preg_match_all('#<a href="/video/(.*).html">(.*)src="(.*)"(.*)title="(.*)"(.*)duration">(.*)</span>#sU', $get, $video);
$cache .='"video":[';
for($i = 0; $i<count($video[1]); $i++):
$arr = [
'href' => $video[1][$i],
'src' => $video[3][$i],
'title' => system::br($video[5][$i]),
'duration' => $video[7][$i]
];
$cache .= '{"href":"'.$arr['href'].'","src":"'.$arr['src'].'","title":"'.$arr['title'].'","duration":"'.$arr['duration'].'"},';
endfor;
preg_match('#<div class="pages">(.*)</div>#sU', $get, $page);
preg_match('#<span>(.*)</span>#sU', $page[1], $page_to);
$cache .= '{}],"page_to":[{"name":"'.$page_to[1].'"}],"page_all":[';
preg_match_all('#href="/'.$pach.'/(.*)"(.*)>(.*)</a>#sU', $page[1], $page_all);
for($i = 0; $i<count($page_all[1]); $i++):
$arr = [
'href' => $page_all[1][$i],
'name' => $page_all[3][$i]
];
$cache .= '{"href":"'.$arr['href'].'","name":"'.$arr['name'].'"},';
endfor;
$cache .= '{}]}';
@file_put_contents($file, $cache);
endif;
return json_decode(@file_get_contents($file));
}
public static function search($id,$post) # search
{
global $config;
$search = ['/','?','\ ',':','*','<','>','"','|'];
$tag = system::trim($id.'_'.$post,$search,'_');
$file = cache."_search/{$tag}.json";
if(@filemtime($file) < time() - $config['cache_time_search']):
$get = curl::get($config['url'].$id,'3ajka_search','word='.$post.'&submit');
preg_match('#<title>(.*)</title>#sU', $get, $title);
preg_match('#найдено совпадений: (.*)</div>#sU', $get, $cn);
preg_match('#<meta name="description" content="(.*)"#sU', $get, $description);
$cache ='{"meta":[{"title":"'.system::br(system::trim($title[1],'zajka.org',domain)).'","cn":"'.$cn[1].'","description":"'. system::br($description[1]).'","keywords":"'. system::br($description[1]).'"}],';
preg_match_all('#<a href="/video/(.*).html">(.*)src="(.*)"(.*)title="(.*)"(.*)duration">(.*)</span>#sU', $get, $video);
$cache .='"video":[';
for($i = 0; $i<count($video[1]); $i++):
$arr = [
'href' => $video[1][$i],
'src' => $video[3][$i],
'title' => system::br($video[5][$i]),
'duration' => $video[7][$i]
];
$cache .= '{"href":"'.$arr['href'].'","src":"'.$arr['src'].'","title":"'.$arr['title'].'","duration":"'.$arr['duration'].'"},';
endfor;
preg_match('#<div class="pages">(.*)</div>#sU', $get, $page);
preg_match('#<span>(.*)</span>#sU', $page[1], $page_to);
$cache .= '{}],"page_to":[{"name":"'.$page_to[1].'"}],"page_all":[';
preg_match_all('#href="/search/(.*)"(.*)>(.*)</a>#sU', $page[1], $page_all);
for($i = 0; $i<count($page_all[1]); $i++):
$arr = [
'href' => $page_all[1][$i],
'name' => $page_all[3][$i]
];
$cache .= '{"href":"'.$arr['href'].'","name":"'.$arr['name'].'"},';
endfor;
$cache .= '{}]}';
@file_put_contents($file, $cache);
endif;
return json_decode(@file_get_contents($file));
}
}
?>