Version Description
Tested for compatibility with WordPress 3.0. Older versions work with it, too, but now it is "official".
Fixed date/time display to 24-hour format. Thanks Daniel for the report.
Test for path validity (directory and extension) is performed before logging the download request, not after. This means that requests for files which don't match the two regular expressions are logged as requests to nonexistent files, while previously they were logged ads successful downloads (even though they were not downloaded by the user who got an error 404 instead).
Cosmetic fix for the paginator: links to first/previous page are displayed on the left side of the table, links to next/last page on the right.
Download this release
Release Info
Developer | pepak.net |
Plugin | Simple Download Monitor |
Version | 0.13 |
Comparing to | |
See all releases |
Code changes from version 0.12 to 0.13
- readme.txt +35 -2
- simple-download-monitor.php +16 -13
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: Pepak
|
|
3 |
Donate link:
|
4 |
Tags: files, counter, count, tracking, download monitor, monitor, downloads, download
|
5 |
Requires at least: 2.8.0
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 0.
|
8 |
|
9 |
Count the number of downloads without having to maintain a comprehensive download page.
|
10 |
|
@@ -47,6 +47,9 @@ username of people who download my files.
|
|
47 |
Add this line directly above it:
|
48 |
`RewriteRule ^(files/.*) /index.php?sdmon=$1 [L]`
|
49 |
(replace 'files/' with your download directory).
|
|
|
|
|
|
|
50 |
|
51 |
== Frequently Asked Questions ==
|
52 |
|
@@ -102,6 +105,24 @@ will fix any errors that are reported to me.
|
|
102 |
|
103 |
== Changelog ==
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
= 0.12 =
|
106 |
|
107 |
* Support for country-flagging of each download. This feature requires
|
@@ -137,12 +158,14 @@ will fix any errors that are reported to me.
|
|
137 |
archives. As a result, PHP 4 version of the plugin was recompressed
|
138 |
to 7Z ( http://www.7-zip.org ).
|
139 |
|
|
|
140 |
= 0.10 =
|
141 |
|
142 |
* Belorussian translation by FatCow ( http://www.fatcow.com )
|
143 |
|
144 |
* PHP 4 version is also available (see the FAQ).
|
145 |
|
|
|
146 |
= 0.09 =
|
147 |
|
148 |
* Fixed incorrect header for file size. That should fix incompatibility
|
@@ -150,7 +173,9 @@ will fix any errors that are reported to me.
|
|
150 |
|
151 |
* Support for resumed transfers.
|
152 |
|
|
|
153 |
= 0.08 =
|
|
|
154 |
* Administrators can now delete download statistics from the Tools panel:
|
155 |
A checkbox is shown next to each record, and a button for deleting checked
|
156 |
records is provided at the bottom of the list. A button for deleting all
|
@@ -160,7 +185,9 @@ will fix any errors that are reported to me.
|
|
160 |
Note: This function is only allowed for users with a "delete_user"
|
161 |
capability (by default, that means only Administrators).
|
162 |
|
|
|
163 |
= 0.07 =
|
|
|
164 |
* Simple Download Monitor now allows inline content, e.g. images and
|
165 |
videos that display within pages rather than download as a file.
|
166 |
By default, all files are set to download, but you can override this
|
@@ -169,11 +196,17 @@ will fix any errors that are reported to me.
|
|
169 |
Note: Do not forget to add image extensions to Allowed Extensions -
|
170 |
a file must be allowed to download before it can be "inlined".
|
171 |
|
|
|
172 |
= 0.06 =
|
|
|
173 |
* Fixed a bug on download display if no downloads were recorded.
|
174 |
|
|
|
175 |
= 0.05 =
|
|
|
176 |
* First intentional public release.
|
177 |
|
|
|
178 |
= 0.04 =
|
|
|
179 |
* Accidental premature public release due to my unfamiliarity with WordPress plugin repository.
|
3 |
Donate link:
|
4 |
Tags: files, counter, count, tracking, download monitor, monitor, downloads, download
|
5 |
Requires at least: 2.8.0
|
6 |
+
Tested up to: 3.0.0
|
7 |
+
Stable tag: 0.13
|
8 |
|
9 |
Count the number of downloads without having to maintain a comprehensive download page.
|
10 |
|
47 |
Add this line directly above it:
|
48 |
`RewriteRule ^(files/.*) /index.php?sdmon=$1 [L]`
|
49 |
(replace 'files/' with your download directory).
|
50 |
+
1. (Optional step) If you want to see country flags in the download stats page, download,
|
51 |
+
install, activate and set up my Country-To-IP Plugin ( http://wordpress.org/extend/plugins/ip-to-country/ ).
|
52 |
+
See changelog of version 0.12 for details.
|
53 |
|
54 |
== Frequently Asked Questions ==
|
55 |
|
105 |
|
106 |
== Changelog ==
|
107 |
|
108 |
+
= 0.13 =
|
109 |
+
|
110 |
+
* Tested for compatibility with WordPress 3.0. Older versions work with
|
111 |
+
it, too, but now it is "official".
|
112 |
+
|
113 |
+
* Fixed date/time display to 24-hour format. Thanks Daniel for the report.
|
114 |
+
|
115 |
+
* Test for path validity (directory and extension) is performed *before*
|
116 |
+
logging the download request, not after. This means that requests for
|
117 |
+
files which don't match the two regular expressions are logged as requests
|
118 |
+
to nonexistent files, while previously they were logged ads successful
|
119 |
+
downloads (even though they were not downloaded by the user who got an
|
120 |
+
error 404 instead).
|
121 |
+
|
122 |
+
* Cosmetic fix for the paginator: links to first/previous page are displayed
|
123 |
+
on the left side of the table, links to next/last page on the right.
|
124 |
+
|
125 |
+
|
126 |
= 0.12 =
|
127 |
|
128 |
* Support for country-flagging of each download. This feature requires
|
158 |
archives. As a result, PHP 4 version of the plugin was recompressed
|
159 |
to 7Z ( http://www.7-zip.org ).
|
160 |
|
161 |
+
|
162 |
= 0.10 =
|
163 |
|
164 |
* Belorussian translation by FatCow ( http://www.fatcow.com )
|
165 |
|
166 |
* PHP 4 version is also available (see the FAQ).
|
167 |
|
168 |
+
|
169 |
= 0.09 =
|
170 |
|
171 |
* Fixed incorrect header for file size. That should fix incompatibility
|
173 |
|
174 |
* Support for resumed transfers.
|
175 |
|
176 |
+
|
177 |
= 0.08 =
|
178 |
+
|
179 |
* Administrators can now delete download statistics from the Tools panel:
|
180 |
A checkbox is shown next to each record, and a button for deleting checked
|
181 |
records is provided at the bottom of the list. A button for deleting all
|
185 |
Note: This function is only allowed for users with a "delete_user"
|
186 |
capability (by default, that means only Administrators).
|
187 |
|
188 |
+
|
189 |
= 0.07 =
|
190 |
+
|
191 |
* Simple Download Monitor now allows inline content, e.g. images and
|
192 |
videos that display within pages rather than download as a file.
|
193 |
By default, all files are set to download, but you can override this
|
196 |
Note: Do not forget to add image extensions to Allowed Extensions -
|
197 |
a file must be allowed to download before it can be "inlined".
|
198 |
|
199 |
+
|
200 |
= 0.06 =
|
201 |
+
|
202 |
* Fixed a bug on download display if no downloads were recorded.
|
203 |
|
204 |
+
|
205 |
= 0.05 =
|
206 |
+
|
207 |
* First intentional public release.
|
208 |
|
209 |
+
|
210 |
= 0.04 =
|
211 |
+
|
212 |
* Accidental premature public release due to my unfamiliarity with WordPress plugin repository.
|
simple-download-monitor.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Simple Download Monitor
|
5 |
Plugin URI: http://www.pepak.net/wordpress/simple-download-monitor-plugin
|
6 |
Description: Count the number of downloads without having to maintain a comprehensive download page.
|
7 |
-
Version: 0.
|
8 |
Author: Pepak
|
9 |
Author URI: http://www.pepak.net
|
10 |
*/
|
@@ -270,6 +270,10 @@ if (!class_exists('SimpleDownloadMonitor'))
|
|
270 |
$relfilename = substr($fullfilename, strlen(ABSPATH));
|
271 |
$relfilename = strtr($relfilename, '\\', '/');
|
272 |
$exists = (file_exists($fullfilename) AND !is_dir($fullfilename)) ? 1 : 0;
|
|
|
|
|
|
|
|
|
273 |
// Get user information and decide if this user should be ignored
|
274 |
get_currentuserinfo();
|
275 |
$userid = $user_ID ? $user_ID : null;
|
@@ -292,13 +296,13 @@ if (!class_exists('SimpleDownloadMonitor'))
|
|
292 |
if ($monitor)
|
293 |
{
|
294 |
$sql = "UPDATE ${downloads} SET download_count=download_count+1, last_date=NOW(), file_exists=%d WHERE id=%d";
|
295 |
-
$wpdb->query($wpdb->prepare($sql, $exists, $id));
|
296 |
}
|
297 |
}
|
298 |
else
|
299 |
{
|
300 |
$sql = "INSERT INTO ${downloads} (filename, download_count, last_date, file_exists) VALUES (%s, 1, NOW(), %d)";
|
301 |
-
$wpdb->query($wpdb->prepare($sql, $filename, $exists));
|
302 |
$id = $wpdb->insert_id;
|
303 |
}
|
304 |
// If details are requested, store them as well
|
@@ -311,14 +315,9 @@ if (!class_exists('SimpleDownloadMonitor'))
|
|
311 |
$wpdb->query($wpdb->prepare($sql, $id, $ip_addr, $referer, $username, $userid));
|
312 |
}
|
313 |
}
|
|
|
314 |
// Make sure the file is available for download
|
315 |
-
if (
|
316 |
-
return FALSE;
|
317 |
-
$dirregexp = self::PREG_DELIMITER . '^' . get_option(self::PREFIX . 'directories') . self::PREG_DELIMITER;
|
318 |
-
if (!preg_match($dirregexp, $relfilename))
|
319 |
-
return FALSE;
|
320 |
-
$extregexp = self::PREG_DELIMITER . '\\.' . get_option(self::PREFIX . 'extensions') . '$' . self::PREG_DELIMITER;
|
321 |
-
if (!preg_match($extregexp, $relfilename))
|
322 |
return FALSE;
|
323 |
// Generate proper headers
|
324 |
$mimetype = '';
|
@@ -546,16 +545,20 @@ if (!class_exists('SimpleDownloadMonitor'))
|
|
546 |
$pages = array();
|
547 |
if ($from > 0)
|
548 |
{
|
|
|
549 |
$pages[] = '<a href="' . $this->GetUrlForList(array_merge($options, array('from'=>0))) . '">' . __("First", self::GETTEXT_REALM) . '</a>';
|
550 |
$pages[] = '<a href="' . $this->GetUrlForList(array_merge($options, array('from'=>($from>self::RECORDS_PER_PAGE ? $from-self::RECORDS_PER_PAGE : 0)))) . '">' . __("Previous", self::GETTEXT_REALM) . '</a>';
|
|
|
551 |
}
|
552 |
|
553 |
if (($from + self::RECORDS_PER_PAGE) < $count)
|
554 |
{
|
|
|
555 |
$pages[] = '<a href="' . $this->GetUrlForList(array_merge($options, array('from'=>$from+self::RECORDS_PER_PAGE))) . '">' . __("Next", self::GETTEXT_REALM) . '</a>';
|
556 |
$pages[] = '<a href="' . $this->GetUrlForList(array_merge($options, array('from'=>$count-self::RECORDS_PER_PAGE))) . '">' . __("Last", self::GETTEXT_REALM) . '</a>';
|
|
|
557 |
}
|
558 |
-
$result = $pages ? '<div class="pages-list">' . implode(' ', $pages) . '
|
559 |
return $result;
|
560 |
}
|
561 |
|
@@ -691,7 +694,7 @@ if (!class_exists('SimpleDownloadMonitor'))
|
|
691 |
<td><?php echo $rownum; ?>.</td>
|
692 |
<td><?php if ($detailed): ?><a href="<?php echo $this->GetUrlForList(array('download' => $download)); ?>"><?php endif; echo htmlspecialchars($filename); if ($detailed): ?></a><?php endif; ?></td>
|
693 |
<td><?php echo $count; ?></td>
|
694 |
-
<td><?php echo mysql2date('Y-m-d
|
695 |
<td><?php if ($this->IsAdmin()): ?><input type="checkbox" name="SimpleDownloadMonitor_DeleteIds[]" value="<?php echo $download; ?>" /><label for="SimpleDownloadMonitor_DeleteIds[]"> <?php echo __('Delete', self::GETTEXT_REALM); ?></label><?php else: ?> <?php endif; ?></td>
|
696 |
</tr>
|
697 |
</tbody><?php
|
@@ -777,7 +780,7 @@ if (!class_exists('SimpleDownloadMonitor'))
|
|
777 |
?>
|
778 |
<tr>
|
779 |
<td><?php echo $rownum; ?>.</td>
|
780 |
-
<td><?php echo mysql2date('Y-m-d
|
781 |
<td><?php echo ($country_flag) ? '<img src="'.htmlspecialchars($country_flag).'" alt="'.$country.'" title="'.$country.'"/>' : $country; ?></td>
|
782 |
<td><?php echo htmlspecialchars($ip); ?></td>
|
783 |
<td><?php echo htmlspecialchars($referer); ?></td>
|
4 |
Plugin Name: Simple Download Monitor
|
5 |
Plugin URI: http://www.pepak.net/wordpress/simple-download-monitor-plugin
|
6 |
Description: Count the number of downloads without having to maintain a comprehensive download page.
|
7 |
+
Version: 0.13
|
8 |
Author: Pepak
|
9 |
Author URI: http://www.pepak.net
|
10 |
*/
|
270 |
$relfilename = substr($fullfilename, strlen(ABSPATH));
|
271 |
$relfilename = strtr($relfilename, '\\', '/');
|
272 |
$exists = (file_exists($fullfilename) AND !is_dir($fullfilename)) ? 1 : 0;
|
273 |
+
// Make sure it is a valid request
|
274 |
+
$dirregexp = self::PREG_DELIMITER . '^' . get_option(self::PREFIX . 'directories') . self::PREG_DELIMITER;
|
275 |
+
$extregexp = self::PREG_DELIMITER . '\\.' . get_option(self::PREFIX . 'extensions') . '$' . self::PREG_DELIMITER;
|
276 |
+
$valid = (preg_match($dirregexp, $relfilename) AND preg_match($extregexp, $relfilename)) ? 1 : 0;
|
277 |
// Get user information and decide if this user should be ignored
|
278 |
get_currentuserinfo();
|
279 |
$userid = $user_ID ? $user_ID : null;
|
296 |
if ($monitor)
|
297 |
{
|
298 |
$sql = "UPDATE ${downloads} SET download_count=download_count+1, last_date=NOW(), file_exists=%d WHERE id=%d";
|
299 |
+
$wpdb->query($wpdb->prepare($sql, $exists * $valid, $id));
|
300 |
}
|
301 |
}
|
302 |
else
|
303 |
{
|
304 |
$sql = "INSERT INTO ${downloads} (filename, download_count, last_date, file_exists) VALUES (%s, 1, NOW(), %d)";
|
305 |
+
$wpdb->query($wpdb->prepare($sql, $filename, $exists * $valid));
|
306 |
$id = $wpdb->insert_id;
|
307 |
}
|
308 |
// If details are requested, store them as well
|
315 |
$wpdb->query($wpdb->prepare($sql, $id, $ip_addr, $referer, $username, $userid));
|
316 |
}
|
317 |
}
|
318 |
+
// If the file exists and is valid, download it
|
319 |
// Make sure the file is available for download
|
320 |
+
if (!($exists * $valid))
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
return FALSE;
|
322 |
// Generate proper headers
|
323 |
$mimetype = '';
|
545 |
$pages = array();
|
546 |
if ($from > 0)
|
547 |
{
|
548 |
+
$pages[] = '<div style="float: left;">';
|
549 |
$pages[] = '<a href="' . $this->GetUrlForList(array_merge($options, array('from'=>0))) . '">' . __("First", self::GETTEXT_REALM) . '</a>';
|
550 |
$pages[] = '<a href="' . $this->GetUrlForList(array_merge($options, array('from'=>($from>self::RECORDS_PER_PAGE ? $from-self::RECORDS_PER_PAGE : 0)))) . '">' . __("Previous", self::GETTEXT_REALM) . '</a>';
|
551 |
+
$pages[] = '</div>';
|
552 |
}
|
553 |
|
554 |
if (($from + self::RECORDS_PER_PAGE) < $count)
|
555 |
{
|
556 |
+
$pages[] = '<div style="float: right;">';
|
557 |
$pages[] = '<a href="' . $this->GetUrlForList(array_merge($options, array('from'=>$from+self::RECORDS_PER_PAGE))) . '">' . __("Next", self::GETTEXT_REALM) . '</a>';
|
558 |
$pages[] = '<a href="' . $this->GetUrlForList(array_merge($options, array('from'=>$count-self::RECORDS_PER_PAGE))) . '">' . __("Last", self::GETTEXT_REALM) . '</a>';
|
559 |
+
$pages[] = '</div>';
|
560 |
}
|
561 |
+
$result = $pages ? '<div class="pages-list">' . implode(' ', $pages) . '<div style="clear: both;" /></div>' : '';
|
562 |
return $result;
|
563 |
}
|
564 |
|
694 |
<td><?php echo $rownum; ?>.</td>
|
695 |
<td><?php if ($detailed): ?><a href="<?php echo $this->GetUrlForList(array('download' => $download)); ?>"><?php endif; echo htmlspecialchars($filename); if ($detailed): ?></a><?php endif; ?></td>
|
696 |
<td><?php echo $count; ?></td>
|
697 |
+
<td><?php echo mysql2date('Y-m-d H:i:s', $date, TRUE); ?></td>
|
698 |
<td><?php if ($this->IsAdmin()): ?><input type="checkbox" name="SimpleDownloadMonitor_DeleteIds[]" value="<?php echo $download; ?>" /><label for="SimpleDownloadMonitor_DeleteIds[]"> <?php echo __('Delete', self::GETTEXT_REALM); ?></label><?php else: ?> <?php endif; ?></td>
|
699 |
</tr>
|
700 |
</tbody><?php
|
780 |
?>
|
781 |
<tr>
|
782 |
<td><?php echo $rownum; ?>.</td>
|
783 |
+
<td><?php echo mysql2date('Y-m-d H:i:s', $date, TRUE); ?></td>
|
784 |
<td><?php echo ($country_flag) ? '<img src="'.htmlspecialchars($country_flag).'" alt="'.$country.'" title="'.$country.'"/>' : $country; ?></td>
|
785 |
<td><?php echo htmlspecialchars($ip); ?></td>
|
786 |
<td><?php echo htmlspecialchars($referer); ?></td>
|