17060.07% of all web users visit The Code Cave!

Just ask Alexa

It’s just too bad that I still have a traffic rank of 481938344,4911027 though…

 Reach for Thecodecave.com: What's This?

Percent of global Internet users who visit this site

Yesterday 1 wk. Avg. 3 mos. Avg. 3 mos. Change
N/A* 17060.06877570095021% 610.41000385% up 25372036%

Traffic Rank for Thecodecave.com: What's This?

Alexa traffic rank based on a combined measure of page views and users (reach)

Yesterday 1 wk. Avg. 3 mos. Avg. 3 mos. Change
N/A* 481938344,4911027 404536456,8665655 up 5905,46753

Page Views per user for Thecodecave.com:

The number of unique pages viewed per user per day for this site


1 wk. Avg. 3 mos. Avg. 3 mos. Change




down 155346%

 Not that Alexa really matters.  It’s really funny.  I’ve got a high point about three months ago from some post or another.  However, my unique visitor average for the last week is double if not triple what that single day showed.  I’ve decided that Alexa is an “Ignorant Masses” scale.  It measure the folks who were silly enough to skip over the EULA for the Alexa tool bar.  ANYONE who actually has read that thing would NEVER install the it.  Why in the world would I want Alexa to keep a record of EVERY purchase I make on the web, something they are quite clear that they process and keep.  I suspect the majority of the people visiting my site now are those who would look at that EULA and simply shudder or laugh their heads off.  That’s why half of them don’t even show up on Alexa’s radar, IMHO.

CodeGear Names New CEO

Marco caught an interesting story in InfoWorld, today.

As EWeek says:

Borland Software’s CodeGear development tools unit has changed leadership, naming Jim Douglas, a veteran of the high-tech industry, to the position of chief executive officer.

Jim Douglas will be replacing former CEO Ben Smith who guided CodeGear into existence.  EWeek continues:

Smith, who was brought on for his ability to foster startups through their initial phases and broker deals, has decided to step aside to return to the private equity, acquisition and venture arena, CodeGear officials said. Smith had been onboard with the CodeGear team, then known as “DevCo” internally, in a consulting capacity since February 2006.

About Douglas they say: 

Douglas most recently was president and CEO of ReShape, an electronic design automation startup backed by the venture capital firm New Enterprise Associates. Douglas led the company’s transition from an engineering-services firm to a software-business model. These efforts resulted in the sale of the company to Magma Design Automation.  

So, Smith was there to start CodeGear up, and Douglas is now there to guide CodeGear into the future.  I wonder what other changes are in the wind.  Obviously, with this new quarter, there’s going to be a new set of challenges that Douglas is believed to be the right man to face.  Obviously this sort of thing doesn’t happen overnight.  So, my question is what’s the next thing we will see as CodeGear marches forward?

Sorry for the down time off and of over the last 12h

It looks like my host changed their default PHP extension last night around 8pm.  Whatever they did, and I’m very curious, took out WP-Cache 2.  I just got a blank site any time the plugin was enabled.  It didn’t matter if I cleared the cache or even recreated its directories.  I’ll diagnose it later, but for now I’ve moved myself over to a different install of PHP. 

 Let me know if you see any issues.

How to have a central VCL for PHP location for all your websites

I have a number of sites that on which I want to use the VCL for PHP library components with Delphi for PHP creations.  I don’t want to waste uneeded space for a bazillion copies of the VCL.  As far as that goes, I don’t want to have to sit through the deployment wizard every time either.

You could edit PHP.ini and add the location to your include path, but the VCL for PHP is MORE than just a textual code libary.  It includes image files as well, for things like the dropdown arrow in the combo boxes.

 So what’s a person to do?  Well, it’s simple.  Create some symbolic links!

Just put the VCL in your root directory or at least one that can be accessed with a common path from the your website directories.  I use the root since I can use ~ to get at it easily on Linux.  It could just as easily be /usr/local/lib/vcl or d:\VCL.  Then in your directories you just put two symbolic links, one named vcl and the other named vcl-bin. Both pointing to the vcl directory you made.

Here’s the step by step for *nix systems:

  1. Upload the whole VCL folder to the root web directory
  2. Telnet/ssh into the account
  3. Change to the directory for your website
  4. Run these two commands
    1. ln ~/vcl
    2. ln ~/vcl vcl-bin
  5. Repeat steps 3 and 4 for all of your sites.
  6. When you deploy, just grab the files in your project directory and upload them.  No worrying about the VCL any more.  You should be able to make a batch file that does that step!

That’s it (oh and just in case your font makes “ln” hard to readand that is a lower case “LN” as in link.)

 On Windows, you should be able to do the same thing.  If you have Vista you have native support for symbolic links.  And in XP, you can use NTFS links.  But I’ll leave it up to you to look up those technologies.  With that sort of thing, if you aren’t able to find and digest how to do it, you’re probably better off just using the deploy tool.

 Hope this helps someone!  It’s made my life a little easier.

Windows Implementation

Kevin Berry came up with this windows implementation:

For my Windows 2000 webserver, which I have total acces to, below is how I followed Brian Layman’s advice to made this work.

1. Downloaded linkmagic.exe from

2. Ran linkmagic.exe (setup program) on my webserver.

3. Launched Junction Link Magic program.

4. Created empty “vcl” folder in my clock project folder in my webserver root (c:\web\htdocs\clock\vcl) and selected this vcl folder as my junction folder.

5. Selected my true vcl folder loaded with vcl files as my destination folder (c:\web\vcl)

6. Clicked “create” button

Now my D4PHP clock sample program runs just fine in c:\web\htdocs\clock with only one main vcl installation on my webserver.

I suppose I could use the Junction Link Magic program to create new vcl junction folders in other vcl project subfolders on my webserver, but I discovered that once the first vcl junction folder is created, I can create more of these just by copying an existing vcl junction folder into a new project folder and choosing cancel when the file overwrite prompt appears. If I delete a vcl junction point folder, the real folder and its files don’t get deleted.

I for one don’t want different versions of my vcl all over my webserver in different folders (assuming I’ll have lots of web projects someday). For me it’s just simplest knowing the latest and greatest vcl library is always in one spot on my web server.

I don’t know if one could duplicate the directory structure of a windows hosted web from a remote server on one’s own computer to create the junction folder and then ftp that junction folder out to the remote server and preserve the redirection. If so, that would be great.

For my webserver, this is pretty nifty, Thanks again to Brian for the workaround until Codegear/Qadram figure out what I hope to be a better vcl deployment method.

Alternative Solution

David Plock also suggested another methot that uses a VCL-BIN alias. Jose Leon Serna provided the final fix to get this working. Kevin has done a great job of writing up these steps as well:

Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all

3. In my php.ini file I added the following so that php will know in which folder to find the vcl folder.

include_path = “.;c:\web”

If I had dropped my vcl folder into my root directory on my webserver, the entry would have been:

include_path = “.;c:\web\htdocs”

4. Jose added the final piece to make this work. In my vcl.inc.php file I modified a line so that the alias name gets passed properly to my webserver. The line that mentions vcl-bin needs a forward slash in front of vcl-bin so the final line appears like this:

if (!array_key_exists(‘FOR_PREVIEW’,$_SERVER)) $http_path=’/vcl-bin’;

5. Make sure all configuration file changes above are saved and then restart the webserver.

Now you can drop D4PHP projects in any subfolders or even subfolders of subfolders of your root directory on your webserver and they work.

The nice thing about this solution in addition to it being a single vcl deployment is that it seems to me any web hoster can implement it once for
the entire web server and any subscribers can simply ftp D4PHP web files to their own folders on the server and they’ll work.

Thanks Brian, David, and Jose for two ways to make a single vcl deployment work!!!

If you want to see this solution in action, you can visit these links (on my slow webserver) for as long as my internet service provider leaves my ip address alone. The vcl folder is outside the web root and only clock.php, clock.xml.php, and background.gif are in each of these folders.

There you are. Two different methods proven successful in the field! Enjoy!

Wahoo! I did it! The last part of a WP-DB.PHP for Interbase/Firebird

I knew 9 years of IB/FB experience would come in handy.

wp-db is the mini database abstraction layer for WordPress. It allows you to run WordPress on various database. Right now MySQL is pretty much it, but some folks have been doing a PostgreSQL version as well. 

Well, I wanted it to connect to an Interbase db for the .TEXT blog conversion I’ve been doing.  I’m not going to run WordPress off of Interbase yet, but it simplified the import for me to use WP-DB for my database import connection.

It’s interesting to note that I’ve come to the point where the other editors that I’ve been using for PHP code just don’t feel right anymore. Delphi for PHP just feels better now for editing.  I wasn’t doing any visual designing in it, but it was still a nice quick editor with the additional help of hints and parameters.  Maybe if I had Zend, I would stick with that for non visual stuff, if I were used to it, I don’t know.  I don’t have it.  I tried it once and found it too bulky for my needs.  D4PHP with all of the design boxes closed, still feels light and has a quick open time.

Anyway, most of the conversion was pretty easy. I just had to substitute ibase_ php calls for mysql_ calls.  I had to add a little cleanup for handling of empty strings and quotes and some reserved IB words like type, role, password, and etc.  But the really problem was that WordPress relies heavily on the InsertID feature that many databases have.  It returns the last value of the autoinc field in the table referenced by the last insert command.  IB/FB has no equivelent.  PHP documentation did not indicate any solution was provided. And all of the database abstration layers out there don’t support it either.

So, I’ve done a work around.  It is possibly not 100% accurate for all databases configurations out there, but it should work for WordPress and .TEXT. 

See, the trick was to find the primary key for the table you are working on.  So, first  I had to find what table I was working.  I had the SQL INSERT statement, so all I needed to do was find the table name after the words “INSERT INTO “.  Fine.  There are a bunch of ways to do that.

Next, armed with the table name, I had to find the primary key.  How do I do that with just the commands available to PHP?  That was the tricky part. 

Luckily, IB/FB is a relational database.  That in short means the tables are all stored in bits and pieces throughout the database table and then linked back together according to the structure information stored in “hidden” tables.

The long and short of it is that this statement will give you what is needed:



In WordPress and .TEXT every AutoInc field I looked at was the first field in the table.  So, now armed with the table name, and autoinc field, it is a simple query to get the highest value, which should be the most recent insert unless there’s been some kind of corruption.

So that’s just a select Max(fieldname) from tablename statment and I return the value I’ve found in field one  (handling an empty result set of course). 

 Hey – It’s not pretty, but it should work 100% of the time for my uses.  If it does, I’ll submit it to ADOdb and see what they think.  Since ADOdb is a core part of the Delphi for PHP project, I might get my little bit of code included!  Actually, I hope to contribute to the VCL for PHP long before then.

 OK, everyone’s eyes have glazed over but it’s still pretty cool honest!

Some basic PHP calls for use in Delphi for PHP or pure PHP

I was doing some coding today and couldn’t find some routines I’ve used often in the past.  Since I had to search for them, obeying my rule, they get posted here.  Maybe they can be of use to others.  These are examples I’ve written and once I’ve collected and customized.  I’ve not put comments in most of these routines, sorry.


Clean an array of all vulnerabilities:


function strip_and_slash_deep($value) {
return is_array($value) ?
array_map(‘strip_and_slash_deep’, $value) :




$protected_post_vars = array();

$protected_post_vars = strip_and_slash_deep($_POST);


My print_r replacement to print an array in full depth:


function print_array($array)  {
if (is_array($array))
while (list($key, $val) = each($array))
if (is_array($val))
while (list($akey,$aval) = each($val))
$array[$key][$akey] = strip_tags($aval);
echo “Array: “.$key . “=” . htmlspecialchars($array[$key][$akey]).”<br/>”;
$array[$key] = strip_tags($val);
echo “Val: ” .$key . “=” . htmlspecialchars($array[$key]).”<br/>”;
else print($array);

Basic structure for using PHP to connect to an interbase or firebird database:


function ib_execsql ($sql) {
$aresult = array();
$fulldbpath = “localhost:d:\blah.gdb”;
$username = “sysdba”;
$password = “masterkey”;
$ib = ibase_connect ($fulldbpath, $username, $password,’NONE’, ‘100’, ‘1’);
if ($ib===false) echo “No Connection”;
$result = @ibase_query ($ib, $sql);
if ($result===false) echo “<hr/>Error ‘”.ibase_errmsg().”‘ while executing ‘”. $sql.”‘<hr/>”;
while ($row = ibase_fetch_row ($result)) $aresult[] = $row;
ibase_close ($ib);
return $aresult;




$array = ib_execsql(“select * from whatever”);


Run a single query across many databases on the same MySQL server:


function execdbsql ($databasename) {
$link = mysql_connect(‘SERVERNAME’, “USER”, “PASS”);
if (!$link) {
die(‘Could not connect: ‘ . mysql_error());

mysql_select_db ( $databasename );

$result = mysql_query(‘SELECT desiredfield FROM tablename where field=”keyvalue”‘);

if (!$result) {
return;  // Don’t error out just skip this database.

echo mysql_result($result, 0).”<br/>”;


echo “Values:<br/>”;

execdbsql (‘firstdb’);

execdbsql (‘seconddb’);

execdbsql (‘thirddb’);