You are here: Home » Building Traffic » Monitoring File Downloads in WordPress Using Drain Hole Plugin

Monitoring File Downloads in WordPress Using Drain Hole Plugin

by Dave Doolin on May 14, 2009 · 1 comment

(Reading time: 4 – 7 minutes)

Drain Hole is an interesting and useful file download management WordPress plugin created by John Godley of Urban Giraffe. Drain Hole has a really large number of incredibly useful options… most of which totally unnecessary unless your offering dozens or hundreds of different files.

Nevertheless, even if you’re offering just one file for download, it’s worth your while to set up Drain Hole now, and track your downloads over time. You might be pleasantly surprised, and decide to offer more downloadable material.

What follows in this article is a simplified explanation of how to set up your own “drain holes,” when you’re dealing with addon domains. If you aren’t using an addon domain and don’t know what that means, no worries, the following still applies. When you’re ready for the gory details, the Drain Hole documentation is otherwise excellent.

Why Drain Holes?

What is this notion of a “drain hole” anyway?

That’s a great question. Here’s the general idea:

  • You want to give stuff away;
  • But you don’t want to just let anyone scrape it off your site;
  • So you need a little bit of security;
  • And you want to get an idea of your download’s popularity.

These requirements mean you need to put your documents and files somewhere you can get them, but not somewhere a web crawler can get them… unless the crawler uses your link.

Setting up the Drain Hole

First, you need to create a directory on your server where the files are located. You can use an FTP client for this, I like FileZilla. Call it “downloadfiles” for the purpose of this article. This is NOT in the public_html directory. It’s a sibling folder to public_html, which your server can access, but a web crawler cannot.

If you’re more comfortable using the file manager interface in a web application such as cPanel, that works just fine as well.

Once you have this directory created, you can upload your file or files now, or wait until later and upload them using the Drain Hole interface.

Dealing with addon domains

When your domain is being operated as an “addon” domain out of subdirectory of the main website’s public_html directory, the Drain Hole admin page may recommend a default file structure which will NOT work. For example, Website In A Weekend is an addon domain for tinobox.com, and this is what it looks like when creating a new drain hole:

Default location for new drain hole

Default location for new drain hole

Go ahead and click on the image to see the default paths suggested by the Drain Hole plugin. In this case, since I’m using an addon directory:

  • URL: This will NOT work. I need to change http://website-in-a-weekend.net/download to something that will work, say, /downloadfiles.
  • Directory: /home393/loginaccount/public_html/websiteinaweekend/download/ will NOT work either. Note that “home393″ and loginaccount are fictitious, replace these with what’s applicable on your WordPress web setup. The problem here is that the “public_html” path needs to be removed.

Removing the addon URL and the “public_html” path directory from the file location path is necessary. Here’s what we have now:

new_hole_created

This should work. If you get an error, check to be sure you provided the correct URL and file locations, and (important), check to make sure your drain hole directory is created and located correctly. Even if you get the paths right, if there is no drain directory already on the server, you’ll get an error… but the error message is currently obtuse with respect to this issue.

Now it’s time to upload your file.

Uploading via Drain Hole interface

How big is the file you want to upload? Bigger than 2M, then read on…

Drain Hole, as all other plugins and WordPress itself, is written in a powerful programming language called PHP. PHP is powerful enough that it’s smart to tell it exactly what it can and can’t do on your website. For example, if you use the php uploaded built in to the Drain Hole Admin page, you may run into a php upload file size limit. This means if your file is too big, you can’t upload it using PHP. If this happens, you have a couple of options:

  1. Upload your file or files using an FTP client (you already know how to do this, right?), or
  2. Change your file size limit in php.ini to a number large enough to accommodate your files.

Changing the file upload size is an easy modification of the php.ini file. Here’s what the relevant lines in my php.ini file look like:

475
476
477
478
479
480
481
482
483
484
485
486
487
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
 
; Whether to allow HTTP file uploads.
file_uploads = On
 
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =
 
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

You want to change line 487 to a number big enough to upload your files.

>>>NOTE: If you are attempting to upload podcasts or video, this is not the correct strategy. Podcasts and videos should be hosted on servers dedicated to serving large multimedia files. Then you just link to your multimedia file through freely-available WordPress plugins.

That’s it. Very easy stuff. Make sure to read ALL of the Drain Hole documentation over at Urban Giraffe.




Would you like more? Send me a letter...
"Hi Dave,
Website In A Weekend seems pretty cool. I'm serious about this WordPress and web stuff, and I'd like to keep up with it. My name is and my email address is . I'm comfortable with email newsletters. I know you will protect my privacy, and that I can unsubscribe at any time. "

{ 1 comment }

rifki November 6, 2009 at 8:07 pm

This information is very helpful .
I’ve looked everywhere and finally I found it here.
thank you so much.

Comments on this entry are closed.

Previous post:

Next post: