PHP vs. ASP.NET

We have a new web-based client portal application we are going to use for my company extranet. However, because it was originally designed to be a hosted application, there are several variables involved in all areas that don’t apply to us, since we host it ourselves.

When using said portal, every URL looks something like:

domain.com/login.aspx?QS=jasbndfiaubnfoaeuifwoeifbwfe

The only difference is that the “QS” GET variable is even longer. I made the request of our developers to get rid of this query string for the login page, and the login page only. This is what that code looks like in PHP, inserted at line 1.

if(!$_GET['QS']) { 
     $_GET['QS'] = 'jasbndfiaubnfoaeuifwoeifbwfe'; 
}

That’s it. One line of code. In ASP.net, this cost me 3 hours of developer time. THREE hours.

Then I asked our old developers to make a change to their code. It was doing a check in login if they are customers from the new app or the old one. If they are old, it processes the login. If it’they are new, it gives them an error message. So I said, instead of giving them the error, let’s redirect them to /new-directory/login.aspx?email=[base64_encoded email]&password=[base64_encoded password].

This is that code in PHP:

if($is_new) { 
     header("Location: /newdirectory/login.aspx?email="
.base64_encode(stripslashes($_POST['email'])) . "&password="
.base64_encode(stripslashes($_POST['password'])));
} else {
     //process login
}

This cost me 2 hours at $165. Am I getting taken for a ride? I keep telling them – this would take 30 seconds in PHP. And they tell me, yes but ASP.net doesn’t work that way, and we need to change the web.config, and we need to recompile the entire site, etc, etc. If it were just one vendor, I’d be more suspicious, but two separate, unrelated developers are giving me crazy quotes like this.

I hear people bitch about PHP online ad nauseum. Every time I see real code, it appears PHP is FAR faster and far more friendly when it comes to customization.

PHP Lesson 1: Pretty URLs!

I am going to start a new practice here. Every now and again I’m going to post some PHP code with some explanation. Today, I’m going to write about what I’ve been calling “pretty URLs” and how to create and manage them in PHP.

PHP includes a variable in the superglobal scope $_SERVER called “PATH_INFO.” PATH_INFO includes information entered after the name of the requested script.

Let’s use firsttube.com as an example. The URL of a story is constructed as such:

http://firsttube.com/read.php/[id]/[url_friendly_title].html

The story is also accessible as /read.php?id=[id]

So how do we construct this so-called “pretty URL?” Using PATH_INFO. Read on for details.
Continue reading

MobileQuo

Eugenia released a little web-let called “MobileQuo” the other day, and it caught my eye. I downloaded it and hacked it up and made some changes.

1. This version is more secure – it won’t let the content of the feed break your HTML. Update: Apparently, the desired behavior is to render the HTML, not to preserve the markup as markup, so the new version Eugenia has released reflects that change. So code will be rendered, including javascript, so beware!!
2. This version outputs friendly errors. The 1.0 version can fail if your php.ini isn’t set up right, or output a blank page if there are certain errors.
3. This version is more portable and doesn’t rely on a particular PHP configuration.
4. Most differently, this version can cache the results. This way, each reload won’t hammer an RSS feed. Rather, the results can be cached for a perdiod and fed from cache, and then when the cache expires, it reloads the cache.

The source code is here: MobileQuo. Note that you will need to upload a blank WRITABLE file in your MobileQuo directory. Then just use the rest of the code from Eugenia here.