Functions Reference

From .:Rapidleech Wiki:.

Jump to: navigation, search

Contents

String Operations

cut_str

Description

string cut_str( string $string, string $left, string $right)

Enables you to cut a string from a large string, namely, a $page that was returned. cut_str() takes 3 arguments: $string: the string you want to search in $left: the string on the left-side of the string you want to capture $right: the string on the right-side of the string you want to capture. Basically, cut_str() strips away text from the left and right side so you are left with the 'middleman'.

Parameters

$string
The original string you want to extract the content from
$left
The string on the left-side of the string you want to capture
$right
The string on the right-side of the string you want to capture.

Return Values

Returns the extracted string on success. Returns empty string when no match is found.

Examples

<?php
$string = "The big brown fox jumps over the fence.";
$left = "big";
$right = "over";
echo cut_str($string,$left,$right);?>

The above will output:

 brown fox jumps 

is_present

Description

void is_present( string $lpage, string $mystr, string $strerror = "", bool $head = 0)

Use this function if you do NOT require a string to be present. Checks to see if some text is present. If the text $mystr is actually present in the string $lpage, then this function will return a custom error $strerror you specify.

Parameters

$lpage
The page you want the function to check on
$mystr
The string you want to check if it's present in $lpage
$strerror
The string you want to be returned if there is an error
$head
Indication if headers are sent

Return Values

This function will not return anything on success, and will exit directly if the string is found.

Examples

<?php
$lpage = "This is a test";
$mystr = "test";
$mystr2 = "not found!";
$strerror = "The word 'test' is found!";
$head = 0;
var_dump(is_present($lpage,$mystr2,$strerror,$head));
is_present($lpage,$mystr,$strerror,$head);
?>

The above will output:

NULL
The word 'test' is found!

is_notpresent

Description

void is_notpresent( string $lpage, string $mystr, string $strerror, bool $head = 0)

Use this function if you require a string to be present. Checks to see if some text is NOT present. If the text $mystr is NOT actually present in the string $lpage, then this function will return a custom error $strerror you specify.

Parameters

$lpage
The page you want the function to check on
$mystr
The string you want to check if it's not present in $lpage
$strerror
The string you want to be returned if there is an error
$head
Indication if headers are sent

Return Values

This function will not return anything on success, and will exit directly if the string is found.

Examples

<?php
$lpage = "This is a test";
$mystr = "test";
$mystr2 = "not found!";
$strerror = "The word 'not found' is not found!";
$head = 0;
var_dump(is_notpresent($lpage,$mystr,$strerror,$head));
is_notpresent($lpage,$mystr2,$strerror,$head);
?>

The above will output:

NULL
The word 'not found' is not found!

bytesToKbOrMbOrGb

bytesToKbOrMbOrGb($bytes)

A handy little function to automatically convert a number of bytes to a human-readable form (in KB, MB or GB).

Transfer Functions

geturl($host, $port, $url, $referer = 0, $cookie = 0, $post = 0, $saveToFile = 0, $proxy = 0, $pauth = 0, $auth = 0, $scheme = "http", $resume_from = 0)

The main download function of Rapidleech. With this function you can download a page. It's a good idea to assign it to a variable such as $page, that way the response will be stored in $page and you can then check the response with other functions.

upfile($host, $port, $url, $referer = 0, $cookie = 0, $post = 0, $file, $filename, $fieldname, $field2name = "", $upagent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.1", $proxy = 0)

The main upload function of Rapidleech. With this function you can upload a file somewhere. It's a good idea to assign it to a variable such as $upfile, that way the response will be stored in $upfile and you can then check the response with other functions.

insert_location($newlocation)

Redirect Rapidleech to the new location $newlocation (url), preferably a location you just found in a $page you just requested.

Miscellaneous Functions

is_page($lpage)

This should be used after any time you use geturl() or upfile(). It makes the $lastError global in case the $page or $upfile response contained any errors, we couldn't see otherwise.

insert_timer($countd, $caption ="", $timeouttext = "", $hide = false)

Outputs a new timer countdown with the specified startime $countd to countdown from. $caption is whatever text you want to display while the timer shows, such as 'Please Wait'.

html_error($msg, $head = 1)

Generates a custom error $msg on the page. Useful for when making download/upload plugins for example if a login was incorrect. If $head is left as the default, it will print out a full html page, otherwise if you just want the error (perhaps you are already within a page context) then set it to 0.


Variables

Upload Variables

These are for when you want to prevent rapidleech uploading a file immediately, in case you want to display a login form to a user just before a file uploads. These variables aren't Rapidleech specific, you can use whatever you like, as long as you use them the same way.

$not_done
Initially, we set this to 'true'
$continue_up
Initially, we set this to 'false'

Now just before the upload stage, a user will be prompted with a form, if they submit this form, $continue_up will be set to true, and $not_done will be set to false, so the upload stage will continue using the form input submitted by the user.

Personal tools