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)
Sample Usage:
http://pastebin.com/NYeMtpyy
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: