faq
marketing

Archive

Archive for June, 2009

PHP - Redirect and continue (without abort)

June 28th, 2009
support
2 comments

The Problem

Sometimes, in PHP, we have to do things that take a long time (like converting user-submitted videos, say), but there's a problem with that: the user has to wait until we're done with whatever we're doing.  The worst part is, it looks like their request was dropped because the browser just sits there "loading" forever and shows no sign of progress until the page is finally done loading or - *shudder* - times out.

Solutions

There are a few strategies to solve this problem:

  1. You could have your PHP script create a cron job on the server.  This approach is overly complex in my opinion and has some problems: You have to be running your PHP code on a Linux server, and you have to have access to cron - not really an option for most people who don't host their own server.
  2. You could write a special PHP script that gets called via AJAX after the page is loaded and returns the results from the operation.  That works just fine and is a great option for someone comfortable with AJAX.  I've actually used this strategy myself, but it's still too complicated for my taste.
  3. My weapon of choice: The PHP redirect and continue.

Read more...

blog
notice

C# Detect Windows OS Version - Part 1

June 22nd, 2009 26 comments

After reading this, check out Part 2: Using WMI for even more info


Introduction

I recently needed to programmatically determine the Operating System my software is running on.  I was amazed at how difficult it was to find reliable, useful information on this subject.  There were bits and pieces here and there, but almost everyone assumed I had some pre-existing knowledge of the process in one manner or another.  Hopefully, this little series will save somebody some time in the future.

The thing that makes this so difficult is that there are almost as many different ways to detect the operating system as there are operating systems!  It's an unbelievably frustrating experience trying to reinvent this wheel, so I'll try to walk through it here.

Strategies

There are 4 basic strategies:

  1. Read and parse information from files in the Windows directory.  This is probably the most difficult and least rewarding method.  The files are different for each generation of OS and the format is not guaranteed in almost any case.
  2. Read information from the registry.  This method works a little better, but you still have varying locations for the information based on which OS you're dealing with.
  3. Use Environment variables.  Nothing is more reliable.  However, it doesn't give you the nitty-gritty detail you might want.  For example: There's no way to detect XP Home vs. XP Professional.
  4. Use WMI to query for information about the OS.  This gives you everything you could possibly want all in one shot.  Unfortunately, it's not supported in pre-NT versions of Windows (of course, this is becoming less and less of a problem).

I started with number 1.  After pulling most of my hair out and wanting to punch my keyboard, I moved on to number 2.  That was a dead end too.  I could have made it work, but I didn't have the patience.  I gave number 3 a try and was very happy...  ...until I decided that the specific version of 2000, XP, Vista, and 7 mattered to me.  So I finally ended up with a combination of 3 and 4.

For part 1 of this series, I'm going to focus on number 3, a.k.a. The Easy Waytm

Read more...

forum

E-mail subscriptions are live

June 15th, 2009 No comments

That's right.  This little blog is finally showing some initiative moving up in the world.

You can now subscribe to notifications of new posts via e-mail.

Enjoy.


 

contact
Categories: Website Tags: , about
research
copyright