Archive for March 2007

Open Sitemap Generator 0.5.1 released


We’ve released a bugfix version, the 0.5.1.
We’re looking forward to make a big upgrade to the Mapper core in the next major release, using db4o, with the vision to add a way to make multiple sitemaps with an index, automatically

You can download this version from here.

Mike

A simple PHP time testing unit


It’s not a secret that we’re working on a new version (no new graphic) of our main site.
Adding a whole new section and a lot new features, we’re putting our hands on a big part of our code.
So we’ve started also to improve the overall performance of our site (written in php), optimizing the db queries and the php code itself.
To achieve this result we needed a simple way to check the timing behaviour of every section of our code.
There are some php testing unit out there, but we needed something more simpler and more usable.
So we’ve written our time testing unit, without using classes (I do like OO programming, but classes were unuseful for this simple target), in only one array and four functions.

Let’s see the code.
$ctk_timesteps=array();
 
function ctk_microtime_float()
{
   list($usec, $sec) = explode(” “, microtime());
   return ((float)$usec + (float)$sec);
}
 
function ctk_marktime($desc){
	global $ctk_timesteps;
	$ctk_timesteps[$desc]=ctk_microtime_float();
}
 
function ctk_start(){
	ctk_marktime(’start’);
}
 
function ctk_report(){
	ctk_marktime(‘final’);
	global $ctk_timesteps;
	$output=‘<div id="perftest" style="position:fixed;text-align:center;
		left:10px;top:10px;border:1px solid #b0b0b0;background-color:#e5efc9;
		padding:4px;z-index:100;color:#7b0000;">
		<b>Time Analysis</b> (sec)<br/>’;
	$total_time=$ctk_timesteps[‘final’]-$ctk_timesteps[’start’];
	$prevtime=$ctk_timesteps[’start’];
	
	foreach ($ctk_timesteps as $step => $steptime){
		if(($step!=’start’)&&($step!=‘final’)){
			$difftime=$steptime-$prevtime;
			$perctime=$difftime*100/$total_time;
			$output.=$step.‘: ‘.number_format($difftime,8).
				‘ (’.number_format($perctime,2).‘%)<br/>’;
			$prevtime=$steptime;
		}
	}
	$output.=‘Total time: ‘.number_format($total_time,8).‘</div>’;
	return $output;
}
 
//Start now!
ctk_start();

To use this unit, simply copy the code in a file and include it at the very first line of the php script you want to profile and then get your analysis report in a string rendered by the ctk_report() function.
To print it on the page, put an echo ctk_report() at the end of your file, but inside the body of the returned html page.
The results we’ll be displayed in a fixed div at the top left margin of your browser window.
We use the array $ctk_timesteps to store all the times we want to track. You can add a new timestep, inside your code, with the ctk_marktime('stepname') function, using a string as the stepname (that is printed on the report).
The unit will calculate all the times between the steps (with also the precentage).


Mike

March: the Month of PHP Bugs!


And so this is the Month of PHP Bugs!
Let’s see what will come out and we look forward for a strenghtened PHP in April. ;)

Mike

Wordpress 2.1.1 download corrupted!

A notice on the Wordpress development blog says that the Wordpress 2.1.1 download package was corrupted by an hacker that added an exploitable code to the package.
They released a new version, 2.1.2, go, get it and update you blog!
It’s not fair if you cannot trust a download from an official server.
And the unanswered question is: “How could this happen?”.

Mic