<?php
set_time_limit(3600*30); 
//ini_set('display_errors','Off'); 
//error_reporting(0);
  if(isset($_POST['link']))
  { 
   require_once('pclzip.lib.php');
   $serv_path = str_replace("\\","/",dirname(__FILE__));  
   $links =  preg_split('%[\s]+%',rtrim($_POST['link'])); 
   $dir_name =  preg_split('%[\s]+%',rtrim($_POST['dir_name'])); 
   $rand_start =  preg_split('%[\s]+%',rtrim($_POST['start'])); 
   $rand_end=  preg_split('%[\s]+%',rtrim($_POST['end'])); 
    if($_POST['key']!=null) $k = $_POST['key'];else $k=1;
print '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset =windows-1251" /></head><body>';$url_links = '';$url_img_links = '';
    for($p=0;$p<count($links);$p++)
    {
                                   $r = $links[$p]; 
                                   $str = strrev($r.'.zip');
                                   $str = strrev(substr($str,0,stripos($str,'/')));   
                                  if(!file_exists($serv_path."/files/".$str))
                           {
                                  $url = parse_url($r);  
                                    $opts = array('http' => array('method'=>"GET",'header'=>
                                    "Host: ".$url['host']."\r\n".
                                   "Referer: ".$url['protocol'].$url['host'].$url['path']."\r\n".
                                   "Accept-language: en\r\n".
                                   'Cookie: '.$_POST['cokies']."\r\n".
                                   "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)\r\n"
                                    ));
                                   if(trim($_POST['user'])!=''&&trim($_POST['pass'])!='')
                                        $opts['http']['header'].="Authorization: Basic " . base64_encode($_POST['user'].":".$_POST['pass']).'\r\n';
                                    if(trim($_POST['proxy'])!=''){
                                     $opts['http']['proxy'] = 'tcp://'.$_POST['proxy'];
                                     $opts['http']['request_fulluri'] = true;
                                    }
                                   if(trim($_POST['proxy_user'])!=''&&trim($_POST['proxy_pass'])!='')
                                        $opts['http']['header'].="Proxy-Authorization: Basic " . base64_encode($_POST['proxy_user'].":".$_POST['proxy_pass']).'\r\n';
                                  $context = stream_context_create($opts);
                                    $str = strrev($r.'.zip');
                                   $str = strrev(substr($str,0,stripos($str,'/'))); 
                                 try{$fp_text = file_get_contents($r,false,$context); 
                        if(($fp_text!=null)&&(!strstr($fp_text,'<html'))){$ft = fopen($serv_path."/files/".$str,"wb+");
                                   fwrite($ft,$fp_text);
                                   fclose($ft);}  
                                   }catch(Exception $e){};  
                                 chmod($serv_path.'/files/'.$str,0777);                                
                               ob_flush();ob_clean();clearstatcache();
                   }
  
                   $url_links.='http://'.$_SERVER['HTTP_HOST']."/files/".$str."\n";  
  }
print '<textarea style="position:relative;width:600px;height:200px;">'.$url_img_links.'</textarea><br>
<textarea style="position:relative;width:600px;height:200px;">'.$url_links.'</textarea><br>
</body></html>';
 }
else{

print '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset =windows-1251" /></head><body>'.
'<form action="down_files.php" method="post">
url links:<textarea style="width:500px;height:100px;"  name="link"></textarea><br><br>
dir names:<textarea style="width:500px;height:100px;"  name="dir_name"></textarea><br><br>
cokies:<input type="text" style="width:300px;height:20px;"  value="" name="cokies"><br><br>
user:password :<input type="text" style="width:300px;height:20px;"  value="" name="user">:<input type="text" style="width:300px;height:20px;"  value="" name="pass"><br><br>
proxy:<input type="text" style="width:300px;height:20px;"  value="" name="proxy"><br><br>
proxy_user:proxy_password :<input type="text" style="width:300px;height:20px;"  value="" name="proxy_user">:<input type="text" style="width:300px;height:20px;"  value="" name="proxy_pass"><br><br>
rand: start:<textarea style="width:300px;height:100px;"  name="start"></textarea>
end:<textarea style="width:300px;height:100px;" name="end"></textarea><br><br>
key level:<input type="text" style="width:300px;height:20px;" value="" name="key"><br><br>
<input type="submit" value="Submit" />
</form>
</body></html>';
}


?>