That page will most likely be gone by tomorrow. There’s a discussion about this on MetaFilter with some interesting comments about the cost differences between US (Region 1) DVDs and those provided to other markets. Yet another bad idea from the MPAA.
Joe Maller.com
I yanked the PayPal and Amazon donation links from the navigation sidebar. It’s been six months and no one has ever clicked them. Experiment over.
Until a few minutes ago, a new month meant broken permalinks, at least until I remembered to redo the Blogger template and make sure a template page was saved with the correct name.
Not any more. Using PHP, I now have a single, multi-use archive template page, which should work to display my archives for as long as I use Blogger for updates.
Here’s a brief explanation of how I did it:
Blogger Archives with PHP
Blogger’s archive file names look like this: 2002_07_01_blog_archive.html where “blog_archive” is the file name specified in each user’s Blogger settings. The rest date is simply glommed onto the front and uploaded.
For my solution, I decided that I would send the archive file name in the URL query string, an example URL would be:
notes_archive.php?a=2002_07_01_blog_archive.shtml#12345678
August 2nd update: I noticed that Google wasn’t indexing those URLs so I decided to use Apache’s mod_rewrite tool to mask the query. Here’s how I did it.
PHP makes processing query strings a breeze, automatically stripping out unneeded data and placing the relevant information into the variable $a.
The simplest thing to do then is to pass the filename to a PHP include command which will embed the file:
if ($a) include "$a";
Using an if statement to check for the existence of $a prevents PHP from trying to embed an empty filename, which causes an error.
July 11th Update: The above code turned out to be a potential security hole. Never include a file in a PHP file without checking the filename first. Instead of checking for and including $a, I modified the code to first make sure the value of $a was a valid file, without any directory information or links to other sites:
if (ereg('^2[^/]+l$', $a)){
The if statement checks the value of $a against a simple regular expression. The pattern simply checks that $a starts with a “2” (^2, not y3k compliant), ends with an “l” (l$) and has a bunch of characters inbetween which are not “/” ([^/]+l). If the value matches the pattern, the filename can be included, otherwise a new value is generated for $a:
$date = strtotime("now");
$a = (date('Y_m', $date) . "_blog_archive.shtml");
Accessing date information
I also wanted to include date information in the body of the HTML page, so the title, meta tags and page information would show the month and year depending on the embedded archive. Since the filename already contains a date, a little bit of text munging did what I needed.
The first step is to generate a UNIX Timestamp based on the existing date information. Once the timestamp is stored, PHP can use it to generate just about any conceivable combination of date and time elements for use anywhere on the page. PHP’s strtotime function takes most common date formats and outputs a UNIX Timestamp. I used a regular expression to extract the date from the filename and store it’s component pieces:
ereg('([^_]+)_([^_]+)_([^_]+)', $a, $dateParts);
([^_]+) is a pattern which matches more than one non-underscore characters in a row. Putting the pattern in parentheses tells the matching engine to store the match in a variable for later. In PHP, the match is stored in the array specified at the end of the function, in this case
Using the PHP function print_r shows the contents of $dateParts to be:
[0] => 2002_06_01
[1] => 2002
[2] => 06
[3] => 01
I rearranged those results and used strtotime, placing the resulting timestamp into variable $date:
$date = strtotime($dateParts[1]."-".$dateParts[2]."-".$dateParts[3]);
PHP’s date function can now be used to output the month and year anywhere in the script by inserting the following line of code:
<? echo date('F Y', $date) ?>
I’ve been actively fiddling around with PHP in my spare time for a little over a week, but I’m amazed at how much is possible in a few lines of code and how much I’ve already been able to build.
Hey wait, that’s not me! (but this is/was)
Install MySQL on Mac OS X. It’s not as scary as I expected.
update: I just spent way too long fighting with “Error 1045: Access for user … denied” messages. When assigning users to the MySQL database, use this page, Adding New Users to MySQL, as a guide, it worked on the first try.
another update:Using PHP to send HTTP headers which will post variables without using forms.
I finally posted a preliminary version of War Strolling & Cabbing.
Last week was a good week for aliens and a bad week for cows.
UFOs visited sacred sites and tourist attractions in Sri Lanka, Chile declared an official UFO tourism zone, and Scotland claims to have the most reported sightings each year.
Argentine cattle mutilations continued (in English, some background with graphic photos, ew.), Ranchers are freaking out and the Argentine government is sending a team of scientists to study the dead cattle.
Chinese scientists are also on their way to study a group of Chinese pyramids known as the “ET Relics“, said by locals to be a launch tower left by space aliens. Chinese pyramids? I had no idea there were pyramids in China!
Not to be left out, residents of South Carolina even got a (floating) piece of the action which is apparently unconnected to these strange round objects which washed ashore in New Hampshire.
Otherwise, the more conventional UFO sightings continue. These people have a lot of work to do.
Thanks to New World Disorder for getting this all started. And yes, I do find these reports amusing. A version of this posting is also on MetaFilter
« Previous Page — Next Page »
![I have no idea whatsoever what regional coding means. But it is essential that you buy a multi-regional [DVD] player.](/images/2002-07_simpsons_region-free-dvd.jpg)