Simple Download Monitor - Version 0.07

Version Description

  • Simple Download Monitor now allows inline content, e.g. images and videos that display within pages rather than download as a file. By default, all files are set to download, but you can override this behavior for specific regular expressions in the configuration.

Note: Do not forget to add image extensions to Allowed Extensions - a file must be allowed to download before it can be "inlined".

Download this release

Release Info

Developer pepak.net
Plugin Icon 128x128 Simple Download Monitor
Version 0.07
Comparing to
See all releases

Code changes from version 0.06 to 0.07

Files changed (4) hide show
  1. lang/cs_CZ.mo +0 -0
  2. lang/cs_CZ.po +52 -36
  3. readme.txt +34 -3
  4. simple-download-monitor.php +20 -5
lang/cs_CZ.mo CHANGED
Binary file
lang/cs_CZ.po CHANGED
@@ -2,9 +2,9 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Simple Download Monitor v0.04\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2009-10-28 09:08+0100\n"
6
  "PO-Revision-Date: \n"
7
- "Last-Translator: pepak <pepak@pepak.net>\n"
8
  "Language-Team: Pepak <pepak@pepak.net>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
@@ -16,129 +16,145 @@ msgstr ""
16
  "X-Poedit-Basepath: ..\n"
17
  "X-Poedit-SearchPath-0: ..\n"
18
 
19
- #: ../sdmon/simple-download-monitor.php:209
20
- #: ../sdmon/simple-download-monitor.php:479
21
  msgid "Simple Download Monitor options"
22
  msgstr "Simple Download Monitor - nastavení"
23
 
24
- #: ../sdmon/simple-download-monitor.php:210
25
  msgid "Allowed directories"
26
  msgstr "Povolené adresáře"
27
 
28
- #: ../sdmon/simple-download-monitor.php:211
29
  msgid "Only requested files whose full names (relative to document root) start with this regular expression will be processed. It is strongly recommended to place all downloadable files (and ONLY downloadable files) into a designated directory and then placing that directory's name followed by a slash here. It is possible to use the power of PREG to allow multiple directories, but make sure there are ONLY files which you are comfortable with malicious users downloading. Do not EVER allow directories which contain PHP files here! That could lead to disclosure of sensitive data, including username and password used to connect to WordPress database."
30
  msgstr "Zpracovávány budou pouze soubory, jejichž plná jména (relativní vůči kořenovému adresáři webu) začínají tímto regulárním výrazem. Silně doporučuji umístit všechny stažitelné soubory (a JENOM stažitelné soubory) do jednoho určeného adresáře a vepsat sem název tohoto adresáře zakončený lomítkem. Lze také využít všech možností, které dává PREG, pro povolení více adresářů, ale dejte si pozor, ať v nich jsou JEDINĚ soubory, u kterých vám nevadí, když si je stáhne útočník. NIKDY do těchto adresářů neukládejte žádné PHP soubory! To by mohlo vést k zveřejnění citlivých dat, včetně uživatelského jména a hesla pro připojení k databázi."
31
 
32
- #: ../sdmon/simple-download-monitor.php:212
33
  msgid "Default value is <code>files/</code>, which only allows download from /files directory (the leading <code>/</code> is implicit)."
34
  msgstr "Výchozí hodnota je <code>files/</code>, která dovolí stahovat pouze soubory z adresáře /files (úvodní <code>/</code> je dosazeno automaticky)."
35
 
36
- #: ../sdmon/simple-download-monitor.php:214
37
  msgid "Allowed extensions"
38
  msgstr "Povolené přípony"
39
 
40
- #: ../sdmon/simple-download-monitor.php:215
41
  msgid "Only files with extensions matching this regular expressions will be processed. This is another important security value. Make sure you only add extensions which are safe for malicious users to have, e.g. archives and possibly images. Do NOT use any expression that could allow a user to download PHP files, even if you think it safe given the Allowed Directories option above."
42
  msgstr "Zpracovávány budou pouze soubory, jejichž přípony odpovídají tomuto regulárnímu výrazu. Jde o další důležitý bezpečnostní prvek. Dejte si pozor, ať jsou zde uvedeny pouze takové přípony, které nemohou být zneužity útočníky, tzn. komprimované archívy a případně obrázky. NEPOUŽÍVEJTE výrazy, které by mohly uživateli dovolit download PHP souborů, ani kdyby tyto soubory vylučovalo nastavení \"Povolené adresáře\" výše."
43
 
44
- #: ../sdmon/simple-download-monitor.php:216
45
  msgid "Default value is <code>zip|rar|7z</code> which only allows download of files ending with <code>.zip</code>, <code>.rar</code> and <code>.7z</code> (the leading <code>.</code> is implicit)."
46
  msgstr "Výchozí hodnota je <code>zip|rar|7z</code>, která povolí pouze stahování souborů s příponou <code>.zip</code>, <code>.rar</code> a <code>.7z</code> (úvodní <code>.</code> je dosazena automaticky)."
47
 
48
- #: ../sdmon/simple-download-monitor.php:218
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  msgid "Store detailed logs?"
50
  msgstr "Ukládat detailní záznamy?"
51
 
52
- #: ../sdmon/simple-download-monitor.php:219
53
  msgid "If detailed logs are allowed, various information (including exact time of download, user's IP address, referrer etc.) is stored. This can fill your database quickly if you have only a little space or a lot of popular downloads. Otherwise just the total numbers of downloads are stored, consuming significantly less space."
54
  msgstr "Pokud je tato volba zapnuta, ukládají se detailní informace (jako přesný čas, IP adresa uživatele nebo referer) o každém downloadu. To může rychle zahltit databázi, pokud máte jen málo prostoru nebo populární downloady. Normálně se ukládá jen celkový počet stažení, který zabírá podstatně méně místa."
55
 
56
- #: ../sdmon/simple-download-monitor.php:220
57
  msgid "Use detailed statistics."
58
  msgstr "Používat detailní statistiky"
59
 
60
- #: ../sdmon/simple-download-monitor.php:221
61
  msgid "Update settings"
62
  msgstr "Uložit nastavení"
63
 
64
- #: ../sdmon/simple-download-monitor.php:326
65
  msgid "First"
66
  msgstr "První"
67
 
68
- #: ../sdmon/simple-download-monitor.php:327
69
  msgid "Previous"
70
  msgstr "Předchozí"
71
 
72
- #: ../sdmon/simple-download-monitor.php:332
73
  msgid "Next"
74
  msgstr "Další"
75
 
76
- #: ../sdmon/simple-download-monitor.php:333
77
  msgid "Last"
78
  msgstr "Poslední"
79
 
80
- #: ../sdmon/simple-download-monitor.php:348
81
- #: ../sdmon/simple-download-monitor.php:411
82
- #: ../sdmon/simple-download-monitor.php:479
83
- #: ../sdmon/simple-download-monitor.php:480
84
  msgid "Simple Download Monitor"
85
  msgstr "Simple Download Monitor"
86
 
87
- #: ../sdmon/simple-download-monitor.php:349
88
  msgid "Nonexistent downloads"
89
  msgstr "Neexistující soubory"
90
 
91
- #: ../sdmon/simple-download-monitor.php:349
92
  msgid "All downloads"
93
  msgstr "Všechny downloady"
94
 
95
- #: ../sdmon/simple-download-monitor.php:350
96
  msgid "Show all downloads"
97
  msgstr "Zobrazit všechny soubory"
98
 
99
- #: ../sdmon/simple-download-monitor.php:350
100
  msgid "Show nonexistent downloads"
101
  msgstr "Zobrazit neexistující soubory"
102
 
103
- #: ../sdmon/simple-download-monitor.php:361
104
  msgid "Filename"
105
  msgstr "Název souboru"
106
 
107
- #: ../sdmon/simple-download-monitor.php:362
108
  msgid "Download count"
109
  msgstr "Počet stažení"
110
 
111
- #: ../sdmon/simple-download-monitor.php:363
112
  msgid "Last date"
113
  msgstr "Poslední datum"
114
 
115
- #: ../sdmon/simple-download-monitor.php:412
116
  #, php-format
117
  msgid "Detailed data for <strong>%s</strong>:"
118
  msgstr "Detailní data pro <strong>%s</strong>:"
119
 
120
- #: ../sdmon/simple-download-monitor.php:413
121
  #, php-format
122
  msgid "Total number of downloads: <strong>%d</strong>."
123
  msgstr "Celkový počet stažení: <strong>%d</strong>."
124
 
125
- #: ../sdmon/simple-download-monitor.php:425
126
  msgid "Date"
127
  msgstr "Datum"
128
 
129
- #: ../sdmon/simple-download-monitor.php:426
130
  msgid "IP address"
131
  msgstr "IP adresa"
132
 
133
- #: ../sdmon/simple-download-monitor.php:427
134
  msgid "Referer"
135
  msgstr "Referer"
136
 
137
- #: ../sdmon/simple-download-monitor.php:428
138
  msgid "Username"
139
  msgstr "Uživatel"
140
 
141
- #: ../sdmon/simple-download-monitor.php:457
142
  msgid "Return to full list."
143
  msgstr "Návrat do úplného seznamu"
144
 
2
  msgstr ""
3
  "Project-Id-Version: Simple Download Monitor v0.04\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2009-11-24 16:50+0100\n"
6
  "PO-Revision-Date: \n"
7
+ "Last-Translator: Pepak <pepak@pepak.net>\n"
8
  "Language-Team: Pepak <pepak@pepak.net>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
16
  "X-Poedit-Basepath: ..\n"
17
  "X-Poedit-SearchPath-0: ..\n"
18
 
19
+ #: ../trunk/simple-download-monitor.php:236
20
+ #: ../trunk/simple-download-monitor.php:513
21
  msgid "Simple Download Monitor options"
22
  msgstr "Simple Download Monitor - nastavení"
23
 
24
+ #: ../trunk/simple-download-monitor.php:237
25
  msgid "Allowed directories"
26
  msgstr "Povolené adresáře"
27
 
28
+ #: ../trunk/simple-download-monitor.php:238
29
  msgid "Only requested files whose full names (relative to document root) start with this regular expression will be processed. It is strongly recommended to place all downloadable files (and ONLY downloadable files) into a designated directory and then placing that directory's name followed by a slash here. It is possible to use the power of PREG to allow multiple directories, but make sure there are ONLY files which you are comfortable with malicious users downloading. Do not EVER allow directories which contain PHP files here! That could lead to disclosure of sensitive data, including username and password used to connect to WordPress database."
30
  msgstr "Zpracovávány budou pouze soubory, jejichž plná jména (relativní vůči kořenovému adresáři webu) začínají tímto regulárním výrazem. Silně doporučuji umístit všechny stažitelné soubory (a JENOM stažitelné soubory) do jednoho určeného adresáře a vepsat sem název tohoto adresáře zakončený lomítkem. Lze také využít všech možností, které dává PREG, pro povolení více adresářů, ale dejte si pozor, ať v nich jsou JEDINĚ soubory, u kterých vám nevadí, když si je stáhne útočník. NIKDY do těchto adresářů neukládejte žádné PHP soubory! To by mohlo vést k zveřejnění citlivých dat, včetně uživatelského jména a hesla pro připojení k databázi."
31
 
32
+ #: ../trunk/simple-download-monitor.php:239
33
  msgid "Default value is <code>files/</code>, which only allows download from /files directory (the leading <code>/</code> is implicit)."
34
  msgstr "Výchozí hodnota je <code>files/</code>, která dovolí stahovat pouze soubory z adresáře /files (úvodní <code>/</code> je dosazeno automaticky)."
35
 
36
+ #: ../trunk/simple-download-monitor.php:241
37
  msgid "Allowed extensions"
38
  msgstr "Povolené přípony"
39
 
40
+ #: ../trunk/simple-download-monitor.php:242
41
  msgid "Only files with extensions matching this regular expressions will be processed. This is another important security value. Make sure you only add extensions which are safe for malicious users to have, e.g. archives and possibly images. Do NOT use any expression that could allow a user to download PHP files, even if you think it safe given the Allowed Directories option above."
42
  msgstr "Zpracovávány budou pouze soubory, jejichž přípony odpovídají tomuto regulárnímu výrazu. Jde o další důležitý bezpečnostní prvek. Dejte si pozor, ať jsou zde uvedeny pouze takové přípony, které nemohou být zneužity útočníky, tzn. komprimované archívy a případně obrázky. NEPOUŽÍVEJTE výrazy, které by mohly uživateli dovolit download PHP souborů, ani kdyby tyto soubory vylučovalo nastavení \"Povolené adresáře\" výše."
43
 
44
+ #: ../trunk/simple-download-monitor.php:243
45
  msgid "Default value is <code>zip|rar|7z</code> which only allows download of files ending with <code>.zip</code>, <code>.rar</code> and <code>.7z</code> (the leading <code>.</code> is implicit)."
46
  msgstr "Výchozí hodnota je <code>zip|rar|7z</code>, která povolí pouze stahování souborů s příponou <code>.zip</code>, <code>.rar</code> a <code>.7z</code> (úvodní <code>.</code> je dosazena automaticky)."
47
 
48
+ #: ../trunk/simple-download-monitor.php:245
49
+ msgid "Inline files"
50
+ msgstr "Soubory pro inline zobrazení"
51
+
52
+ #: ../trunk/simple-download-monitor.php:246
53
+ msgid "Files whose names match this regular expression will be displayed inline (within a HTML page) rather than downloaded."
54
+ msgstr "Soubory, které vyhovují tomuto regulárnímu výrazu, budou zobrazeny inline (jako objekt - např. obrázek nebo video - uvnitř HTML stránky) místo aby se stahovaly."
55
+
56
+ #: ../trunk/simple-download-monitor.php:247
57
+ msgid "By default, this value is empty - no files will appear inline, all will be downloaded. You may want to place something like <code>\\.(jpe?g|gif|png|swf)$</code> here to make images and Flash videos appear inline."
58
+ msgstr "Výchozí hodnotou je prázdný řetězec - všechny soubory se budou stahovat, žádný nebude zobrazen inline. Vepište sem něco jako <code>\\.(jpe?g|gif|png|swf)$</code> pro zobrazování obrázků a Flashů inline."
59
+
60
+ #: ../trunk/simple-download-monitor.php:248
61
+ msgid "Note: Unlike the options above, nothing is implied in this regular expression. You <em>must</em> use an explicit <code>\\.</code> to denote \"start of extension\", you <em>must</em> use an explicit <code>$</code> to mark \"end of filename\", etc."
62
+ msgstr "Pozn.: Narozdíl od nastavení uvedených výše se do tohoto regulárního výrazu nic nedoplňuje. Pokud chcete vyznačit \"začátek přípony\", <em>musíte</em> sem napsat <code>\\.</code>; pokud chcete vyznačit \"konec názvu souboru\", <em>musíte</em> sem napsat <code>$</code>, a podobně."
63
+
64
+ #: ../trunk/simple-download-monitor.php:250
65
  msgid "Store detailed logs?"
66
  msgstr "Ukládat detailní záznamy?"
67
 
68
+ #: ../trunk/simple-download-monitor.php:251
69
  msgid "If detailed logs are allowed, various information (including exact time of download, user's IP address, referrer etc.) is stored. This can fill your database quickly if you have only a little space or a lot of popular downloads. Otherwise just the total numbers of downloads are stored, consuming significantly less space."
70
  msgstr "Pokud je tato volba zapnuta, ukládají se detailní informace (jako přesný čas, IP adresa uživatele nebo referer) o každém downloadu. To může rychle zahltit databázi, pokud máte jen málo prostoru nebo populární downloady. Normálně se ukládá jen celkový počet stažení, který zabírá podstatně méně místa."
71
 
72
+ #: ../trunk/simple-download-monitor.php:252
73
  msgid "Use detailed statistics."
74
  msgstr "Používat detailní statistiky"
75
 
76
+ #: ../trunk/simple-download-monitor.php:253
77
  msgid "Update settings"
78
  msgstr "Uložit nastavení"
79
 
80
+ #: ../trunk/simple-download-monitor.php:358
81
  msgid "First"
82
  msgstr "První"
83
 
84
+ #: ../trunk/simple-download-monitor.php:359
85
  msgid "Previous"
86
  msgstr "Předchozí"
87
 
88
+ #: ../trunk/simple-download-monitor.php:364
89
  msgid "Next"
90
  msgstr "Další"
91
 
92
+ #: ../trunk/simple-download-monitor.php:365
93
  msgid "Last"
94
  msgstr "Poslední"
95
 
96
+ #: ../trunk/simple-download-monitor.php:380
97
+ #: ../trunk/simple-download-monitor.php:445
98
+ #: ../trunk/simple-download-monitor.php:513
99
+ #: ../trunk/simple-download-monitor.php:514
100
  msgid "Simple Download Monitor"
101
  msgstr "Simple Download Monitor"
102
 
103
+ #: ../trunk/simple-download-monitor.php:381
104
  msgid "Nonexistent downloads"
105
  msgstr "Neexistující soubory"
106
 
107
+ #: ../trunk/simple-download-monitor.php:381
108
  msgid "All downloads"
109
  msgstr "Všechny downloady"
110
 
111
+ #: ../trunk/simple-download-monitor.php:382
112
  msgid "Show all downloads"
113
  msgstr "Zobrazit všechny soubory"
114
 
115
+ #: ../trunk/simple-download-monitor.php:382
116
  msgid "Show nonexistent downloads"
117
  msgstr "Zobrazit neexistující soubory"
118
 
119
+ #: ../trunk/simple-download-monitor.php:393
120
  msgid "Filename"
121
  msgstr "Název souboru"
122
 
123
+ #: ../trunk/simple-download-monitor.php:394
124
  msgid "Download count"
125
  msgstr "Počet stažení"
126
 
127
+ #: ../trunk/simple-download-monitor.php:395
128
  msgid "Last date"
129
  msgstr "Poslední datum"
130
 
131
+ #: ../trunk/simple-download-monitor.php:446
132
  #, php-format
133
  msgid "Detailed data for <strong>%s</strong>:"
134
  msgstr "Detailní data pro <strong>%s</strong>:"
135
 
136
+ #: ../trunk/simple-download-monitor.php:447
137
  #, php-format
138
  msgid "Total number of downloads: <strong>%d</strong>."
139
  msgstr "Celkový počet stažení: <strong>%d</strong>."
140
 
141
+ #: ../trunk/simple-download-monitor.php:459
142
  msgid "Date"
143
  msgstr "Datum"
144
 
145
+ #: ../trunk/simple-download-monitor.php:460
146
  msgid "IP address"
147
  msgstr "IP adresa"
148
 
149
+ #: ../trunk/simple-download-monitor.php:461
150
  msgid "Referer"
151
  msgstr "Referer"
152
 
153
+ #: ../trunk/simple-download-monitor.php:462
154
  msgid "Username"
155
  msgstr "Uživatel"
156
 
157
+ #: ../trunk/simple-download-monitor.php:491
158
  msgid "Return to full list."
159
  msgstr "Návrat do úplného seznamu"
160
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link:
4
  Tags: files, counter, count, tracking, download monitor, monitor, downloads, download
5
  Requires at least: 2.8.0
6
  Tested up to: 2.8.4
7
- Stable tag: 0.06
8
 
9
  Count the number of downloads without having to maintain a comprehensive download page.
10
 
@@ -50,9 +50,31 @@ username of people who download my files.
50
 
51
  == Frequently Asked Questions ==
52
 
53
- = Where are the frequently asked questions?
54
 
55
- Nobody asked any yet.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  == Screenshots ==
58
 
@@ -62,6 +84,15 @@ Nobody asked any yet.
62
 
63
  == Changelog ==
64
 
 
 
 
 
 
 
 
 
 
65
  = 0.06 =
66
  * Fixed a bug on download display if no downloads were recorded.
67
 
4
  Tags: files, counter, count, tracking, download monitor, monitor, downloads, download
5
  Requires at least: 2.8.0
6
  Tested up to: 2.8.4
7
+ Stable tag: 0.07
8
 
9
  Count the number of downloads without having to maintain a comprehensive download page.
10
 
50
 
51
  == Frequently Asked Questions ==
52
 
53
+ = Why don't I see any files in the download statistics? =
54
 
55
+ Because nobody downloaded any file yet. Simple Download Monitor does not
56
+ scan all available files and assign "zero" downloads to them; instead, it
57
+ starts with an empty list and populates it with attempted downloads. If
58
+ you want to see something, just try to download one of the monitored files.
59
+
60
+ = Simple Download Monitor doesn't monitor my downloads. Why? =
61
+
62
+ The most common cause is that your webhoster doesn't support user-definable
63
+ .htaccess and/or mod_rewrite, both of which are required for the expected
64
+ (standard) behavior of Simple Download Monitor. The second common cause is
65
+ a misconfigured .htaccess.
66
+
67
+ You can verify that Simple Download Monitor itself is running by using a
68
+ specially-formatted URL for download: instead of
69
+ `http://www.mywebsite.com/files/somefile.zip`
70
+ try this URL:
71
+ `http://www.mywebsite.com/index.php?sdmon=files/somefile.zip`
72
+ This URL calls Simple Download Monitor directly, without any interaction
73
+ with mod_rewrite, and should therefore work at all times (unless there
74
+ is a bug in Simple Download Monitor or its installation went wrong). If
75
+ it succeeds, you know the problem lies either in your .htaccess file or
76
+ in the fact that the required functionality is not provided by your
77
+ webhosting.
78
 
79
  == Screenshots ==
80
 
84
 
85
  == Changelog ==
86
 
87
+ = 0.07 =
88
+ * Simple Download Monitor now allows inline content, e.g. images and
89
+ videos that display within pages rather than download as a file.
90
+ By default, all files are set to download, but you can override this
91
+ behavior for specific regular expressions in the configuration.
92
+
93
+ Note: Do not forget to add image extensions to Allowed Extensions -
94
+ a file must be allowed to download before it can be "inlined".
95
+
96
  = 0.06 =
97
  * Fixed a bug on download display if no downloads were recorded.
98
 
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.06
8
  Author: Pepak
9
  Author URI: http://www.pepak.net
10
  */
@@ -31,7 +31,7 @@ if (!class_exists('SimpleDownloadMonitor'))
31
  class SimpleDownloadMonitor
32
  {
33
 
34
- const VERSION = '0.06';
35
  const PREFIX = 'sdmon_';
36
  const PREG_DELIMITER = '`';
37
  const GET_PARAM = 'sdmon';
@@ -90,6 +90,7 @@ if (!class_exists('SimpleDownloadMonitor'))
90
  add_option(self::PREFIX . 'directories', 'files/');
91
  add_option(self::PREFIX . 'extensions', 'zip|rar|7z');
92
  add_option(self::PREFIX . 'detailed', '0');
 
93
  }
94
 
95
  protected function table_downloads()
@@ -153,17 +154,22 @@ if (!class_exists('SimpleDownloadMonitor'))
153
  if (!preg_match($extregexp, $relfilename))
154
  return FALSE;
155
  // Generate proper headers
 
156
  if (function_exists('finfo_open'))
157
  {
158
  $finfo = finfo_open(FILEINFO_MIME_TYPE);
159
  $mimetype = finfo_file($finfo, $fullfilename);
160
  }
161
- elseif (function_exists('mime_content_type'))
162
  $mimetype = mime_content_type($fullfilename);
163
- else
164
  $mimetype = 'application/octet-stream';
 
 
 
 
165
  header('Content-type: ' . $mimetype);
166
- header('Content-disposition: attachment; filename=' . basename($fullfilename));
167
  header('Content-size: ' . filesize($fullfilename));
168
  // Send the file to user.
169
  $fp = fopen($fullfilename, 'rb');
@@ -202,11 +208,13 @@ if (!class_exists('SimpleDownloadMonitor'))
202
  $directories = strval($_POST[self::PREFIX . 'directories']);
203
  $extensions = strval($_POST[self::PREFIX . 'extensions']);
204
  $detailed = intval($_POST[self::PREFIX . 'detailed']);
 
205
  // Remove slashes if necessary
206
  if (get_magic_quotes_gpc())
207
  {
208
  $directories = stripslashes($directories);
209
  $extensions = stripslashes($extensions);
 
210
  }
211
  // Escape the delimiter
212
  list($directories, $extensions) = str_replace(self::PREG_DELIMITER, '\\'.self::PREG_DELIMITER, array($directories, $extensions));
@@ -214,11 +222,13 @@ if (!class_exists('SimpleDownloadMonitor'))
214
  update_option(self::PREFIX . 'directories', $directories);
215
  update_option(self::PREFIX . 'extensions', $extensions);
216
  update_option(self::PREFIX . 'detailed', $detailed);
 
217
  }
218
  // Load options from the database
219
  $directories = get_option(self::PREFIX . 'directories');
220
  $extensions = get_option(self::PREFIX . 'extensions');
221
  $detailed = get_option(self::PREFIX . 'detailed');
 
222
  // Build the form
223
  ?>
224
  <div class="wrap">
@@ -232,6 +242,11 @@ if (!class_exists('SimpleDownloadMonitor'))
232
  <p><?php echo __('Only files with extensions matching this regular expressions will be processed. This is another important security value. Make sure you only add extensions which are safe for malicious users to have, e.g. archives and possibly images. Do NOT use any expression that could allow a user to download PHP files, even if you think it safe given the Allowed Directories option above.', 'simple-download-monitor'); ?></p>
233
  <p><?php echo __("Default value is <code>zip|rar|7z</code> which only allows download of files ending with <code>.zip</code>, <code>.rar</code> and <code>.7z</code> (the leading <code>.</code> is implicit).", 'simple-download-monitor'); ?></p>
234
  <p><input type="text" name="<?php echo self::PREFIX; ?>extensions" value="<?php echo attribute_escape($extensions); ?>" /></p>
 
 
 
 
 
235
  <h3><?php echo __("Store detailed logs?", 'simple-download-monitor'); ?></h3>
236
  <p><?php echo __("If detailed logs are allowed, various information (including exact time of download, user's IP address, referrer etc.) is stored. This can fill your database quickly if you have only a little space or a lot of popular downloads. Otherwise just the total numbers of downloads are stored, consuming significantly less space.", 'simple-download-monitor'); ?></p>
237
  <p><label for="<?php echo self::PREFIX; ?>detailed"><input type="checkbox" name="<?php echo self::PREFIX; ?>detailed" value="1" <?php if ($detailed) echo 'checked="checked" '; ?>/> <?php echo __('Use detailed statistics.', 'simple-download-monitor'); ?></label></p>
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.07
8
  Author: Pepak
9
  Author URI: http://www.pepak.net
10
  */
31
  class SimpleDownloadMonitor
32
  {
33
 
34
+ const VERSION = '0.07';
35
  const PREFIX = 'sdmon_';
36
  const PREG_DELIMITER = '`';
37
  const GET_PARAM = 'sdmon';
90
  add_option(self::PREFIX . 'directories', 'files/');
91
  add_option(self::PREFIX . 'extensions', 'zip|rar|7z');
92
  add_option(self::PREFIX . 'detailed', '0');
93
+ add_option(self::PREFIX . 'inline', '');
94
  }
95
 
96
  protected function table_downloads()
154
  if (!preg_match($extregexp, $relfilename))
155
  return FALSE;
156
  // Generate proper headers
157
+ $mimetype = '';
158
  if (function_exists('finfo_open'))
159
  {
160
  $finfo = finfo_open(FILEINFO_MIME_TYPE);
161
  $mimetype = finfo_file($finfo, $fullfilename);
162
  }
163
+ if (!$mimetype && function_exists('mime_content_type'))
164
  $mimetype = mime_content_type($fullfilename);
165
+ if (!$mimetype || ((strpos($mimetype, '/')) === FALSE))
166
  $mimetype = 'application/octet-stream';
167
+ $disposition = 'attachment';
168
+ $inlineregexp = self::PREG_DELIMITER . get_option(self::PREFIX . 'inline') . self::PREG_DELIMITER;
169
+ if ($inlineregexp && preg_match($inlineregexp, $relfilename))
170
+ $disposition = 'inline';
171
  header('Content-type: ' . $mimetype);
172
+ header('Content-disposition: '.$disposition.'; filename=' . basename($fullfilename));
173
  header('Content-size: ' . filesize($fullfilename));
174
  // Send the file to user.
175
  $fp = fopen($fullfilename, 'rb');
208
  $directories = strval($_POST[self::PREFIX . 'directories']);
209
  $extensions = strval($_POST[self::PREFIX . 'extensions']);
210
  $detailed = intval($_POST[self::PREFIX . 'detailed']);
211
+ $inline = strval($_POST[self::PREFIX . 'inline']);
212
  // Remove slashes if necessary
213
  if (get_magic_quotes_gpc())
214
  {
215
  $directories = stripslashes($directories);
216
  $extensions = stripslashes($extensions);
217
+ $inline = stripslashes($inline);
218
  }
219
  // Escape the delimiter
220
  list($directories, $extensions) = str_replace(self::PREG_DELIMITER, '\\'.self::PREG_DELIMITER, array($directories, $extensions));
222
  update_option(self::PREFIX . 'directories', $directories);
223
  update_option(self::PREFIX . 'extensions', $extensions);
224
  update_option(self::PREFIX . 'detailed', $detailed);
225
+ update_option(self::PREFIX . 'inline', $inline);
226
  }
227
  // Load options from the database
228
  $directories = get_option(self::PREFIX . 'directories');
229
  $extensions = get_option(self::PREFIX . 'extensions');
230
  $detailed = get_option(self::PREFIX . 'detailed');
231
+ $inline = get_option(self::PREFIX . 'inline');
232
  // Build the form
233
  ?>
234
  <div class="wrap">
242
  <p><?php echo __('Only files with extensions matching this regular expressions will be processed. This is another important security value. Make sure you only add extensions which are safe for malicious users to have, e.g. archives and possibly images. Do NOT use any expression that could allow a user to download PHP files, even if you think it safe given the Allowed Directories option above.', 'simple-download-monitor'); ?></p>
243
  <p><?php echo __("Default value is <code>zip|rar|7z</code> which only allows download of files ending with <code>.zip</code>, <code>.rar</code> and <code>.7z</code> (the leading <code>.</code> is implicit).", 'simple-download-monitor'); ?></p>
244
  <p><input type="text" name="<?php echo self::PREFIX; ?>extensions" value="<?php echo attribute_escape($extensions); ?>" /></p>
245
+ <h3><?php echo __('Inline files', 'simple-download-monitor'); ?></h3>
246
+ <p><?php echo __('Files whose names match this regular expression will be displayed inline (within a HTML page) rather than downloaded.', 'simple-download-monitor'); ?></p>
247
+ <p><?php echo __("By default, this value is empty - no files will appear inline, all will be downloaded. You may want to place something like <code>\.(jpe?g|gif|png|swf)$</code> here to make images and Flash videos appear inline.", 'simple-download-monitor'); ?></p>
248
+ <p><?php echo __('Note: Unlike the options above, nothing is implied in this regular expression. You <em>must</em> use an explicit <code>\.</code> to denote "start of extension", you <em>must</em> use an explicit <code>$</code> to mark "end of filename", etc.', 'simple-download-monitor'); ?></p>
249
+ <p><input type="text" name="<?php echo self::PREFIX; ?>inline" value="<?php echo attribute_escape($inline); ?>" /></p>
250
  <h3><?php echo __("Store detailed logs?", 'simple-download-monitor'); ?></h3>
251
  <p><?php echo __("If detailed logs are allowed, various information (including exact time of download, user's IP address, referrer etc.) is stored. This can fill your database quickly if you have only a little space or a lot of popular downloads. Otherwise just the total numbers of downloads are stored, consuming significantly less space.", 'simple-download-monitor'); ?></p>
252
  <p><label for="<?php echo self::PREFIX; ?>detailed"><input type="checkbox" name="<?php echo self::PREFIX; ?>detailed" value="1" <?php if ($detailed) echo 'checked="checked" '; ?>/> <?php echo __('Use detailed statistics.', 'simple-download-monitor'); ?></label></p>