Archive for May, 2007

More black & white from Zilker Gardens

Posted in Photography  

These are from the same set as the previous thread on Black & White @ Zilker.  While I like the shot from the previous posting, and I’ve printed it at 11×14 and it looks great, these close ups seem to fit more with the subject.
20070314-0137.jpg

20070314-0138.jpg

ForumsBlogsWikis.com

Posted in Blogging, Internet, Programming  

Yup, another blog.

If you read back through the archives here you’ll see that I have a real problem with starting new projects. Not that I have a problem starting one. I have a problem starting too many. Right now I’ve got 2 forums, 1 eCommerce site, and 6 blogs (only 3 of which are regularly updated).

But, I had an idea for a new blog so about 2 hours after I registered the domain name ForumsBlogsWikis.com is live. The idea is to keep up with news on any web programs that allow interaction with your visitors.

Download script using PHP

Posted in Programming  

This is a short PHP script that I use on my DailyFont.com site to handle downloads. Sure it's easy to just link to the zip, but this allows me to keep track of how many times each file has been downloaded which I then use to rank the fonts on popularity.

PHP:
  1. <?php
  2. include('shared.inc.php');
  3.  
  4. if (!is_numeric($_GET['id']))
  5. {
  6. die();
  7. }
  8.  
  9. $rs = mysql_query("SELECT file_name FROM table WHERE id='".$_GET['id']."' LIMIT 1");
  10. if (mysql_num_rows($rs)==0)
  11. {
  12. header("HTTP/1.0 404 Not Found");
  13. die();
  14. }
  15. $row = mysql_fetch_row($rs);
  16. $fhandle = fopen('files/'.$row[0], 'rb');
  17.  
  18. $zip_data = fread($fhandle, filesize('files/'.$row[0]));
  19.  
  20. header("Content-type: application/zip");
  21. header('Content-Disposition: attachment; filename="'.$row[0].'"');
  22. echo $zip_data;
  23.  
  24. //    Update download counter
  25. mysql_query("UPDATE table SET download_counter=download_counter+1 WHERE id='".$_GET['id']."' LIMIT 1");
  26. die();
  27.  
  28. ?>

The actual script uses a slug for each font similar to how WordPress uses the permalink structure. I decided to go this way rather than an id number because it would be neater. Plus the download link is /font_slug/download/ rewritten with a mod_rewrite call to this script.

I've seen lots of download management scripts that are called using something similar to download.php?filename=myfile.zip. This is potentially a really big security risk. If somebody typed in download.php?filename=/home/yourusername/.htpasswd they might be able to get your username and password. For that matter download.php?filename=/etc/httpd/conf/httpd.conf would pull up your Apache config file if your server isn't configured tightly enough.

Along the same security lines, lines 4-7 of the code above make sure that the id number passed is numeric to keep people from trying to send random commands to your database server.

White Sands, New Mexico and a new scanner

Posted in Photography  

I finally got around to getting a flatbed scanner this afternoon. The Epson 4490 had been calling to me, but I wound up bringing a Canonscan 8600f home because it seemed to be a better deal. What I learned is that a 4800dpi scan of 645 film works out to a huge file. The image below is a reduced version of a 234meg file that took 10 minutes to scan.

White Sands, New Mexico