Made this for a guy here.

Thought it might be useful for someone.

Edit:
Since FileSonic doesn't allow downloads anymore I doubt this script is handy anymore.
Anyway, perhaps it helps someone else.

Resume support added.

PHP Code: 
<?php
    
/***************************\
    #    Filesonic stream shit   #
    #    Robin@houtevelts.com    #
    #    http://file-remoter.com #
    #    25-dec-2011             #
    # Updated 7-jan-2012         #
    #    - Added resume support  #
    \****************************/
    
        
    
$url 'http://www.filesonic.com/file/jC5PZMo/1-3-3-8.com_tl-tll.720p.mkv';
    
$filename 'The.Last.Lions.2011.LIMITED.720p.BluRay.x264-THUGLiNE.mkv';
    
    
$direct_link get_direct_link('username','password',$url);
    
download($direct_link,$filename);
    
    function 
get_id($url){
        
$regex '#/file/(.*?)(/|$)#';
        
preg_match($regex$url$matches);
        if(!
$matches)
            return 
false;
        
$id str_replace('/''-'$matches[1]);
        return 
$id;
    }
    
    function 
get_direct_link($username,$password,$url){
        
$id get_id($url);
        
$fileinfo file_get_contents('http://api.filesonic.com/link?method=getInfo&format=json&ids='.$id);
        
$fileinfo json_decode($fileinfo,1);
        
$fileinfo $fileinfo['FSApi_Link']['getInfo'];
        
        if(
$fileinfo['status'] != 'success')
            die(
'ERROR: API Error!');
        
        
$fileinfo $fileinfo['response']['links'][0];
        
        if(
$fileinfo['status'] != 'AVAILABLE')
            die(
'ERROR: File is dead!');

        
$url file_get_contents('http://api.filesonic.com/link?method=getDownloadLink&u='.$username.'&p='.$password.'&ids='.$id);
        
$url json_decode($url,1);
        
        
$url $url['FSApi_Link']['getDownloadLink'];
        
        if(
$url['status'] != 'success'){
            if(!empty(
$url['errors']['FSApi_Auth_Exception']))
                die(
$url['errors']['FSApi_Auth_Exception']);
            die(
'ERROR: API Error!');
        }
        
        
$url $url['response']['links'];
        
$url end($url);
        
$url $url['url'];
        return 
$url;
    }
    
    function 
download($url,$filename){
        
$host parse_url($url);
        
$headers '';
        
$rn "\r\n";
        
        
$headers .= 'GET '.$host['path'] . ($host['query'] == true '?'.$host['query'] : '').' HTTP/1.1' $rn;
        
$headers .= 'Host: '.$host['host'] . $rn;
        if(!empty(
$_SERVER['HTTP_RANGE'])){
            
$headers .= 'Range: '.$_SERVER['HTTP_RANGE'] . $rn;
        }
        
$headers .= 'Accept: */*' $rn $rn;
        
        
$fs fsockopen($host['host'],80,$errno,$errstr,30);
        if(
$errno||$errstr){
            echo 
'ERROR: '.$errstr;
            @
fclose($fs);
            exit;
        }
        
fwrite($fs,$headers);
        unset(
$headers);
        
        
$header '';
        
        do {
            
$header .= fgets $fs16384 );
        }while(
strpos($header,$rn.$rn) === false);

        
$headers = array();
        
        
$headr preg_match('#Content-Length: (\d+)#',$header,$match);
        if(!empty(
$match[1]))
            
$headers['Content-Length'] = trim($match[1]);
        
$headr preg_match('#Accept-Ranges: (\w+)#',$header,$match);
        if(!empty(
$match[1]))
            
$headers['Accept-Ranges'] = trim($match[1]);
        
$headr preg_match("#Content-Type: (.*?)\r\n#",$header,$match);
        if(!empty(
$match[1]))
            
$headers['Content-Type'] = trim($match[1]);
        
$headr preg_match('#Content-Range: (.*?)\r\n#',$header,$match);
        if(!empty(
$match[1])){
            
$headers['Content-Range'] = trim($match[1]);
            
header('HTTP/1.1 206 Partial Content');
        }

        foreach(
$headers as $k => $v){
            
header($k ': ' $v);
        }
        unset(
$headers,$match,$headr);
        
header('Content-Disposition: attachment; filename="' $filename '"');
        
header('Connection: Close');
        
        while (!
feof($fs)){
            echo 
fread($fs,8192);
        }
        
fclose($fs);
    }
?>
And an HTML'd version for the noobs:
Just paste this in a file and rename it to bliebliebloebloe.php
PHP Code: 
<?php
    
/***************************\
    #    Filesonic stream shit   #
    #    Robin@houtevelts.com    #
    #    http://file-remoter.com #
    #    25-dec-2011             #
    # Updated 7-jan-2012         #
    #    - Added resume support  #
    #    - Added support for     #
    #            multiple links  #
    #    - Added more insults    #
    \****************************/
    
$uri explode('/',$_SERVER['REQUEST_URI']);
$b array_search(basename(__FILE__),$uri);

if(
$uri[$b+1] == 'dl'){
    
$username trim($uri[$b+2]);
    
$password trim($uri[$b+3]);
    
$id trim($uri[$b+4]);
    
$filename trim($uri[$b+5]);
    
    if(empty(
$username))
        die(
'No username, how do u expect me to download from FS?!');
    if(empty(
$password))
        die(
'No password, pleaaase give it! I shall not tell it to anyone else! I promise.. hehe');
    if(empty(
$id))
        die(
'No fileID, I don\'t even want to know why you removed it from the URL..');
    
    
$fileinfo file_get_contents('http://api.filesonic.com/link?method=getInfo&format=json&ids='.$id);
    
$fileinfo json_decode($fileinfo,1);
    
$fileinfo $fileinfo['FSApi_Link']['getInfo'];
    
    if(
$fileinfo['status'] != 'success')
        die(
'API Error! mofo');
    
    
$fileinfo $fileinfo['response']['links'][0];
    
    if(
$fileinfo['status'] != 'AVAILABLE')
        die(
'File is no moar!');

    
$url file_get_contents('http://api.filesonic.com/link?method=getDownloadLink&u='.$username.'&p='.$password.'&ids='.$id);
    
$url json_decode($url,1);
    
    
$url $url['FSApi_Link']['getDownloadLink'];
    
    if(
$url['status'] != 'success'){
        if(!empty(
$url['errors']['FSApi_Auth_Exception']))
            die(
$url['errors']['FSApi_Auth_Exception'] . ' You dumbass!');
        die(
'API Error! mofo');
    }
    
    
$url $url['response']['links'];
    
$url end($url);
    
$url $url['url'];
    
    
/* The real shit */
    
    
$host parse_url($url);
    
$headers '';
    
$rn "\r\n";
    
    
$headers .= 'GET '.$host['path'] . ($host['query'] == true '?'.$host['query'] : '').' HTTP/1.1' $rn;
    
$headers .= 'Host: '.$host['host'] . $rn;
    if(!empty(
$_SERVER['HTTP_RANGE'])){
        
$headers .= 'Range: '.$_SERVER['HTTP_RANGE'] . $rn;
    }
    
$headers .= 'Accept: */*' $rn $rn;
    
    
$fs fsockopen($host['host'],80,$errno,$errstr,30);
    if(
$errno||$errstr){
        echo 
'ERROR: '.$errstr;
        @
fclose($fs);
        exit;
    }
    
fwrite($fs,$headers);
    unset(
$headers);
    
    
$header '';
    
    do {
        
$header .= fgets $fs16384 );
    }while(
strpos($header,$rn.$rn) === false);
    
    
/*
        $header now contains the received headers
        You could fetch the filesize etc from it etc, but we already know it.
        But since I'm such a nice guy:
    */

    
$headers = array();
    
    
$headr preg_match('#Content-Length: (\d+)#',$header,$match);
    if(!empty(
$match[1]))
        
$headers['Content-Length'] = trim($match[1]);
    
$headr preg_match('#Accept-Ranges: (\w+)#',$header,$match);
    if(!empty(
$match[1]))
        
$headers['Accept-Ranges'] = trim($match[1]);
    
$headr preg_match("#Content-Type: (.*?)\r\n#",$header,$match);
    if(!empty(
$match[1]))
        
$headers['Content-Type'] = trim($match[1]);
    
$headr preg_match('#Content-Range: (.*?)\r\n#',$header,$match);
    if(!empty(
$match[1])){
        
$headers['Content-Range'] = trim($match[1]);
        
header('HTTP/1.1 206 Partial Content');
    }

    foreach(
$headers as $k => $v){
        
header($k ': ' $v);
    }
    unset(
$headers,$match,$headr);
    
header('Content-Disposition: attachment; filename="' . (empty($filename) ? 'No.Filename.Fuck.You.This.is.virus.exe' $filename) . '"');
    
header('Connection: Close');
    
    while (!
feof($fs)){
        echo 
fread($fs,8192);
    }
    
fclose($fs);
}elseif(!empty(
$_POST['Generate'])){
    
$username $_POST['username'];
    
$password $_POST['password'];
    
    if(empty(
$username) || empty($password))
        die(
'No username or password! Are you stupid?!<br />Just give it alright?!<br />
        I promise you I didn\'t write this just to steal your account.. Or did I? Mwuhahahaaaa *cough*give it*cough*..'
);
    
    
$ids = array();
    
$urls explode("\n",$_POST['urls']);
    
$regex '#/file/(.*?)(/|$)#';
    foreach(
$urls as $url){
        
$url trim($url);
        if(
parse_url($url) === false)
            continue;
        
$matches = array();
        
preg_match($regex$url$matches);
        if(!
$matches)
            continue;
        
$id str_replace('/''-'$matches[1]);
        unset(
$matches);
        if(!
$id)
            continue;
        
$ids[] = $id;
    }
    unset(
$regex,$url,$urls);
    if(empty(
$ids))
        die(
'ERROR: No valid links. I\'m not giving you any more specific details as to why this error appeared.<br />
        The links are just not valid OK?!'
);
    
    
$id implode(',',$ids);
    
$fileinfo file_get_contents('http://api.filesonic.com/link?method=getInfo&format=json&ids='.$id);
    
$fileinfo json_decode($fileinfo,1);
    
$fileinfo $fileinfo['FSApi_Link']['getInfo'];

    if(
$fileinfo['status'] != 'success')
        die(
'API Error! mofo<br />Guess you\'ll have to wait until FileSonic fixes their shit. Or you got banned.. I don\'t care.');
    
    
$fileinfo $fileinfo['response']['links'];
    
    
$links = array();
    foreach(
$fileinfo as $file){
        if(
$file['status'] == 'AVAILABLE')
            
$links[] = 'http://' $_SERVER['HTTP_HOST'] . (strlen($_SERVER['REQUEST_URI']) < '/'.basename($_SERVER['SCRIPT_FILENAME']) : $_SERVER['REQUEST_URI']) . '/dl/' $username '/' $password '/' $file['id'] . '/'$file['filename'];
        else
            
$links[] = 'File with ID '.$file['id'].' is dead! I suggest you cry in a corner.';
    }
    
    echo 
'<html>
        <head>
            <title>Filesonic direct link creator or whatever you want to use this for</title>
        </head>
        <body>
            <center>
                
                <textarea>'
.implode("\n",$links).'</textarea>
            </center>
        </body>
    </html>'
;
    
}else{
?>
    <html>
        <head>
            <title>Filesonic direct link creator or whatever you want to use this for</title>
        </head>
        <body>
            <center>
                <form action="" method="POST">
                    Filesonic Username: <input type="text" name="username" /><br />
                    Filesonic Password: <input type="text" name="password" /><br />
                    <br />
                    Urls: <textarea name="urls"></textarea>
                    <br />
                    <input type="submit" name="Generate" value="Generate" />
                </form>
            </center>
        </body>
    </html>
<?php
}
?>
____________________________
Old Versions:
25-dec-2011
Robin H Reviewed by Robin H on . [PHP] Filesonic stream script. Made this for a guy here. Thought it might be useful for someone. Edit: Since FileSonic doesn't allow downloads anymore I doubt this script is handy anymore. Anyway, perhaps it helps someone else. Resume support added. Rating: 5