UltraMega Blog
26Apr/090

TempServers Status Update

This is just a quick update on the status of our TempServers project. After the first public beta, we realized there was much room for improvement, so we went back to the drawing board. The original goal was to create a simple yet powerful user interface that took as few steps as possible to perform each task. With this goal in mind, several parts of the site are undergoing changes to improve the user experience. Here is a brief overview of these changes:

  • User Registration. During beta 1, there was no user registration required to use the service. Each server reservation was a sort of user account with its own unique name and password, but we decided this would get annoying, especially to repeat customers. So we decided it would be simpler in the long run to require a user account to reserve servers, with all servers accessible from the same account. This also allows us to save user preferences.
  • Time Zone Conversions. Another problem we had to solve was the lack of internal time zone handling. During beta 1, the user had to deal with converting their local time to our server's local time, which does not fit the original goal of user-friendliness. Now during user registration, we ask the user to provide their time zone (we decided it was easier for the users to figure out their own time zone than to think in our time zone). This info allows us to automatically convert times to the user's local time seamlessly. Read about the process here
  • Custom Configurations. We also improved the server control panel by allowing the user to add their own configuration options instead of the predefined options.

We are also working on more features such as email notifications, as well as adding more games to the lineup. Stay tuned for more updates!

 
21Apr/0917

Working With Time Zones in PHP

Let's say you are developing an online application that involves users selecting or viewing times. One problem that you'll need to address is time zones. If your application is going to be used by users all over the world, you'll want to adjust the times to be in their local time zone to prevent confusion. Fortunately, PHP 5.2.0+ greatly simplifies this process with the DateTime and DateTimeZone classes.

The DateTime class provides all the date and time handling functionality, while the DateTimeZone provides DateTime objects with all the time zone information. We just need to provide DateTimeZone with the time zone in the Area/Location format (for example, the time zone in which this server is located is America/Los_Angeles), and it will return an object representing that time zone. We can pass this to a DateTime object to convert any time into this time zone.

Here is an overview of the steps required to accomplish this:

  1. Collect the time zone from the user and store in Area/Location format
  2. Create a DateTimeZone object using the provided time zone
  3. Create a DateTime object, providing it the time in the local time zone
  4. Convert the DateTime object to the time zone created in step 1
  5. Output the time from the DateTime object
 
7Apr/095

Creating a BBCode Parser

Have you ever wanted to implement BBCode, the special formatting codes used by forums, into your own PHP scripts? Well, it's actually pretty easy to accomplish using some simple regular expressions and the preg_replace PHP function. This mini-tutorial will show you how to create a function that you can use on any string to convert BBCode into its XHTML equivalent.

The advantage to using BBCode instead of allowing XHTML in user input is that it allows users to safely format their content without the risk of invalid code breaking the page formatting. It also tends to be easier to understand BBCode over XHTML due to its simplified syntax.

 
3Apr/090

How To Center a Page With CSS

When designing the layout of a web page, it is common to want to center the entire page. Luckily, this is very easy to do without breaking standards. All you have to do is wrap the entire page with a div with the left and right margins set to auto (margin: 0px auto;).

Here is an example:

<html>
<body>
<div class="wrapper">Contents of page...</div>
</body>
</html>
.wrapper {
   margin: 0px auto;
   width: 600px;
}

Here, margin specifies the top/bottom and the left/right respectively.

That's all there is to it!

 
   

Page optimized by WP Minify WordPress Plugin