|
|
A problem with the file system on one of the web server’s hard drives caused RocketReviews.com to be down for about 12 hours recently. The operating system detected an error writing to one of the hard drives so it marked the drive as “read-only” to avoid more errors. Ironically, this occurred over night as I was running a full backup of the server – the first full backup that I had attempted since moving RocketReviews.com and the other sites to the new server.
I rebooted the server so that it would run a file system check and repair any problems with the drive. Because the web server is located in a data center in another state, I wasn’t able to monitor it directly. Instead I used an application which allows me to remotely monitor it through the Internet. What I did not realize is that the boot process had stopped and was waiting for
Continue reading Misbehaving Hard Drives and Backups …
Images are important to RocketReviews.com. The site permits users to upload images which means that it has to deal with multiple sizes and types of image files. Users can also upload non-image files such as PDF files and Rocksim data files. The RocketReviews.com Image Manager is used to handle images as well as the other types of uploaded files.
Uploaded images are stored in a directory on the server. When a file is uploaded, a unique new filename is assigned to it since user’s might upload a file with the same name as one that already exists. The unique filename is stored with the user’s ID and the original name of the file in a record in the database. If the file is an image file, the dimensions (height and width) of the image are also stored in the database record. A unique ID is returned for the image.
To allow the image to be
Continue reading Under the Hood – Image Management …
RocketReviews.com uses the Smarty template system to define the layout of the web pages displayed by the web site. Smarty one of the ways the “Application Layer” and “Presentation Layer” of the web site are kept seperate. This allows the functionality of the web site to be changed or expanded without affecting the overall “look and feel” of the site. It also allows the overall appearance of the site to be changed without having to change the software that generates the content of the site.
Originally, I had planned to use Smarty to define both the general layout of each page (the header, sidebars, content area, and footer) as well as to define the layout of the content of each page. But, I found it easier to use Smarty just for the site’s overall theme. For the content of each page, I use HTML produced by the PHP scripts and CSS defined in a text
Continue reading Under the Hood – Templates …
RocketReviews.com uses GIFEncoder by Laszlo Zsidi to dynamically create animated GIF images for widgets and other purposes. When I ported the site to a new server running PHP 5, the code failed with the following error:
Catchable fatal error: Object of class GIFEncoder could not be converted to string in …
The fix turned out to be simple. Change all occurrences of $$this->OFS to $this->OFS in the source code. The mistake needs to be fixed in two places.
To determine which Action to execute, the CMS looks at the action parameter passed in the URL. If you’ve used RocketReviews.com, however, you may have never seen “?action=xxxxx” in a URL for the site. This is because RocketReviews.com uses “friendly” URLs. A friendly URL looks more like a title than a function call. For example, the actual URL for displaying a dynamically-generated web page might look like:
http://www.rocketreviews.com/index.php?action=reviews
Instead of the above, RocketReviews.com will display the more friendly-looking URL:
http://www.rocketreviews.com/rocket-kit-reviews.html
</pre> function getFriendly($title, $url) { $xurl = addslashes($url); $result = mysql_query("SELECT Friendly_ID, FriendlyName FROM view_friendly WHERE URL = ‘$xurl’"); if (list($id, $friendlyname) = mysql_fetch_row($result)) { return $friendlyname . ".html"; } $extra = rand(1000, 9999); $title = strip_tags($title); $FriendlyName = preg_replace(‘/[^a-z0-9\-]+/i’, ”, strtolower(str_replace(" ", "-", trim($title)))); $FriendlyName2 = $FriendlyName; $result = mysql_query("SELECT FriendlyName FROM view_friendly WHERE FriendlyName = ‘$FriendlyName’"); while (list($x) = mysql_fetch_row($result)) { $FriendlyName = $FriendlyName2 . "-" . $extra; $result
Continue reading Under the Hood – Friendly URLs …
Menus – the main menus displayed by RocketReviews.com are also defined by classes. When the CMS displays an Action, it loops though the Menu Blocks defined by the Action. Each Menu Block is defined by a class in a source file in a specific menu block directly. Each Menu Block class returns a list of Menu Items which are represented by classes in sources files in a menu items directory.
The Menu Block and Menu Item Classes include functions which are called by the CMS to determine if the Block or Item should be displayed. If the function returns false, the Block or Item is not displayed. This is how, for example, RocketReviews.com displays different menu options when you are logged into the site than when you are not logged into the site.
The Menu Item class returns the URL of the web page to display when the item is clicked. Generally, the URL is
Continue reading Under the Hood – Menus …
The CMS for RocketReviews.com is built around the concept of “Actions.” An Action represents a web page displayed to the user or a group of related web pages. For example, RocketReviews.com has a “Reviews” action for displaying pages related to rocketry reviews.
Internally, an Action is represented by a class. A new Action can be easily added to the site. To add a new Action, I ceate a source file containing the new Action class and save it in a specific directory. The CMS recognizes any class files added to the directory as new Actions.
An Action class must implement a few functions that are used to do common things such as returning the content for the body of the page, setting the metadata attributes for the web page (such as the page Title), and defining which menu blocks to display on the page.
The class may contain optional functions which do things such as
Continue reading Under the Hood – Action Classes …
Most web sites like RocketReviews.com are built on top of a Content Management System (CMS). There are a number of popular CMSs such as Drupal and WordPress. But, instead of starting with an existing CMS, I decided to develop my own for RocketReviews.com. Of course, I didn’t start completely from scratch. I re-used code I had written for other web sites such as PayloadBay.com and R-O-C-K.org.
Traditionally, web sites were developed “off-line” then uploaded to the server. Any changes to the web site or its content required making edits to the original files and uploading any changes to the server.
A CMS is a software program which creates a web site that easy to manage online through the web site itself. Instead of developing and maintaining the web site on a separate computer using special software, the CMS is managed through interfaces it provides. The web site may be updated and new content added by
Continue reading Under the Hood – Content Management System …
I’ve benefited greatly from the availability of open source software while building the RocketReviews.com web site. The site runs on a server using Linux as the operating system and Apache as the web server. The database server is MySQL and PHP is used to interpret most of the scripts that make up RocketReviews.com.
I also relied on a number of open source packages to create the custom software for the site. To help pay back to the software development community, I’m posting this series of “behind the scenes” articles about RocketReviews.com. This series will give credit to the open source software used by RocketReviews.com as well as to the number of web sites providing information which I found helpful as I developed the site.
For most visitors to RocketReviews.com, the posts in this series will not be of interest. But, I hope they will be of help to other software developers working on web sites.
|