Archive for March, 2008

New type hinting patch

Monday, March 31st, 2008

This new type hinting patch includes support for objects with __toString methods, allowing them to pass a string type hint.

Scalar Type Hinting Patch (March 31, 2008)

Brute force login attack protection system

Sunday, March 30th, 2008

This script allows a user X failed logins. After this, their account is locked for N minutes. After the lock ends, they are allowed X more failed logins, and the process starts from the beginning. All logins are logged with IP address and timestamp.

This script is specific to a site I recently made, so it will have to be adapted to your login system. I can do this if you are interested, charging for my time, or you can do it, just replace my site specific functions (alerts_add, app_redirect, and db_*) and create the tables.

Login Protection System Script
Login Protection System SQL Export

Common matching functions

Sunday, March 30th, 2008

These are 3 functions that will match zip codes, alphanumeric strings, and email address.

Common matching functions

Database Select Query Builder

Thursday, March 27th, 2008

Just something I was messing around with. I made a class that allows you to build your own queries, with full support for conditionals. Pretty interesting, take a look. It’s all done using object oriented.

Database Select Query Builder

Database Security Functions

Tuesday, March 11th, 2008

These two functions escape data for sql queries, and apply backticks to table/column names. They can be used in conjunction with the mysql functions for easy updating, insertion, etc. that I will be posting soon.

DB Security Functions

My Ubuntu Hardware Site

Tuesday, March 11th, 2008

Many of you may have heard of my Ubuntu Linux hardware compatibility site. For those that are not aware, I did a complete from-scratch rewrite a couple of weeks back, along with new hosting. You can check out the new site at ubuntuhcl.org.

Contribute!
Leave a review on your Ubuntu hardware and contribute to our database of hundreds of reviews.

Access the hardware review rss feed at ubuntuhcl.org/reviews/rss.

Full Featured Type Hinting Patch

Tuesday, March 11th, 2008

Attached is my more complete type hinting patch. It allows type hinting for int, float, string, bool, num (int or float), resource, object, and scalar.

Full Scalar Type Hinting Patch

CSV Escape Functions

Thursday, March 6th, 2008

Use these functions in place of fputcsv() if you are using an earlier version of php, or if you want to parse a CSV row but not write it directly to a file.

CSV Escape Functions

CSS Compression Function

Thursday, March 6th, 2008

Nice function, I use it in pretty much every application I develop. I can’t guarantee that it’s safe but in all the time I’ve used it I’ve never had a problem.

I went on one of those CSS compression sites, and this function that I had wrote reduced my CSS file to 2506 bytes, exactly the same size as the most advanced compression the site offered.

function compressCss(scalar $string) {
$blank = array(”\r”, “\n”, “\t”);
$string = str_replace($blank, ”, $string);
$string = str_replace(’ {’, ‘{’, $string);
$string = str_replace(’;', ‘;’, $string);
$string = str_replace(’: ‘, ‘:’, $string);
$string = str_replace(’, ‘, ‘,’, $string);
$string = str_replace(’;}’, ‘}’, $string);
$string = str_replace(’ }’, ‘}’, $string);
$string = preg_replace(
array(’#/\*.*?\*/#s’), ”, $string
);
return trim($string);
}

Useful date/time functions.

Thursday, March 6th, 2008

Attached is a few functions I have written having to do with dates and times.

Date/Time Functions