Archive for the 'Programming' Category

ProofBuddy 1.0 released

One of my web projects met a milestone a few days ago with the 1.0 release. It took me over 2 years working part time, but 1.0 finally contains the full feature set that I wanted when I started writing ProofBuddy in the fall of 2005.

ProofBuddy Logo

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.

osCommerce and duplicate content

Posted in Programming  

If you've got an osCommerce store set up you are probably fighting a duplicate content problem with the search engines. The problem is that OSC has an almost limitless number of ways to view any one particular product page - 1 for each category that the product is in plus one without any category information. The cPath variable in the query string is the culprint.

Here's how I got around it and my search engine traffic, as small as it is, has been growing. Read the rest of this entry »

List functions disabled in PHP

Posted in Programming  

I've got a web client having some really odd problems with a program of mine logging him out randomly. Normally I upload a phpinfo file and use that to see if I could find out anything but when I did that I got an error that phpinfo had been disabled for "security purposes". Read the rest of this entry »

Google Webmaster Tools now show links

Posted in Programming  

The Google Webmaster Tools dashboard has been expanded to show internal and external links to each page on your site and it seems to do a better job than the link: command.

Google Links Screenshot

When you log in to the webmaster tools you'll see a new tab called "Links". Click it and you'll see a list of your pages that are linked from the outside world. Further clicking will allow you to drill down and see what pages on the internet are linking to each of your pages.

Refresh the Firefox view-source window

Posted in Programming  

I spend a lot of time looking at HTML source while developing sites. It's pretty much refresh the browser, right click, view source, find my mistake, close the view-source window, fix the mistake, rinse, repeat.

It's amazing I haven't stumbled upon this before. I accidentally hit F5 in the view-source window and it refreshed the source code.  That takes out about half of the steps of my usual process.

Keeping yourself out of Google Analytics stats

Posted in Programming  

A few months ago I wrote about a technique I use so that Adsense ads aren't shown to me when I'm viewing my sites. Recently I started doing the same with Google Analytics code so that I don't show up in my stats.

Read the rest of this entry »

5 things you may not know about PHP

Posted in Internet, Programming  

PHP is one of the dominant web languages in use today. If you do any web design work you probably have at least a passing knowledge of PHP. Heck, even if you don't do any web design you've probably noticed web pages ending in .php.

But here are 5 things you may not have known about PHP. If you've been working in PHP for a while you probably already know all these, but they're still there to look at.
Read the rest of this entry »

Building BobSmithPhotography.net

Posted in Photography, Programming  

I spend a lot of time of several photography forums, but I tend to hang out in the web design parts. What can I say, I'm a web nerd. What I realized after helping several people set up sites is that often it's just getting started with a new website that a lot of people have trouble with. Acronyms like DNS, IP, HTML, ASP, JS, CSS, and PHP are enough to make a budding web designer's head spin.

Enter BobSmithPhotography.net. Originally the site started as a single posting on Pro Photo Forum on the first steps to take, but it expanded to around 20 posts each going over a step needed for a photographer to get their site up and running. As I wrote it I had more ideas that fit with the tutorial, but not in a thread. So I started Building BobSmithPhotography.net as a place where new web designers can come to find basic information on how to set up a web site. The tutorial section walks through a fictional photographer (Bob Smith) setting up his site, but there are other articles.

« Previous Entries