The Myriad Blog

Category: Programming


Conflict Between Apache URL Rewriting and Basic Authentication

| Posted by Peter Schultheiss on May 7th, 2009 at 04:04 pm

The Apache module mod_rewrite provides a rule-based rewriting engine that is used by most MVC frameworks (i.e. CakePHP and Zend Framework) and content management solutions (i.e. Drupal and WordPress.)

The benefits of using a rewrite engine include:

  • Making website URLs more memorable to users
  • Making website URLs more relevant to search engines
  • Masking the inner workings of the site by hiding file extensions

I ran into an issue the other day where I needed to run a legacy application that was being protected by basic .htaccess authentication. The legacy application was located in a subdirectory.

Typically, you would just add the following line of code to your .htaccess file to instruct the rewrite engine to ignore the directory:

RewriteEngine off

Unfortunately, this won't work as expected. For basic authentication, the server writes a "401 Unauthorized" header and then looks for an error document based on a pre-defined path. Most of the time, the error document won't exist in the directory that you want to protect, so the request gets handled by the rewrite engine which throws a 404 error.

The solution to this problem is pretty straightforward. You need to add a single line of code to your .htaccess file instructing Apache to ignore the error document. When you're done, the code should look something like this:

ErrorDocument 401 "Unauthorized Access"

RewriteEngine off

AuthType Basic
AuthName "Administration"
require valid-user
AuthUserFile "/home/user/.htpasswds/public_html/admin/passwd"

Hopefully this will save somebody a bit of aggravation.


Fixing the IE7 Z-Index Bug

| Posted by Peter Schultheiss on February 24th, 2009 at 09:15 am

Dynamic drop down menus have always been a headache for web developers, mostly due to quirky rendering behavior across different browsers. IE7 presents a unique challenge with the way it renders z-index stacking orders.

Even though I had all of my z-index values correct, drop down menus were being placed underneath a relatively positioned <div> that occured further down the page.

There is a very elegant solution to this problem that requires jQuery and a few lines of javascript code at the bottom of the page. The following code traverses through your <div> tags assigning the ones at the top of the page a higher value. Worked like a charm for me!

jQuery(function() {
    var intIndex = 1000;
    jQuery('div').each(function() {
        jQuery(this).css('zIndex', intIndex); intIndex -= 10;

Special thanks to Vance Lucas for posting this function on his blog.


PHP Coding Standards

| Posted by Peter Schultheiss on February 20th, 2009 at 10:06 am

All Myriad contractors should follow the PHP coding standards used by the Zend Framework.


Communication Between Two Flash Movies

| Posted by Peter Schultheiss on January 28th, 2009 at 12:12 pm

We recently created banner advertisments for the Arizona Department of Transportation that involved a hot air ballon flying from a top banner to a side banner on rollover.

ADOT Banner Example

In order to acheive something like this, you need to open a Local Connection between the two movies and send a function call and (optional) argument over that connection. The following snippet of code would go in the sending movie and could be attached to a button:

on (rollOver) {
    obj_sending_lc = new LocalConnection();
    obj_sending_lc.send('_ConnA', 'traceMyName', 'Peter');

In order for this to work, we will need to add code to the receiving movie making it ready to receive this information. The following snippet of code would go in the receiving movie:

obj_receiving_lc = new LocalConnection();
obj_receiving_lc.traceMyName = function(str_argument) {

In this example, my name would be traced to the output window of the second movie. Obviously, you would want to make changes to the function name and what it does, but this will get you going quickly.

Before you try this out on your own, be forewarned that you can't run the webpage in multiple tabs (which can happen during development) as only the first one will work.


CSS Tricks: IE6 "min-height" Hack

| Posted by Peter Schultheiss on January 9th, 2009 at 11:53 am

It's very useful to be able to specify a minimum height for an HTML container. Unfortunately, IE6 does not properly support the min-height attribute. This frustrated me for a long time, but there's a solution! The following example is simple, valid and just plain works.

Say you want to enforce a minimum height of 200px on a container, simply add the following code to your identity or class:

min-height: 200px;
height: auto !important;
height: 200px;

That's all there is to it. I didn't come up with this on my own, so a special thanks goes to Dustin Diaz for publishing this hack.


Zend Framework Version 1.7 Supports Adobe AMF, jQuery, Twitter, etc.

| Posted by Peter Schultheiss on November 19th, 2008 at 01:55 pm

The least release of the Zend Framework (Version 1.7) provides a number of new features, bug fixes and performance enhancements.

It seems that Zend is concentrating on Rich Internet Applications (RIAs) in this release as they are now providing support for Adobe's Action Message Format (AMF) which allows developers to easily share data between PHP applications and Flash (including Flex and AIR). While I haven't had the opportuity to test this out personally, I'm sure it will be a huge time saver for our developers.

Version 1.7 will also offer integration with jQuery's AJAX library. This is great for our team as we already include the jQuery library on all of our projects. In addition to outstanding AJAX support, jQuery's lightweight code base is great for HTML document traversing, event handling and animating.

Zend has also provided us with a little goodie that will make it possible for developers to add Twitter to their site without requiring the Twitter interface. Twitter is making a big impact on the Web so I'm glad that this service is available to developers.

Finally, I'd like to mention that the Zend has made done some fine tuning to improve performance. You can expect a 25% to 50% improvement in load times by upgrading your Zend library. This could be the best enhancement of all.

Thanks to the entire Zend community for making this new release available!


Spanish Characters in Flash via XML

| Posted by Peter Schultheiss on November 12th, 2008 at 03:29 pm

We've been populating dynamic content in Flash for a few years now. The other day, I was faced with the task of populating Spanish text into a Flash movie via XML. The underlying code is the same, but when I published my movie and viewed it online I noticed that the special characters didn't show up. What went wrong? After spending several hours reading through forum posts and tech notes, I found the solution. Here's what you need to do:

1. Embed Special Characters in Flash
For starters, we need to make sure that all of the special characters (i.e. á, é, í, ó, ú, etc.) are embedded in our flash movie. You also have to make sure those characters are available for the font you're using. The "Character Map" application in Windows will be a big help. If you're not familiar withCharacter Map, you can find it here: Start > Programs > Accessories > System Tools > Character Map

2. Use UTF-8 Encoding
Next, make sure that your XML document uses UTF-8 encoding. To endcode the XML as UTF-8, make sure the first line of your XML file looks like this:

<?xml version="1.0" encoding="UTF-8"?>

3. Save as UTF-8
Almost all text editors default to ANSI encoding. When saving your XML file, be sure to select "UTF-8" from the "encoding" drop down menu.

4. Upload as Binary
When uploading, it's important to note that your XML document should be transferred as a binary file. Most FTP programs will auto-detect this, but if you're having problems set the transfer type to binary before you upload the file.

¡Buena suerte!


Don't Show the Cursor on a Flash Button

| Posted by Nate Allen on September 7th, 2008 at 11:03 am

Do you ever want to use a button to trigger an action in flash but avoid get the mouse hand since it doesn't actually click through to anything? No problem, just a simple line of code and you're all set.

From the Main Timeline:
(button or mc name).useHandCursor=false;

Within a Button or MovieClip:

< Previous | 1 | Next >

Recent Projects
Our Services
Follow Us