Файл: 3020.ru/_core/_class/cache.php
Строк: 277
<?php
//3020.ru - скрипты скачать можно тут
# класс кэша
# author penny wise
# telegram @the_penny_wise
class cache {
public static function get_sz() # сохранение и вывод кэша главная папка sz
{
global $config;
$file = cache."_sz/index.json";
if(!file_exists($file)):
$get = curl::get($config['spc'].'/sz/','spc');
preg_match_all('#<a href="(.*)/sz(.*)</a>#sU', $get, $data);
$cache ='[{';
for($i = 0; $i<count($data[2]); $i++):
preg_match('/(.*?)/"/', $data[2][$i], $url);
preg_match('/<span class="m" >(.*?)</', $data[2][$i], $name);
preg_match('/<span class=" grey c-grey" >(.*?)</', $data[2][$i], $cnt);
$arr = array(
'url' => $url[1],
'name' => $name[1],
'cn' => $cnt[1]
);
$cache .= '"url":"'.$arr['url'].'","name":"'.$arr['name'].'","cn":"'.$arr['cn'].'"}, {';
endfor;
$cache .= '}]';
file_put_contents($file, $cache);
endif;
return file_get_contents($file);
}
public static function get_sz_all($id) # сохранение и вывод кэша всех папок,файлов sz
{
global $config;
$tm = 0;
$trim_dr = array('/','?',' ',':','*','<','>','"','|');
$id_dir = str_replace($trim_dr,'_',$id);
$id_dir = stripslashes(trim($id_dir));
$file = cache."_sz/_dir/{$id_dir}.json";
$file_dir = cache."_sz/_dir_file/{$id_dir}.json";
if(!file_exists($file)):
if(@filemtime($file_dir) < time() - $config['cache_time_spc']):
$get = curl::get(''.$config['spc'].'/sz/'.$id.'','spc');
preg_match('#<title>(.*)</title>#sU', $get, $title_get);
preg_match('#<div class="list(.*)footer#sU', $get, $data_get);
preg_match_all('#<a href="(.*)/sz(.*)</a>#sU', $data_get[1], $data);
$trim_tl = array('Спакес','Зона','Обмена','Обмена','на','Spaces','-','Spaces.ru','.ru','/','Spcs.me','.im','"');
$tl = system::trim($title_get[1],$trim_tl).' на '.domain.' / '.domain;
$cache ='[{';
preg_match_all('#<span class="blk">(.*)из(.*)</span>#sU', $get, $cn_get);
$trim_cn = array(' ');
$cn = system::trim($cn_get[2][0],$trim_cn);
$cache .= '"title":"'.$tl.'"'.($cn != null ? ',"cn":"'.$cn.'"':'').'}, {';
if($data[2]):
$trim = array('<!--','-->','span','class','=','"','grey','-','>','<','(',')','m ');
$trim_cn_s = array('<!--','-->','span','class','=','"','grey','c','-','>','<','(',')','m ');
for($i = 0; $i<count($data[2]); $i++):
preg_match('/(.*?)/"/', $data[2][$i], $url);
preg_match('/<span class="m" >(.*?)</', $data[2][$i], $name);
preg_match('/<span class=" grey c-grey" >(.*?)</', $data[2][$i], $cnt);
$arr = array(
'url' => $url[1],
'name' => $name[1],
'cn' => $cnt[1]
);
$cache .= '"url":"'.$arr['url'].'","name":"'.$arr['name'].'","cn":"'.$arr['cn'].'"}, {';
endfor;
endif;
preg_match_all('#<div class="tiled_inner t_center relative">(.*)</div>#sU', $get, $image);
if($image[1]):
$tm = 1;
for($i = 0; $i<count($image[1]); $i++):
preg_match('/href="htt(.*?)://(.*?)/(.*?)/view/(.*?)"/', $image[1][$i], $url);
preg_match('/src="(.*?)"/', $image[1][$i], $img);
$arr_img = array(
'img' => $img[1],
'url' => $url[4],
'type' => $url[3]
);
$cache .= '"img":"'.$arr_img['img'].'","url_img":"'.$arr_img['url'].'","type_img":"'.$arr_img['type'].'"}, {';
endfor;
endif;
preg_match_all('#bord-botm">(.*)</div> </div>#sU', $get, $get_file);
$get_file[1] = preg_replace('|'.$config['spc'].'/index/redirect/(.*?)"|is', '', $get_file[1]);
$get_file[1] = preg_replace('|'.$config['spc'].'/?S=(.*?)"|is', '', $get_file[1]);
if($get_file[1]):
$tm = 1;
for($i = 0; $i<count($get_file[1]); $i++):
preg_match('/href="htt(.*?)://(.*?)/(.*?)/view/(.*?)"/', $get_file[1][$i], $url);
preg_match('#<div class="left(.*)src="(.*)" aria-label="#sU', $get_file[1][$i], $img_file);
preg_match('#<b class="m break-word darkblue break-word">(.*)<#sU', $get_file[1][$i], $name_file);
preg_match('#<b class="break-word lgrey3 m break-word">(.*)<#sU', $get_file[1][$i], $format_file);
preg_match('#<span class="m t-padd_left">(.*)<#sU', $get_file[1][$i], $size_file);
preg_match('#<div class="pad_t_a black break-word">(.*)<#sU', $get_file[1][$i], $msg_file);
$trim_format = array('.');
$trim_name = array(''');
$trim_msg = array(''',' ');
$arr_file = array(
'img' => $img_file[2],
'url' => $url[4],
'type' => $url[3],
'name' => system::trim($name_file[1],$trim_name),
'format' => system::trim($format_file[1],$trim_format),
'msg' => system::trim(strip_tags($msg_file[1]),$trim_msg),
'size' => $size_file[1]
);
$cache .= '"img_file":"'.$arr_file['img'].'","url_file":"'.$arr_file['url'].'","type_file":"'.$arr_file['type'].'","name_file":"'.$arr_file['name'].'","msg_file":"'.$arr_file['msg'].'","size_file":"'.$arr_file['size'].'","format_file":"'.$arr_file['format'].'"}, {';
endfor;
endif;
$cache .= '}]';
$files = ($tm == 1 ? $file_dir:$file);
file_put_contents($files, $cache);
endif;
endif;
$files = (file_exists($file) ? $file:'').(file_exists($file_dir) ? $file_dir:'');
return file_get_contents($files);
}
public static function get_sz_file($type,$id) # сохранение и вывод кэша файлов
{
global $config;
$trim_dr = array('/','?',' ',':','*','<','>','"','|');
$id_dir = str_replace($trim_dr,'_',$id);
$id_dir = stripslashes(trim($id_dir));
$file = cache."_sz/_file/{$id_dir}.json";
if(@filemtime($file) < time() - $config['cache_time_spc']):
$get = curl::get(''.$config['spc'].'/'.$type.'/view/'.$id.'/','spc');
preg_match('#<title>(.*)</title>#sU', $get, $title_get);
preg_match('#<div class=" title oh black relative text_left ">(.*)</div>#sU', $get, $name_get);
preg_match('#<h1(.*)>(.*)</h1>#sU', $name_get[1], $files_name);
preg_match('#<span class="grey" >(.*)</span>#sU', $name_get[1], $files_types);
preg_match('#<b class="nick">(.*)</a>(.*)</div>#sU', $get, $time_get);
preg_match('#block-title(.*)<div class="grey"> Добавлен:#sU', preg_replace('|-->)(.*?)Смотреть онлайн(.*?)</a>|is', '-->)</a>', $get), $download_get);
if(strripos($download_get[1], 'mp4</span>')):
preg_match('#<div id="download(.*).3gp(.*)<a href="(.*)"#sU', preg_replace('|&sid=(.*?)"|is', '"', str_replace('%3Freal=','?real=',$download_get[1])), $mp4_get);
endif;
if(strripos($download_get[1], 'mp3</span>')):
preg_match('#<div id="download(.*)<a href="(.*)"#sU', str_replace('%3Freal=','?real=',$download_get[1]), $mp3_get);
endif;
preg_match('#itemprop="(image|thumbnail)"(.*)src="(.*)"#sU', $get, $screen_get);
preg_match('#duration m">(.*)<#sU', $download_get[1], $duration_get);
preg_match('#<div itemprop="description">(.*)</div>#sU', $download_get[1], $msg_get);
preg_match('#<div id="download(.*)<div class="block">#sU', $download_get[1], $loads_get);
preg_match_all('#href="(.*)"(.*)class="m"(.*)</a>#sU', preg_replace('|&sid=(.*?)"|is', '"', str_replace('spcs.me.','_'.$_SERVER['HTTP_HOST'].'.', $loads_get[1])), $link_get);
$trim_tl = array('Спакес','Зона','Обмена','Обмена','на','Spaces','-','Spaces.ru','.ru','/','Spcs.me','SPCS.ME');
$trim_name = array('<!--','-->');
$trim_msg = array(''',' ','<div class="pad_t_a break-word">','<div class="quote">');
$arr_file = array(
'title' => system::trim($title_get[1],$trim_tl).' на '.domain.' / '.domain,
'name' => system::trim($files_name[2],$trim_name),
'type' => $files_types[1],
'time' => strip_tags(str_replace(array('(',')'),'',$time_get[2])),
'img' => $screen_get[3],
'v_onl' => $mp4_get[3],
'm_onl' => $mp3_get[2],
'v_dur' => $duration_get[1],
'msg' => system::trim(strip_tags($msg_get[1]),$trim_msg)
);
$cache = '[{"title":"'.$arr_file['title'].'",
"name":"'.$arr_file['name'].'",
"type":"'.$arr_file['type'].'",
"time":"'.$arr_file['time'].'",
"img":"'.$arr_file['img'].'",
"v_onl":"'.$arr_file['v_onl'].'",
"m_onl":"'.$arr_file['m_onl'].'",
"v_dur":"'.$arr_file['v_dur'].'",
"msg":"'.$arr_file['msg'].'"}, {';
if($link_get[1]):
for($i = 0; $i<count($link_get[1]); $i++):
$arr = array(
'link' => ($link_get[1][$i] ? preg_replace('|'.$config['spc'].'/(.*?)redirect=|is', '', str_replace('%3Freal','?real',$link_get[1][$i])) : null) .'?real=&xyz-1',
'size' => ($link_get[3][$i] ? str_replace('/>','',strip_tags($link_get[3][$i])) : null)
);
$cache .= '"link":"'.$arr['link'].'","size":"'.$arr['size'].'"}, {';
endfor;
endif;
$cache .= '}]';
file_put_contents($file, $cache);
endif;
return file_get_contents($file);
}
public static function get_sz_x() # 18+
{
global $config;
$file = cache."_sz/x.data";
if(@filemtime($file) < time() - $config['cache_time_spc']):
$get = curl::get(''.$config['spc'].'/pictures/view/20200821-080646-277079618/','spc');
preg_match('#CK=(.*)&#sU', $get, $CK);
$adult = '/services/adult_confirm/?CK='.$CK[1];
curl::get(''.$config['spc'].$adult,'spc');
$cache = 1;
file_put_contents($file, $cache);
endif;
}
public static function get_sz_file_search($id) # поиск файлов
{
global $config;
$trim_dr = array('/','?',' ',':','*','<','>','"','|',' ');
$id_dir = str_replace($trim_dr,'_',$id);
$id_dir = stripslashes(trim($id_dir));
$id_dir = iconv('utf-8', 'windows-1251', $id_dir);
$file = cache."_sz/_search/{$id_dir}.json";
$id = system::check($id);
if(@filemtime($file) < time() - $config['cache_time_s_spc']):
$cache ='[{';
$ses = curl::get(''.$config['spc'].'/files/search/','spc');
preg_match('#name="stt" value="(.*)"#sU', $ses, $session);
$session[1] = system::check($session[1]);
$get = curl::get(''.$config['spc'].'/files/search/','spc','word='.$id.'&cfms&submit&stt='.$session[1]);
preg_match_all('#Slist=(.*)&(.*)darkblue">(.*)<span class="grey">(.*)</span>#sU', $get, $data);
if ($data[1]):
for($i = 0; $i<count($data[1]); $i++):
$arr = array(
'id' => $data[1][$i],
'name' => $data[3][$i],
'cn' => preg_replace('/[^p{L}0-9]/iu',' ',strip_tags($data[4][$i])),
'session' => $session[1]
);
$cache .= '
"id":"'.$arr['id'].'",
"name":"'.$arr['name'].'",
"cn":"'.$arr['cn'].'",
"session":"'.$arr['session'].'"}, {';
endfor;
endif;
$cache .= '}]';
file_put_contents($file, $cache);
endif;
return file_get_contents($file);
}
public static function get_sz_file_search_all($id) # поиск файлов
{
global $config;
$trim_dr = array('/','?',' ',':','*','<','>','"','|',' ');
$id_dir = str_replace($trim_dr,'_',$id);
$id_dir = stripslashes(trim($id_dir));
$id_dir = iconv('utf-8', 'windows-1251', $id_dir);
$file = cache."_sz/_search/{$id_dir}.json";
$trim = array('(',' ',')','*',',','i_dr');
$repl = array('%28','%20','%29','%2A','%2C','i_dr.');
$id = str_replace($trim,$repl,$id);
$id = stripslashes(trim($id));
if(@filemtime($file) < time() - $config['cache_time_s_spc']):
$get = curl::get(''.$config['spc'].'/files/search/'.$id,'spc');
preg_match_all('#<span class="blk">(.*)из(.*)</span>#sU', $get, $cn_get);
$trim_cn = array(' ');
$cn = system::trim($cn_get[2][0],$trim_cn);
$cache ='[{"cn":"'.$cn.'"}, {';
preg_match_all('#bord-botm">(.*)</div> </div>#sU', $get, $get_file);
$get_file[1] = preg_replace('|'.$config['spc'].'/index/redirect/(.*?)"|is', '', $get_file[1]);
$get_file[1] = preg_replace('|href="'.$config['spc'].'/?S=(.*?)"|is', '', $get_file[1]);
$get_file[1] = preg_replace('|'.$config['spc'].'/music/copy2me/(.*?)"|is', '', $get_file[1]);
if($get_file[1]):
for($i = 0; $i<count($get_file[1]); $i++):
preg_match('/href="htt(.*?)://(.*?)/(.*?)/view/(.*?)"/', $get_file[1][$i], $url);
preg_match('#<div class="left(.*)src="(.*)" aria-label="#sU', $get_file[1][$i], $img_file);
preg_match('#<b class="m break-word darkblue break-word">(.*)<#sU', $get_file[1][$i], $name_file);
preg_match('#<b class="break-word lgrey3 m break-word">(.*)<#sU', $get_file[1][$i], $format_file);
preg_match('#<span class="m t-padd_left">(.*)<#sU', $get_file[1][$i], $size_file);
preg_match('#<div class="pad_t_a black break-word">(.*)<#sU', $get_file[1][$i], $msg_file);
$trim_format = array('.');
$trim_name = array(''');
$trim_msg = array(''',' ');
$arr_file = array(
'img' => $img_file[2],
'url' => $url[4],
'type' => ($url[3] =! 'files' || $url[3] =! 'video' ? 'music' : $url[3]),
'name' => system::trim($name_file[1],$trim_name),
'format' => system::trim($format_file[1],$trim_format),
'msg' => system::trim(strip_tags($msg_file[1]),$trim_msg),
'size' => $size_file[1]
);
$arr_file['type'] = ($arr_file['type'] == 1 ? 'music' : $arr_file['type']);
$cache .= '"img_file":"'.$arr_file['img'].'","url_file":"'.$arr_file['url'].'","type_file":"'.$arr_file['type'].'","name_file":"'.$arr_file['name'].'","msg_file":"'.$arr_file['msg'].'","size_file":"'.$arr_file['size'].'","format_file":"'.$arr_file['format'].'"}, {';
endfor;
endif;
$cache .= '}]';
file_put_contents($file, $cache);
endif;
return file_get_contents($file);
}
# ------------------ Очиска всего кэша
public static function get_sz_clea() # удаление кэша
{
global $config;
$file = cache."_sz/x.data";
if(file_exists($file) && @filemtime($file) < time() - $config['cache_time_clea']):
if (file_exists(cache.'_sz/_file/')):
foreach (glob(cache.'_sz/_file/*') as $file):
unlink($file);
endforeach;
endif;
if (file_exists(cache.'_sz/_dir_file/')):
foreach (glob(cache.'_sz/_dir_file/*') as $dir_file):
unlink($dir_file);
endforeach;
endif;
if (file_exists(cache.'_sz/_dir/')):
foreach (glob(cache.'_sz/_dir/*') as $dir):
unlink($dir);
endforeach;
endif;
if (file_exists(cache.'_sz/_search/')):
foreach (glob(cache.'_sz/_search/*') as $search):
unlink($search);
endforeach;
endif;
unlink(cache.'_sz/index.json');
unlink(cache.'_sz/x.data');
endif;
}
}
?>