Popular Posts
Tools and Tips
Search
Archives
Monday, November 26. 2007
PHP Toolkit - Version 0.1
The PHP Toolkit is a collection of functions that I've written and have ended up using on more than one occasion, thus making it my Toolkit. There's a little for everyone in here, sanitizing input, validation, generation, security, and more. As of version 0.1, it can...- Force HTTPS
- Filter and remove 'bad' words
- Sanitize user input
- Validate user names
- Validate email addresses
- Validate hex colors
- Validate postal codes
- Generate cryptographically secure hashes
- Generate random strings of any length
- Generate a select list of countries and states
- Test regular expressions against common user input ailments
And there are even more tools inside. And of course, it's licensed under the GPL.
Tools
To use, either create a new instance of the tools class in a variable and run the appropriate function, like so...$tool = new tools();
$tool->forceHttps('urlhere');
or you can simply run an instance of the class anywhere, like this...
tools::forceHttps('urlhere');
Either way works, and here are all of the functions and parameters in the class tools.
forceHttps($redirectURI) - If the connection is not using HTTPS, it redirects the page to https:// and the URI parameter. Must be run at the start of a page, or buffered first.
wordFilter($input, $options) - Strips out filtered words that are set in the script from the input ($options = 1), or returns false if the input contains a filtered word ($options = 2).
cleanInput($input, $options, $maxLen) - Cleans the input based on the options (1 = Full, 2 = Post, Get, Request, 3 = Integer) and returns false if the input is greater than the max length.
validUsername($input, $minlength, $maxlength) - Validates a username as alpha-numeric and between the minimum length and maximum length.
validEmail($email) - Validates an email address. Returns true or false.
validHex($hex) - Validates a hex color code. Works with or without a # and with 3 or 6 number notation.
validPostal($postal) - Validates a US postal code. Works with or without the last 4 digits and a dash.
secHash($input) - Generates a cryptographically secure sha512 hash, with a configurable salt key.
regexFuzz($regex) - Runs a series of commonly used XSS, SQL Injection, Null Byte, Newline and other various problematic strings against the provided Perl Compatible Regular Expression provided.
getUserIP() - Returns the IP of whoever is running the script.
getUserAgent() - Returns the Useragent string of whoever is running the script.
getUserRef() - Returns the referrer to the current page for whoever is running the script.
getRandStr($length) - Generates a random (not cryptographically secure,) string of the length you set.
countrySelect() - Generates a select box and populates it with countries.
stateSelect() - Generates a select box and populates it with states.
Con($dbname) - Connects to the MySQL database with that name, and configured login information.
dCon() - Disconnects from the MySQL database.
If you have any suggestions, comments, or want to add to the Toolkit, leave a comment.
Download PHP Toolkit v0.1

The internet phones facilities are given by different VIOP related sites and enable communication through broadband and phone. The website design is also important for any business to flourish and to give the users a good interface. The web page hosting is a part of website hosting and the popular way of advertisement of your website is the cpc program. It is click per pay program, which pay the user who clicks their ads. The affiliate program is a sort of option that can implemented on a website to earn money by referring clients to main affiliate seller. The internet telephone service can be purchased online and it costs some extra money to call unlimited number of countries free. The affiliate commission is there which pay the commission for number of sales generated through specific website referrals. The web hosting varies in accordance to requirements and website traffic as well.
Trackbacks
Trackback specific URI for this entry
No Trackbacks
