DownloadManager
Questions answered by this recipe
How can I know how many times a file was downloaded from my wiki?
Answer
Download unofficial version 0.5: downloadman_0_5_aidin.phpΔ (see changelog, old official version 0.4. is still available: downloadman.phpΔ ).
- downloadman_0_6_aidin.phpΔ - Former versions incorrectly placed info in
download.manager
instead of.download.manager
. Changed it so that it matches the description below, and now works out-of-the-box with TotalCounter which expects to find.download.manager
. see the changlog below for more details. overtones99 July 18, 2008, at 09:33 PM
It is a very simple download manager. It keeps track of every file download and displays the counter next to it.
After you install it (see below) you can use instead than the usual syntax Attach:filename.ext
the new syntax Download:filename.ext
which will give you the download indication.
Notes
Installation:
Download the script from above and place it in your cookbook directory. Then add include_once('cookbook/downloadman.php');
in your local configuration (local/config.php).
Configuration:
No particular configuration is necessary but if you want you can change the "action=" that the script uses by giving a value to the $DownloadManagerAction
variable before including the script (default action is "downloadman").
$DownloadManagerAction = 'downloadman';
Use:
To see the download count next to your attachments use instead than the usual syntax Attach:filename.ext
the new syntax Download:filename.ext
.
New in 0.5:
DownloadCount:filename.ext
.
i18n:
The $[downloads] string is used and can be internationalized (i18n).
Other
Of course the download count is strictly dependent to the upload system of PmWiki. For example if in two different pages we have two occurances of the same file, the same download count will be displayed. Two occurances of two different files with same name will correctly display the two distinct download count.
A single text file is saved in the wiki.d
directory with the name .download.manager
in which the informations are stored. Since the directory already has write permissions, no configuration is needed.
- note that v0.5 & 0.4 seem to actually use
download.manager
(no leading period (.)), which makes it not work with TotalCounter, and doesn't seem to match the description here. overtones99 July 18, 2008, at 09:33 PM
Part of the code is based on the original PmWiki upload.php
script by Pm.
Examples:
You can see the recipe live this one
Releases
- 0.1 - 12.12.2005
- First implementation
- 0.2 - 21.12.2005
- Public release
- 0.2b - 16.01.2006
- Added a fix which may prevent some problems with multiple accesses.
- 0.3 - 24.01.2006
- Reduced locking loop to 5 seconds.
- Changed creation of lock directory to lock file, to prevent problems with some providers.
- 0.4 - 16.05.2007 - Dave Carver
- Fix issue with Internet Explorer 6.0 not recognizing files.
- 0.5 - 09.09.2007 - Aidin Abedi
- Added
DownloadCount:filename.ext
to only display count whileDownload:filename.ext
is only used as url link.
- Added
- 0.6 - 07.18.2008 - overtones99
- According to both this DownloadManager page and the TotalCounter page, download info is supposed to be stored in
.download.manager
-- however it appears earlier versions (at least 0.4 & 0.5) were putting them indownload.manager
(no leading .); i changed all occurrences ofdownload.manager
to.download.manager
, and one instance ofdownload.manager.lock
to.download.manager.lock
-TotalCounter
now works with DownloadManager by default, and the code matches the descriptions above...
- According to both this DownloadManager page and the TotalCounter page, download info is supposed to be stored in
See Also
- PmWiki.Uploads for more informations on uploads.
- PmWiki.UploadsAdmin for more informations on administration/uploads.
- PmWiki.Internationalizations for more information on i18n.
Contributors
Comments
See discussion at DownloadManager-Talk
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.