[php] Filejungle.com upload plugin

Status
Not open for further replies.

Halcyon

Active Member
1,306
2009
343
15
One of my dear client pasted this on pastebin and it was available to public :facepalm: So I guess there's no harm in posting it here. (As you would end up with the same code while searching on google)

Have fun (y)

PHP:
<?php
/** Author        : Halcyon aka V3g3t4
 *  Website       : http://sborg.us
 *  Description   : Uploader functions for FileJungle.com
 *  Usage         : upFileJungle('/path/to/file/',$username,$password)
 *  Returns       : Links to uploaded files
 *
 *  Date          : 2-Mar-2012
 */

function uFJunLogin($ufjuser, $ufjpass, $ufjcookie) {

    $post = array();
    $post['loginUserName'] = $ufjuser;
    $post['loginUserPassword'] = $ufjpass;
    $post["recaptcha_response_field"] = "Login";
    $post["recaptcha_challenge_field"] = "Login";
    $post["recaptcha_shortencode_field"] = "Login";
    $post["loginFormSubmit"] = "Login";

    $url = "http://filejungle.com/login.php";

    $page = RL_based_curl($url, $post, $ufjcookie);
    is_notpresent($page, "Account Settings", "Login failed");
}

function upFileJungle($filelocation, $ufjcookie) {

    $url = "http://filejungle.com/upload.php";
    $ref = "http://filejungle.com/dashboard.php";
    $page = RL_based_curl($url, '', $ufjcookie, $ref);
    $uploadUrl = cut_str($page, "uploadUrl = '", "'");

    $ref = "http://filejungle.com";
    $url = $uploadUrl . "/new?callback=jsonp" . round(microtime(true) * 1000);
    $page = RL_based_curl($url, '', $ufjcookie);

    $sessionId = cut_str($page, "sessionId:'", "'");
    $upurl = $uploadUrl . "/s/{$sessionId}/up";

    echo "Uploading to {$upurl}<br />";
    $post = array();
    $post['files'] = "@" . $filelocation;
    $page = RL_based_curl($upurl, $post, $ufjcookie, $ref);

    $shortcode = cut_str($page, '"shortenCode":"', '"');
    $filename = cut_str($page, '"fileName":"', '"');
    $download_link = "http://www.filejungle.com/f/{$shortcode}/{$filename}";

    if ($shortcode) {
        return $download_link;
    } else {
        echo('Error in uploading file');
        return false;
    }
}

function is_notpresent($lpage, $mystr, $strerror, $head = 0) {
    if (!stristr($lpage, $mystr)) {
        echo $strerror;
    }
}

function cut_str($str, $left, $right) {
    $str = substr(stristr($str, $left), strlen($left));
    $leftLen = strlen(stristr($str, $right));
    $leftLen = $leftLen ? - ($leftLen) : strlen($str);
    $str = substr($str, 0, $leftLen);
    return $str;
}

function RL_based_curl($link, $postfields = '', $cookie = '', $refer = '', $header = 1, $follow = 1, $usragent = '') {

    $ch = curl_init($link);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    if ($header)
        curl_setopt($ch, CURLOPT_HEADER, 1);
    else
        curl_setopt($ch, CURLOPT_HEADER, 0);
    if ($follow)
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    else
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
    if ($usragent)
        curl_setopt($ch, CURLOPT_USERAGENT, $usragent);
    else
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');

    if ($refer)
        curl_setopt($ch, CURLOPT_REFERER, $refer);

    if ($postfields) {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    }
    if ($cookie) {
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
    }

    $page = curl_exec($ch);

    curl_close($ch);

    if (empty($page)) {
        echo "<br/>Could not connect to host: <br/> $link <br/>";
        die();
    } else {
        return $page;
    }
}
?>

Sample Usage:

http://pastebin.com/NYeMtpyy
 
Last edited:
11 comments
Thanks t3o, I had freakshare plugin open in another window as well :|

Topic reported, hopefully a mod will rename the title.
 
Last edited:
any tutorial how to make that script? =)
step by step pls :'(

Lol, I'll add the steps soon :) (Will PM you specially in this case).


You got those from some pirate community ?
or made yourself ?

but none of the filehosts are stable at present :(

I made the plugins myself :)

And yeah, they're not stable. But I had to make them because of requests!



Why does the post URL have a -1?

Can you PM me the link to this script on your server?

P.S: Check if the filelocation is set properly or not.
 
Awrite. I've updated the script a bit (fixed the login part) and hopefully it should work fine now.

If you're having any other issues, let me know!

@dev, if you can see /u/{Your Username}/ then it logs in perfectly. Make sure you're providing complete server path to your file in the filelocation variable.
 
Status
Not open for further replies.
Back
Top