Friday, August 29, 2008

Problems with CakePHP - follow-up

Some people have responded including the Datepicker fame Marc Grabanski. So, this follow-up...

First of all, I was not ranting nor complaining; I've just blogged/documented my experience.

The common problem most of the people pointed out are that it scales for Those who have accessed their source code can understand that they've done lot of things and also the site is not database-intensive. You should really create a real database-intensive website to understand what I mean.

The other point that been pointed out is about open source and community. Lot of people may not be knowing that it's 2 people pushing it and don't want others to be credited. The generic model or dynamic model idea was originally been from grigri and Marcel. It's hard to be called as open source as only few and sycophants are driving it's direction (I'm not talking about svn access)

So, here are my humble checklist before you start shouting at me

  • Did you read and understand my post?

  • Can you code or at least read PHP? -- This is very important. My post is not indented for some naive people who want to create software in 2mins without really understanding the programming languages and tools.

  • Have you looked at the framework's source?

  • Have you tried to profile the code?

  • Have you witnessed the xdebug crashing due to deeper cyclic chains when you profile?

  • Have you created any application where you have to replace regexp calls to increase speed?

  • Have you optimized the DB and tried to scale a database-intensive site?

  • Have you referred the frequent discussion page? (It was originally created by me and I have contributed to the most of it) -- You'll hit that page only when you create webpage and get into problems. I have a strong opinion that some sycophants and Evangelist aren't using CakePHP at all. (Evangelist is always trying to sell his "intellects" with philosophical/unscientific remarks and bootlicking some naive people whom intern want networking. Note, this is not a flame, but my strong opinion)

  • Have you read codes of cakebaker, ad7six, grigri, franky, baz...? Do you think, they have a better fork with them?

  • Have you removed some/many automagic things? or Have you used it just for dispatching?

  • Have you checked source of Akelos, Solar, CI or fase?

  • Finally, have you read Rasmus's Simple is Hard?

If you answer "Yes" to most of the above list, you may be with me.

And, at this moment, like I mentioned, the state of my mind is that, the need for the contemporary world is to have a better toolkit, which I believe could be developed with good readability, coding standards/practices, scalability and simplicity.

Update (2008-09-06): My apologies for Chris Hartjes, who found the post to be personal attack on him. I understand that I could have used better wordings.

Sunday, August 17, 2008

Open source PHP frameworks and problems

I was using CakePHP for sometime and proposed CakePlus, another UIMS toolkit on the top of CakePHP but also altering some problematic core of it. The thread should explain the outcome of the post. And, then I noted Akelos framework has most of the things built in.

Issues with frameworks esp. CakePHP

  • Scalability not a priority - Developers aren't aware that we can't throw more and more hardware

  • Excessive use of regular expressions

  • Evangelist isn't aware that the framework throws many queries unnecessarily

  • More memory consumption - 100M would never be enough for a simple project

  • Poor coding standards and practices - Prolong use of extract() often leads to more memory consumption

  • Can't use the native approaches or baked codes. The override approach always lead to hard to debug codes

  • Poor architected codes and no clear defined approaches. People belong to the cult drives the direction and often throws unprofiled codes. No native provision to share codes between M-V-C and no distinction between "libs" and "vendors".

  • Overlooked wrappers

  • Community - Only few are educated, majority overlook the common application features, some freelancers use it for networking and sycophancy to get jobs

  • Not actually open source

Update (2008-09-01): Follow-up

Saturday, August 16, 2008

Working with Jeremy Zawodny, Alan Knowles, Cal Henderson

My life and career are full of surprise...

  • I wanted to work in film direction

  • Wanted to work in AT&T Bell Labs with Dr. Dennis M. Ritchie (creator of C)

  • Wanted to work in Borland with the great developers of Delphi

But, none of these dreams came true. And, after 6 years of my career into Web Application Development, I informed the company about my humble desire to work with the great minds I came to know through internet--to see if the company can offer employment for them: Jeremy Zawodny, Alan Knowles, Cal Henderson. Peter (who is actually from UK), who approached them updated me that Jeremy cannot join the company due to his marriage and Alan feels that the company may not offer the international salary.

And, my dreams are just dreams!

If anyone wants to work with me, ping me through LinkedIn

Track previous link of a site in PHP

I just spotted through Google that Raj Shekhar has quoted my post to comp.lang.php in his Blog Ideas page:

mr_burns wrote:
> Is it possible to get the previous url. For example, if I am on page
> page01.php - and I then click to - page02.php - from page02.php, can
> use script to determine that I have come from page01.php? It doesnt
> have to be the entire url, even just the file name. Cheers

Add this line in the beginning of every script or possibly using a
global-common include file say config.php

output_add_rewrite_var('referer', htmlspecialchars($_SERVER['PHP_SELF'])); online manual user notes contributions

Sometime ago I had lot of interest in contributing to the online manual's notes. Thought lot of them are deleted now and not even relevant now, I'd thought of archiving them for my own reference:
Date: 7 Jun 2003 06:42:11 -0000

If you want to create PDF without using PDFlib library, you may try FPDF ( ).

If you want to know, how to use FPDF in PHP scripts, you can look at the source code of phpMyAdmin as phyMyAdmin uses this FPDF. ( )
Date: 12 Jun 2003 11:32:58 -0000

If you want to remove a particular element from the array without loosing the keys, you can use the following function:

function RemoveArrayElement($arr, $element)
if (($key=array_search($element, $arr))!==false)
return( $arr );



$arr = array("a","b","c","f","x","d","e","z","l");
print_r($arr); //debug
$arr = RemoveArrayElement($arr, "a");
print_r($arr); //removes the "a"
$arr = RemoveArrayElement($arr, "xxx");
print_r($arr); //no match of "xxx"; so displays the original array
Date: 17 Jun 2003 07:21:58 -0000

A nice article/code for creating auto-password with uniqid is at
Date: 20 Jun 2003 05:14:08 -0000

A very nice class to play with dates is available at

You can look at it's application at
Date: 20 Jun 2003 05:35:33 -0000

If you want to just compare any two dates, store them in ISO format (yyyy-mm-dd) and compare with < or > or == operators.

For example, $date1 = "2003-12-30"; $date2 = "2004-02-15";

if ($date1 < $date2) echo "date1 is less than date2";

Note, $date1 & $date2 are just strings. You can use this logic in MySQL too.
Date: 29 Aug 2003 10:20:47 -0000

[Recently realized a flaw in my previous note related to sending mail using ArGoSoft Mail Server. Only the IP should be used to relay, otherwise others may anonymously send spam mails using that IP. So, here is the improved note about the stuff]

For Windows users who work on local machine:

If you want to send emails from your local machine you can try ArGoSoft Mail Server ( )

1. Install ArGoSoft Mail Server
2. Open the ArGoSoft Mail Server and click Tools > Options to configure.
3. Enter the DNS server name or let the ArGoSoft Mail Server to auto-detect.
4. In the IP Homes tab, enter
5. Start (run) the ArGoSoft Mail Server and make sure there is no error.
6. Now, the "localhost" ( is your SMTP & POP3 server.

1. Open your php.ini
2. Enter the value of SMTP like SMTP = localhost

That's all!

Do not trust "sendmail_from" of php.ini. Always set headers parameter in mail() function.
Date: 3 Sep 2003 08:04:27 -0000

[Worked depending upon the comment of "hanez at forpresident dot com". Reviewed Anders Winther and "Joenema at aol dot com"'s "bullet-proof" IP address fetcher and came out with a new tight code.]


//Get the real client IP ("bullet-proof"???)

function GetIP()
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
$ip = getenv("HTTP_CLIENT_IP");
else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
$ip = getenv("REMOTE_ADDR");
else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
$ip = "unknown";

Date: 08-Sep-2003 03:32

Important note about the CSV format:
There should *not* be any space in between the fields. For example,
field1, field2, field3 [Wrong!]
field1,field2,field3 [Correct-No space between fields]

If you add space between the fields, MS Excel won't recognize the fields (especially date and multi-line text fields).
Date: 10 Sep 2003 12:15:03 -0000

Since IE 5.5, IE has a typical bug called "IE title refresh bug". If the connection is broken while browsing certain sites, IE will show "Cannot find server" page and the title will remain "Cannot find server" even if the page is get loaded after the connection is established. AFAIK, there is no fix for this bug.

I have recently found that Google's pages don't have this problem; Google uses header('Cache-control: private')
Date: 30 Oct 2003 12:03:12 -0000

The improved CSV Explode function of "hhromic at udec dot cl" again has one limitation with MS Excel.

His version returns "" for """". But the expected result is " for """"

And so, I have modified his code with additional inside check.


//Explode CSV (MS Excel) string

function csv_explode($str, $delim = ',', $qual = "\"")
$len = strlen($str);
$inside = false;
$word = '';
for ($i = 0; $i < $len; ++$i) {
if ($str[$i]==$delim && !$inside) {
$out[] = $word;
$word = '';
} else if ($inside && $str[$i]==$qual && ($i<$len && $str[$i+1]==$qual)) {
$word .= $qual;
} else if ($str[$i] == $qual) {
$inside = !$inside;
} else {
$word .= $str[$i];
$out[] = $word;
return $out;

} /*-------csv_explode()------------*/

$csv_str = 'a,"""","""",d,e,f';
print_r( csv_explode($csv_str) );

Date: 7 Nov 2003 12:19:21 -0000

Very nice MS PowerPoint presentation titled "SQLite and PHP" (author: Wez Furlong) can be downloaded at [134 KB]
Date: 16-Dec-2003 04:49

Zend has a nice tutorial titled "Accepting payments using Verisign's Payflow Pro" at
Date: 16 Dec 2003 06:56:22 -0000

This is just a comment on the note by "jason at thinkingman dot org". His note should be better modified to give the idea that it's a workaround for Win32 Platforms. Also, the Editor's link is missing.
Date: 26-Feb-2004 04:41

Here is a better workaround for Windows platform. Tested on Windows XP. Highly impressed by "geoffbrisbine A T y a h o o DOT c o m"'s idea of nslookup usage.

function getmxrr($hostname, &$mxhosts)
$mxhosts = array();
exec('nslookup -type=mx '.$hostname, $result_arr);
foreach($result_arr as $line)
if (preg_match("/.*mail exchanger = (.*)/", $line, $matches))
$mxhosts[] = $matches[1];
return( count($mxhosts) > 0 );
}//--End of workaround

echo getmxrr('', $mxhosts);
Date: 18-Mar-2006 01:07

Some useful links on SDO:
1. Quick intro ( )
2. SDO for Zend Conf 2005 ( ), Presentation, [481 KB], Graham Charters, 2005-10-18
3. Introducing Service Data Objects for PHP ( ), 2005-08-05
4. Service Data Objects specification ( ), 2003-2005
Date: 22-Jun-2004 08:40
Here is a code to convert ISO 8859-1 to UTF-8 and vice versa without using iconv.

//Logic from
$str_iso8859_1 = 'foo in ISO 8859-1';
//ISO 8859-1 to UTF-8
$str_utf8 = preg_replace("/([\x80-\xFF])/e",
//UTF-8 to ISO 8859-1
$str_iso8859_1 = preg_replace("/([\xC2\xC3])([\x80-\xBF])/e",
Date: 05-Oct-2004 08:01

[Fixed a bug in my previous note; ord() is missing in first condition]

uniord() function like "v0rbiz at yahoo dot com" (Note# 42778), but without using mbstring extension. Note: If the passed character is not valid, it may throw "Uninitialized string offset" notice (may set the error reporting to 0).

* @Algorithm:
* @Logic: UTF-8 to Unicode conversion
function uniord($c)
$ud = 0;
if (ord($c{0})>=0 && ord($c{0})<=127)
$ud = ord($c{0});
if (ord($c{0})>=192 && ord($c{0})<=223)
$ud = (ord($c{0})-192)*64 + (ord($c{1})-128);
if (ord($c{0})>=224 && ord($c{0})<=239)
$ud = (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128);
if (ord($c{0})>=240 && ord($c{0})<=247)
$ud = (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128);
if (ord($c{0})>=248 && ord($c{0})<=251)
$ud = (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128);
if (ord($c{0})>=252 && ord($c{0})<=253)
$ud = (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
if (ord($c{0})>=254 && ord($c{0})<=255) //error
$ud = false;
return $ud;

echo uniord('A'); //65
echo uniord("\xe0\xae\xb4"); //2996
Date: 17-Nov-2004 10:51

Here is a nice comment on benchmarking PHP codes using getrusage function
Date: 19-Jun-2005 02:41

This function obeys url_rewriter.tags ( ) configuration and hence can be used to rewrite selected tags.
Date: 19-Jun-2005 03:37

The note regarding url_rewriter.tags and XHTML conformity in the manual is bit confusing; it's applicable only when we use <fieldset> tags. Refer

Friday, August 15, 2008

"A to Z of C" book turns 5

A to Z of C, the DOS/Turbo C programming book written by K. Joseph Wesley and myself turned 5 on August 1.

Initially, we felt bad for spending our time in writing a book that were rejected and deceived by publishers. Now we get quite reasonable appreciations from people around the world--even though it's having technical and grammatical errors. Long live the internet publishing!

Probably a time for "A to Z of PHP" ?

Blessed with a girl baby

It's been quite long time since I last blogged... and for the sake of blogging/record, Heleena and myself are blessed with a wonderful girl baby on February 21, 2008