Drain Hole Plugin

download

Download: Drain Hole
Version: 2.2.8
Supports: WordPress 2.5-2.9
Other: This plugin is no longer actively maintained

Drain Hole is a centralized download manager, with full monitoring and statistics, versioning, SVN support, and SEO download URLs (no more nasty query strings!).

In addition to it’s monitoring abilities, Drain Hole has a run-time tag replacement feature that lets you embed special tags in your post which are replaced with information from Drain Hole. For example, you can embed download URLs, version information, last update times, and so on. Whenever you change a downloadable file it is automatically updated throughout your blog, without you needing to change anything else.

Features include:

  • SEO download URLs – a unique feature that allows files to look like real links
  • Local or remote file storage – keep your files on your own server or have them stored somewhere else such as Amazon S3 or wordpress.org
  • SVN support – attach a file directly to an SVN repository and have the contents automatically updated
  • Versioning – maintain multiple versions of a file, allowing users to download older files
  • Full download statistics, including number of downloads, access times, referrer, and download speed, available as CSV and Flash-based graphs
  • Download security – permissions can be assigned to downloads (including Flash files), restricting them to WordPress roles
  • Template tags – insert dynamic download data into posts, and into the sidebar as a Widget
  • Hot-link protection
  • Fully localized

Installation

Installation is like any WordPress plugin:

  • Download Drain Hole
  • Unzip
  • Upload drain-hole directory to /wp-content/plugins on your server
  • Activate the plugin
  • Use Drain Hole from the Manage/Drain Hole menu

You can find full details of installing a plugin on the plugin installation page. SVN access to the plugin is provided at the SVN repository.

General Concepts

The Drain Hole plugin makes use of two fundamental concepts:

  • Drain hole – a base URL and associated directory where files are stored and downloaded from
  • Files – a file belongs to a particular Drain hole

It is important to understand the mapping between a Drain Hole’s URL and its associated directory. To do this you need to know two pieces of information:

  1. Where files are to be downloaded from (i.e. http://urbangiraffe.com/download/)
  2. Where files are to be stored (i.e /users/john/download/)

This is a mapping from URL to directory:

http://urbangiraffe.com/download/ => /users/john/download/

All files inside the directory will be available at the Drain Hole URL. For example:

/users/john/download/myplugin.zip => http://urbangiraffe.com/download/myplugin.zip

It is preferable that your directory is not in a public location (i.e. in public_html) as Drain Hole may not then be able to function. Your URL must be part of your WordPress installation, but you should not create a directory for it.

Creating a Drain Hole

New Drain Holes require the following information:

New Drain Hole

The URL is the URL on your website at which to make the files available. The directory is the real directory in which the files exist. These two values do not have to match up and the files do not (and ideally should not) be publicly available.

Once a Drain Hole has been created you can then edit it from the list of Drain Holes:

Drain Holes

Editing a Drain Hole will allow you to set additional options:

Edit Hole

The Access Level is the minimum user level required to download files from the hole. This allows you to restrict download access to certain types of user. If a user does not meet the required access level then they will be returned a 404 error page or will be redirected to the configured URL.

The Stop Hot-links option allows you to stop external users from downloading files in the hole. This protection is achieved by analyzing the referring page for a given download – if the referrer is not from your site then the user is sent a 404 error page or redirect to the error URL.

Files

A Drain Hole can contain any number of files and sub-directories.

Files

As with the rest of the plugin, columns are sortable, and data can be searched.

Each file allows you to:

  • Edit the file configuration
  • Manage version history (by clicking on the version number)
  • View download statistics (by clicking on the number of hits or the charts link)
  • Create a new version or update from SVN (by clicking on the branch link)

When editing a file you will be shown additional configuration details:

Edit File

The filename is the actual name of the file and this may differ from the name, which is what will be shown in a download link. If no name is given then the filename will be used. As an extra function, you can insert $version$ into the name and it will be replaced with the file’s current version.

The description is a free-form field allowing you to enter further details about the download. This can be shown when the file is displayed.

The SVN field allows you to enter an SVN repository. See the SVN section later.

When displaying a file to download, an icon can be shown. You can change which icon is shown when editing a file.

The MIME type allows you to specify a custom MIME type for the file. This may be useful if you want a file to open inside the browser. If set to ‘automatic’ then Drain Hole will try and decide what the file is.

Forcing a download allows you to override default browser behaviour and force the file to always be downloaded. This is useful if you have a file that a browser usually tries to open (for example, a PDF), but you want it to always be downloaded.

Forcing the access level is an advanced option that is useful if you are trying to restrict files that are used inside Flash. For example, you may have a video tutorial that you want to restrict to registered users only. The flash video player requires your video file to be available, but may not provide any restriction options. Storing the video inside Drain Hole and then forcing the access level will ensure that only allowed users can access the file, even inside Flash.

Adding new files

New files can be added by any of these methods:

  • Uploading a file directly into the Drain Hole directory and ‘rescanning’
  • Uploading a file through the browser
  • Creating an empty file which can be uploaded later, or which requires an SVN repository

Add File

Versions

Drain Hole allows you to retain old versions of files, either for archiving purposes or for user downloads. To modify a file’s version you need to create a new branch:

Branch

You can enter details about the reason for the new version, and this will be presented to the end user. To retain an old version you must check ‘retain old version’. This old version can be downloaded as follows:

http://urbangiraffe.com/download/myplugin.zip?version=1.2

SVN

Drain Hole provides simple SVN functionality that allows you to associate a file with an SVN repository. A file that uses SVN can then be ‘refreshed’ directly from the SVN repository, rather than requiring you to manually update the file.

SVN functionality requires that you have SVN installed on your host. You must configure the Drain Hole options and provide the full path to the svn executable. If you are in doubt you should consult your host for details.

When an SVN-based file is refreshed, Drain Hole will use SVN to retrieve the latest copy of the files. If a repository contains multiple files they will be automatically zipped.

As additional functionality, Drain Hole will detect if the SVN repository is for a WordPress plugin, and will automatically set the version according to the version information inside the plugin.

Note that no direct capabilities are provided for username and passwords. However, you can pass a username and password to SVN by including it on the SVN field:

http://svn.mysite.com/plugin/trunk/ --username=john --password=thing

Download As – Remote File Storage

With version 2.2, Drain Hole now allows you to keep your files stored on a remote server. For example, you may want to have the files stored on Amazon’s S3. To achieve this you can enter the full URL of the remote file in the ‘download as’ field on a file.

Note that entering a filename in the ‘download as’ will allow you to have the file download with a name different to the original. Additionally, if you enter $version$ in this filename then Drain Hole will automatically replace it with the file’s current version. This will be useful if you want one download URL that when clicked will download a versioned file.

Download Tags

The following tags can be inserted inside posts and pages to embed Drain Hole information. This information is generated dynamically, and will change whenever the underlying information changes:

  • [drain hole ID hits] – Displays the total number of hits from the specified hole ID
  • [drain hole ID show] – Show a list of all files in the specified hole (change display code by copying view/drain-hole/show_hole.php from the Drain Hole plugin directory to the same directory path in your theme’s directory and editing the file)
  • [drain file ID show template] – Displays the download template for the specified file ID. ‘template‘ is optional and can be ignored (the default template will be used)
  • [drain file ID version] – Displays the version of the specified file
  • [drain file ID versions limit] – Displays the specified number of versions from the file’s history
  • [drain file ID hits] – Displays the total downloads for the specified file
  • [drain file ID url name] – Displays a URL allowing the specified file to be downloaded. ‘name‘ is optional and is the text that will appear inside the download link (if not specified then the filename is used)
  • [drain file ID updated] – Displays the update time of the specified file
  • [drain file ID size] – Displays the size of the specified file
  • [drain file ID icon] – Displays the download icon for the specified file
  • [drain file ID href] – Displays the URL of the file

Where ID refers to the ID of the file or hole, as shown in the Drain Hole administration pages.

Download Templates & File Icons

A download template is a section of HTML code that is used to display all the information for a file download. For example, on this page in the top right corner is the download for Drain Hole itself. The icon and file information are all part of a download template that is re-used on each of the other plugin pages available from this site.

A download template is a file that is stored in your theme directory and contains standard HTML as well as special Drain Hole template tags:

  • $icon$
  • $url$
  • $version$
  • $updated$
  • $size$
  • $href$

These template tags function similar to the post & page tags, but do not require an ID to be specified.

A default template is provided with Drain Hole. Custom templates are PHP files that are stored in view/drain-hole, inside your theme directory. For example, if you are using the default WordPress theme then:

/wp-content/themes/default/view/drain-hole/mytemplate.php

To use this template in a post you would insert the tag:

[drain file 5 show mytemplate]

This tells Drain Hole to use ‘mytemplate.php‘ to display file 5.

Custom icons can be stored inside your theme:

/wp-content/themes/default/view/drain-hole/icons/

Statistics

Drain Hole provides full download statistics:

Statistics

Support & Bugs

This plugin is no longer actively maintained.

438 comments

  1. Hi, my observations on v 2.0.8 of this plugin used with a local wordpress 2.3 install:

    1. To clarify my comments in comment #92, I was using the wrong dir structure; the virtual URI must be inside the wordpress directory and the Directory must be set to whatever your Operating System’s file structure looks like (/user/john/sites/urbangiraffe.com/etc for linux, c:\xampp\etc for windows)
    2. Contrary to your instructions under "Files" above, I dont seem to be able to create sub-directories inside a drainhole; I need to
      • Create my drainhole directory structure first, including all subfolders, before creating the drainholes with the plugin’s dashboard
      • A new drainhole needs to be created for every subfolder
      • Each drainhole needs its own URI to map to (i.e. drainholes can’t share virtual URIs)
      • The virtual URI must be inside the wordpress directory or the script will not function (fail with "server reset" for example)
    3. Scanning directories with "re-scan" doesn’t work, at least on my local install; I need to "upload" each file manually to see it listed
    4. The lightbox-style editing dialog is neat (I love it, I use lightbox myself), but it is cut off above the "Save" button and wont scroll back into view in Firefox 2.0.0.7 windows. It just works because a tiny sliver of the top edge of the button is visible.

    Hope this helps, great work so far!

  2. More observations and questions:

    • The editing dialog box for the drainhole works correctly, only the file editing dialog is cut off.
    • The "names" in the list of drain holes should not be the same as either the virtual URI (as it is now) or the absolute file location, the user should be able to set something that is easy to understand. For example, if you create a virtual URI structure like "/yourdomain/i/" "/yourdomain/v/" or "/yourdomain/download/y/", it’s pretty hard to find your way around your drainholes for other users with administrative access.
  3. More:

    • Versioning: drain hole adds "version 0.1" to *some* of my files (but not all), although I never intended to give them a version number. When I add a [drain file ID url name] tag to a page, the mouseover (the title attribute of the <a> tag) says "Download version 0.1 of this file". How do I turn this off, and how do I stop drain hole from adding version numbers to files?
    • Please remind people to update their permalink structures in the documentation at the top of the page. Not everyone is going to read all the way through comment #87.
    • Even with permalinks updated, drain hole is ok with some files and not with others. If it throws up an error, I get this page from apache:Object not found!

      The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

      If you think this is a server error, please contact the webmaster.
      Error 404
      localhost
      (date) (time)
      Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8d mod_autoindex_color PHP/5.2.1

      and the apache error log has[Date & Time] [error] [client 127.0.0.1] File does not exist: e:/xampp/htdocs/i, referer: http://localhost/mywordpressdomain/wordpress-page/

  4. Roger, fixed in latest version.

    Joe, Drain Hole operates inside WordPress, so every download is similar to a WordPress page access (but not as intensive)

    ctree:

    • The download URL should be relative to your site (i.e. /downloads/, not http://localhost/downloads). Also, the directory should be a directory path, not a URL. I’ve changed the latest version to not allow full URLs
    • Sub-directories are allowed, but must be created manually (you can’t create them from the interface) and then ‘scanned’ for. You do not need a Drain Hole for every folder. Yes, Drain Holes cannot share the same address (otherwise I have no way to determine which hole is to be used). Yes, a hole URL must be relative to WordPress.
    • How isn’t scanning working? Any errors? No files being picked up? Do you have the correct directory configured?
    • I don’t see the edit boxes being cut off, for holes or files, in Firefox 2.0.0.7 on Windows
    • Re-saving permalinks is not a required action, it was just needed in comment 87 to try and resolve an issue someone else was having
    • The idea of the download URLs is to have something that is understandable. For example, I have a Drain Hole for /plugins/ and one for /themes/.
    • What files are not working?
    • A default version of 0.1 is added to any new file you create. If you don’t need this then you can delete the version number. The new version of Drain Hole will not display the version if undefined.

    Sid, looking at your page I notice you have the tag specified as: <span>[</span>drain hole 1 show]. It should be [drain hole 1]

    Paul, are you seeing any javascript errors?

    Jaclyn, your files are probably stored in public_html somewhere. If this is so you need a .htaccess file to route everything through Drain Hole. I’ve enabled this by default in the new version of Drain Hole, but you’ll need to enable the ‘create .htaccess in holes’ option and then re-create the Drain Hole so the file is created.

    YikYak, the same with .htaccess may be affecting you too. If still no luck then get in touch with me via email and I’ll try and locate what’s going wrong.

    Over, the only thing I can suggest is to pick the ‘delete drainhole’ option from inside Drain Hole and then re-activate it. The database should be created automatically.

  5. Hi John,

    Thank you for your reply. The problem with errors after installing is solved. Now when i want to create a drain hole i get a popup for saving the file edit.php. Therefor i can’t create drain holes at this moment. How is this problem solved? I’m using hosted servers so i don’t have full access to them. Could you please help me with this problem? Thnx in advance!

  6. Hi John,

    All problems are solved! I’m able to create drain holes and download the files! Please ignore my previous message. Thnx for this superb plugin!

    Regards.

  7. I tried to install Drainhole on my local server. The server enviornment is Windows version of Xampp 1.6.3a

    PHP 5.2.3
    MySQL 5.0.45

    I got the following error.

    Fatal error: Call to undefined function wp_enqueue_script() in D:\xampp\htdocs\wordpress\wp-content\plugins\drain-hole\drain-hole.php on line 78

  8. I am also having the "blank page" issue.

    I wonder if there is some creation going on in the back ground and WP is set to time out?

    Would really like to try this out but cant seem to get a drain hole created.

  9. Pushing the limit or gently said: one notch more suggestion.

    Could you add this feature:

    Forcing the access level is an advanced option that is useful if you are trying to restrict files that are used inside Flash….

    Add the option to override the access level of the drain hole main configuration. Example: main hole is configures for Subscriber. So you could have 100 files set at this level…minus one, that could be set up for Level Administration in the Forcing the access level (that would be a new option).

    I know I could create Drain Holes restricted only for ADMIN and put these files in it. But I think to have the flexibility to override the Level Access on individual file would be fantastic.

    Again like:

    Drain Hole#7 =Access Level =Subscriber
    File #122 =Access Level=Admin (or whatever)

    Thanks for your support by the way!

    Roger

  10. Chris, the plugin requires WP2.2+. It sounds like you are using an older version?

    Roger, I chose not to have permissions per file for the added complication it would introduce to the interface (each file already has enough options to configure!). The idea being that if you did want permissions you could (as you suggest) create a drain hole for admin and one for other users.

  11. StarChip, there is some creation going on in the background, but only a single database insert – not something that would cause a webserver to timeout. I could send you a special debug version to try and locate what’s happening?

  12. Thannks for all your work on this John.

    I am getting the same "blank page" error.

    wordpress 2.3/dreamhost

  13. John,
    I am having a problem when I edit a file or drain-hole. The lightbox comes up, I edit what I need, then click Save. Every time, it will look like it saved, start closing the lightbox, then hang up and sit there. This happens in IE7 and gives the following Javascript error:
    Line: 270
    Char: 4
    Error: Can’t move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.
    Code: 0

    I have not been able to find out why this happens. I have to refresh the page to get the box to go away, and the settings for the drain-hole will not save (the file settings will, but I still get the error and have to refresh).

    Any idea what is causing this? I do not replicate the problem in firefox 2.x.

    Thanks,
    Drew

  14. I had two other minor questions,
    Is there a way to display the most recent file uploaded to a drain-hole with some special drain file dowload tag? Basically, I would like to display the most current file from a certain drain-hole on a different page than where I use the [drain hole ID show] tag to display all of the files in the drain-hole.

    By the way, I searched for days for a plugin like this! Great work!

    Drew

  15. This looks like an awesome plugin. However, I’m running WP 2.3.1 and I’m having trouble, is it not compatible with this version? I too am getting a blank screen after putting in the url and directory and hitting enter to make a new drain hole. Any help appreciated. Thank a lot.

  16. Great plugin. I think the proper mime type for gzip files is "application/x-gzip" – otherwise some browsers, like opera, will save .tar.gz files as .zip. I changed the mime_types.php to reflect this a it worked fine.

    Also, is there a way to customize the output of $updated$ ? I’d prefer to have YYYY-MM-DD.

    Thanks again!

  17. Angelo,

    I had the same problem initially (running WP 2.3.1). Here’s how I got it to work:
    Create the folders in the root of your wordpress installation
    Set URL –> relative to your wordpress install (mine was like —.com/wp/) so in the URL field, I put /wp/downloads/ – where download was the folder I created.
    Set Directory –> relative to the server absolute path to the folder you created (e.g. /home/htdocs/wp/downloads)

    Once you create your drain holes right, it works (no blank page)… and I have found this plugin to be pretty awesome.

    – Drew

  18. Thanks Drew.
    I still couldn’t get it to work, but then I checked the absolute path again and it turns out I just had it wrong all along. I fixed the path and I put the folder, in which to store the files, outside the public folder, no problems. So, if you get a blank screen just check the directory path again I guess…

  19. Great plugin, but why isn’t [drain file ID href] documented? Took me some searching to find it, and it’s quite a useful tag.

  20. Two more questions:
    1) Drain Hole doesnt count the file download statistics, how can I make it work?
    2) The graph stats are not displaying any stats, how can I make them work?

    Thank you ๐Ÿ™‚

  21. As per the documentation above, your download directory should not be in your public_html area. If it is in your public_html area then Drain Hole tries to create a .htaccess file to protect your files (they are publically available) and to record statistics. If Drain Hole cannot create this file (maybe due to write permissions) then no downloads will be recorded as Drain Hole is not being activated on a download. To add this file yourself create .htaccess in the download directory:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ /path/to/wordpress/index.php
    </IfModule>

  22. Whenever I use Internet Explorer 6 or 7 and choose Open rather than Save As, the file is corrupted. This happens on .wsz (winamp skins) as well as .jpg with force download. Firefox works fine in both cases.

  23. Commenting out the following line in file.php:

    header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1

    Seems to solve the IE problem somewhat. However, force download will be broken on the next download attempt, and I get MySQL errors popping up rather than pages if I surf to another page, like so:

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1]
    SELECT *,NOW() AS now FROM wp_drainhole_access WHERE id=

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1]
    UPDATE wp_drainhole_access SET speed=13914, time_taken=0 WHERE id=

  24. Commenting out:
    DH_Access::finished ($id, $this->filesize ($hole, $version));

    Seems to solve the errors after using Open in IE, however it’s obviously not desirable to do so. It does give a pretty good idea where the problem is, though.

  25. Hiya,

    Thanks for your hard work. I can’t seem to activate the plugin. I get the following error message:

    Fatal error: Call to undefined function wp_enqueue_script() in /var/www/imbloggingthis/wp-content/plugins/drain-hole/drain-hole.php on line 79

    What to do?

    yours,

    Erik

  26. I’m having the 404 error with WP 2.3.1 also. I have tried pretty much everything on this page to get it to work with 404 errors, but I still can’t get it to work.

    Everything displays fine until I click on the link it creates, then its nothing but 404 errors.

    Has anyone having the 404 error with WP 2.3.1 got this to work? If so, what was your solution? This is really frustrating seeing how great this plugin is.

    I’ve spent several hours trying to figure out the problem with no solution.

    Please HELP!

    Lee

    P. S. – I use BLUEHOST as my webhost.

  27. Okay I’ve discovered what may be the problem:

    In WP 2.3.1 and version 2.0.10 of drain hole, it is only allowing for the "url" and the "directory" to be exactly the same in relation to its context. As Drew mentioned previously (with my minor modifications),

    Set "URL" –> relative to your wordpress install (i.e. http://www.example.com/wp/) so in the "URL" field, put /wp/downloads/ – where "downloads" is a folder you create.

    Set "Directory" –> relative to the server absolute path to the folder you created (i.e. /home/username/public_html/wp/downloads)

    Now, that that’s established, it will work if you do that, BUT your files will become vulnerable and anyone can just copy and paste the location in any browser and start downloading your hidden files.

    If you change the "directory" location of the files, it fails to work again.

    What I have discovered is that the script is not REDIRECTING at all. It only provides the DIRECT link to the download.

    So with that said, is there anyway to fix the area of the script that’s hindering redirection? If so, how?

    Trying to help,
    Lee

    P.S. – I’m not sure if this is happening to anyone else, but I know how frustrating it is if this is happening to you.

  28. I finally managed to get Drain Hole working (to some extent) on WordPress 2.3.1, after struggling with 404 errors for several hours. I think the sleep must have done the magic. I think I caught myself dreaming about how I was going to get Dream Hole working after I got up ๐Ÿ™‚

    For those of you still struggling with the dreaded 404 problem, try disabling the hot-link protection! This seem to be broken. If you’ve setup everything else properly, disable the hot-link protection and see if it works. That’s what worked for me (even though this is something I really need).

    For Daniel (Author):

    I think you could save yourself the many repeated requests and problems being reported by updating the plugin’s page above. You’ve done a great deal of work to incorporate many requests from users, but one has to read all the 130 comments down here to get to the "state of affairs".

    For instance, the Redirection plugin is not required at all, but I only found this all the way down in comment #52, and that was after installing the Redirection plugin and struggling unsuccessfully to configure it.

    Also the new template tags are not documented anywhere at all. By trial and error (I don’t speak code!), I found I could display the description (with $desc$ tag) and the download counter (with $hits$ tag) directly in the CUSTOM TEMPLATE file… but these are not mentioned in your list of "special Drain Hole template tags" at all.

    Anyway, thanks a million times or this great plugin.

    And to everyone please forgive my poor grammar. English is my third language.

  29. Erik, the plugin is WordPress 2.2+ only.

    George, my name’s John, not Daniel! I’m confused as to why you had to read all 130 comments. The above page is up-to-date and says nothing about needing the Redirection plugin. The comments are shown in reverse order, so the latest issues are shown first – there should be no need to start from comment 1 and make your way through the entire history of Drain Hole (which has changed substantially and will contain a lot of now-irrelevant information). You are correct that the description tag is not documented (it is now), but the hits one is detailed above. I’ve fixed an issue regarding hotlink protection.

    Lee, Drain Hole does allow the URL and directory to be different (and doesnt require any redirecting). In fact, the whole point of the plugin is that they are different. See if the above hotlink fix changes anything for you.

    Rirath, I’ve tried forcing files to be downloaded through IE and it works fine. Judging by the errors I would say that the problem is somewhere else – it should be impossible for Drain Hole to affect another page you browse to. You could try disabling all other plugins and see if anything is affecting Drain Hole
    Tomsn, the .htaccess file has to be in the directory where your files are stored. This is only necessary if the directory can be accessed from public_html

  30. John: it’s your call of course, but I’m fairly certain of both bugs I’ve reported (tested on more than one computer, by more than one user), and I’m also fairly certain of the fixes. While the file appears to download fine, the headers are screwed up because of the no-cache line. This is a documented problem by Microsoft, though usually pertaining to PDF files. As for affecting other pages, I can only report what I find.

    All I can say is if anyone else if having the same issues, commenting out the lines I mention works for me.

  31. Rirath, I’m not denying you don’t have a problem, or that it isn’t caused by Drain Hole. However, I only have a limited amount of time to track down bugs, and in most cases the problem can be attributed to something outside of my control. As you can imagine this is a huge drain on my time. Given that I’ve reproduced the steps you described and saw no problem at all, and that no one else has reported this, then I can only assume something else must be involved. This may be a head-in-the-sand approach, but it’s the only one that time allows.

    Until I can reproduce the problem myself it’s not something I can fix. In this instance testing on multiple computers wouldn’t do anything other than prove that IE is consistent. Have you tested on a fresh WordPress installation? What environment is WordPress running under? Do you have a URL I can download from to test it myself?

    If there is a problem with Drain Hole then I’m more than willing to fix it, and it will be a lot more preferable than forcing people to keep changing files everytime I update the plugin. If you can help towards making Drain Hole better then I do appreciate it.

  32. Understood. DH is by far one of the best WP download managers around, just wanted to post up an FYI for anyone else who happens to be seeing the same problems when I noticed nobody else had mentioned it.

  33. Hey Guys,

    I am eager to get drain hole working and to donate some money once I know it does what I need it to do

    I have installed the plugin, and just tried to ‘Add a file’ using the ‘re-scan’

    when I hit re-scan I get a loop of:
    warning: escapeshellcmd() has been disabled for security reasons in /home/finitofi/public_html/wp-content/plugins/drain-hole/models/hole.php on line 327

    any ideas?

    Cheers!

    Adam

  34. Hello, I get the following DB error using the latest version of the plugin on WordPress 2.2.3:

    WordPress database error: [Unknown column ‘s’ in ‘where clause’]
    SELECT * FROM wp_DLM_DOWNLOADS WHERE id=s/filename.foo;
    Download does not exist!

    Deleting and reactivating Drain Hole did not work. My hole is set up with the correct paths (Drain Hole admin sees the files etc). Any advice as to what might be going on here?
    Thanks,
    SP

  35. Update: I created a new drain hole and now am getting a different error:

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘/filename.foo’ at line 1]
    SELECT * FROM wp_DLM_DOWNLOADS WHERE id=/filename.foo;
    Download does not exist!

    Is that a rogue backslash b0rking the download somehow?

  36. I got it working eventually, sorry for the n00b spam. ๐Ÿ˜‰
    (PS it might be worth saying explicitly in the documentation that you don’t create your "downloads" directory, as opposed to the directory you are really storing your files in. That had me confused for a while.)

  37. All, Has anyone done any editing with the show_hole.php file to parse through the files and list them in two even columns? Before I go off and spend time figuring it out, I just wanted to make sure I am not reinventing the wheel.

    Thanks,
    Drew

  38. Hi,

    I am try using your Drain Hole Plug in.
    but I having problem with the files. when I klik to download, there a error message, the request url not found.

    I put the file in download directory, on the root.

    my setting is :

    url : /http//www.funkymovie.com/download –> is it right ?
    directory : /home/okabija/download

    i have rescan the directory, and found 1 file (I only put 1 file).
    but why the file can’t be found ? where is my mistake ?

    thanks very much for the reply

  39. Okay I figured out what my problem was. I will explain my problem and the solution for those who may be reading this and having the same problem.

    I was having the 404 error that many people have mentioned and I thought the script just wasn’t redirecting. What I discovered is that the script was redirecting it was just being stopped by my .htaccess file which was in the subdirectory of my website, where I installed WordPress.

    For example:
    Website: http://www.example.com
    Wordpress installation: http://www.example.com/blog/

    WordPress automatically creates an .htaccess file to control redirections associated with pages and posts you have created and to coincide with the permalinks structure you have established. The .htaccess file looks like this:

    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]

    # END WordPress

    To fix the error, you need to COPY this file and change it to look like this:


    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]

    # END WordPress

    Notice immediately after "RewriteBase" the change. It is now on the ROOT directory and not a SUBdirectory.

    After you have made the change, add the new COPIED file to the ROOT directory of your site, i. e. – http://www.example.com/ or home/username/public_html/website/

    The idea is to make sure it is on the ROOT directory and not a subdirectory.

    Be sure to NOT change or move the original .htaccess file created by WordPress, because this is still needed in order for your WordPress installation to work properly. You will now have two .htaccess files now, one in the subdirectory with your WordPress installation and the other under the root directory of your site.

    If you need further info about .htaccess files, do a search on Google.

    Well, I hope this helps someone.

    Lee

    P.S.- This is just one solution that helped me and hopefully others, you still have to install Drain Hole correctly.

  40. Thanks for the great plugin!

    I’d like to offer a "smart" hotlink protection. Now you check the referer. But if the user for example copy-pastes an url to the location bar, the script will refuse to provide the file. The same with download managers.

    What if you put a cookie when the user opens any wordpress page. The life of the cookie will be the current browser session. When a file is requested, the script will check if our cookie is in place. This way we can solve the problem with the copy-pasted url and with those download masters smart enough to pass the cookie to the server.

    Slava.

  41. Adam, it seems your host has blocked the ‘escapeshellcmd’ function, which Drain Hole is using. I’ve added a check in the code for this so the error will disappear.

    Steven, those database errors you reported are from some other download manager!

    Chio, you should use a relative URL, not an absolute URL. Currently you have the URL setup as /http//www.funkymovie.com/download – change this to just /download/

  42. Hey John,

    If someone were to create patches for Drain Hole to add the following functionality, would you incorporate them into the main plugin?

    Possible functionality:

    Add ability to assign screenshots to a file. (create a new table and link screenshots to file IDs)
    Add ability to change the Download icon to a custom one (instead of having to choose from the predfined ones)

    I think Drain Hole is an awesome plugin, and by adding the functionalities above, it could be a powerful solution to easily create "file download" sites with WordPress.

  43. It would be great if Drain Hole could restrict file requests to one at a time per IP, or something. I’m getting hammered by download managers/accelerators which request the same file tens or hundreds of times per minute, and can’t keep up with all the user-agent descriptions to ban them. Is this possible?

  44. Hi friend,

    Thanks for the great plugin.

    I made some changes in show_hole.php file to look better on my site, like show the name instead of the filename but the list of files are not ordered alphabeticaly… may you help me?

    here is the code:

    <?php if ($file->description) echo ''.$file->description; ?>

    <?php endforeach; ?>

    <?php endif; ?>">

    Very thank you.

  45. Sorry, this is the code:

    <?php if (!empty ($files)) : ?>

    <?php foreach ($files AS $file) : ?>

    <?php echo $file->url ($hole, $name->file); ?> (<?php echo $file->bytes ($file->filesize ($hole)) ?>)
    <?php if ($file->description) echo ”.$file->description; ?>

    <?php endforeach; ?>

    <?php endif; ?>

  46. […] a seรƒยงรƒยฃo de Downloads com a substituiรƒยงรƒยฃo do Plugin WP-DownloadManager pelo Drain Hole. Essa alteraรƒยงรƒยฃo permitiu a categorizaรƒยงรƒยฃo das seรƒยงรƒยตes de downloads em […]

  47. Hi John,
    I want to display the file version while using [drain hole ID show].
    What is the code to place into show_hole.php?

  48. Hello everyone

    I see that this issue has come up before.
    So this is a revisted of sorts from some of you.

    I’am using WP 2.2+ with latest drain hole.

    Unsuccessful as of yet with my exsiting configuration.

    url:/download/files
    directory: /home/lightconecorp/download/files
    This message pops-up below after selecting the jpg link for download.
    "The document you requested is not found on this server."
    http://www.lightconecorp.net/download/files
    The above url I’m trying to get to work.

    I deactivate Redirection 1.7.2.6, No joy there.
    In search of clues here.

    Very impressive software work John.

    Thanks
    P.S.
    Message for today, support open source programming
    Donate

  49. Great tool. Thanks!

    Can you tell me how to manually call the widget on a page? I use a custom theme that is not widget ready and dont want to hack it to add widget support.

    Thanks.

  50. Hello, I love the plugin.

    I have one small question. How do I add a new file for a new branch/version. Shouldn’t there be a place to upload a new file when you click on "New Branch"?

  51. I see there is a checkbox named "Google analytics tracking" under "Options" tab, however it does not ask me for the tracking ID. Does it work? How it does? ๐Ÿ˜€

    Hey John, wonderful work!

  52. Is it possible to have something like that:

    Let say I have on one page 10 files. If somebody wants to download a file and he will click on it he will be redirected to the page where he has to give for example his e-mail address. After that he will be able to download this file and every other. So maybe use for that cookie.

    ??

    Great plugin.
    Tino

  53. razor, the only thing I tell you is to check if you wrote the tag [drainhole bla bla bla] in the code section and not in the wysiwyg…

  54. it has been wrote in the code section ๐Ÿ™‚

    ive tried renaming url to URL is set to /wordpress/downloads (my wp is located in wordpress)

    also tried removing the hotlink protection as someone eles suggested and still nothing!

    ๐Ÿ™

  55. DanyO, you can already add your own custom icons – see the above section ‘Download Templates & File Icons’.

    Aantn, whenever you upload a file (via FTP or from the upload form) it overwrites the current version. Therefore if you create a new version and then upload the file it will achieve the effect you are looking for.

    Tino, you can do that if you ask the downloader to register at your site.

    Sid, the Google Analytics tracking assumes that Google Analytics is enabled on your site. It works by telling Analytics to monitor clicks to any download link

    Glenn, you can call the_drainhole_stats();

    Joel, show_hole.php should already display the name in preference to filename. The code you have for $name->file won’t work. I’ve changed the ‘hole show’ tag to order by name

    Karimun, <?php echo $file->version; ?> will show the file version.

    Curtis, redirection is no longer needed so it will have no effect if you enable or disable it. Do you have permalinks enabled? Is the ‘download’ directory in your WordPress home?

    Curtis, the same questions for you too – is the downloads directory available inside your WordPress installation?

  56. "Tino, you can do that if you ask the downloader to register at your site" yes John I know that but I don’t want the downloader to go to the registration page. Simply only to page where he writes his e-mail and thats it.

  57. Tino, that functionality isn’t in Drain Hole and the registration step is all you can do for the moment. I’ll have a think about it for the future.

  58. any ideas on a solution for my problem??? im desperate to get this plugin too work, ive tried others but yours is better 10 times over

  59. ive read throu the whole list of comments and im still non the wiser ๐Ÿ™

    im havin some trouble, everything has installed correctly

    i placed a tag on my site but its not working

    URL is set to /wordpress/downloads
    dir is set to /home/hvdesig/HV_DOWNLOADS

    when you hover over the link it says "http://mysite.co.uk/downloads/filename.zip&quot; but when clicked it doesnt work i get 404
    any ideas?

    help much appreciated

  60. Razor, do you have permalinks enabled? What version of WP are you using? There’s not a lot I can suggest here, but if you want to send me an admin login to your site then I’ll take a look and see if I can figure out what’s happening.

  61. first you have to make sure that your permalink is set to "Date and name based" not the default one .
    and your configuration :
    URL is set to /wordpress/downloads
    dir is set to /home/hvdesig/HV_DOWNLOADS

    should stay the same ..
    in this case your gana to make sure that url mapping will work just fine

  62. John,

    Why do you state "A default template is provided with Drain Hole." And then say that one isn’t provided in the plugin’s thread? You should remove the sentence, it would have saved me some time.

    Actually, it would be nice if you did provide a sample template!!! (I know … only so many hours in a day ๐Ÿ™‚

    Thanks for another great plugin. Installing on a client blog now and will leave a post about the experience.

    –Craiger

  63. Please excuse my ignorance,but there’s a few things i can’t get clear:

    – to link a file, i MUST use this format to get stats??? [drain file ID url name]. if i just link it with html, what will happen? just no stats?

    – is there a way to embed a player and count this as a download? i mean, theres a plugin that uses this format:

    [audio:http://blabla.com/audio.mp3%5D

    i guess i cannot use something like this:

    [audio:[drain file ID url name]]

    is there a way to do this?

    thank you!

  64. Hmn… Sadly, I can’t get this plugin to work, because I have a master domain/user (with HostGator) that is used to host multiple domain and the path to the DomainName I want to use is: /home/masterdomainuser/public_html/DomainNameForDrainHole/

    So, I’m wonder if this plugin can be used if I host at HostGator (or similar webhost with the same path as above). And if this plugin can be used, please add some "how to" documentations, as I really would like to use this plugin (instead of the current Download Counter plugin => uses similar concepts as this plugin =).

  65. When I installed the drain-hole plugin, it created an icon in the visual editor to add a file to a page. This icon only appears in Firefox and not IE. I’m using version 6 of IE.

    Anyone else had this problem?

  66. Hi John,
    I’ve found a big (for me) bug in permalinks in your plugin. However this bug seems to appear only to me: not found on the internet!

    I think it depends on my ‘access error url’ or ‘stop-hot-link’ settings (seem to happen after I modifyed them, but not sure!). Maybe on my provider setting…
    The bug ‘happens’ only if permalinks are turned on (and your plugin).

    The bug is an error string appearing in the head of every page and every RSS (not in every entry, but in the entire FEED, corrupting it):
    Warning: preg_match() [function.preg-match]: Unknown modifier '.' in /.../wp-includes/classes.php on line 99
    Warning: preg_match() [function.preg-match]: Unknown modifier '.' in /.../wp-includes/classes.php on line 100

    Those lines are:
    if (preg_match("!^$match!", $request_match, $matches) ||
    preg_match("!^$match!", urldecode($request_match), $matches)) {

    These lines are executed a lot of times when loading the page, but just one time them fail. Excelly the passed parameters ($request_match and $matches) are always the same, so I don’t understand of what ‘.’ modifier parameter the error is talking about…

    Those errors persist after you disable Drainhole and disappear if you delete the rewrite_rules record in the _options table of the DB.

    I do not understand regular expressions. Maybe the bug is updating hooks to files in holes in that record (which you do in drainhole.php)…

    An example of that record which *maybe* is the reason of that bug is available here:
    http://www.sugata.eu/public/eMail/pregmatch.txt

    Cheers!
    Sid.

  67. PS) You won’t see the error in my blog because I embraced those lines with ini_set(‘display_errors’, ‘x’);

  68. Sid, does the new version change anything?

    SEO Blogger, I see no reason why you shouldn’t be able to use the plugin. Hopefully the documentation on this page should be sufficient – just pick a directory and a URL and that’s it.

    Dubo, you can link to a file anyway you want. The Drainhole tag method is for convenience, but you can link directly. You can link directly to a file from inside another plugin:

    [audo:http://your.file.com/file.mp3%5D

    If you are getting no statistics then please read the Drain Hole FAQ.

    Craig, a default template is provided and is automatically used. My comment said that no template called ‘mytemplate’ is provided.

    Aantn, an old version is simply an older version of a file which you may want users to be able to download. For an example of this see the version history on this page where you can download older versions of the plugin.

    Razor/mhd, permalinks can be set to anything other than the default, not just ‘date and name based’.

  69. When I click on downloads in the submenu I get the list:
    Downloaded At | File | IP | User | Referer
    รขโ‚ฌยฆ

    The problem is when I wont to search thru this list.

    I get this error:

    WordPress database error: [Unknown table ‘file’ in where clause]
    SELECT SQL_CALC_FOUND_ROWS wp_drainhole_access.*,wp_drainhole_files.file,wp_users.user_login FROM wp_drainhole_access LEFT JOIN wp_drainhole_files ON wp_drainhole_access.file_id=wp_drainhole_files.id LEFT JOIN wp_users ON wp_drainhole_access.user_id=wp_users.ID WHERE (file.file LIKE "%exp%") ORDER BY created_at DESC LIMIT 0,25

    The where clause cause this problem. And by the way, from this query I see that search is only provided for file. Is it possible to add in this WHERE clause also argument so it will look also for IP? Where can I change it, in what file?

    I using the newest version 2.0.14

    Regards,
    Tino

  70. Oh and one more thing.

    What can I do to prevent opening file if someone knows the direct path. For example google shows direct path.

    The problem is that I cannot pick a directory outside of your public_html.

    Any advise?

    Thanks,
    Tino

  71. Tino, if you can’t pick a path outside of public_html then you need to create a .htaccess file in the download directory. See the FAQ for more details. I’ve released a new version which should fix the search problem. Currently it’s not possible to search IP addresses as they are stored as decimal numbers, not strings of characters.

    Sid, the new version has $href$ which returns only the URL

  72. John:

    Great plugin! But I just ran into a problem when I upgraded to 2.0.15. The file show tag ceased to work in my pages. The Hole Show tag worked fine, and file hits and file url tags worked but not file show. I rolled back to version 2.0.14 and now everything works great again.

    THanks again for a great plug-in.

  73. Great plugin! I just set up all my holes and got them working on my WP pages; however, the stats still aren’t working. I read the FAQ section about the htaccess, and my htaccess looks like:
    RewriteEngine On
    RewriteRule ^(.*)$ /home/rishi-ku/public_html/index.php

    My directory structure is like this: My WP is installed in /home/rishi-ku/public_html and my holes are in /home/rishi-ku/public-html/wp-content/files
    Where do I need to put the htaccess file? I tried putting it in several places, but I ended up losing my theme. Thanks for your time!

  74. Rishi, it is better if you put your drainhole in a private directory. The htaccess file can be generated by the plugin if you turn on the option. Don’t know if it helps.

Comments are closed.