Categories
Apple Hardware

New Home Server

Over the past few weeks, I’ve been in the process of setting up a new home server. The previous one was an old Beige G3 (266MHz) running Mac OS X 10.2 that was starting to show it’s age. The new system is a much more capable B&W G3 (400MHz) running Mac OS X 10.4. Despite only a slight increase in clock speed, the B&W G3 has much more modern hardware (USB, Firewire) not to mention more room for more storage. The opportunities are endless.

Decided to go with a multi-drive setup considering the extra bays. The system had a still usable 40GB Seagate Barracuda IV drive which would make a perfect system disk for OS/Software. Installed via a ACard ATA/66 controller it’s no speed daemon, but for the purpose it’s fine. For the data drive I decided to get a SIIG SATA card and a pair of Seagate SATA drives I found a good deal on at BestBuy. The drives were Seagate ST303204N1A1AS, which corresponds to 320GB. Inside the boxes as expected were (the newer and better) ST3320620AS, which is a Seagate Barracuda 7200.10 with firmware 3.AAE (not the AAK people have had in the past). Perfect.

Next I wanted to replicate data across the drives on a cron. Initially I was thinking rsync, since as of 10.4, it’s resource-fork aware. It turns out that’s not really true. I ended up going back to SuperDuper to copy between the drives. It only copies changed files, and once a week will delete removed files (so if you accidentally delete something, there’s still a chance to recover, unless you do it at the wrong time). Not a bad solution IMHO. Still would prefer rsync more. Initial backup took less than 1/2 hour. Just a few minutes should be enough to keep the disks in sync. I briefly considered setting up RAID, but decided against it since RAID is not backup. It doesn’t protect against things like corruption.

Apple needs to kill off resource forks ASAP. They should have done so when moving to Mac OS X several years ago.

Next up, I tried putting a copy of TechTools Pro I no longer use on my Mac Mini since upgrading to Leopard on the system, but that resulted in some drive problems that I couldn’t resolve without uninstalling. They seem to know about the problem, but haven’t fixed it. You see the following error repeatedly in the system.log file until you reboot:

kernel[0]: IOATAController device blocking bus.

Drag.

Also updated mrtg, and this time compiled GD, libpng, libjpeg, etc. all by hand, rather than use fink. Last time I went with fink, which saved me a few keystrokes, but when fink no longer updated packages for 10.2, left me high and dry. This time I think I’ll avoid it when possible. I need to try getting RRDtool setup at some point, since it’s so much better.

I use a few PHP scripts for easy admin of the box, and decided PHP 4 wasn’t adequate since it’s pretty much discontinued. So I upgraded to PHP 5.2, and all seems good so far. I think Apache 1.3.33 will serve me just fine for the moment, so not upgrading that.

I might give setting up BIND a try, since local DNS would be pretty handy for easily accessing the server without modifying the host file on computers.

I also disabled things like spotlight, which have absolutely no purpose on this box.

On another note, glib for some reason won’t compile for me. No clue what’s going on. Overall it’s looking pretty good. Should be about ready for real use. Just want to make sure the backups work as expected.

Categories
Open Source Web Development

Snoopy’s Relative Redirect Bug

Snoopy is a PHP class that automates many common web browsing functions making it easier to fetch and navigate the web using PHP. It’s pretty handy. I found an interesting bug recently and diagnosed it this afternoon.

If you navigate to a 301 or 302 redirect in a subdirectory you can get something like this:

HTTP/1.1 302
Date: Sat, 13 Oct 2007 20:26:46 GMT
Server: Apache/1.3.33 (Unix)
Location: destination.xml
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8

The key thing to pay attention to here is Location: destination.xml. Say your initial request was to:

http://somesite.tld/directory/request.xml

Our next request based on the redirect should be to:

http://somesite.tld/directory/desination.xml

Instead what Snoopy is doing is appending to the hostname, resulting in an incorrect request:

http://somesite.tld/request.xml

This is correct in cases where the first character of a redirect location contains a “/”. In this case it does not, which makes it incorrect. The following patch I wrote corrects this behavior. As far as I can tell (I haven’t read every word of the spec, but many chunks over the years) the HTTP 1.1 specs RFC 2616 only dictate that URI be provided, it doesn’t seem to require full URL’s. See comments for follow up discussion on the specs. My conclusion is that it’s best practice but not required to use absolute URI’s). I wouldn’t call this a very common practice, but it does exist in the wild.

— Snoopy.class.php    200511-08 01:55:33.000000000 -0500
+++ Snoopy-patched.class.php    2007-10-13 16:10:38.000000000 -0400
@@ -871,8 +871,18 @@
                                // look for :// in the Location header to see if hostname is included
                                if(!preg_match("|\:\/\/|",$matches[2]))
                                {
                                        // no host in the path, so prepend
                                        $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
+                                       // START patch by Robert Accettura
+                                       // Make sure to keep the directory if it doesn’t start with a ‘/’
+                                       if($matches[2]{0} != ‘/’)
+                                       {
+                                               list($urlPath, $urlParams) = explode(‘?’, $URL);
+                                               $urlDirPath = substr($urlPath, 0, strrpos($urlPath, ‘/’)+1);
+                                               $this->_redirectaddr .= $urlDirPath;
+                                       }
+                                       // END patch by Robert Accettura
+
                                        // eliminate double slash
                                        if(!preg_match("|^/|",$matches[2]))
                                                        $this->_redirectaddr .= "/".$matches[2];

Code provided in this post is released under the same license as Snoopy itself (GNU Lesser General Public License).

Hopefully that solves this problem for anyone else who runs across it. It also teaches a good lesson about redirects. I bet this isn’t the only code out there that incorrectly handles this. Most redirects don’t do this, but there are a few out there that will.

Categories
Internet Open Source Programming Web Development

Wikipedia Infrastructure

Here’s a great read on Wikipedia’s Infrastructure. Two excellent sets of slides. A lot can be done with a LAMP stack. The common theme: caching and careful optimization. There are some really impressive stats in there.

Categories
Programming Software Web Development

Coda Coolness

So I downloaded and tested out Coda a little bit today. My initial impression is that I’m very impressed. It could be the new standard. A few like Alex King point out that it uses Safari as the default engine. I don’t think that’s so bad. Nothing stops you from using 2 windows one being Firefox (obviously running Firebug). I think the editor itself is rather well polished and very refined. The use of Bonjour to allow for collaboration makes it perfect for multi-developer environments. And yes, you can have more than two developers collaborating in 1 document.

My typical workflow is very abrupt. I tend to have Firefox, IE, and an IDE open at all times when coding pages. Not to mention a KVM switch to go between platforms. This still consolidates several things, and with a much nicer UI.

I’ll need to try it (for actual development purposes) for a few days before I could tell if it really works as well I hope. Panic is one of my favorite Mac developers. Really well polished products are their specialty.

Categories
Programming Web Development

Asynchronous Processing With PHP

Several weeks ago I was looking on line for a way to have PHP execute a background process, so that the page didn’t hang while some functionality happened. One way to do that is to use fsockopen() to open a URL to exec what you want. But I wanted to see if there was another way. This is what I came up with.

I should note that this isn’t that well tested. I ran it on a Windows and Linux system without incident to test it, but I haven’t given it a very thorough exam. Also note $call is completely unsanitized. If you’re using this and accepting anything from the web, you need to make really sure that $call is completely sane and free of evil.

Categories
Internet Programming Web Development

Yahoo hosting PHP

Found this rather interesting:

Yahoo's PHP Mirror

It’s been known for a while Yahoo is a PHP user, but it’s interesting to see them giving back. Very cool.

Categories
Personal Programming

Really Busy

I’ve been really busy lately, hence posting is a bit light. I plan to pickup soon. I’ve been working on many things.

On a side note, switching programming languages (Visual Basic .NET, JavaScript, HTML, CSS, PHP, Perl) all in one day can be very confusing at times. I’ve been finding myself mixing up syntax quite a bit in the past few days. Yuck. For those wondering, Visual Basic is by far my least favorite.

Categories
Open Source Web Development

WYSIWYG

After seeing Matt’s post that TinyMCE has been integrated into WordPress, I think I’m doing the same to a few things I’m currently developing. I was considering a WYSIWYG tool previously for these projects, but decided against it mainly because of the poor code they often produce. TinyMCE is rather good, but didn’t support Safari. Now that appears to be changing (they are testing and working with Apple). So I really have no reason not to use it right?

It’s a great thing for those who don’t know much (or good) HTML. Keeps the crud out. Now I need to either find, or write a really good HTML sanitizing function for PHP so I can make sure it’s pure safe HTML. Right now I just delete any tags.

Categories
Blog

Fun With Wordage 3.0 {Beta}

Last night I shut down this blog for almost 24hrs. It’s now open, but not fully restored. It will take me a while to put everything back, finish cleaning up, and debugging. There are known issues (I’ll talk about those and how you can help in a moment).

I’m no longer using MovableType. Instead I choose to go with WordPress. I choose it for several reasons (in no particular order):

  • Licensing (GPL) – Is very friendly and open source. I’m an open source kind of guy. So that makes me feel good.
  • Good HTML validation – Unlike MovableType, it doesn’t seem to want to put tags everywhere mangling the HTML. It’s very smart. I don’t need to do stuff like make posts all 1 line to get it to stop messing up my code.
  • Compatible – I’m was able to import everything with no real trouble.
  • Feature Packed – look at the comparison
  • Spam Prevention – I find it easier to hack with WordPress than MovableType. So I can put some good anti-spam solutions in place. Rather than wait for plugins to evolve. This isn’t an insult towards Jay Allen. I’ve said more than once his mt-blacklist saved this blog. I just don’t think it’s the best solution. Nor do I like being so reliant on others. His list goes down for a day and the spammers get the upper hand. I don’t like moderating all comments either.
  • Speed – fast UI. Database driven, no rebuilds. Very nice.
  • Learning – I plan to use WordPress a bit professionally, so getting acquainted with a blog is a perfect first step.

MovableType is good, and still is by far the most popular. It’s also the best choice for someone running a large install. If you have an organization for example, MovableType is bar far the best solution (as of this posting date). But for a geeky individual like me who likes to tinker, and likes features and open source, WordPress is better. I found WordPress to be more innovative and open. It’s administrative features are better. Though MovableType has a slightly nicer skin. The PHP based templates are far superior to those proprietary tags.

Overall, I’m pretty happy so far. Some new features already are in place, and more will be coming.

New Features

  • Smilies for your comments. As well as select HTML tags.
  • You should be able to view this site fairly well on a PDA or cell phone now.
  • RSS feeds galore. Including for comments on a specific post.
  • Lower Page Size. Should be much faster for my 56k friends.
  • Highlighting text on search.
  • Much more!

And more is on the way.

Known Issues

  • Images in some posts overextend the div (anyone know why?)
  • Some feeds still broke
  • Some toys on the left hand column are missing
  • Spam Prevention stuff is considered ‘beta’. Checking out how well it works.
  • Contact form hasn’t been brought into new system.
Categories
Web Development

PHP 5.0 is Released!

The PHP development team is proud to announce the official release of PHP 5.

Some of the key features of PHP 5 include:

  • The Zend Engine II with a new object model and dozens of new features.
  • XML support has been completely redone in PHP 5, all extensions are now focused around the excellent libxml2 library (http://www.xmlsoft.org/).
  • A new SimpleXML extension for easily accessing and manipulating XML as PHP objects. It can also interface with the DOM extension and vice-versa.
  • A brand new built-in SOAP extension for interoperability with Web Services.
  • A new MySQL extension named MySQLi for developers using MySQL 4.1 and later. This new extension includes an object-oriented interface in addition to a traditional interface; as well as support for many of MySQL’s new features, such as prepared statements.
  • SQLite has been bundled with PHP. For more information on SQLite, please visit their website (http://www.sqlite.org/).
  • Streams have been greatly improved, including the ability to access low-level socket operations on streams.
  • And lots more…

Enjoy!
PHP Development Team

Sweet, I’ll have to update Bender this weekend so I can toy around with it.