Annas hotel website

Recently finished another website in Flash. It is for a nice hotel in Latvia with SPA & restaurant.
I have switched back to Actionscript 2.0 in Flash, because AS 3.0 is a bit too much headache and tough learning curve.
Website is based on SWFAddress deep-linking structure and uses other free Actionscript libraries. Database is MySQL driven, connected in simple XML loadData manner. All text data can be edited with WYSIWYG type editor.

Intro section welcome page … reservation

Visit: http://www.annashotel.com

Add or remove trailing slash in URL with .htaccess

If you`re using some kind of CMS, usually its normal that each URL works with or without trailing slash, e.g. these URLs would be the same:
http://example.org/about
http://example.org/about/

Still Google, Yahoo, MSN and other search engines treat them as different urls and gives penalty as they are dupliate URLs with identical content.
You have two options – to add or to remove the trailing slash. After a bit of reading I chose to remove the slash from my celica site, because I`m using Drupal CMS that removes trailing slashes for new content and I don`t really want to hack the CMS plugins. To alter the URLs, you need to edit .htaccess file at the root directory of your website ( http://example.org/.htaccess )
Add this code to your .htaccess file to remove trailing slashes:

#get rid of trailing slashes
RewriteCond %{HTTP_HOST} ^(www.)?turbocelica\.lv$ [NC]
RewriteRule ^(.+)/$ http://www.turbocelica.lv/$1 [R=301,L]

or use this code to ADD trailing slash to the end of each URL:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)([^/])$ http://example.org/$1$2/ [R=301,L]

Make sure you backup your .htaccess file before you edit. It`s easy to get “500 Internal server error” if you don`t know what you`re doing ;)
Read more here: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Flash player 9, 10 – security policy file

I encountered problems for last 6 months to upload music on my dj site – www.djnet.lv . I have flash CMS admin on djnet.lv but the songs are uploaded to other site of mine, where HDD space is not a problem. about half year ago I couldnt upload songs from some computers, now its from all computers. It just stops. I had suspicion it had something to do with new Flash Player versions 9 and 10. So today I fixed it just by uploading simple file to my file hosting server: crossdomain.xml.
Flash player always looks for domain.com/crossdomain.xml file when it accesses its contents or uploads something. The is what my security policy file contains:









Drupal imagecache and robots.txt

Today i discovered a very stupid configuration in Imagecache module for Drupal. Imagecache saves all presets (thumbs, big images, etc) in subdirectory /sites/default/files/imagecache/[presetname]/. Of course this is conflicting with robots.txt, which says “Disallow: /sites/”. I created a few sites that really are targeted for Google`s image search, but I couldn`t find a single pic in google. This is so annoying to find out. I just removed the deriative in robots.txt and will update this post with results soon.

How to: Disable new user registration in Drupal

How to: Disable new user registration in DrupalAfter a quick search I didn`t find how to simply switch off new user registration in Drupal. But it has even better feature – access roles. You can specify what usernames/emails/hostnames can access the members area or even register as user.
To disable new user registration, you have to add access rules for existing users. Go to yoursite.com/admin/user/rules/ and add a new rule. For example, first add an allow rule for user “admin“. Then for other existing users. After you have finished, add a deny rule and write “%” in the username field. This will allow to login only the allowed usernames and deny everything else. If the username is not defined it cannot be also registered.
You can even make private site and say to your friends add e.g. “-foo” to their usernames. So you make an allow rule with “%-foo” in username field.
The reason I need to block new user registration is spam. New users register everyday with random spam usernames.

PHP, UTF-8 encoding, CSV and Excel

Horrible combination, spent all day on this!
My goal was to take some data (which contain UTF-8 unicode characters), generate a CSV file using PHP and send it via mail. The problem is that Microsoft Excel doesn`t accept UTF-8 CSV files.
Some people suggest using mb_convert_encoding($contents, "ISO-8859-1", "UTF-8"); or mb_convert_encoding($contents, "UTF-16LE", "UTF-8");, neither worked for me, though I have multibyte extension installed
It seems that the solution is different by server setups. This solution worked for me:

$message= iconv("UTF-8","WINDOWS-1257",html_entity_decode( $message ,ENT_COMPAT,'utf-8'));

You might want to change “WINDOWS-1257” to something else, like WINDOWS-1255 or WINDOWS-1252 or ISO-8859-1, etc.. My server did not have the “iconv” function enabled, so I asked server administrator to enable it and it worked!

Campaing tracking in Flash ClickTAG

Today we encountered a problem. Nothing showed up in Google Analytics tracking campaigns. We used a clickTAG code to swfobject (a.k.a FlashObject) like this:

so.addVariable(“clickTAG”, “http://domain.com/some_page/?utm_source=Banner&utm_medium=Banner&utm_campaign=Banner3”);

But the banner link only went to “http://domain.com/some_page/?utm_source=Banner”. After a bit of research I found out that Flash didn`t accept anything that’s after the ampersand &. Some suggested using & instead of &, but it did not work. I`m not sure if it`s a problem of Flash or SWFobject, but anyway I found a simple solution – use javascript escape() function to translate the URL, like this:

so.addVariable(“clickTAG”, escape(“http://domain.com/some_page/?utm_source=Banner&utm_medium=Banner&utm_campaign=Banner3”));

Voila! Now the banner opens full URL with tracking code! I think this is a problem with other tracking and ad network users also.
I hope this helps someone! :)

Scite default encoding to UTF-8

Scite is one of the best text editors out there – functional, fast and lightweight! If you write a lot of text that is not in english (read: UTF-8) it becomes pretty annoying as every time you open Scite.exe it defaults to 8-bit character set. To write or see the opened document with UTF8 characters you have to click File > Encoding > UTF-8. While there is no graphical interface for options, you can still change the default encoding manually. Here is how:

  • Open Scite, click Options > Open global options file
  • search for “#code.page=65001” (mine is at line 218) and uncomment it (remove # symbol)
  • comment out “code.page=0” (add # symbol)
  • save the global ooptions file and restart Scite.exe

Now every time you open scite or a document in it, the default encoding will be “Code page property” or UTF-8 in most cases. If it doesn`t work, there area few other lines that you can uncomment right under the mentioned ones.
Hope this helps!

Tutorial: create animated favicon

Animated favicon is supported only by Firefox, for now. (Are you still using Internet Explorer??
)
If you don`t know how to create a simple favicon – just put an icon file with name “favicon.ico” in your web root folder (e.g. www.yourdomain.com/favicon.ico).

Animated favicons are stored in .gif image. You can see an example of animated icon at information security awareness blog , it shows in the address bar and on the tab. You can create it yourself using some gif animation software or exporting from Adobe Flash (I do it). When you have your gif icon ready, upload both “favicon.ico” and “favicon.gif” to your web root folder, then add this code to your webpage somewhere between and tags:


That should do it! You can also create both static and animated icon files from any image (favicon from jpg, jpeg, gif, bmp, tif, png, etc) using a favicon generator available here.