Warning: strpos() [function.strpos]: needle is not a string or an integer in /home/chaosorg/bugfeatures.com/blog/index.php on line 31

Warning: strpos() [function.strpos]: needle is not a string or an integer in /home/chaosorg/bugfeatures.com/blog/index.php on line 37
Bug Features - Free bug report and feature request service for your Web site.
Not all days are created equal 
Some days just suck. Especially the ones that aren't 24 hours long. You see, there I was calculating all the names and dates for the next 28 days, as you do when building a calendar or something. The obvious way to do it was to loop from 1 to 14 adding 60x60x24 seconds per iteration and then formatting the timestamp accordingly.

So, being PHP, I did something like this:

$timestamp=time();
for($i=1;$i<=28;$i++){
$timestamp += 60*60*24*$i;
$dates[] = date("Y-m-d",$timestamp);
}


Why not? That's the way everyone does it, right? Well, lo and behold I was getting an array with 2 copies of "2007-03-25" in it. At first I thought it was an integer rounding bug, so I started using this: 60.0*60.0*24.0*$i. Needless to say that didn't fix it. Anyway, to cut a long story short you already know what was happening don't you?

The 25th of March marks the end of daylight savings in Sydney, Australia which is the default timezone of my server. It just so happens that this day is 25 hours long, which means adding 24 hours to midnight gives me 11pm on the same darn day. Hence two copies of the date in my array.

Now I know better than to perform my own timestamp calculations on anything other than GMT, where every day really is 24 hours long. Anywhere else and you need to do something like this instead:

$date = new DateTime(date("Y-m-d",$timestamp));
for($i=1;$i<=28;$i++){
$date->modify("+1 day");
$dates[] = $date->format("Y-m-d");
}


[ Note that here the $date variable is a PHP5 date object]

  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 911 )
domTT and Firefox Uncaught Exception  
domTT is an excellent cross-platform DHTML tool-tip library which I have used for about 2 years on a range of projects. While building a custom AJAX interface for my current project I came across a weird error for the first time...

In FireFox under Windows, the domTT library sometimes throws an exception "Permission denied to get propertyHTMLDivElement.tagName".


After scouring the Web I see I am not the only one to have experienced this, but no-one has posted a solution. Well, if you found this page on Google then you are in luck! Open up domLib.js and change this: if (typeof(in_bannedTags) != 'undefined' &&
(',' + in_bannedTags.join(',') + ',').indexOf(',' + in_object.tagName + ',') != -1)
{
return false;
}

to this:
try {
if (typeof(in_bannedTags) != 'undefined' &&
(',' + in_bannedTags.join(',') + ',').indexOf(',' + in_object.tagName + ',') != -1)
{
return false;
}
} catch(err) {
return false;
}

Your page will now be catching the exceptions and FireBug will stop giving you those nasty red lines that ruin your day...
  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 927 )
Multiple PHP versions in a single Apache installation 
For some time now I have been two versions of Apache - one for PHP4 and the other for PHP5. This has been satisfactory except that my SVN repository was only installed for the Apache 2 install (the other install was 2.2 which doesn't support SVN).

So after a forced rebuild of my server I had trouble getting the 2 Apache's coexisting again so I went looking for another solution - and I found one that is way more elegant than having to stop-start every time I switched between projects....

Thanks to lukasz who posted a tip on php.net I have set up php5 as the default CGI handler for my Apache server with PHP4 set to override the default for specified directories. It works like a charm. I can now have specific PHP versions with specific extensions loaded for each project in the one Apache instance. Here's what it looks like:
ScriptAlias /php5/ "C:/Program Files/Apache Group/php-5.2.0/"
ScriptAlias /php4/ "C:/Program Files/Apache Group/php-4.4.2/"

AddType application/x-httpd-php .php
Action application/x-httpd-php "/php5/php-cgi.exe"

<Directory "C:/inetpub/wwwroot/BestAdsRebuild">
Action application/x-httpd-php "/php4/php.exe"
SetEnv PHPRC "C:/Program Files/Apache Group/php-4.4.2/"
</Directory>

<Directory "C:/inetpub/wwwroot/">
SetEnv PHPRC "C:/Program Files/Apache Group/php-5.2.0/"
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>

  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 951 )
Rounded Corners - Pure CSS 
It's been done a million times, but the fastest way to do it is to use the online rounded corner generator at:

http://www.roundedcornr.com

You get the CSS, the DIV tags and the four corner images all dynamically generated and ready to copy into your code....
  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 913 )
Xinha Warrior Editor! 


Came across a little problem today where my Xinha WYSIWYG HTML editor fields were not being submitted when the form was submitted from JavaScript. As a workaround, the getHTML() method can be called and dynamically assigned to the text area like so:
var html = xinha_editors.my_text_area.outwardHtml(editor.getHTML());
document.my_form.my_text_area.value = html;

Of course, replace my_text_area and my_form with the actual textarea and form elements' names and you can now do this:
<script>
/* xinha init code snipped */
function do_submit(){
myed = xinha_editors.my_text_area;
var html = myed.outwardHtml(myed.getHTML());
document.account.my_text_area.value = html;
document.my_form.submit();
}
</script>
<form name="my_form">
<textarea name="my_text_area"></textarea>
</form>

<a href="javascript:do_submit()">Submit!</a>

This is also a handy trick if you want to submit your Xinha HTML using AJAX.
  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 910 )
Prototype 1.5 and Rico 
Aha a bug! Well, sort of. If you use Rico and Prototype/Script.aculo.us then you may find updating to Prototype 1.5.0 makes ALL your XHR requests fail. Ouch! Well, it turns out Rico defines a function called extend which is then added as a header in Ajax.request() that forces Firefox to throw an exception. The fix?

Change this (line 916):
for (var name in headers)
this.transport.setRequestHeader(name, headers[name]);

To this:
for (var name in headers){
if (typeof headers[name] != 'function'){
this.transport.setRequestHeader(name, headers[name]);
}
}

Hopefully Rico will get an update that renames the extend function accordingly...
  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 902 )
Get checkbox values with Prototype 
After some trial and error using $F() and other serialize commands from the Prototype AJAX library I googled this tasty treat:

var checked = Form.getInputs(element.form, 
"checkbox",
element.name).findAll(function(item)


Then I turned it into a function like so:

function get_checkboxes(from_form, from_field){
return Form.getInputs(from_form, "checkbox",
from_field).findAll(function(item) {
return item.checked;
}).pluck("value");
}

  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 897 )
Vista on VMWare - "A required CD/DVD drive device driver is missing" 
It turns out you cannot use an ISO image mounted in VMware to install Windows Vista. While the installer will boot, once it goes to Vista's desktop, the virtual CD/DVD device is not detected and you cannot continue.



The solution? Mount the ISO in Alcohol 120% and retry! Note that my ISO wouldn't mount correctly in PowerISO due to the UDF file system.
  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 917 )
Profiling and Interactive AJAX Debugging - FireBug Tutorial 
The author of the FireFox FireBug extension has written an excellent tutorial on how to use it - including profiling and interactive testing via the console. A must read for any AJAX developer!

http://www.ddj.com/dept/debug/196802787?pgno=1
  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 889 )
OSX Tiger on a PC with networking 
Testing Websites across all browsers and operating systems on a single PC without rebooting? I used to do it with PearPC, but I've discovered a VMware compatible virtual machine does the job much more elegantly. The machine comes without networking support, but some clever chap has written an ethernet driver so you can run a Web browser. It's a bit slow, but it does the job. It is also alleged that using NAT instead of bridged networking in VMWare also works...

* Vmware
* Network Driver
* Pear PC





If all you want to do is see how your Web pages look on a Mac, check out this site:

http://www.browsrcamp.com/

  |  [ 0 trackbacks ]   |  permalink  |  related link  |   ( 3 / 902 )

Back Next