IIS Fails with Multiple Referers, but not Referrers

August 24th, 2009

This is something I came across today when we launched a new section for a website. It’s something I’ve never encountered before, and I ended up spending most of my afternoon debugging what was causing our issue. Let me begin by saying the correct spelling of Referrer does have two r’s, however it is misspelled in the HTTP Specification. To the end user, this should mean nothing as most software that uses the HTTP Spec uses the incorrect spelling, as it’s what was defined in the spec.

When we launched the site, we checked it out in all our normal browsers and everything was good. Then we fired up IE 6 (unfortunately the client in question needs IE 6 support), navigated to the new secti-OH CRAP! The page itself would load, but none of the external assets (images, stylesheets and scripts) were loading. Refresh the page and bingo! it works fine! What the heck is going on?!

It turns out IE 6 was sending not one, but two referers to the web server. While it’s odd to have 2 referers, it shouldn’t cause 4xx Errors when sending a request. From this, we were able to find out a few things:

  1. IIS accepts both Referer and Referrer as valid HTTP headers.
  2. IIS will not accept more than one Referer.
  3. IIS will accept more than one Referrer (note this is the dictionary spelling of referrer, not the spec spelling).
  4. IE 6 will add 2 referrers if the link you clicked is located inside of a Flash element for all external assets: the URI to the Flash file and the URI of the page you are on.

Read more »

Show Only Children Pages on Parent Page

August 3rd, 2009

There is still much to be desired within WordPress when it comes to dealing with parent and children pages. The core code is there, and it’s usable, but there’s not a lot “out of the box” to play with.

We’ve developed a bit of code to help make your life a little easier.

Adding the code below to your functions.php file will let you remove the other children pages while on the parent page.

add_filter('wp_list_pages_excludes', 'remove_others_children');
function remove_others_children($excludes = array()) {
  $all_pages = get_pages();
  $all_children = (array) get_page_children(true, $all_pages);
  foreach ( $all_children as $child )
    $excludes[] = $child->ID;

  if ( ! is_page() )
    return $excludes;

  global $post;

  $this_heirarchy = (array) $post->ancestors;
  $this_children = (array) get_page_children($post->ID, $all_pages);
  foreach ( $this_heirarchy as $ancestor )
    $this_children = array_merge($this_children, (array) get_page_children($ancestor, $all_pages));

  foreach ($this_children as $child)
    $this_heirarchy[] = $child->ID;

  return array_diff($excludes, $this_heirarchy);
}

Here are some examples of what it would like without the code, then with the code.

WordPress:  Remove Children Pages from Parent Pages

A huge thanks goes out to Matt Martz for working with us on helping get this code ready.

WordPress Tutorial: Using SSH to Install/Upgrade

February 9th, 2009

This tutorial will guide you step by step on how to setup your server so you can install new plugins and upgrade existing plugins using an SSH2 layer in PHP and WordPress.

What is WordPress?
WordPress started in 2003 with a single bit of code to enhance the typography of everyday writing and with fewer users than you can count on your fingers and toes. Since then it has grown to be the largest self-hosted blogging tool in the world, used on hundreds of thousands of sites and seen by tens of millions of people every day.

What is SSH[2]?
SSH (Secure Shell) is a protocol allowing a secure channel to be established between a web server and a client’s local machine. Many web hosting companies now offer SSH for greater security.
Read more »

OpenX Advanced Targeting Using WordPress

October 20th, 2008

What is Openx

OpenX is, in my opinion, the most efficient and hands-free open source ad server on the web today. It’s flexible, easy to use, and best of all, free.

What is WordPress

WordPress is one of the leading platforms in blogging on the web today. Whether you are self-hosted (using wordpress.org) or being hosted on Automattic servers (using wordpress.com), WordPress is an amazing blogging platform which makes blogging easy and fun.

This OpenX and WordPress tutorial will outline how to more effectively use the targeting features of OpenX utilizing the built-in features of WordPress. It will explain how to do this by using WordPress tags and OpenX source parameters, both built-in features to WordPress and OpenX, respectively.

OpenX Solution Used: Hosted OpenX (http://hosted.openx.org/)
WordPress Version: 2.6.2

For this tutorial, I will be using tags are the “source” for OpenX.


Step 1: Setup tags so OpenX can view them as a “source.”

<?php
        while ( have_posts() ) : the_post();
                $fsm_oxtags = get_the_tags();
                if ($fsm_oxtags) { foreach ($fsm_oxtags as $tag) {
                        $taglist .= $tag->name . '|';
                }
                $taglist = rtrim($taglist, '|');
                $oxtags = rawurlencode($taglist);
                }
        endwhile;
?>

I have these in the top of my single.php file within WordPress. This only creates the variable of $oxtags so it can be echo’d elsewhere.

Details of Step 1: The first bit of code will create the loop. then it will go through each tag and set it as “tag |” because I am using pipes to separate each tag for OpenX. Next, it will trim off the last pipe because it’s not needed, creating something like… “tag 1|tag 2|tag 3|tag 4″ … and like I just mentioned, it will strip off the last pipe. Lastly, it will put that string, “tag 1|tag 2|tag 3|tag 4″ … into a raw encoded URL string which we will be able to echo later in the page. Note: this is only being set at $oxtags so it can be used elsewhere, nothing is echo’d in this part of the script.
Read more »

WordCamp NY 2008 Photos & Videos

October 13th, 2008

First of all, a huge, HUGE, thank you to all of our speakers and sponsors for making this event possible. It was a huge success and would not have been possible without everyone involved.

Photos

WordCampNY2008_091 WordCampNY2008_090 WordCampNY2008_089 WordCampNY2008_088 WordCampNY2008_087 WordCampNY2008_086 WordCampNY2008_085 WordCampNY2008_084 WordCampNY2008_083 WordCampNY2008_082 WordCampNY2008_081 WordCampNY2008_080

Read more »

WordCamp NY was a Success!

October 6th, 2008

Thank you to everyone involved with WordCamp NY! It was a great time and I feel it was very successful.

Here is a quick recap of the speakers.

  • Matt Mullenweg – The State of the Word
  • Aaron Brazell – Making it into the Big Leagues
  • Shay David – How to Use Kaltura
  • Jeremy Clarke – How to Run a Blog Network
  • Jen Simmons – Video on WordPress
  • Jeremy Zilar – How the New York Times uses WordPress

A huge thanks to our videographer, Valerie Gurka. She recorded each speaker and the videos will be ready in about a week.

Second, a huge thanks to Leora Israel for being the official photographer for the event. A ton of great photos that will already be ready soon. I’ll make another post when the photos are ready.

And of course, our sponsors. Thank you so much for making this event possible. Sun Microsystems, Atlantic Metro Communications, Margaret Roach, and Kaltura.

Flickr Details

WordCamp NY this Weekend

September 29th, 2008

This weekend is WordCamp NY 2008. I have been organizing this event for the past 3 or 4 months now and I’m really excited for it.

We have a great list of speakers lined up and it’s going to be an awesome event.

Matt Mullenweg will be keynoting the event. I have never met Matt, so it will be a first to meet him and hear him speak about The State of WordPress.

Thanks to everyone involved with the event!

The Power of XSL

February 22nd, 2008

When we did the last rewrite of Christian Lyrics I spent a good bit of time working on the template system. I loathe Smarty due to how bloated it is, but almost went with it because needed modular caching (guests all see the same static files, logged in users see their user info, etc…). We ended up using a Savant style system (no stupid custom tags, no parsing, just PHP) that works pretty well, but has some short comings still. After we finished the rewrite, I spent some time exploring other options. Only one caught my eye: XSL.

The eXtensible Stylesheet Language (XSL) is a family of transformation languages which allows one to describe how files encoded in the XML standard are to be formatted or transformed. XSL is designed to be data driven and strongly encourages the Inversion of control design pattern. There are three languages in the family:

  1. XSL Transformations (XSLT): an XML language for transforming XML documents
  2. XSL Formatting Objects (XSL-FO): an XML language for specifying the visual formatting of an XML document
  3. the XML Path Language (XPath): a non-XML language used by XSLT, and also available for use in non-XSLT contexts, for addressing the parts of an XML document.

Source: Wikipedia

In a nutshell, XSL can be used to transform a plain XML document into a full-fledged HTML document. One thing I really like about XSL is that the processing can be done either server-side or client-side. Most modern browsers understand XSL and do all the dirty work for you, leaving your server to do other, more important, things. Not only that, but if you send the XML to the client for processing, then you have the base of your API already done.

But the best part is how modular you can make the caching. Here’s how I do it:

  1. If the data is cacheable it gets saved to disk in an XML file. Queries are only done to the SQL server for this data if the cache file doesn’t exist or has expired.
  2. If it’s not cacheable, insert it into the cached XML document on the fly.

Then the XSL document handles the rest. I can’t think of any simpler way to do it.

However, there are downsides (when aren’t there?):

  • IE has notoriously bad support for XSL (of course).
  • PHP has XSL support natively in PHP5, but PHP4 requires a PECL library (I can’t find the extension on PECL for some reason).
  • More syntax to remember
  • The only good documentation I’ve come across is the specification itself. W3Schools, which usually has a pretty decent overview, I found lacking.
  • Most variable processing has to be done before you transform the XML. It is possible to use variables in the XSL itself, but it is very limited.
  • Javascript does not work on the XML document itself, just the generated source. This means if you use AJAX to grab eg. a list of languages, you have to either do the transformation server-side or in the Javascript itself. Thankfully, Google has an excellent Javascript library to do XSL transformations! Some browsers (Mozilla is one I believe) also have built-in XSLT support in Javascript.
  • Unless you do the transformation on the server-side search engine crawlers will not be able to index your site. Of course you could set it up to only transform server-side if a crawler comes.

Now I ask: why don’t more sites use XSL? I know I’ll be building most of my sites in the future with XSL, the benefits far outweigh the downsides in my opinion.

Update: I completely forgot to mention a very important downside. I bolded it in the list.

Fireside Media LLC Software Development

February 20th, 2008

We have the start of what will be a long line of open source products by Fireside Media, LLC. To start it, we are releasing an updated version of the Twitter Updater plugin.

The plugin was originally written by Victoria, but she gave us permission to release the updated version here. The plugin was modified by Jonathan to include tinyurl.com’s API as part of the Twitter updating.

We have some other great ideas for Wordpress plugins already coming along and will be releasing them in stages. Expect some new plugins to come out within the next few weeks.