As requested by humour [hmmm] [meh]

PHP Code: 
<?php

/** Author        : Halcyon aka V3g3t4
 *  Description   : Upload functions for turbobit.net
 *  Date          : 26-Jan-2012
 *  Copyrights    : Full rights to copy!
 */

/*
 * All functions
 */

/*
 * Function name : tbitLogin
 * Parameters    : username, password, cookie location
 * Returns       : True if login is successful
 */
function tbitLogin($tbituser$tbitpass$tbitcookie) {

    
$postURL "http://turbobit.net/user/login";
    
$ref "http://turbobit.net/";

    
curl($ref "lang/en/"''$tbitcookie$ref);

    
$post['user[login]'] = $tbituser;
    
$post['user[pass]'] = $tbitpass;
    
$post['user[memory]'] = "on";
    
$post['user[submit]'] = "Login";

    
$page curl($postURL$post$tbitcookie$ref);
    
is_present($page"forgot password?""Incorrect logins",1);

    return 
true;
}

/*
 * Function name : tbitUpload
 * Parameters    : Filelocation and cookie location
 * Returns       : Download link, if successful
 */
function tbitUpload($filelocation$tbitcookie) {

    
$url "http://turbobit.net/";

    
$page curl($url0$tbitcookie);

    
preg_match('/flashvars="cancelLang=Cancel&browserLang=Add&downloadLang=Upload&maxSize=(.*?)&domain=main&urlSite=(.*?)&userId=(.*?)&apptype=(.*?)"/'$page$flashVars);

    
$upload_url $flashVars[2];
    
$agent 'Shockwave Flash';
    
$data['Filename'] = basename($filelocation);
    
$data['stype'] = 'null';
    
$data['apptype'] = $flashVars[4];
    
$data['user_id'] = $flashVars[3];
    
$data['id'] = 'null';
    
$data['Filedata'] = "@" $filelocation;

    
$upfiles curl($upload_url$data$tbitcookie$url11$agent);
    
preg_match('/"result":true,"id":"(.*?)","message":"Everything is ok"/'$upfiles$link);
    if (!empty(
$link[1])) {
        
$download_link 'http://turbobit.net/' $link[1] . '.html';
    } else {
        die(
"Error - Unable to retrive the download link, please try again later.");
    }

    return 
$download_link;
}

/*
 * Function name : is_present
 * Parameters    : String to search in, string to search and error message
 * Returns       : None
 */
function is_present($lpage$mystr$strerror$head 0) {
    if (
stristr($lpage$mystr)) {
        if(
$head)
            die(
$strerror);
        else
            echo 
$strerror;
    }
}

/*
 * Function name : cut_str
 * Parametsr     : String, delimiter on the left of required output,
 *               : delimiter on the right of required output
 * Returns       : Required string
 */
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($str0$leftLen);
    return 
$str;
}

/*
 * Function name : curl
 * Parameters    : Link, postfields, cookie location, referrer, true/false for
 *               : header and follow location, user agent if any
 * Returns       : Curl data or error response
 */
function curl($link$postfields ''$cookie ''$refer ''$header 1$follow 1$usragent 0) {

    
$ch curl_init($link);
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    if (
$header)
        
curl_setopt($chCURLOPT_HEADER1);
    else
        
curl_setopt($chCURLOPT_HEADER0);
    if (
$follow)
        
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    else
        
curl_setopt($chCURLOPT_FOLLOWLOCATION0);

    if (
$usragent)
        
curl_setopt($chCURLOPT_USERAGENT$usragent);
    else
        
curl_setopt($chCURLOPT_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($chCURLOPT_REFERER$refer);

    if (
$postfields) {
        
curl_setopt($chCURLOPT_POST1);
        
curl_setopt($chCURLOPT_POSTFIELDS$postfields);
    }
    if (
$cookie) {
        
curl_setopt($chCURLOPT_COOKIEJAR$cookie);
        
curl_setopt($chCURLOPT_COOKIEFILE$cookie);
    }

    
$page curl_exec($ch);

    
curl_close($ch);

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

/*
 * Sample usage
 */

$cookie    getcwd() . '/.cookie';
$filelocation "/path/to/your/file.rar";
$userEmail "test@turbobit.net";
$userPass  "testPass";
if(
tbitLogin($userEmail$userPass$cookie)){
    echo 
tbitUpload($filelocation$cookie);
}

?>
Halcyon Reviewed by Halcyon on . [PHP] Turbobit.net Upload Function As requested by humour <?php /** Author : Halcyon aka V3g3t4 * Description : Upload functions for turbobit.net * Date : 26-Jan-2012 * Copyrights : Full rights to copy! */ Rating: 5