Guest User

Filesonic Stream Script

a guest
Jan 7th, 2012
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.80 KB | None | 0 0
  1. <?php
  2.     /***************************\
  3.     #    Filesonic stream shit   #
  4.     #    Robin@houtevelts.com    #
  5.     #    http://file-remoter.com #
  6.     #    25-dec-2011             #
  7.     \****************************/
  8.      
  9.     $username = 'username';
  10.     $password = 'password';
  11.      
  12.     $url = 'http://www.filesonic.com/file/GjRJgk7/FinalWire.AIDA64.Extreme.Edition.v2.00.1700.MULTILINGUAL.Incl.Keygen.WORKING-Lz0.rar';
  13.      
  14.     $regex = '#/file/(.*?)(/|$)#';
  15.     $matches = array();
  16.     preg_match($regex, $url, $matches);
  17.     $id = str_replace('/', '-', $matches[1]);
  18.     unset($matches,$regex);
  19.      
  20.     $fileinfo = file_get_contents('http://api.filesonic.com/link?method=getInfo&format=json&ids='.$id);
  21.     $fileinfo = json_decode($fileinfo,1);
  22.     $fileinfo = $fileinfo['FSApi_Link']['getInfo'];
  23.      
  24.     if($fileinfo['status'] != 'success')
  25.         die('API Error! mofo');
  26.      
  27.     $fileinfo = $fileinfo['response']['links'][0];
  28.      
  29.     if($fileinfo['status'] != 'AVAILABLE')
  30.         die('File is no moar!');
  31.  
  32.      
  33.     $filename = $fileinfo['filename'];
  34.     $filesize = $fileinfo['size'];
  35.  
  36.      
  37.     $url = file_get_contents('http://api.filesonic.com/link?method=getDownloadLink&u='.$username.'&p='.$password.'&ids='.$id);
  38.     $url = json_decode($url,1);
  39.     $url = $url['FSApi_Link']['getDownloadLink'];
  40.      
  41.     if($url['status'] != 'success')
  42.         die('API Error! mofo');
  43.      
  44.     $url = $url['response']['links'];
  45.     $url = end($url);
  46.     $url = $url['url'];
  47.      
  48.      
  49.     //The actual shit
  50.     $url = $url;
  51.     $host = parse_url($url);
  52.     $headers = '';
  53.     $rn = "\r\n";
  54.      
  55.     $headers .= 'GET '.$host['path'] . ($host['query'] == true ? '?'.$host['query'] : '').' HTTP/1.1' . $rn;
  56.     $headers .= 'Host: '.$host['host'] . $rn;
  57.     $headers .= 'Accept: */*' . $rn . $rn;
  58.      
  59.     $fs = fsockopen($host['host'],80,$errno,$errstr,30);
  60.     if($errno||$errstr){
  61.         echo 'ERROR: '.$errstr;
  62.         @fclose($fs);
  63.         exit;
  64.     }
  65.     fwrite($fs,$headers);
  66.     unset($headers);
  67.      
  68.     $header = '';
  69.      
  70.     do {
  71.         $header .= fgets ( $fs, 16384 );
  72.     }while(strpos($header,$rn.$rn) === false);
  73.      
  74.     /*
  75.         $header now contains the received headers
  76.         You could fetch the filesize etc from it etc, but we already know it.
  77.         But since I'm such a nice guy:
  78.     */
  79.     $filesize = preg_match('#Content-Length: (\d+)#',$header,$match);
  80.     $filesize = trim($match[1]);
  81.     unset($match,$header);
  82.      
  83.     header('Content-Length: '.$filesize);
  84.     header('Content-Disposition: attachment; filename="' . $filename . '"');
  85.     header('Connection: Close');
  86.      
  87.     while (!feof($fs)){
  88.         echo fread($fs,8192);
  89.     }
  90.     fclose($fs);
  91.      
  92. ?>
Add Comment
Please, Sign In to add comment