My Validation Class
The class
Download My Validation Class From http://github.com/harake
This is a very basic class that allows you to add more public static functions to validate more data types other than integer, boolean, decimal, and ids
(more…)
The Resize Helper to Resize Images On The Fly
The class
Download The Resize Helper From http://github.com/harake
Copy it to your ‘app\views\helpers’ folder and rename it as resize.php
The Resize Helper requirements
How to make the jQuery UI Accordion widget multiple?
One of the missing features in the jQuery UI Acordion widget is the possiblity to have more than one expanded section.
Now you can download the new source code that allows you to add the feature (option) multiple: true when you initialize your accordion instrument.
Download The jQuery UI Accordion Widget From http://github.com/Harake
Please leave a comment, If you like this article or have one or more remark(s) on it
How to make Base64 encoding and decoding safe?
base64 and the PHP manual
string base64_encode ( string data )
base64_encode() returns data encoded with base64.
This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.
Base64-encoded data takes about 33% more space than the original data.
Example 1. base64_encode() example
<?php $str = 'This is an encoded string'; echo base64_encode($str); ?>
This example will produce:
VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==
The MySQL Connection Manager for classic (no-ORM) queries
Singleton And Connection Manager
Singleton: one class that (via itself) creates one and only one instance (of itself) if that instance was not created before, and always returns that instance.
ConnectionManager: Class that acts as a a set of singletons, so it creates for each database account one and only one singleton.
The default database account in CakePHP is ‘default’ and it is is of type mysql.
Since most of PHP developers are fans of MySQL (both the mysql and mysqli extensions), I created the class below, to show you how to integrate your old Mysql Connection Manager into the CakePHP framework.
The Include Engine
Include Engine Features
The FileEngine is currently the default cache engine in CakePHP.
In this article I will change the behavior of the FileEngine caching class by sub-classing it to make it able to do the following:
- Creates/reads a cached PHP file (real PHP file) that stores one more variable(s).
- Although IncludeEngine is used for temporary caching (by default), however, adding the key ‘forever’ => true in its configuration will make this cached version “permanent” so the date-time checking is skipped
- The ‘serialize’ key of the configuration is still true by default, and is still recommend (more secure and even faster!) for any non-resource data type variable (int, float, string, boolean, array, object). However, you may ask the IncludeEngine to create a human readable (in our case non serialized) cached version of the variables you want to store (cache). So setting the ‘serialize’ key of the configuration to false is secure for just scalar variables and scalar arrays (int, float string, boolean and arrays that are based on primitive scalar data type
2 comments