<?php
set_time_limit(44);
ini_set('display_errors',1);
error_reporting(E_ALL);
header('Content-Type: text/html; charset=utf-8');
$url_part = explode('/', $_SERVER['REQUEST_URI']);
$llllllllll = '##@#@##';
$filecache_now = 'cache/'.$_SERVER['HTTP_HOST'].'-links-'.date('Y-m-d').'.txt';
$filecache_next = 'cache/'.$_SERVER['HTTP_HOST'].'-links-'.date('Y-m-d',time()+86400).'.txt';
$filecache_now_content = 'cache/'.$_SERVER['HTTP_HOST'].'-all-content-'.date('Y-m-d').'.txt';
$filecache_next_content = 'cache/'.$_SERVER['HTTP_HOST'].'-all-content-'.date('Y-m-d',time()+86400).'.txt';
function base64url_encode($data) {
return rtrim(strtr(base64_encode(gzcompress($data,9)), '+/', '-_'), '=');
}
function base64url_decode($data) {
return gzuncompress(base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)));
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER,1);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($curl, CURLOPT_URL, 'http://www.tinydl.com/last.html' );
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
$response = curl_exec($curl);
$curl_getinfo = curl_getinfo($curl);
@list($header, $body) = @explode("\r\n\r\n", $response, 2);
curl_close($curl);
$body = str_replace('window.location = window.location.href.replace(window.location.host, \'tiny\' + \'dl.com\');','',$body);
$body = iconv("windows-1251", "UTF-8", $body);
preg_match_all('~<li><a href=\"http://www.tinydl.com/(.*?).html.*?target=\"_blank\">(.*?)<\/a><\/li>~is',$body,$links);
//print_r($links);
$i = 0;
while ( !empty($links[1][$i]) && !empty($links[2][$i]) )
{
//echo '<a href="/500px/'.$links[1][$i].'/'.$links[3][$i].'/'.$links[4][$i].'/'.$links[2][$i].'"><img src="http://pcdn.500px.net/'.$links[1][$i].'/'.$links[2][$i].'/3.jpg" alt="'.$links[4][$i].'"></a>';
file_put_contents ($filecache_now, $links[1][$i].$llllllllll.$links[2][$i].PHP_EOL, FILE_APPEND | LOCK_EX);
file_put_contents ($filecache_next, $links[1][$i].$llllllllll.$links[2][$i].PHP_EOL, FILE_APPEND | LOCK_EX);
$i++;
}
file_put_contents($filecache_now, array_flip(array_flip(file($filecache_now))), LOCK_EX);
file_put_contents($filecache_next, array_flip(array_flip(file($filecache_next))), LOCK_EX);
///////////////////////////////////tinydl
if ( $url_part[1] == 'td' && !empty($url_part[2]) )
{
$out_title = '';
$out_menu = '';
$out_content = '';
$url = 'http://www.tinydl.com/'.$url_part[2].'.html';
$cache_file_name = 'cache/'.md5($url).'.txt';
$cache_time = 10*30;
if ( (file_exists($cache_file_name)) && ((time()-filemtime($cache_file_name))<$cache_time) )
{
$body = file_get_contents($cache_file_name);
echo $body;
}
else
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER,1);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($curl, CURLOPT_URL, $url );
curl_setopt($curl, CURLOPT_TIMEOUT, 90);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 90);
$response = curl_exec($curl);
$curl_getinfo = curl_getinfo($curl);
@list($header, $body) = @explode("\r\n\r\n", $response, 2);
curl_close($curl);
$body = str_replace('window.location = window.location.href.replace(window.location.host, \'tiny\' + \'dl.com\');','',$body);
//echo $body;
$body = iconv("windows-1251", "UTF-8", $body);
preg_match('~<title>(.*?) » Tinydl.Com Full And Free Download<\/title>~is',$body,$title);
//print_r($title);
$out_title .= ''.strip_tags($title[1]).'';
preg_match('~<div class=\"newsstory\">(.*?)<div id=\"ads"\>~is',$body,$content);
//print_r($content);
$out_content .= strip_tags($content[1], '<p><a><br /><br/><br><img><b>');
file_put_contents ($cache_file_name, base64url_encode($out_title.$llllllllll.$out_content), LOCK_EX);
}
}
///////////////////////////////////tinydl
$rand_keys = $filecache_now;
if ( file_exists($rand_keys) ) {
$fp = fopen($rand_keys,'r');
fseek($fp, 0, SEEK_END);
$len = ftell($fp);
$x=0;
while ($x<50)
{
$x++;
fseek($fp,rand(0,$len));
fgets($fp);
if(feof($fp)) fseek($fp,0);
$str[$x] = trim(fgets($fp));
if ( strlen($str[$x])>2 )
{
$str_part[$x] = explode($llllllllll, $str[$x]);
echo '<a href="/td/'.$str_part[$x][0].'">'.$str_part[$x][1].'</a><br>'."\n";
}
}
}
preferences:
34.95 ms | 402 KiB | 5 Q