jump to navigation

Complete cheatsheet January 29, 2006

Posted by chmod775 in HTML/XHTML/XML, MySQL, PHP Programming, javascript.
1 comment so far

Every developer needs a reference and/or a cheatsheet.
This one came up in del.icio.us search and is very complete.

http://www.petefreitag.com/item/455.cfm 

Do you have a cheatsheet you still reference by?

Google sitemap December 12, 2005

Posted by chmod775 in Google.
1 comment so far

Here a PHP script to build a dynamic a google sitemap. It is based on the files in your webroot and will ignore the robots.txt files.

You can also add filenames or fragments of filenames that need special priority.
I didn’t had time to implement a dynamic change frequency patch.

Dowload here.

UTF-8 encoding with PHP/MySQL December 1, 2005

Posted by chmod775 in MySQL.
2 comments

CharsetsUTF-8 is an encoding that is used for internationalization of a web-based app. I use it for an application that is fetching RSS feeds from any country and saves them to a database like MySQL.

In the beginning it was only fetching feeds from blogs and news sites with the latin language. But as the app was growing also feeds that came from China or Japan ware added. But these character sets were not supported and shows only squares and other strange (=not readable) characters.

In more then one case a RSS feed is encoding according to the unicode character set. A good RSS and atom parser like magpieRSS can handle these charsets and output everything in the desired encoding like utf-8, iso-8859-1, etc.
Als the database tables I had to set the charset to ‘utf-8 general‘ so that there was no loss of original caharacters that were in that feed.

Now only in PHP to show it on the screen or to make an aggregated feed of those items.
Before I print it on the screen I did some string manupilation.After a while I read about the multi-byte support in PHP and tries some functions. It worked for a bit, but not for the ë, é, etc. characters. They still were garbled on the screen.
Then in a comment there was a perfect hint!

$text = mb_convert_encoding($text, 'HTML-ENTITIES', "UTF-8");
After that it was solved. also all the regular expressions with the mb_ereg_replace() function worked as expected.
The next step is to change the encoding of your HTML page to utf-8. The you are complete and you have a full unicode supporting webapp!
Good articles about this issue:
- http://www.w3.org/International/questions/qa-changing-encoding
- http://www.php.net/mbstring

Secure or Not Secure; That’s the question (IN IE!) November 2, 2005

Posted by chmod775 in javascript.
add a comment

SSL In one of my web applications I build is, after logon, a secure connection with a SSL certificate. After a while of developing I released a new version. From that point on Internet Explorer on the PC gives us much trouble by putting up a box which was the annoying “This page contains both secure and non secure items” message.

After checking all the links, images, stylesheet links, jsavascript links and favicons whcih they are ok, I was puzzled! What the F*CK ‘not secure’! Give me more info! (Duh, you are screaming at your screen with IE in front!…)

After a while of searching I ran into a site of ‘Experts exchanges‘ which is a very, full of adverts, annoying site. But it helped me a lot.

The conclusion was that in a datePicker javascript I use a iframe was dynamicly build to fix a bug in IE. But when a frame has no src attached to it it will assume that it is ‘about:blank’. which is not secure. After adding the source pointing to a blank EXISTING file everything was ok.

Firefox on PC and Mac give me no notice of this security issue.