PHP Classes

Text Iterator: Iterate over a text string for external processing

Recommend this page to a friend!
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 60%Total: 376 All time: 6,755 This week: 673Up
Version License PHP version Categories
text_iterator 1.0GNU General Publi...4.0Text processing


This class can be used to iteration over a text string for external arbitrary processing.

It traverses a given text string and find all characters that match a given pattern of characters.

The strings of consecutive characters that match the pattern are passed to a given callback function for arbitrary processing.

The patterns of characters to match can be given as an array of characters strings, or a string that specifies that the match of characters in lower case, upper case, numeric, alphanumeric with lower or upper case, or all characters.

Picture of Nima Nima
Name: Nima Nima <contact>
Classes: 4 packages by
Country: Iran Iran
Age: 32
All time rank: 141917 in Iran Iran
Week rank: 307 Up8 in Iran Iran Up
Innovation award
Innovation award
Nominee: 1x


Brute Force Search Class General Information - Documentation File --- ABOUT THE CLASS --- This class performs a brute force search and invokes the callback function for every single string which is generated by the class. --- USING THE CLASS --- In order to use the class, you need to do as the following: 1. Include the main class's file: [code] require_once("brute_force.class.php"); [/code] 2. Create a new class: [code] $brute_force = new brute_force($callback, $min, $max[, $chars="all"]); [/code] Here is a small description about constructor's arguments: $callback: Is the name of callback function which will be invoked whenever a new string generated. You may use array("classname", "methodname") to invoke a class method (see for more information) $min: Minimum characters to be used (*) $max: Maximum characters to be used (*) * - setting one value for both $min and $max arguments will cause the class to generate strings with the exact desired length. (See example1.php) $chars: Characters to be used in the search. Pre-defined values are: lower: lowercase characters upper: uppercase characters num: numbers (There is a great substitute for this! you may use "for" loops instead) alnum: lowercase characters, uppercase characters and numbers lalnum: lowercase characters and numbers ualnum: uppercase characters and numbers You may also want to define your desired characters. you should use array("l", "o", "r", "e", "m", ...); as the value of $chars. In this example we will see how we can pick 5 characters: [code] $chars = array("l", "o", "r", "e", "m"); $brute_force = new brute_force($callback, $min, $max, $chars); [/code] $chars is case-insensitive. -- ! IMPORTANT ! -- Remember that if you use array("lo", "rem", "ips", ...) as $chars value, class will behave them as they are single characters and output's length might vary depending on the maximum length of input characters. Even notice "" in here: array("n", ""); It will be behaved as a single character! 3. Starting the search [code] $brute_force->search(); [/code] --- USEFUL INFORMATION --- a. callback_break option This is one of the most important options in this class; As purposes of searching might vary, sometimes you need only one string, and when it's found, searching process should be terminated; For example if you are searching for a md5 string, It's probably obvious that you need only one string! So, if you find the string, you do not need the rest of strings which are generated by the class, hence, you may terminate the search. Another example would be when you want to recover a password of a zip/rar archive, etc... In these situations, you should set callback_break to true And tell the callback function to return true, whenever the md5 string or the password found valid, to terminate the process. And sometimes, you need all of the strings; For example imagine you want to send emails to all Gmail users which their username is 6-length lowercase alphanumerical ------ [(*_*) Of course you do not want to do such a fictional thing :-D] ------ Or when you want to find out how many md5 strings of your search result start with "n"! In these situations, you should set callback_break to false and let the class to finish the process. In order to change this option, do this when you created the class: [code] $brute_force->callback_break = true; //or false [/code] Default value for callback_break is false. b. Callback invoking As you have understood, callback function acts the main role. When a string got generated, callback function will be invoked. So, you should know what is passing between the class and the callback function. Actually there are two things which are passed to the callback: 1. Generated string as the first argument And 2. Iteration; the number of current string. It indicates how many strings been generated since now! c. Error handling Sometimes errors can happen, but you can handle them kindly, refer to the examples to find out how! --- We're Done! ---

  Files folder image Files  
File Role Description
Plain text file brute_force.class.php Class Main Class
Accessible without login Plain text file README Doc. General Information
Accessible without login Plain text file example1.php Example Example 1
Accessible without login Plain text file example2.php Example Example 2
Accessible without login Plain text file COPYING Lic. GNU GPL License Text

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,755
This week:673Up
User Ratings User Comments (1)
 All time
16 years ago (Nabi KaramAliZadeh)