Version Description
Download this release
Release Info
Developer | mandsconsulting |
Plugin | Email Before Download |
Version | 5.0.0 |
Comparing to | |
See all releases |
Code changes from version 3.4.1 to 5.0.0
- LICENSE.txt +339 -0
- admin/class-email-before-download-admin.php +419 -0
- admin/class-email-before-download-table.php +167 -0
- admin/css/email-before-download-admin.css +32 -0
- admin/index.php +1 -0
- admin/partials/email-before-download-admin-display.php +39 -0
- checkcurl.php +0 -8
- clearlog.php +0 -31
- download.php +0 -265
- email-before-download.php +31 -1076
- export.php +0 -90
- includes/class-email-before-download-activator.php +72 -0
- includes/class-email-before-download-db.php +152 -0
- includes/class-email-before-download-downloader.php +61 -0
- includes/class-email-before-download-form.php +103 -0
- includes/class-email-before-download-i18n.php +47 -0
- includes/class-email-before-download-loader.php +72 -0
- includes/class-email-before-download-process.php +272 -0
- includes/class-email-before-download-shortcode.php +76 -0
- includes/class-email-before-download.php +116 -0
- includes/index.php +1 -0
- index.php +1 -0
- public/class-email-before-download-public.php +38 -0
- public/css/email-before-download-public.css +15 -0
- public/index.php +1 -0
- public/js/email-before-download-public.js +14 -0
- readme.txt +245 -223
- uninstall.php +40 -0
LICENSE.txt
ADDED
@@ -0,0 +1,339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
5 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
7 |
+
of this license document, but changing it is not allowed.
|
8 |
+
|
9 |
+
Preamble
|
10 |
+
|
11 |
+
The licenses for most software are designed to take away your
|
12 |
+
freedom to share and change it. By contrast, the GNU General Public
|
13 |
+
License is intended to guarantee your freedom to share and change free
|
14 |
+
software--to make sure the software is free for all its users. This
|
15 |
+
General Public License applies to most of the Free Software
|
16 |
+
Foundation's software and to any other program whose authors commit to
|
17 |
+
using it. (Some other Free Software Foundation software is covered by
|
18 |
+
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
+
your programs, too.
|
20 |
+
|
21 |
+
When we speak of free software, we are referring to freedom, not
|
22 |
+
price. Our General Public Licenses are designed to make sure that you
|
23 |
+
have the freedom to distribute copies of free software (and charge for
|
24 |
+
this service if you wish), that you receive source code or can get it
|
25 |
+
if you want it, that you can change the software or use pieces of it
|
26 |
+
in new free programs; and that you know you can do these things.
|
27 |
+
|
28 |
+
To protect your rights, we need to make restrictions that forbid
|
29 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
+
These restrictions translate to certain responsibilities for you if you
|
31 |
+
distribute copies of the software, or if you modify it.
|
32 |
+
|
33 |
+
For example, if you distribute copies of such a program, whether
|
34 |
+
gratis or for a fee, you must give the recipients all the rights that
|
35 |
+
you have. You must make sure that they, too, receive or can get the
|
36 |
+
source code. And you must show them these terms so they know their
|
37 |
+
rights.
|
38 |
+
|
39 |
+
We protect your rights with two steps: (1) copyright the software, and
|
40 |
+
(2) offer you this license which gives you legal permission to copy,
|
41 |
+
distribute and/or modify the software.
|
42 |
+
|
43 |
+
Also, for each author's protection and ours, we want to make certain
|
44 |
+
that everyone understands that there is no warranty for this free
|
45 |
+
software. If the software is modified by someone else and passed on, we
|
46 |
+
want its recipients to know that what they have is not the original, so
|
47 |
+
that any problems introduced by others will not reflect on the original
|
48 |
+
authors' reputations.
|
49 |
+
|
50 |
+
Finally, any free program is threatened constantly by software
|
51 |
+
patents. We wish to avoid the danger that redistributors of a free
|
52 |
+
program will individually obtain patent licenses, in effect making the
|
53 |
+
program proprietary. To prevent this, we have made it clear that any
|
54 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
GNU GENERAL PUBLIC LICENSE
|
60 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
+
|
62 |
+
0. This License applies to any program or other work which contains
|
63 |
+
a notice placed by the copyright holder saying it may be distributed
|
64 |
+
under the terms of this General Public License. The "Program", below,
|
65 |
+
refers to any such program or work, and a "work based on the Program"
|
66 |
+
means either the Program or any derivative work under copyright law:
|
67 |
+
that is to say, a work containing the Program or a portion of it,
|
68 |
+
either verbatim or with modifications and/or translated into another
|
69 |
+
language. (Hereinafter, translation is included without limitation in
|
70 |
+
the term "modification".) Each licensee is addressed as "you".
|
71 |
+
|
72 |
+
Activities other than copying, distribution and modification are not
|
73 |
+
covered by this License; they are outside its scope. The act of
|
74 |
+
running the Program is not restricted, and the output from the Program
|
75 |
+
is covered only if its contents constitute a work based on the
|
76 |
+
Program (independent of having been made by running the Program).
|
77 |
+
Whether that is true depends on what the Program does.
|
78 |
+
|
79 |
+
1. You may copy and distribute verbatim copies of the Program's
|
80 |
+
source code as you receive it, in any medium, provided that you
|
81 |
+
conspicuously and appropriately publish on each copy an appropriate
|
82 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
+
notices that refer to this License and to the absence of any warranty;
|
84 |
+
and give any other recipients of the Program a copy of this License
|
85 |
+
along with the Program.
|
86 |
+
|
87 |
+
You may charge a fee for the physical act of transferring a copy, and
|
88 |
+
you may at your option offer warranty protection in exchange for a fee.
|
89 |
+
|
90 |
+
2. You may modify your copy or copies of the Program or any portion
|
91 |
+
of it, thus forming a work based on the Program, and copy and
|
92 |
+
distribute such modifications or work under the terms of Section 1
|
93 |
+
above, provided that you also meet all of these conditions:
|
94 |
+
|
95 |
+
a) You must cause the modified files to carry prominent notices
|
96 |
+
stating that you changed the files and the date of any change.
|
97 |
+
|
98 |
+
b) You must cause any work that you distribute or publish, that in
|
99 |
+
whole or in part contains or is derived from the Program or any
|
100 |
+
part thereof, to be licensed as a whole at no charge to all third
|
101 |
+
parties under the terms of this License.
|
102 |
+
|
103 |
+
c) If the modified program normally reads commands interactively
|
104 |
+
when run, you must cause it, when started running for such
|
105 |
+
interactive use in the most ordinary way, to print or display an
|
106 |
+
announcement including an appropriate copyright notice and a
|
107 |
+
notice that there is no warranty (or else, saying that you provide
|
108 |
+
a warranty) and that users may redistribute the program under
|
109 |
+
these conditions, and telling the user how to view a copy of this
|
110 |
+
License. (Exception: if the Program itself is interactive but
|
111 |
+
does not normally print such an announcement, your work based on
|
112 |
+
the Program is not required to print an announcement.)
|
113 |
+
|
114 |
+
These requirements apply to the modified work as a whole. If
|
115 |
+
identifiable sections of that work are not derived from the Program,
|
116 |
+
and can be reasonably considered independent and separate works in
|
117 |
+
themselves, then this License, and its terms, do not apply to those
|
118 |
+
sections when you distribute them as separate works. But when you
|
119 |
+
distribute the same sections as part of a whole which is a work based
|
120 |
+
on the Program, the distribution of the whole must be on the terms of
|
121 |
+
this License, whose permissions for other licensees extend to the
|
122 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
+
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
282 |
+
How to Apply These Terms to Your New Programs
|
283 |
+
|
284 |
+
If you develop a new program, and you want it to be of the greatest
|
285 |
+
possible use to the public, the best way to achieve this is to make it
|
286 |
+
free software which everyone can redistribute and change under these terms.
|
287 |
+
|
288 |
+
To do so, attach the following notices to the program. It is safest
|
289 |
+
to attach them to the start of each source file to most effectively
|
290 |
+
convey the exclusion of warranty; and each file should have at least
|
291 |
+
the "copyright" line and a pointer to where the full notice is found.
|
292 |
+
|
293 |
+
<one line to give the program's name and a brief idea of what it does.>
|
294 |
+
Copyright (C) <year> <name of author>
|
295 |
+
|
296 |
+
This program is free software; you can redistribute it and/or modify
|
297 |
+
it under the terms of the GNU General Public License as published by
|
298 |
+
the Free Software Foundation; either version 2 of the License, or
|
299 |
+
(at your option) any later version.
|
300 |
+
|
301 |
+
This program is distributed in the hope that it will be useful,
|
302 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
+
GNU General Public License for more details.
|
305 |
+
|
306 |
+
You should have received a copy of the GNU General Public License along
|
307 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
+
|
310 |
+
Also add information on how to contact you by electronic and paper mail.
|
311 |
+
|
312 |
+
If the program is interactive, make it output a short notice like this
|
313 |
+
when it starts in an interactive mode:
|
314 |
+
|
315 |
+
Gnomovision version 69, Copyright (C) year name of author
|
316 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
+
This is free software, and you are welcome to redistribute it
|
318 |
+
under certain conditions; type `show c' for details.
|
319 |
+
|
320 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
+
parts of the General Public License. Of course, the commands you use may
|
322 |
+
be called something other than `show w' and `show c'; they could even be
|
323 |
+
mouse-clicks or menu items--whatever suits your program.
|
324 |
+
|
325 |
+
You should also get your employer (if you work as a programmer) or your
|
326 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
+
necessary. Here is a sample; alter the names:
|
328 |
+
|
329 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
+
|
332 |
+
<signature of Ty Coon>, 1 April 1989
|
333 |
+
Ty Coon, President of Vice
|
334 |
+
|
335 |
+
This General Public License does not permit incorporating your program into
|
336 |
+
proprietary programs. If your program is a subroutine library, you may
|
337 |
+
consider it more useful to permit linking proprietary applications with the
|
338 |
+
library. If this is what you want to do, use the GNU Lesser General
|
339 |
+
Public License instead of this License.
|
admin/class-email-before-download-admin.php
ADDED
@@ -0,0 +1,419 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
*
|
6 |
+
* @since 5.0.0
|
7 |
+
* @package Email_Before_Download
|
8 |
+
* @subpackage Email_Before_Download/admin
|
9 |
+
* @author M & S Consulting
|
10 |
+
*/
|
11 |
+
class Email_Before_Download_Admin
|
12 |
+
{
|
13 |
+
|
14 |
+
private $plugin_name;
|
15 |
+
private $version;
|
16 |
+
private $option_name = 'email_before_download';
|
17 |
+
private $page_title = "Email Before Download";
|
18 |
+
private $db;
|
19 |
+
private $options = [
|
20 |
+
['name' => '_support', 'type' => 'section','label' => "Support Links"],
|
21 |
+
['name' => '_general', 'type' => 'section','label' => "General Settings"],
|
22 |
+
['name' => '_delivery_format', 'type' => 'setting', 'label' => "Default Delivery Format", 'section' => '_general'],
|
23 |
+
['name' => '_expire', 'type' => 'setting', 'label' => "Default Link Expiration Time", 'section' => '_general'],
|
24 |
+
['name' => '_forbidden', 'type' => 'setting', 'label' => "Forbidden Domains", 'section' => '_general'],
|
25 |
+
['name' => '_inline', 'type' => 'section','label' => "Inline Link Settings"],
|
26 |
+
['name' => '_link_format', 'type' => 'setting', 'label' => "Default Link Target", 'section' => '_inline'],
|
27 |
+
['name' => '_link_css', 'type' => 'setting', 'label' => "Custom CSS", 'section' => '_inline'],
|
28 |
+
['name' => '_html_before', 'type' => 'setting', 'label' => "HTML Before Link", 'section' => '_inline'],
|
29 |
+
['name' => '_html_after', 'type' => 'setting', 'label' => "HTML After Link", 'section' => '_inline'],
|
30 |
+
['name' => '_email', 'type' => 'section','label' => "Email Settings"],
|
31 |
+
['name' => '_single_email', 'type' => 'setting', 'label' => "Single URL Template", 'section' => '_email'],
|
32 |
+
['name' => '_multi_email', 'type' => 'setting', 'label' => "Multiple URL Template", 'section' => '_email'],
|
33 |
+
['name' => '_attachment', 'type' => 'setting', 'label' => "Default Attachment", 'section' => '_email'],
|
34 |
+
['name' => '_subject', 'type' => 'setting', 'label' => "Email Subject", 'section' => '_email'],
|
35 |
+
['name' => '_from_email', 'type' => 'setting', 'label' => "Delivery Email", 'section' => '_email'],
|
36 |
+
['name' => '_other', 'type' => 'section','label' => "Additional Settings"],
|
37 |
+
['name' => '_default_cf7', 'type' => 'setting', 'label' => "Default CF7 Form ID", 'section' => '_other'],
|
38 |
+
['name' => '_multi_check', 'type' => 'setting', 'label' => "Default Checkbox State", 'section' => '_other'],
|
39 |
+
['name' => '_hidden_form', 'type' => 'setting', 'label' => "Default Hide Form", 'section' => '_other'],
|
40 |
+
['name' => '_radio', 'type' => 'setting', 'label' => "Default Radio Buttons", 'section' => '_other']
|
41 |
+
];
|
42 |
+
|
43 |
+
public function __construct($plugin_name, $version)
|
44 |
+
{
|
45 |
+
$this->plugin_name = $plugin_name;
|
46 |
+
$this->version = $version;
|
47 |
+
$this->db = new Email_Before_Download_DB();
|
48 |
+
}
|
49 |
+
|
50 |
+
public function enqueue_styles()
|
51 |
+
{
|
52 |
+
wp_enqueue_style($this->plugin_name,
|
53 |
+
plugin_dir_url(__FILE__) . 'css/email-before-download-admin.css', array(),
|
54 |
+
$this->version,
|
55 |
+
'all');
|
56 |
+
}
|
57 |
+
|
58 |
+
public function enqueue_scripts()
|
59 |
+
{
|
60 |
+
wp_enqueue_script($this->plugin_name,
|
61 |
+
plugin_dir_url(__FILE__) . 'js/email-before-download-admin.js',
|
62 |
+
array('jquery'),
|
63 |
+
$this->version,
|
64 |
+
true);
|
65 |
+
}
|
66 |
+
|
67 |
+
public function add_options_page()
|
68 |
+
{
|
69 |
+
$this->plugin_screen_hook_suffix = add_options_page(
|
70 |
+
__('Email Before Download', 'email-before-download'),
|
71 |
+
__('Email Before Download', 'email-before-download'),
|
72 |
+
'manage_options',
|
73 |
+
$this->plugin_name,
|
74 |
+
array($this, 'display_options_page')
|
75 |
+
);
|
76 |
+
add_submenu_page(
|
77 |
+
null,
|
78 |
+
'Email Before Download Links',
|
79 |
+
'',
|
80 |
+
'administrator',
|
81 |
+
$this->plugin_name.'-links',
|
82 |
+
array($this,'display_links_page'));
|
83 |
+
add_submenu_page(
|
84 |
+
null,
|
85 |
+
'Email Before Download Logs',
|
86 |
+
'',
|
87 |
+
'administrator',
|
88 |
+
$this->plugin_name.'-logs',
|
89 |
+
array($this,'display_logs_page'));
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
public function display_options_page()
|
94 |
+
{
|
95 |
+
include_once 'partials/email-before-download-admin-display.php';
|
96 |
+
}
|
97 |
+
public function display_links_page()
|
98 |
+
{
|
99 |
+
$wp_table = new Email_Before_download_Table();
|
100 |
+
$wp_table->set_table('links');
|
101 |
+
$wp_table->prepare_items();
|
102 |
+
$title = $this->page_title. " Links";
|
103 |
+
include_once 'partials/email-before-download-admin-table.php';
|
104 |
+
}
|
105 |
+
public function display_logs_page()
|
106 |
+
{
|
107 |
+
$wp_table = new Email_Before_download_Table();
|
108 |
+
$wp_table->set_table('logs');
|
109 |
+
$wp_table->prepare_items();
|
110 |
+
$title = $this->page_title. " Logs";
|
111 |
+
include_once 'partials/email-before-download-admin-table.php';
|
112 |
+
}
|
113 |
+
function print_csv()
|
114 |
+
{
|
115 |
+
if ( ! current_user_can( 'manage_options' ) )
|
116 |
+
return;
|
117 |
+
if(isset($_GET['table'])){
|
118 |
+
$table = $_GET['table'];
|
119 |
+
$csv = $this->db->export($table);
|
120 |
+
$filename = $table.'-'.date('Y-m-d H:i:s',time()).'.csv';
|
121 |
+
header('Content-Type: application/csv');
|
122 |
+
header('Content-Disposition: attachment; filename='.$filename);
|
123 |
+
header('Pragma: no-cache');
|
124 |
+
echo $csv;
|
125 |
+
}
|
126 |
+
|
127 |
+
return;
|
128 |
+
|
129 |
+
}
|
130 |
+
public function purge_data()
|
131 |
+
{
|
132 |
+
if ( ! current_user_can( 'manage_options' ) )
|
133 |
+
return;
|
134 |
+
if(isset($_GET['table'])) {
|
135 |
+
$table = $_GET['table'];
|
136 |
+
$this->db->clean_up($table);
|
137 |
+
}
|
138 |
+
return;
|
139 |
+
|
140 |
+
}
|
141 |
+
public function build_settings()
|
142 |
+
{
|
143 |
+
if( !session_id() )
|
144 |
+
session_start();
|
145 |
+
|
146 |
+
foreach ($this->options as $option){
|
147 |
+
if($option['type'] == 'section'){
|
148 |
+
add_settings_section(
|
149 |
+
$this->option_name . $option['name'],
|
150 |
+
$option['label'],
|
151 |
+
array($this, $this->option_name . $option['name'].'_cb'),
|
152 |
+
$this->plugin_name
|
153 |
+
);
|
154 |
+
}else{
|
155 |
+
add_settings_field(
|
156 |
+
$this->option_name . $option['name'],
|
157 |
+
$option['label'],
|
158 |
+
array($this, $this->option_name . $option['name'].'_cb'),
|
159 |
+
$this->plugin_name,
|
160 |
+
$this->option_name . $option['section'],
|
161 |
+
array('label_for' => $this->option_name . $option['name'])
|
162 |
+
);
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
public function register_settings()
|
169 |
+
{
|
170 |
+
foreach ($this->options as $option){
|
171 |
+
if($option['type'] == 'setting')
|
172 |
+
register_setting(
|
173 |
+
$this->plugin_name,
|
174 |
+
$this->option_name . $option['name'],
|
175 |
+
'string'
|
176 |
+
);
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
public function email_before_download_inline_cb()
|
181 |
+
{
|
182 |
+
echo '<div class="ebd_section_description">' . __('The following settings apply if you selected "Inline Link" or "Both" as the Delivery Format ', 'email-before-download') . '</div>';
|
183 |
+
}
|
184 |
+
|
185 |
+
public function email_before_download_email_cb()
|
186 |
+
{
|
187 |
+
echo '<div class="ebd_section_description">' . __('The following settings apply if you selected "Email" or "Both" as the Delivery Format ', 'email-before-download') . '</div>';
|
188 |
+
}
|
189 |
+
public function email_before_download_general_cb()
|
190 |
+
{
|
191 |
+
echo '<div class="ebd_section_description">' . __('General plugin settings ', 'email-before-download') . '</div>';
|
192 |
+
}
|
193 |
+
public function email_before_download_support_cb()
|
194 |
+
{
|
195 |
+
echo "<span class='subtitle'>". __('Email Before Download started as a plugin we developed for personal in-house needs. We realized this could be useful to other WordPress users. At that point, we made the decision to release the plugin for anyone to use. We apologize if we cannot provide support to you on an individual or timely basis. However, please feel free to post in the WordPress forums where we hope your questions can be answered by the WordPress community.', 'email-before-download')."</span>";
|
196 |
+
echo "<ul>
|
197 |
+
<li><a href=\"https://www.mandsconsulting.com/products/wp-email-before-downloadic\" target=\"_blank\">".__('Plugin Homepage at M&S Consulting with Live Demos and Test Download','email-before-download')."</a></li>
|
198 |
+
<li><a href=\"https://wordpress.org/plugins/email-before-download/V\" target=\"_blank\">". __('Plugin Homepage at WordPress', 'email-before-download')."</a></li>
|
199 |
+
<li><a href=\"https://wordpress.org/plugins/email-before-download/#changelog\" target=\"_blank\">".__('Plugin Changelog: Current and Past Releases','email-before-download')."</a></li>
|
200 |
+
<li><a href=\"https://wordpress.org/support/topic-tag/email-before-download/?forum_id=10\" target=\"_blank\">".__('Plugin Support Forums','email-before-download')."</a></li>
|
201 |
+
</ul>";
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
public function email_before_download_delivery_format_cb()
|
206 |
+
{
|
207 |
+
?>
|
208 |
+
<select class="ebd_input" name="<?php echo $this->option_name . '_delivery_format' ?>">
|
209 |
+
<option value="inline link" <?php if (get_option($this->option_name . '_delivery_format') == 'inline link') echo 'selected="selected"'; ?> >
|
210 |
+
<?php _e('Inline Link','email-before-download'); ?>
|
211 |
+
</option>
|
212 |
+
<option value="send email" <?php if (get_option($this->option_name . '_delivery_format') == 'send email') echo 'selected="selected"'; ?> >
|
213 |
+
<?php _e('Send Email','email-before-download'); ?>
|
214 |
+
</option>
|
215 |
+
<option value="both" <?php if (get_option($this->option_name . '_delivery_format') == 'both') echo 'selected="selected"'; ?> >
|
216 |
+
<?php _e('Both','email-before-download'); ?>
|
217 |
+
</option>
|
218 |
+
</select>
|
219 |
+
<span class="subtitle"> <?php _e('Can be overridden in the shortcode with: delivery_format="inline link/send email/both" ','email-before-downlaod'); ?></span>
|
220 |
+
|
221 |
+
<?php
|
222 |
+
}
|
223 |
+
|
224 |
+
|
225 |
+
|
226 |
+
public function email_before_download_expire_cb()
|
227 |
+
{
|
228 |
+
?>
|
229 |
+
<select class="ebd_input" id="<?php echo $this->option_name . '_expire' ?>"
|
230 |
+
name="<?php echo $this->option_name . '_expire' ?>">
|
231 |
+
<option value="0" <?php if (get_option($this->option_name . '_expire') == '0') echo 'selected="selected"'; ?> >
|
232 |
+
Never
|
233 |
+
</option>
|
234 |
+
<option value="1 minute" <?php if (get_option($this->option_name . '_expire') == '1 minute') echo 'selected="selected"'; ?> >
|
235 |
+
1 min
|
236 |
+
</option>
|
237 |
+
<option value="3 minute" <?php if (get_option($this->option_name . '_expire') == '3 minute') echo 'selected="selected"'; ?> >
|
238 |
+
3 min
|
239 |
+
</option>
|
240 |
+
<option value="10 minute" <?php if (get_option($this->option_name . '_expire') == '10 minute') echo 'selected="selected"'; ?> >
|
241 |
+
10 min
|
242 |
+
</option>
|
243 |
+
<option value="30 minute" <?php if (get_option($this->option_name . '_expire') == '30 minute') echo 'selected="selected"'; ?> >
|
244 |
+
30 min
|
245 |
+
</option>
|
246 |
+
<option value="1 hour" <?php if (get_option($this->option_name . '_expire') == '1 hour') echo 'selected="selected"'; ?> >
|
247 |
+
1 hr
|
248 |
+
</option>
|
249 |
+
<option value="12 hour" <?php if (get_option($this->option_name . '_expire') == '12 hour') echo 'selected="selected"'; ?> >
|
250 |
+
12 hr
|
251 |
+
</option>
|
252 |
+
<option value="1 day" <?php if (get_option($this->option_name . '_expire') == '1 day') echo 'selected="selected"'; ?> >
|
253 |
+
1 day
|
254 |
+
</option>
|
255 |
+
<option value="1 week" <?php if (get_option($this->option_name . '_expire') == '1 week') echo 'selected="selected"'; ?> >
|
256 |
+
1 week
|
257 |
+
</option>
|
258 |
+
</select>
|
259 |
+
<span class="subtitle"> <?php _e('This option expires the link after a set period of time. <br>It can be overridden in the shortcode with: expire_time="X minute/hour/day/week".','email-before-downlaod'); ?></span>
|
260 |
+
<?php
|
261 |
+
}
|
262 |
+
|
263 |
+
public function email_before_download_forbidden_cb()
|
264 |
+
{
|
265 |
+
?>
|
266 |
+
<textarea class="ebd_input" cols="40" rows="10"
|
267 |
+
name="<?php echo $this->option_name . '_forbidden' ?>"><?php echo get_option($this->option_name . '_forbidden'); ?></textarea>
|
268 |
+
<span class="subtitle"><?php _e('A comma separated list of the forbidden domains','email-before-download'); ?></span>
|
269 |
+
<?php
|
270 |
+
}
|
271 |
+
|
272 |
+
public function email_before_download_link_format_cb()
|
273 |
+
{
|
274 |
+
?>
|
275 |
+
<select class="ebd_input" name="<?php echo $this->option_name . '_link_format' ?>">
|
276 |
+
<option value="_blank" <?php if (get_option($this->option_name . '_link_format') == '_blank') echo 'selected="selected"'; ?> >
|
277 |
+
_blank
|
278 |
+
</option>
|
279 |
+
<option value="_self" <?php if (get_option($this->option_name . '_link_format') == '_self') echo 'selected="selected"'; ?> >
|
280 |
+
_self
|
281 |
+
</option>
|
282 |
+
</select>
|
283 |
+
<span class="subtitle"><i> <?php _e('This option can be overridden in the shortcode with: link_format="_self/_blank"','email-before-download'); ?></i></span>
|
284 |
+
<?php
|
285 |
+
}
|
286 |
+
|
287 |
+
public function email_before_download_link_css_cb()
|
288 |
+
{
|
289 |
+
?>
|
290 |
+
<input type="text" size="40" name="<?php echo $this->option_name . '_link_css' ?>"
|
291 |
+
value="<?php echo get_option($this->option_name . '_link_css'); ?>"/>
|
292 |
+
<span class="subtitle"> <?php _e('CSS class used to render the div and the link','email-before-download'); ?></span>
|
293 |
+
<?php
|
294 |
+
}
|
295 |
+
|
296 |
+
public function email_before_download_html_before_cb()
|
297 |
+
{
|
298 |
+
?>
|
299 |
+
<input type="text" size="40" name="<?php echo $this->option_name . '_html_before' ?>"
|
300 |
+
value="<?php echo get_option($this->option_name . '_html_before'); ?>"/>
|
301 |
+
<span class="subtitle"> <?php _e('HTML you want to be added before the link','email-before-dowjnload'); ?></span>
|
302 |
+
<?php
|
303 |
+
}
|
304 |
+
|
305 |
+
public function email_before_download_html_after_cb()
|
306 |
+
{
|
307 |
+
?>
|
308 |
+
<input type="text" size="40" name="<?php echo $this->option_name . '_html_after' ?>"
|
309 |
+
value="<?php echo get_option($this->option_name . '_html_after'); ?>"/>
|
310 |
+
<span class="subtitle"> <?php _e('HTML you want to be added after the link','email-before-download'); ?> </span>
|
311 |
+
<?php
|
312 |
+
}
|
313 |
+
|
314 |
+
public function email_before_download_single_email_cb()
|
315 |
+
{
|
316 |
+
?>
|
317 |
+
<textarea class="ebd_input" cols="40" rows="10"
|
318 |
+
name="<?php echo $this->option_name . '_single_email' ?>"><?php echo get_option($this->option_name . '_single_email'); ?></textarea>
|
319 |
+
<span class="subtitle"> <?php _e("[file_name] and [file_url] are specific placeholders for Email Before Download. Placeholders from Contact Form 7 can be used as long as your form has the same fields. If a placeholder is used with no corresponding form field, it will be ignored.",'email-before-download'); ?><br>
|
320 |
+
<br><?php _e('Note. If you leave this field empty, The default template will be used.','email-before-download'); ?>
|
321 |
+
<p><?php _e("The Default template is:<br><strong> Here is the download for",'email-before-download'); echo htmlentities('<a href="[file_url]">[file_name]</a>'); _e("that you requested.</strong>",'email-before-download'); ?>
|
322 |
+
</p></span>
|
323 |
+
<?php
|
324 |
+
}
|
325 |
+
|
326 |
+
public function email_before_download_multi_email_cb()
|
327 |
+
{
|
328 |
+
?>
|
329 |
+
<textarea class="ebd_input" cols="40" rows="10"
|
330 |
+
name="<?php echo $this->option_name . '_multi_email' ?>"><?php echo get_option($this->option_name . '_multi_email'); ?></textarea>
|
331 |
+
<span class="subtitle"><?php _e('The same rules apply to this template as the single URL template. <br>Use the following placeholder for multiple urls: [file_urls]</br> If this is left blank, a list of URLs will be sent.','email-before-download'); ?> </span>
|
332 |
+
<?php
|
333 |
+
}
|
334 |
+
|
335 |
+
public function email_before_download_attachment_cb()
|
336 |
+
{
|
337 |
+
?>
|
338 |
+
<input type="checkbox" size="40" id="<?php echo $this->option_name . '_attachment' ?>"
|
339 |
+
name="<?php echo $this->option_name . '_attachment' ?>"
|
340 |
+
value="1" <?php if (get_option($this->option_name . '_attachment')) echo 'checked="checked"'; ?> />
|
341 |
+
<span class="subtitle"><?php _e('This can only be applied to the files uploaded using Download Monitor plugin.<br> This option can be overridden in the shorcode with: attachment="yes/no"','email-before-download');?></span>
|
342 |
+
<?php
|
343 |
+
}
|
344 |
+
|
345 |
+
public function email_before_download_subject_cb()
|
346 |
+
{
|
347 |
+
?>
|
348 |
+
<input type="text" size="40" name="<?php echo $this->option_name . '_subject' ?>"
|
349 |
+
value="<?php echo get_option($this->option_name . '_subject'); ?>"/>
|
350 |
+
<span class="subtitle"><?php _e('If this field is left blank, the default subject is: "Your requested file(s)".','email-before-download');?></span>
|
351 |
+
<?php
|
352 |
+
}
|
353 |
+
public function email_before_download_from_email_cb()
|
354 |
+
{
|
355 |
+
?>
|
356 |
+
<input type="text" size="40" name="<?php echo $this->option_name . '_from_email' ?>"
|
357 |
+
value="<?php echo get_option($this->option_name . '_from_email'); ?>"/>
|
358 |
+
<span class="subtitle"><?php _e('Email address used to deliver the download links. If this field is left blank, the default wordpress email will be used..','email-before-download');?></span>
|
359 |
+
<?php
|
360 |
+
}
|
361 |
+
|
362 |
+
public function email_before_download_other_cb()
|
363 |
+
{
|
364 |
+
echo '<div class="ebd_section_description">' . __('The following settings only apply if you have multiple urls in you shortcode ', 'email-before-download') . '</div>';
|
365 |
+
}
|
366 |
+
public function email_before_download_default_cf7_cb()
|
367 |
+
{
|
368 |
+
?>
|
369 |
+
<input type="text" size="40" name="<?php echo $this->option_name . '_default_cf7' ?>"
|
370 |
+
value="<?php echo get_option($this->option_name . '_default_cf7'); ?>"/>
|
371 |
+
<span class="subtitle"> <?php _e('If you want to use the same form for all your downloads.</br> This can be overwritten in the shortcode with: contact-form-id="X" ','email-before-download'); ?></span>
|
372 |
+
<?php
|
373 |
+
}
|
374 |
+
|
375 |
+
public function email_before_download_multi_check_cb()
|
376 |
+
{
|
377 |
+
?>
|
378 |
+
<select class="ebd_input" name="<?php echo $this->option_name . '_multi_check' ?>">
|
379 |
+
<option value="checked" <?php if (get_option($this->option_name . '_multi_check') == 'checked') echo 'selected="selected"'; ?> >
|
380 |
+
Checked
|
381 |
+
</option>
|
382 |
+
<option value="" <?php if (get_option($this->option_name . '_multi_check') == '') echo 'selected="selected"'; ?> >
|
383 |
+
Unchecked
|
384 |
+
</option>
|
385 |
+
</select>
|
386 |
+
<span class="subtitle"><?php _e('The default state of the Multiple Checkboxes.<br> This can be overridden in the shortcode with: checked="yes/no"','email-before-download'); ?></span>
|
387 |
+
<?php
|
388 |
+
}
|
389 |
+
|
390 |
+
public function email_before_download_hidden_form_cb()
|
391 |
+
{
|
392 |
+
?>
|
393 |
+
<select class="ebd_input" name="<?php echo $this->option_name . '_hidden_form' ?>">
|
394 |
+
<option value="yes" <?php if (get_option($this->option_name . '_hidden_form') == 'yes') echo 'selected="selected"'; ?> >
|
395 |
+
<?php _e('Yes','email-before-download'); ?>
|
396 |
+
</option>
|
397 |
+
<option value="no" <?php if (get_option($this->option_name . '_hidden_form') == 'no') echo 'selected="selected"'; ?> >
|
398 |
+
<?php _e('No','email-before-download'); ?>
|
399 |
+
</option>
|
400 |
+
</select>
|
401 |
+
<span class="subtitle"> <?php _e('Hide the form until user selects a download. <br> This can be overriden in the shortcode with hide_form="yes/no"','email-before-download'); ?></span>
|
402 |
+
<?php
|
403 |
+
}
|
404 |
+
|
405 |
+
public function email_before_download_radio_cb()
|
406 |
+
{
|
407 |
+
?>
|
408 |
+
<select class="ebd_input" name="<?php echo $this->option_name . '_radio' ?>">
|
409 |
+
<option value="yes" <?php if (get_option($this->option_name . '_radio') == 'yes') echo 'selected="selected"'; ?> >
|
410 |
+
<?php _e('Yes','email-before-download'); ?>
|
411 |
+
</option>
|
412 |
+
<option value="no" <?php if ((get_option($this->option_name . '_radio') == 'no') || (!get_option($this->option_name . '_radio'))) echo 'selected="selected"'; ?> >
|
413 |
+
<?php _e('No','email-before-download'); ?>
|
414 |
+
</option>
|
415 |
+
</select>
|
416 |
+
<span class="subtitle"><?php _e('Radio buttons instead of checkboxes.<br> This can be overridden in the shortcode with: radio="yes/no"','email-before-download'); ?></span>
|
417 |
+
<?php
|
418 |
+
}
|
419 |
+
}
|
admin/class-email-before-download-table.php
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @since 5.0.0
|
4 |
+
* @package Email_Before_Download
|
5 |
+
* @subpackage Email_Before_Download/admin
|
6 |
+
* @author M & S Consulting
|
7 |
+
*/
|
8 |
+
if (!class_exists('WP_List_Table')) {
|
9 |
+
require_once(ABSPATH . 'wp-admin/includes/screen.php');
|
10 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
11 |
+
}
|
12 |
+
|
13 |
+
class Email_Before_download_Table extends WP_List_Table
|
14 |
+
{
|
15 |
+
|
16 |
+
public $atts;
|
17 |
+
public $db;
|
18 |
+
|
19 |
+
function __construct()
|
20 |
+
{
|
21 |
+
parent::__construct(array(
|
22 |
+
'singular' => 'ebd_download',
|
23 |
+
'plural' => 'ebd_downloads',
|
24 |
+
'ajax' => false
|
25 |
+
));
|
26 |
+
global $wpdb;
|
27 |
+
$this->db = $wpdb;
|
28 |
+
}
|
29 |
+
|
30 |
+
function get_columns()
|
31 |
+
{
|
32 |
+
return $this->atts['columns'];
|
33 |
+
}
|
34 |
+
|
35 |
+
public function get_sortable_columns()
|
36 |
+
{
|
37 |
+
return $this->atts['sortable'];
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
function prepare_items()
|
42 |
+
{
|
43 |
+
global $_wp_column_headers;
|
44 |
+
$table = $this->atts['table'];
|
45 |
+
$screen = get_current_screen();
|
46 |
+
$query = "SELECT * FROM $table";
|
47 |
+
$orderby = !empty($_GET["orderby"]) ? esc_sql($_GET["orderby"]) : '';
|
48 |
+
$order = !empty($_GET["order"]) ? esc_sql($_GET["order"]) : '';
|
49 |
+
if (!empty($orderby) & !empty($order)) {
|
50 |
+
$query .= ' ORDER BY ' . $orderby . ' ' . $order;
|
51 |
+
}else {
|
52 |
+
$query .= " ORDER BY time_requested DESC";
|
53 |
+
}
|
54 |
+
|
55 |
+
$totalitems = $this->db->query($query);
|
56 |
+
$perpage = 25;
|
57 |
+
$paged = !empty($_GET["paged"]) ? esc_sql($_GET["paged"]) : '';
|
58 |
+
if (empty($paged) || !is_numeric($paged) || $paged <= 0) {
|
59 |
+
$paged = 1;
|
60 |
+
}
|
61 |
+
$totalpages = ceil($totalitems / $perpage);
|
62 |
+
if (!empty($paged) && !empty($perpage)) {
|
63 |
+
$offset = ($paged - 1) * $perpage;
|
64 |
+
$query .= ' LIMIT ' . (int)$offset . ',' . (int)$perpage;
|
65 |
+
$this->set_pagination_args(array(
|
66 |
+
"total_items" => $totalitems,
|
67 |
+
"total_pages" => $totalpages,
|
68 |
+
"per_page" => $perpage,
|
69 |
+
));
|
70 |
+
$columns = $this->get_columns();
|
71 |
+
$_wp_column_headers[$screen->id] = $columns;
|
72 |
+
$this->_column_headers = array(
|
73 |
+
$this->get_columns(),
|
74 |
+
array(),
|
75 |
+
$this->get_sortable_columns(),
|
76 |
+
);
|
77 |
+
$this->items = $this->db->get_results($query);
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
function display_rows()
|
82 |
+
{
|
83 |
+
$records = $this->items;
|
84 |
+
list($columns, $hidden) = $this->get_column_info();
|
85 |
+
if (!empty($records)) {
|
86 |
+
foreach ($records as $rec) {
|
87 |
+
if (isset($rec->id)) {
|
88 |
+
echo '<tr id="record_' . $rec->id . '">';
|
89 |
+
} else {
|
90 |
+
echo '<tr class="record">';
|
91 |
+
}
|
92 |
+
foreach ($columns as $column_name => $column_display_name) {
|
93 |
+
//Style attributes for each col
|
94 |
+
$class = "class='$column_name column-$column_name'";
|
95 |
+
$style = "";
|
96 |
+
if (in_array($column_name, $hidden)) $style = ' style="display:none;"';
|
97 |
+
$attributes = $class . $style;
|
98 |
+
if ($column_name == "is_downloaded") {
|
99 |
+
$rec->$column_name = ($rec->$column_name < 1 ? 'No' : 'Yes');
|
100 |
+
} elseif ($column_name == "expire_time") {
|
101 |
+
$rec->$column_name = ($rec->$column_name ? $rec->$column_name : "Doesn't Expire");
|
102 |
+
if ($rec->$column_name != "Doesn't Expire") {
|
103 |
+
if (time() > $rec->$column_name) {
|
104 |
+
$rec->$column_name = "<span style='color:red'>".date('Y-m-d H:i:s', stripslashes($rec->$column_name))."</span>";
|
105 |
+
}
|
106 |
+
}
|
107 |
+
} elseif ($column_name == "posted_data") {
|
108 |
+
$rec->$column_name = "<div class='ebd_xml'>" . htmlentities($rec->$column_name) . "</div>";
|
109 |
+
}
|
110 |
+
if ($this->isValidTimeStamp($rec->$column_name)) {
|
111 |
+
echo '<td ' . $attributes . '>' . date('Y-m-d H:i:s', stripslashes($rec->$column_name)) . '</td>';
|
112 |
+
} else {
|
113 |
+
echo '<td ' . $attributes . '>' . stripslashes($rec->$column_name) . '</td>';
|
114 |
+
}
|
115 |
+
}
|
116 |
+
echo '</tr>';
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
public function set_table($table)
|
122 |
+
{
|
123 |
+
if ($table == 'links') {
|
124 |
+
$this->atts = [
|
125 |
+
'table' => $this->db->prefix . "ebd_link",
|
126 |
+
'columns' => array(
|
127 |
+
'email' => __('Email'),
|
128 |
+
'is_downloaded' => __('Downloaded'),
|
129 |
+
'time_requested' => __('Time Requested'),
|
130 |
+
'delivered_as' => __('Delivered As'),
|
131 |
+
'expire_time' => "Expires"
|
132 |
+
),
|
133 |
+
'sortable' => array(
|
134 |
+
'email' => ['email', true],
|
135 |
+
'is_downloaded' => ['is_downloaded', true],
|
136 |
+
'time_requested' => ['time_requested', true],
|
137 |
+
'delivered_as' => ['delivered_as', true],
|
138 |
+
'expire_time' => ['expire_time', true],
|
139 |
+
),
|
140 |
+
'purge_text' => __("Purge Expired Links",'email-before-download')];
|
141 |
+
} else {
|
142 |
+
$this->atts = [
|
143 |
+
'table' => $this->db->prefix . "ebd_posted_data",
|
144 |
+
'columns' => array(
|
145 |
+
'email' => __('Email'),
|
146 |
+
'user_name' => __('Name'),
|
147 |
+
'time_requested' => __('Time Requested'),
|
148 |
+
'posted_data' => "XML Data"
|
149 |
+
),
|
150 |
+
'sortable' => array(
|
151 |
+
'email' => ['email', true],
|
152 |
+
'is_downloaded' => ['is_downloaded', true],
|
153 |
+
'time_requested' => ['time_requested', true],
|
154 |
+
),
|
155 |
+
'purge_text' => __("Purge Logs",'email-before-download')];
|
156 |
+
}
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
public function isValidTimeStamp($timestamp)
|
161 |
+
{
|
162 |
+
return ((string)(int)$timestamp === $timestamp)
|
163 |
+
&& ($timestamp <= PHP_INT_MAX)
|
164 |
+
&& ($timestamp >= ~PHP_INT_MAX)
|
165 |
+
&& (strlen($timestamp) > 9);
|
166 |
+
}
|
167 |
+
}
|
admin/css/email-before-download-admin.css
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* All of the CSS for your admin-specific functionality should be
|
3 |
+
* included in this file.
|
4 |
+
*/
|
5 |
+
|
6 |
+
.ebd_section_description {
|
7 |
+
background: #fff;
|
8 |
+
border-left: 4px solid #fff;
|
9 |
+
box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
10 |
+
margin: 5px 15px 2px;
|
11 |
+
padding: 1px 12px;
|
12 |
+
}
|
13 |
+
.form-table tr {
|
14 |
+
border-bottom: 1px solid #ddd;
|
15 |
+
}
|
16 |
+
span.subtitle {
|
17 |
+
float: right;
|
18 |
+
width: 50%;
|
19 |
+
}
|
20 |
+
.ebd_input {
|
21 |
+
min-width: 300px;
|
22 |
+
}
|
23 |
+
.ebd_xml {
|
24 |
+
overflow: hidden;
|
25 |
+
display: -webkit-box;
|
26 |
+
-webkit-line-clamp: 2;
|
27 |
+
-webkit-box-orient: vertical;
|
28 |
+
}
|
29 |
+
.ebd_xml:hover {
|
30 |
+
cursor: pointer;
|
31 |
+
overflow: auto;
|
32 |
+
}
|
admin/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
admin/partials/email-before-download-admin-display.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Provide a admin area view for the plugin
|
5 |
+
*
|
6 |
+
* This file is used to markup the admin-facing aspects of the plugin.
|
7 |
+
*
|
8 |
+
* @since 5.0.0
|
9 |
+
* @package Email_Before_Download
|
10 |
+
* @subpackage Email_Before_Download/admin/partials
|
11 |
+
* @author M & S Consulting
|
12 |
+
*/
|
13 |
+
?>
|
14 |
+
|
15 |
+
<!-- This file should primarily consist of HTML with a little bit of PHP. -->
|
16 |
+
<div class="wrap">
|
17 |
+
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
|
18 |
+
<div class="buttons">
|
19 |
+
<a href="<?php echo admin_url( "options-general.php?page=email-before-download-links" ); ?>" class="button button-primary">
|
20 |
+
<?php _e('View Download Links','email-before-download'); ?></a>
|
21 |
+
<a href="<?php echo admin_url( "options-general.php?page=email-before-download-logs" ); ?>" class="button button-primary">
|
22 |
+
<?php _e('View Submission Logs','email-before-download'); ?></a>
|
23 |
+
</div>
|
24 |
+
<div style="float:right">
|
25 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
|
26 |
+
<input type="hidden" name="cmd" value="_s-xclick" />
|
27 |
+
<input type="hidden" name="hosted_button_id" value="47FLSBA363KAU" />
|
28 |
+
<input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" alt="PayPal - The safer, easier way to pay online!" />
|
29 |
+
<img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" width="1" height="1" border="0" />
|
30 |
+
</form>
|
31 |
+
</div>
|
32 |
+
<form action="options.php" method="post">
|
33 |
+
<?php
|
34 |
+
settings_fields( $this->plugin_name );
|
35 |
+
do_settings_sections( $this->plugin_name );
|
36 |
+
submit_button();
|
37 |
+
?>
|
38 |
+
</form>
|
39 |
+
</div>
|
checkcurl.php
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(function_exists('curl_init')){
|
3 |
-
echo 'cURL is enabled';
|
4 |
-
|
5 |
-
}
|
6 |
-
else
|
7 |
-
echo 'cURL is not enabled';
|
8 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clearlog.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
//wordpress
|
3 |
-
define('WP_USE_THEMES', false);
|
4 |
-
$wp_root = dirname(__FILE__) .'/../../../';
|
5 |
-
if(file_exists($wp_root . 'wp-load.php')) {
|
6 |
-
require_once($wp_root . "wp-load.php");
|
7 |
-
} else if(file_exists($wp_root . 'wp-config.php')) {
|
8 |
-
require_once($wp_root . "wp-config.php");
|
9 |
-
} else {
|
10 |
-
exit;
|
11 |
-
}
|
12 |
-
|
13 |
-
if ( !current_user_can('manage_options') ) {
|
14 |
-
echo "You don't have permission to perform this operation!";
|
15 |
-
exit(0);
|
16 |
-
}
|
17 |
-
|
18 |
-
global $wpdb,$wp_dlm_root, $wp_dlm_db;
|
19 |
-
$table_item = $wpdb->prefix . "ebd_item";
|
20 |
-
$table_link = $wpdb->prefix . "ebd_link";
|
21 |
-
$table_posted_data = $wpdb->prefix . "ebd_posted_data";
|
22 |
-
|
23 |
-
$sql="truncate $table_item;" ;
|
24 |
-
$wpdb->query($sql);
|
25 |
-
$sql="truncate $table_link;" ;
|
26 |
-
$wpdb->query($sql);
|
27 |
-
$sql="truncate $table_posted_data;";
|
28 |
-
$wpdb->query($sql);
|
29 |
-
|
30 |
-
?>
|
31 |
-
The Email Before Download log entries have been cleared!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
download.php
DELETED
@@ -1,265 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
$wp_root = dirname(__FILE__) .'/../../../';
|
3 |
-
if(file_exists($wp_root . 'wp-load.php')) {
|
4 |
-
require_once($wp_root . "wp-load.php");
|
5 |
-
} else if(file_exists($wp_root . 'wp-config.php')) {
|
6 |
-
require_once($wp_root . "wp-config.php");
|
7 |
-
} else {
|
8 |
-
exit;
|
9 |
-
}
|
10 |
-
|
11 |
-
|
12 |
-
//get file id
|
13 |
-
$dId = $_REQUEST['dl'];
|
14 |
-
|
15 |
-
//
|
16 |
-
global $wpdb;
|
17 |
-
$table_item = $wpdb->prefix . "ebd_item";
|
18 |
-
$table_link = $wpdb->prefix . "ebd_link";
|
19 |
-
$ebd_link = $wpdb->get_row( "SELECT * FROM $table_link WHERE uid = '".esc_sql($dId)."';" );
|
20 |
-
|
21 |
-
$dld = null;
|
22 |
-
$is_new_dm = false;
|
23 |
-
$old_rep = error_reporting(E_ERROR | E_PARSE);;
|
24 |
-
|
25 |
-
$pd = &get_file_data( WP_PLUGIN_DIR . "/download-monitor/download-monitor.php", array("Version"=>"Version"), 'plugin');
|
26 |
-
if(!($pd['Version'])) {
|
27 |
-
}
|
28 |
-
else $is_new_dm = true;
|
29 |
-
|
30 |
-
$new = error_reporting($old_rep);
|
31 |
-
|
32 |
-
if($ebd_link->expire_time != NULL && $ebd_link->expire_time != 0 && $ebd_link->expire_time < time()){
|
33 |
-
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
34 |
-
wp_die( sprintf(__('The link you are trying to access is expired. <br/><br/><a href="%1$s"><strong>← Back to %2$s</strong></a>', "email-before-download"), get_bloginfo('url'), get_bloginfo('name')), __('The link you are trying to access is expired.',"email-before-download"));
|
35 |
-
}
|
36 |
-
$is_force_download = $ebd_link->is_force_download == 'yes' || $ebd_link->is_force_download == 'true';
|
37 |
-
if($ebd_link->selected_id != NULL && $ebd_link->selected_id != 0){
|
38 |
-
$dl = $wpdb->get_row( "SELECT * FROM $wp_dlm_db WHERE id = ".esc_sql($ebd_link->selected_id).";" );
|
39 |
-
$file = '';
|
40 |
-
if(!$is_new_dm){
|
41 |
-
$downloads = get_downloads('include='.$ebd_link->selected_id.'');
|
42 |
-
$file = $downloads[0]->url;
|
43 |
-
}
|
44 |
-
else $file = do_shortcode('[download_data id="'.$ebd_link->selected_id.'" data="download_link"]');
|
45 |
-
|
46 |
-
$wpdb->update( $table_link, array("is_downloaded"=>1), array("uid"=>esc_sql($dId)) );
|
47 |
-
header("Location: $file");
|
48 |
-
exit(0);
|
49 |
-
}
|
50 |
-
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE id = '".esc_sql($ebd_link->item_id)."';" );
|
51 |
-
|
52 |
-
$is_masked = get_option('email_before_download_hide');
|
53 |
-
//is the "hide" option overriden for the individual download
|
54 |
-
if($ebd_link->is_masked != NULL)
|
55 |
-
$is_masked = $ebd_link->is_masked == 'yes' || $ebd_link->is_masked == 'true';
|
56 |
-
|
57 |
-
if($is_force_download){
|
58 |
-
$is_masked = true;
|
59 |
-
}
|
60 |
-
$file = '';
|
61 |
-
if($ebd_item->file){
|
62 |
-
$file = $ebd_item->file;
|
63 |
-
}
|
64 |
-
if($ebd_item->download_id){
|
65 |
-
if(!$is_new_dm){
|
66 |
-
$dl = $wpdb->get_row( "SELECT * FROM $wp_dlm_db WHERE id = '".esc_sql($ebd_item->download_id)."';" );
|
67 |
-
|
68 |
-
//another way of getting downloads from download monitor
|
69 |
-
$downloads = get_downloads('include='.$ebd_item->download_id.'');
|
70 |
-
|
71 |
-
$d = new downloadable_file($dl);
|
72 |
-
$file = $downloads[0]->url;
|
73 |
-
|
74 |
-
//if the link is masked use the real path of the DM file
|
75 |
-
if ($is_masked && function_exists('curl_init')) $file = $d->filename;
|
76 |
-
}
|
77 |
-
else{
|
78 |
-
//$file = do_shortcode('[download_data id="'.$ebd_item->download_id.'" data="download_link"]');
|
79 |
-
if ($is_masked && function_exists('curl_init')) {
|
80 |
-
$dld = new DLM_Download($ebd_item->download_id);
|
81 |
-
|
82 |
-
$file = $dld->get_file_version()->url;
|
83 |
-
if(!isset($_SERVER['HTTP_RANGE'])){
|
84 |
-
$dld->get_file_version()->increase_download_count();
|
85 |
-
}
|
86 |
-
}
|
87 |
-
else $file = do_shortcode('[download_data id="'.$ebd_item->download_id.'" data="download_link"]');
|
88 |
-
}
|
89 |
-
}
|
90 |
-
$wpdb->update( $table_link, array("is_downloaded"=>1), array("uid"=>esc_sql($dId)) );
|
91 |
-
|
92 |
-
|
93 |
-
//Check if the cUrl functions are available and the url hide option is enabled.
|
94 |
-
//If not, just rederect to real file url.
|
95 |
-
|
96 |
-
if ($is_masked && function_exists('curl_init')) {
|
97 |
-
$filesize = 0;
|
98 |
-
if($dld == null){
|
99 |
-
$curl = curl_init();
|
100 |
-
$url = $file;
|
101 |
-
$options = array
|
102 |
-
(
|
103 |
-
CURLOPT_URL=>$url,
|
104 |
-
CURLOPT_HEADER=>true,
|
105 |
-
CURLOPT_RETURNTRANSFER=>true,
|
106 |
-
CURLOPT_NOBODY=>TRUE,
|
107 |
-
);
|
108 |
-
curl_setopt_array($curl,$options);
|
109 |
-
$r = curl_exec ($curl);
|
110 |
-
$header_size = curl_getinfo($curl,CURLINFO_HEADER_SIZE);
|
111 |
-
$header = substr($r, 0, $header_size);
|
112 |
-
$body = substr( $r, $header_size );
|
113 |
-
|
114 |
-
curl_close ($curl);
|
115 |
-
|
116 |
-
|
117 |
-
$my_headers = ebd_parse_headers ( $header );
|
118 |
-
|
119 |
-
|
120 |
-
$regex = '/Content-Length:\s([0-9].+?)\s/';
|
121 |
-
$count = preg_match($regex, $header, $matches);
|
122 |
-
|
123 |
-
$filesize = isset($matches[1]) ? $matches[1] : "";
|
124 |
-
|
125 |
-
$dirs = wp_upload_dir();
|
126 |
-
$uploadpath = trailingslashit( $dirs['baseurl'] );
|
127 |
-
$absuploadpath = trailingslashit( $dirs['basedir'] );
|
128 |
-
|
129 |
-
if ( $uploadpath && ( strstr ( $file, $uploadpath ) || strstr ( $file, $absuploadpath )) ) {
|
130 |
-
$file = str_replace( $uploadpath , "" , $file);
|
131 |
-
if(is_file($absuploadpath.$file)){
|
132 |
-
$file = $absuploadpath.$file;
|
133 |
-
}
|
134 |
-
else {
|
135 |
-
//
|
136 |
-
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
137 |
-
wp_die( sprintf(__('The file you are trying to download is not available. <br/><br/><a href="%1$s"><strong>← Back to %2$s</strong></a>', "email-before-download"), get_bloginfo('url'), get_bloginfo('name')), __('The link you are trying to access is expired.',"email-before-download"));
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
foreach($my_headers as $key=>$value){
|
142 |
-
if($key == 'Location') continue;
|
143 |
-
header("$key: $value");
|
144 |
-
|
145 |
-
}
|
146 |
-
}
|
147 |
-
else{
|
148 |
-
$filesize = $dld->get_file_version()->filesize;
|
149 |
-
$mimetypes = get_allowed_mime_types();
|
150 |
-
|
151 |
-
$mime_type = 'application/force-download';
|
152 |
-
foreach(get_allowed_mime_types() as $mime => $type) {
|
153 |
-
$mimes = explode( '|', $mime );
|
154 |
-
if (strpos($mime, $dld->get_file_version()->filetype) !== false) {
|
155 |
-
$mime_type = $type;
|
156 |
-
break;
|
157 |
-
}
|
158 |
-
}
|
159 |
-
|
160 |
-
$dirs = wp_upload_dir();
|
161 |
-
$uploadpath = trailingslashit( $dirs['baseurl'] );
|
162 |
-
$absuploadpath = trailingslashit( $dirs['basedir'] );
|
163 |
-
|
164 |
-
if ( $uploadpath && ( strstr ( $file, $uploadpath ) || strstr ( $file, $absuploadpath )) ) {
|
165 |
-
$file = str_replace( $uploadpath , "" , $file);
|
166 |
-
if(is_file($absuploadpath.$file)){
|
167 |
-
$file = $absuploadpath.$file;
|
168 |
-
}
|
169 |
-
else {
|
170 |
-
//
|
171 |
-
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
172 |
-
wp_die( sprintf(__('The file you are trying to download is not available. <br/><br/><a href="%1$s"><strong>← Back to %2$s</strong></a>', "email-before-download"), get_bloginfo('url'), get_bloginfo('name')), __('The link you are trying to access is expired.',"email-before-download"));
|
173 |
-
}
|
174 |
-
}
|
175 |
-
|
176 |
-
header( "Robots: none" );
|
177 |
-
header( "Content-Type: " . $mime_type );
|
178 |
-
header( "Content-Description: File Transfer" );
|
179 |
-
|
180 |
-
}
|
181 |
-
//
|
182 |
-
//HTTPRange support
|
183 |
-
$size =$filesize;
|
184 |
-
$begin=0;
|
185 |
-
$end=$size;
|
186 |
-
|
187 |
-
if(isset($_SERVER['HTTP_RANGE']))
|
188 |
-
{ if(preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches))
|
189 |
-
{ $begin=intval($matches[0]);
|
190 |
-
if(!empty($matches[1]))
|
191 |
-
$end=intval($matches[1]);
|
192 |
-
}
|
193 |
-
}
|
194 |
-
|
195 |
-
if($begin>0||$end<$size)
|
196 |
-
header('HTTP/1.0 206 Partial Content');
|
197 |
-
else
|
198 |
-
header('HTTP/1.0 200 OK');
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
header('Accept-Ranges: bytes');
|
203 |
-
|
204 |
-
header("Content-Range: bytes $begin-$end/$size");
|
205 |
-
|
206 |
-
$base_file_name = basename($file);
|
207 |
-
if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") != false) {
|
208 |
-
$base_file_name = urlencode(basename($file));
|
209 |
-
$is_force_download = TRUE;
|
210 |
-
}
|
211 |
-
if($is_force_download)
|
212 |
-
header("Content-Disposition: attachment; filename=\"" . $base_file_name . "\"");
|
213 |
-
else header("Content-Disposition: filename=\"" . $base_file_name . "\"");
|
214 |
-
|
215 |
-
header('Content-Length:'.($end-$begin));
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
$chunksize = 1 * (1024 * 1024); // how many bytes per chunk
|
220 |
-
if ($filesize > $chunksize) {
|
221 |
-
$handle = fopen($file, 'rb');
|
222 |
-
$buffer = '';
|
223 |
-
// If it's a large file we don't want the script to timeout, so:
|
224 |
-
@set_time_limit(0);
|
225 |
-
fseek($handle,$begin,0);
|
226 |
-
while (!feof($handle)) {
|
227 |
-
|
228 |
-
|
229 |
-
$buffer = fread($handle, $chunksize);
|
230 |
-
echo $buffer;
|
231 |
-
ob_flush();
|
232 |
-
flush();
|
233 |
-
}
|
234 |
-
fclose($handle);
|
235 |
-
} else {
|
236 |
-
readfile($file);
|
237 |
-
}
|
238 |
-
|
239 |
-
|
240 |
-
exit(0);
|
241 |
-
|
242 |
-
}
|
243 |
-
else {
|
244 |
-
header("Location: $file");
|
245 |
-
}
|
246 |
-
|
247 |
-
function ebd_parse_headers( $header )
|
248 |
-
{
|
249 |
-
$retVal = array();
|
250 |
-
$fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header));
|
251 |
-
foreach( $fields as $field ) {
|
252 |
-
if( preg_match('/([^:]+): (.+)/m', $field, $match) ) {
|
253 |
-
$match[1] = preg_replace('/(?<=^|[\x09\x20\x2D])./e', 'strtoupper("\0")', strtolower(trim($match[1])));
|
254 |
-
if( isset($retVal[$match[1]]) ) {
|
255 |
-
$retVal[$match[1]] = array($retVal[$match[1]], $match[2]);
|
256 |
-
} else {
|
257 |
-
$retVal[$match[1]] = trim($match[2]);
|
258 |
-
}
|
259 |
-
}
|
260 |
-
}
|
261 |
-
return $retVal;
|
262 |
-
}
|
263 |
-
|
264 |
-
|
265 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
email-before-download.php
CHANGED
@@ -1,1089 +1,44 @@
|
|
1 |
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Email Before Download
|
4 |
-
Plugin URI: http://www.mandsconsulting.com/
|
5 |
-
Description: This plugin seamlessly integrates two popular plugins (Contact Form 7 and Download Monitor) to create a simple shortcode for requesting an end-user to fill out a form before providing the download URL. You can use an existing Contact Form 7 form, where you might typically request contact information like an email address, but the questions in the form are completely up to you. Once the end user completes the form, you can choose to either show a link directly to the download or send an email with the direct link to the email provided in the contact form.
|
6 |
-
Author: M&S Consulting
|
7 |
-
Version: 3.4
|
8 |
-
Author URI: http://www.mandsconsulting.com
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
/*
|
22 |
-
* Init database tables
|
23 |
-
*/
|
24 |
-
|
25 |
-
global $wpdb;
|
26 |
-
|
27 |
-
$table_item = $wpdb->prefix . "ebd_item";
|
28 |
-
$table_link = $wpdb->prefix . "ebd_link";
|
29 |
-
$table_posted_data = $wpdb->prefix . "ebd_posted_data";
|
30 |
-
|
31 |
-
if($wpdb->get_var("SHOW TABLES LIKE '$table_item'") != $table_item) {
|
32 |
-
|
33 |
-
$sql = "CREATE TABLE " . $table_item . " (
|
34 |
-
`id` int(11) NOT NULL auto_increment,
|
35 |
-
`download_id` varchar(128) NULL,
|
36 |
-
`file` varchar(255) NULL,
|
37 |
-
`title` varchar(255) NULL,
|
38 |
-
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
39 |
-
PRIMARY KEY (`id`)
|
40 |
-
)";
|
41 |
-
$wpdb->query($sql);
|
42 |
-
|
43 |
-
}
|
44 |
-
if($wpdb->get_var("SHOW TABLES LIKE '$table_link'") != $table_link) {
|
45 |
-
|
46 |
-
$sql = "CREATE TABLE " . $table_link . " (
|
47 |
-
id mediumint(9) NOT NULL AUTO_INCREMENT,
|
48 |
-
item_id int(11) NOT NULL,
|
49 |
-
is_downloaded smallint(3) NOT NULL default '0',
|
50 |
-
email VARCHAR(128) NOT NULL,
|
51 |
-
expire_time bigint(11),
|
52 |
-
time_requested bigint(11),
|
53 |
-
uid varchar(255) NOT NULL,
|
54 |
-
selected_id BIGINT NOT NULL,
|
55 |
-
delivered_as varchar(255) NULL,
|
56 |
-
UNIQUE KEY id (id)
|
57 |
-
);";
|
58 |
-
$wpdb->query($sql);
|
59 |
-
}
|
60 |
-
|
61 |
-
// time_requested bigint(11),
|
62 |
-
//ALTER TABLE `wp_ebd_link` ADD `selected_id` VARCHAR( 128 ) NULL AFTER `uid` ;
|
63 |
-
if(!$wpdb->get_row("SHOW COLUMNS
|
64 |
-
FROM $table_link
|
65 |
-
LIKE 'selected_id'"))
|
66 |
-
$wpdb->query("ALTER TABLE `$table_link` ADD `selected_id` BIGINT NOT NULL ;");
|
67 |
-
//ALTER TABLE `wp_ebd_link` ADD `time_requested` BIGINT NOT NULL ;
|
68 |
-
if(!$wpdb->get_row("SHOW COLUMNS
|
69 |
-
FROM $table_link
|
70 |
-
LIKE 'time_requested'"))
|
71 |
-
$wpdb->query("ALTER TABLE `$table_link` ADD `time_requested` BIGINT NOT NULL ;");
|
72 |
-
|
73 |
-
if(!$wpdb->get_row("SHOW COLUMNS
|
74 |
-
FROM $table_link
|
75 |
-
LIKE 'is_masked'"))
|
76 |
-
$wpdb->query("ALTER TABLE `$table_link` ADD `is_masked` VARCHAR(4) NULL DEFAULT NULL;");
|
77 |
-
|
78 |
-
if(!$wpdb->get_row("SHOW COLUMNS
|
79 |
-
FROM $table_link
|
80 |
-
LIKE 'is_force_download'"))
|
81 |
-
$wpdb->query("ALTER TABLE `$table_link` ADD `is_force_download` VARCHAR(4) NULL DEFAULT NULL;");
|
82 |
-
|
83 |
-
if($wpdb->get_var("SHOW TABLES LIKE '$table_posted_data'") != $table_posted_data) {
|
84 |
-
|
85 |
-
$sql = "CREATE TABLE " . $table_posted_data . " (
|
86 |
-
time_requested bigint(20),
|
87 |
-
email VARCHAR(128) NULL,
|
88 |
-
user_name VARCHAR(128)CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL,
|
89 |
-
posted_data text(2000) NOT NULL,
|
90 |
-
UNIQUE KEY id (time_requested)
|
91 |
-
);";
|
92 |
-
$wpdb->query($sql);
|
93 |
-
}
|
94 |
-
//check title field collation
|
95 |
-
$show_query = "SHOW FULL COLUMNS FROM `$table_item` LIKE 'title'";
|
96 |
-
$collation_row = $wpdb->get_row($show_query);
|
97 |
-
if($collation_row->Collation != 'utf8_unicode_ci'){
|
98 |
-
$wpdb->query("ALTER TABLE `$table_item` CHANGE `title` `title` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL");
|
99 |
-
}
|
100 |
-
if(!$wpdb->get_row("SHOW COLUMNS
|
101 |
-
FROM $table_posted_data
|
102 |
-
LIKE 'user_name'"))
|
103 |
-
$wpdb->query("ALTER TABLE `$table_posted_data` ADD `user_name` VARCHAR(128)CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;");
|
104 |
-
|
105 |
-
if(!$wpdb->get_row("SHOW COLUMNS
|
106 |
-
FROM $table_posted_data
|
107 |
-
LIKE 'email'"))
|
108 |
-
$wpdb->query("ALTER TABLE `$table_posted_data` ADD `email` VARCHAR(128) NULL DEFAULT NULL;");
|
109 |
-
|
110 |
-
|
111 |
-
//Shortcode function
|
112 |
-
function emailreqtag_func($atts) {
|
113 |
-
extract(shortcode_atts(array(
|
114 |
-
'download_id' => NULL,
|
115 |
-
'contact_form_id' => NULL,
|
116 |
-
'title' => NULL,
|
117 |
-
'file' => NULL,
|
118 |
-
'format' => NULL,
|
119 |
-
'delivered_as' => NULL,
|
120 |
-
'masked'=>NULL,
|
121 |
-
'attachment'=>NULL,
|
122 |
-
'force_download'=>NULL,
|
123 |
-
'email_from'=>NULL,
|
124 |
-
'checked'=>NULL,
|
125 |
-
'hidden_form'=>NULL,
|
126 |
-
'use_radio'=>NULL
|
127 |
-
|
128 |
-
), $atts));
|
129 |
-
|
130 |
-
global $wpdb,$wp_dlm_root,$wp_dlm_db,$wp_dlm_db_taxonomies, $def_format, $dlm_url, $downloadurl, $downloadtype, $wp_dlm_db_meta;
|
131 |
-
|
132 |
-
$str = '';
|
133 |
-
$chekboxes = "";
|
134 |
-
$chekboxesL = "";
|
135 |
-
//$title = '';
|
136 |
-
|
137 |
-
$url = '';
|
138 |
-
$hf = '';
|
139 |
-
$dldArray = array();
|
140 |
-
$table_item = $wpdb->prefix . "ebd_item";
|
141 |
-
$is_new_dm = false;
|
142 |
-
if($download_id != NULL){
|
143 |
-
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE download_id = '".esc_sql($download_id)."';" );
|
144 |
-
|
145 |
-
$old_rep = error_reporting(E_ERROR | E_PARSE);;
|
146 |
-
|
147 |
-
$pd = &get_file_data( WP_PLUGIN_DIR . "/download-monitor/download-monitor.php", array("Version"=>"Version"), 'plugin');
|
148 |
-
if(!($pd['Version'])) {
|
149 |
-
}
|
150 |
-
else $is_new_dm = true;
|
151 |
-
|
152 |
-
$new = error_reporting($old_rep);
|
153 |
-
|
154 |
-
|
155 |
-
$dldArray = explode(",", $download_id);
|
156 |
-
$title_tmp = '';
|
157 |
-
foreach ($dldArray as $dl_id) {
|
158 |
-
$d = NULL;
|
159 |
-
if(!$is_new_dm){
|
160 |
-
$dl = $wpdb->get_row( "SELECT * FROM $wp_dlm_db WHERE id = '".esc_sql($dl_id)."';" );
|
161 |
-
$d = new downloadable_file($dl);
|
162 |
-
}
|
163 |
-
else{
|
164 |
-
$d = new stdClass;
|
165 |
-
|
166 |
-
$d->title = do_shortcode('[download_data id="'.$dl_id.'" data="title"]');
|
167 |
-
|
168 |
-
}
|
169 |
-
$checked_state_html = 'checked="true"';
|
170 |
-
$checked_state = get_option('email_before_download_chekboxes_state');
|
171 |
-
if($checked != NULL){
|
172 |
-
$checked_state = $checked;
|
173 |
-
}
|
174 |
-
if($checked_state == 'no') $checked_state_html = '';
|
175 |
-
|
176 |
-
$checkbox = 'checkbox';
|
177 |
-
|
178 |
-
$is_radio = get_option('email_before_download_is_radio');
|
179 |
-
|
180 |
-
if($use_radio !=NULL)
|
181 |
-
$is_radio = $use_radio;
|
182 |
-
|
183 |
-
if($is_radio == 'yes'){
|
184 |
-
$checkbox = 'radio';
|
185 |
-
$checked_state_html = '';
|
186 |
-
}
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
if (!empty($d)) {
|
191 |
-
//$date = date("jS M Y", strtotime($d->date));
|
192 |
-
if ($title == NULL || $title == '') $title_tmp .= $d->title . '|';
|
193 |
-
|
194 |
-
$chekboxes .= '<br />' . $d->title. ' <input type="'.$checkbox.'" '.$checked_state_html.' name="ebd_downloads[]" value="'. $dl_id . '"/>';
|
195 |
-
$chekboxesL .= '<br /> <input type="'.$checkbox.'" '.$checked_state_html.' name="ebd_downloads[]" value="'. $dl_id . '"/> '. $d->title;
|
196 |
-
}
|
197 |
-
|
198 |
-
}
|
199 |
-
if(count($title_tmp) > 0) $title = rtrim($title_tmp, '|');
|
200 |
-
|
201 |
-
if (empty($ebd_item)){
|
202 |
-
$wpdb->insert( $table_item, array("download_id"=>$download_id, "title"=>$title) );
|
203 |
-
$download_id = $wpdb->insert_id;
|
204 |
-
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE id = '".esc_sql($download_id)."';" );
|
205 |
-
}
|
206 |
-
else $download_id = $ebd_item->id;
|
207 |
-
//update title if needed
|
208 |
-
if(($title != NULL || $title != '') && $ebd_item->title != $title)
|
209 |
-
$wpdb->update( $table_item, array("title"=>$title), array("id"=>$download_id) );
|
210 |
-
}
|
211 |
-
else if($file){
|
212 |
-
|
213 |
-
if ($title == NULL || $title == '') $title = basename($file);
|
214 |
-
|
215 |
-
|
216 |
-
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE file = '".esc_sql($file)."';" );
|
217 |
-
|
218 |
-
if (empty($ebd_item)){
|
219 |
-
$wpdb->insert( $table_item, array("file"=>esc_sql($file), "title"=>$title) );
|
220 |
-
$download_id = $wpdb->insert_id;
|
221 |
-
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE file = '".esc_sql($file)."';" );
|
222 |
-
|
223 |
-
}
|
224 |
-
else $download_id = $ebd_item->id;
|
225 |
-
//update title if needed
|
226 |
-
if(($title != NULL || $title != '') && $ebd_item->title != $title)
|
227 |
-
$wpdb->update( $table_item, array("title"=>$title), array("id"=>$download_id) );
|
228 |
-
|
229 |
-
}
|
230 |
-
$contact_form = do_shortcode("[contact-form-7 id=\"$contact_form_id\" \"$title\"]");
|
231 |
-
|
232 |
-
if(strpos($contact_form, 'contact-form-7 404')!== false) $contact_form = do_shortcode("[contact-form id=\"$contact_form_id\" \"$title\"]");
|
233 |
-
|
234 |
-
// add checkboxes if count is more than one
|
235 |
-
$hidden = get_option('email_before_download_hidden_form');
|
236 |
-
if($hidden_form != NULL){
|
237 |
-
$hidden = ($hidden_form == 'yes');
|
238 |
-
}
|
239 |
-
|
240 |
-
if (count($dldArray) > 1){
|
241 |
-
if($hidden){
|
242 |
-
$doc = new DOMDocument();
|
243 |
-
$doc->loadXML(xml_character_encode($contact_form));
|
244 |
-
$form = $doc->getElementsByTagName('form')->item(0);
|
245 |
-
$form_children = array();
|
246 |
-
$domElemsToRemove = array();
|
247 |
-
foreach ($form->childNodes as $child){
|
248 |
-
$domElemsToRemove[] = $child;
|
249 |
-
}
|
250 |
-
|
251 |
-
foreach ($domElemsToRemove as $child){
|
252 |
-
$form_children[] = $form->removeChild($child);
|
253 |
-
}
|
254 |
-
|
255 |
-
$f = $doc->createDocumentFragment();
|
256 |
-
|
257 |
-
if(strpos($contact_form, "<ebd_left />") !== false)
|
258 |
-
$f->appendXML($chekboxesL);
|
259 |
-
else
|
260 |
-
$f->appendXML($chekboxes);
|
261 |
-
$form->appendChild($f);
|
262 |
-
|
263 |
-
$hidden_css = 'display:none;';
|
264 |
-
$css_option = get_option('email_before_hidden_div_css');
|
265 |
-
|
266 |
-
if($css_option){
|
267 |
-
$hidden_css = $css_option;
|
268 |
-
}
|
269 |
-
$hidden_div = $doc->createDocumentFragment();
|
270 |
-
$hidden_div->appendXML('<div id="downloadinputform" style="' . $hidden_css .'" />');
|
271 |
-
$hidden_div = $form->appendChild($hidden_div);
|
272 |
-
|
273 |
-
|
274 |
-
foreach ($form_children as $child){
|
275 |
-
$hidden_div->appendChild($child);
|
276 |
-
}
|
277 |
-
|
278 |
-
$contact_form = $doc->saveHTML();
|
279 |
-
$js = '<script>
|
280 |
-
function countChecked() {
|
281 |
-
var n = jQuery( "input:checked[name*=ebd_downloads]" ).length;
|
282 |
-
if(n > 0) jQuery( "#downloadinputform" ).show();
|
283 |
-
else jQuery( "#downloadinputform" ).hide();
|
284 |
-
};
|
285 |
-
jQuery(document).ready(function(){
|
286 |
-
jQuery( "input[name*=ebd_downloads]" ).on( "click", countChecked );
|
287 |
-
countChecked();
|
288 |
-
});
|
289 |
-
|
290 |
-
</script>';
|
291 |
-
$contact_form .= $js;
|
292 |
-
|
293 |
-
}
|
294 |
-
else {
|
295 |
-
$contact_form = str_replace("<ebd />", $chekboxes, $contact_form);
|
296 |
-
$contact_form = str_replace("<ebd_left />", $chekboxesL, $contact_form);
|
297 |
-
}
|
298 |
-
}
|
299 |
-
else {
|
300 |
-
$contact_form = str_replace("<ebd />", "", $contact_form);
|
301 |
-
$contact_form = str_replace("<ebd_left />", "", $contact_form);
|
302 |
-
}
|
303 |
-
|
304 |
-
if($delivered_as != NULL)
|
305 |
-
$hf .= '<input type="hidden" name="delivered_as" value="' . $delivered_as. '" />';
|
306 |
-
//masked
|
307 |
-
if($masked != NULL)
|
308 |
-
$hf .= '<input type="hidden" name="masked" value="' . $masked. '" />';
|
309 |
-
|
310 |
-
if($force_download != NULL)
|
311 |
-
$hf .= '<input type="hidden" name="force_download" value="' . $force_download . '" />';
|
312 |
-
|
313 |
-
if($attachment != NULL)
|
314 |
-
$hf .= '<input type="hidden" name="attachment" value="' . $attachment. '" />';
|
315 |
-
if($format != NULL)
|
316 |
-
$hf .= '<input type="hidden" name="format" value="' . $format. '" />';
|
317 |
-
if($email_from != NULL)
|
318 |
-
$hf .= '<input type="hidden" name="email_from" value="' . urlencode($email_from) . '" />';
|
319 |
-
|
320 |
-
|
321 |
-
$hf .= '<input type="hidden" name="_wpcf7_download_id" value="' . $download_id. '" /></form>';
|
322 |
-
|
323 |
-
$contact_form = str_replace("</form>", $hf, $contact_form);
|
324 |
-
|
325 |
-
$wrap_in_div = get_option('email_before_download_wrap_in_div');
|
326 |
-
$div_class = '';
|
327 |
-
if(strlen(trim($wrap_in_div)) > 0 ){
|
328 |
-
$div_class = 'class="' . trim($wrap_in_div) . '"';
|
329 |
-
}
|
330 |
-
|
331 |
-
return "<br/>" . $contact_form . '<div id="wpm_download_' . $download_id . '" ' . $div_class . ' style="display:none;"> </div>';
|
332 |
-
}
|
333 |
-
add_shortcode('emailreq', 'emailreqtag_func');
|
334 |
-
add_shortcode('email-download', 'emailreqtag_func');
|
335 |
-
|
336 |
-
/* Helper functions to check the allowed domains */
|
337 |
-
function check_domains($haystack, $domains, $offset=0) {
|
338 |
-
foreach($domains as $needle) {
|
339 |
-
$pos = stripos($haystack, trim($needle), $offset);
|
340 |
-
|
341 |
-
if ($pos !== false) {
|
342 |
-
return true;
|
343 |
-
}
|
344 |
-
}
|
345 |
-
return false;
|
346 |
-
}
|
347 |
-
|
348 |
-
/* helper function to translate some html entities to safer xml format */
|
349 |
-
function xml_character_encode($string, $trans='') {
|
350 |
-
$trans = (is_array($trans)) ? $trans : get_html_translation_table(HTML_ENTITIES);
|
351 |
-
$trans2 =array();
|
352 |
-
|
353 |
-
foreach ($trans as $k=>$v) {
|
354 |
-
|
355 |
-
if(in_array($v, array('"', '<', '>', '&', ''' ))) { continue;}
|
356 |
-
$trans2[$v]= "&#".ord($k).";";
|
357 |
-
}
|
358 |
-
|
359 |
-
return strtr($string, $trans2);
|
360 |
-
}
|
361 |
-
|
362 |
-
/*Function that processes contact form 7, generates links, sends emails */
|
363 |
-
function ebd_process_email_form( $cf7 ) {
|
364 |
-
if(isset( $_POST['_wpcf7_download_id'] )){
|
365 |
-
global $wpdb,$wp_dlm_root,$wp_dlm_db,$wp_dlm_db_taxonomies, $def_format, $dlm_url, $downloadurl, $downloadtype, $wp_dlm_db_meta;
|
366 |
-
|
367 |
-
//compatibility check for the Contact Form 7 plugin
|
368 |
-
$is_new_cf7 = true;
|
369 |
-
|
370 |
-
if(isset($cf7->posted_data)){
|
371 |
-
$is_new_cf7 = false;
|
372 |
-
}
|
373 |
-
else $cf7->posted_data = $_POST;
|
374 |
-
|
375 |
-
$is_new_dm = false;
|
376 |
-
$old_rep = error_reporting(E_ERROR | E_PARSE);;
|
377 |
-
|
378 |
-
$pd = &get_file_data( WP_PLUGIN_DIR . "/download-monitor/download-monitor.php", array("Version"=>"Version"), 'plugin');
|
379 |
-
if(!($pd['Version'])) {
|
380 |
-
}
|
381 |
-
else $is_new_dm = true;
|
382 |
-
|
383 |
-
$new = error_reporting($old_rep);
|
384 |
-
|
385 |
-
|
386 |
-
//table names
|
387 |
-
$table_item = $wpdb->prefix . "ebd_item";
|
388 |
-
$table_link = $wpdb->prefix . "ebd_link";
|
389 |
-
$table_posted_data = $wpdb->prefix . "ebd_posted_data";
|
390 |
-
|
391 |
-
$delivered_as = get_option('email_before_download_send_email');
|
392 |
-
$emailFrom = get_option('email_before_download_email_from');
|
393 |
-
if (isset($_POST['email_from'])){
|
394 |
-
$emailFrom = htmlspecialchars_decode(urldecode($_POST['email_from']));;
|
395 |
-
}
|
396 |
-
|
397 |
-
if (strlen($emailFrom) > 0 )
|
398 |
-
$emailFrom = 'From: '. $emailFrom . "\r\n";
|
399 |
-
|
400 |
-
$use_attachments = get_option('email_before_download_attachment');
|
401 |
-
if(isset($_POST['delivered_as'])) $delivered_as = $_POST['delivered_as'];
|
402 |
-
if(isset($_POST['attachment'])) $use_attachments = trim($_POST['attachment']) == 'yes';
|
403 |
-
|
404 |
-
//check if email is allowed
|
405 |
-
|
406 |
-
$email = $cf7->posted_data['your-email'];
|
407 |
-
//compare email againts not allowed domains.
|
408 |
-
$forbidden_domains = get_option('email_before_download_forbidden_domains');
|
409 |
-
$domains = explode(',', $forbidden_domains);
|
410 |
-
|
411 |
-
if(check_domains($email, $domains)){
|
412 |
-
$id = (int) $_POST['_wpcf7'];
|
413 |
-
$unit_tag = $_POST['_wpcf7_unit_tag'];
|
414 |
-
|
415 |
-
$items = array(
|
416 |
-
'mailSent' => false,
|
417 |
-
'into' => '#' . $unit_tag,
|
418 |
-
'captcha' => null );
|
419 |
-
//error message
|
420 |
-
$items['message'] = "The email that you provided is not allowed. Please provide another one.";
|
421 |
-
$on_sent_ok = $cf7->additional_setting( 'on_sent_ok', false );
|
422 |
-
$items['onSentOk'] = $on_sent_ok;
|
423 |
-
$echo = json_encode( $items );
|
424 |
-
|
425 |
-
@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
|
426 |
-
echo $echo;
|
427 |
-
die();
|
428 |
-
}
|
429 |
-
|
430 |
-
|
431 |
-
//get selected downloads
|
432 |
-
$dIds = $_POST['ebd_downloads'];
|
433 |
-
|
434 |
-
$dl_items = array();
|
435 |
-
$multipleLinks = '';
|
436 |
-
$message_mult = '';
|
437 |
-
$attachments = array();
|
438 |
-
$time_requested = time();
|
439 |
-
$target = '_blank';
|
440 |
-
|
441 |
-
//get all download monitor objects
|
442 |
-
if($dIds)
|
443 |
-
foreach($dIds as $id){
|
444 |
-
if(!$is_new_dm){
|
445 |
-
$dl_it = $wpdb->get_row( "SELECT * FROM $wp_dlm_db WHERE id = '".esc_sql($id)."';" );
|
446 |
-
|
447 |
-
$dl_items[] = new downloadable_file($dl_it);
|
448 |
-
}
|
449 |
-
else {
|
450 |
-
$dl_it = new stdClass;
|
451 |
-
|
452 |
-
//$dl_it->title = do_shortcode('[download_data id="'.$id.'" data="title"]');
|
453 |
-
//$d->url = do_shortcode('[download_data id="'.$id.'" data="filename"]');
|
454 |
-
$dl_tmp = new DLM_Download($id);
|
455 |
-
$dl_it->title = $dl_tmp->get_the_title();
|
456 |
-
$dl_it->filename = $dl_tmp->get_file_version()->url;
|
457 |
-
$dl_it->id = $id;
|
458 |
-
$dl_items[] = $dl_it;
|
459 |
-
}
|
460 |
-
}
|
461 |
-
|
462 |
-
//get edb items: it's common for all
|
463 |
-
$dId = $_POST['_wpcf7_download_id'];
|
464 |
-
|
465 |
-
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE id = '".esc_sql($dId)."';" );
|
466 |
-
|
467 |
-
$d = null;
|
468 |
-
$dl = null;
|
469 |
-
//get single download, multible are comma separated so the $dl for this will be NULL
|
470 |
-
if(!$is_new_dm){
|
471 |
-
$dl = $wpdb->get_row( "SELECT * FROM $wp_dlm_db WHERE id = '".esc_sql($ebd_item->download_id)."';" );
|
472 |
-
$d = new downloadable_file($dl);
|
473 |
-
}
|
474 |
-
else{
|
475 |
-
$d = new stdClass;
|
476 |
-
$dl_tmp = new DLM_Download($ebd_item->download_id);
|
477 |
-
$d->title = $dl_tmp->get_the_title();
|
478 |
-
$d->filename = $dl_tmp->get_file_version()->url;
|
479 |
-
}
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
//variable for the title it wll be used only for the single downloads and the email subject
|
485 |
-
$title = '';
|
486 |
-
|
487 |
-
$title = $ebd_item->title;
|
488 |
-
|
489 |
-
if($title == NULL || $title == '')
|
490 |
-
{
|
491 |
-
if($ebd_item->file)
|
492 |
-
{
|
493 |
-
$title = basename($ebd_item->file);
|
494 |
-
}
|
495 |
-
else
|
496 |
-
{
|
497 |
-
$title = $d->title;
|
498 |
-
}
|
499 |
-
}
|
500 |
-
|
501 |
-
$url = '';
|
502 |
-
//titles and urls for multiple
|
503 |
-
$titles = array();
|
504 |
-
$urls = array();
|
505 |
-
|
506 |
-
$innerHtml = '';
|
507 |
-
|
508 |
-
//if checkboxes were selected
|
509 |
-
if(count($dl_items) > 0){
|
510 |
-
foreach($dl_items as $dl_item){
|
511 |
-
//generate unique id for the file (link)
|
512 |
-
$uid = md5(uniqid(rand(), true));
|
513 |
-
|
514 |
-
//expiration date if needed if it's 0 or NULL the link will never expire
|
515 |
-
$expireAt = 0;
|
516 |
-
if(get_option('email_before_download_expire_time') != NULL && get_option('email_before_download_expire_time') != "0")
|
517 |
-
$expireAt = strtotime(get_option('email_before_download_expire_time'));
|
518 |
-
|
519 |
-
$link_data = array();
|
520 |
-
$link_data['uid'] = $uid;
|
521 |
-
$link_data['selected_id'] = $dl_item->id;
|
522 |
-
$link_data['expire_time'] = $expireAt;
|
523 |
-
$link_data['time_requested'] = $time_requested;
|
524 |
-
$link_data['email'] = $cf7->posted_data['your-email'];
|
525 |
-
$link_data['item_id'] = $_POST['_wpcf7_download_id'];
|
526 |
-
$link_data['delivered_as'] = $delivered_as;
|
527 |
-
if(isset($_POST['masked'])) $link_data['is_masked'] = $_POST['masked'];
|
528 |
-
$wpdb->insert( $table_link, $link_data );
|
529 |
-
|
530 |
-
//
|
531 |
-
$url = WP_PLUGIN_URL."/email-before-download/download.php?dl=".$uid;
|
532 |
-
$titles[] = $dl_item->title ;
|
533 |
-
$title = implode($titles, '|');
|
534 |
-
if(isset($_POST['format'])){
|
535 |
-
$link = do_shortcode('[download id="' . $dl_item->id. '" format="' .$_POST['format'].'"]');
|
536 |
-
$innerHtml .= $link . '<br />';
|
537 |
-
}
|
538 |
-
else
|
539 |
-
$innerHtml .= '<a class="icon-button download-icon" target="' . $target . '" href="' . $url .'"><span class="et-icon"><span>' . addslashes( $dl_item->title ). '</span></span></a><br />' ;
|
540 |
-
|
541 |
-
// if(get_option('email_before_download_send_email') == 'Send Email' || get_option('email_before_download_send_email') == 'Both'){
|
542 |
-
// }
|
543 |
-
|
544 |
-
if($use_attachments){
|
545 |
-
$dirs = wp_upload_dir();
|
546 |
-
$uploadpath = trailingslashit( $dirs['baseurl'] );
|
547 |
-
$absuploadpath = trailingslashit( $dirs['basedir'] );
|
548 |
-
$attachment = NULL;
|
549 |
-
if ( $uploadpath && ( strstr ( $dl_item->filename, $uploadpath ) || strstr ( $dl_item->filename, $absuploadpath )) ) {
|
550 |
-
|
551 |
-
$file = str_replace( $uploadpath , "" , $dl_item->filename);
|
552 |
-
if(is_file($absuploadpath.$file)){
|
553 |
-
$attachment = $absuploadpath.$file;
|
554 |
-
}
|
555 |
-
}
|
556 |
-
$attachments[] = $attachment;
|
557 |
-
}
|
558 |
-
|
559 |
-
}
|
560 |
-
}
|
561 |
-
// single download for the download monitor file or file lnk
|
562 |
-
else if(!empty($d) || !empty($ebd_item->file) ){
|
563 |
-
//generate unique id for the file (link)
|
564 |
-
$uid = md5(uniqid(rand(), true));
|
565 |
-
|
566 |
-
//expiration date if needed if it's 0 or NULL the link will never expire
|
567 |
-
$expireAt = 0;
|
568 |
-
if(get_option('email_before_download_expire_time') != NULL && get_option('email_before_download_expire_time') != "0")
|
569 |
-
$expireAt = strtotime(get_option('email_before_download_expire_time'));
|
570 |
-
|
571 |
-
$link_data = array();
|
572 |
-
$link_data['uid'] = $uid;
|
573 |
-
$link_data['expire_time'] = $expireAt;
|
574 |
-
$link_data['time_requested'] = $time_requested;
|
575 |
-
$link_data['email'] = $cf7->posted_data['your-email'];
|
576 |
-
$link_data['item_id'] = $_POST['_wpcf7_download_id'];
|
577 |
-
$link_data['delivered_as'] = $delivered_as;
|
578 |
-
$link_data['selected_id'] = 0;
|
579 |
-
if(isset($_POST['masked'])) $link_data['is_masked'] = $_POST['masked'];
|
580 |
-
if(isset($_POST['force_download'])) $link_data['is_force_download'] = $_POST['force_download'];
|
581 |
-
$wpdb->insert( $table_link, $link_data );
|
582 |
-
|
583 |
-
if(isset($_POST['format']) && $ebd_item->download_id != NULL){
|
584 |
-
$link = do_shortcode('[download id="' . $ebd_item->download_id. '" format="' .$_POST['format'].'"]');
|
585 |
-
$innerHtml .= $link . '<br />';
|
586 |
-
}
|
587 |
-
else {
|
588 |
-
$url = WP_PLUGIN_URL."/email-before-download/download.php?dl=".$uid;
|
589 |
-
$innerHtml = '<a class="icon-button download-icon" target="' . $target . '" href="' . $url .'"><span class="et-icon"><span>' . addslashes($title) . '</span></span></a><br />' ;
|
590 |
-
}
|
591 |
-
}
|
592 |
-
//nothing is selected for the download
|
593 |
-
else {
|
594 |
-
//we don't sent an email and throw an error
|
595 |
-
$cf7->skip_mail = true;
|
596 |
-
//this message doesn't seem to appear but we leave it for now
|
597 |
-
if($is_new_cf7){
|
598 |
-
$additional_settings = $cf7->prop( 'additional_settings' );
|
599 |
-
$additional_settings .= "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='You should select the files to dowload.'; \"";
|
600 |
-
$cf7->set_properties( array( 'additional_settings' => $additional_settings ) );
|
601 |
-
}
|
602 |
-
else
|
603 |
-
$cf7->additional_settings .= "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='You should select the files to dowload.'; \"";
|
604 |
-
$id = (int) $_POST['_wpcf7'];
|
605 |
-
$unit_tag = $_POST['_wpcf7_unit_tag'];
|
606 |
-
|
607 |
-
$items = array(
|
608 |
-
'mailSent' => false,
|
609 |
-
'into' => '#' . $unit_tag,
|
610 |
-
'captcha' => null );
|
611 |
-
//error message
|
612 |
-
$items['message'] = "Please select at least one of the documents";
|
613 |
-
$on_sent_ok = $cf7->additional_setting( 'on_sent_ok', false );
|
614 |
-
$items['onSentOk'] = $on_sent_ok;
|
615 |
-
$echo = json_encode( $items );
|
616 |
-
|
617 |
-
@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
|
618 |
-
echo $echo;
|
619 |
-
die();
|
620 |
-
}
|
621 |
-
$cf7->posted_data['your-message'] = 'The downloaded file name(s): ' . $title;
|
622 |
-
if($is_new_cf7){
|
623 |
-
$mail = $cf7->prop( 'mail' );
|
624 |
-
|
625 |
-
if(strpos($mail['body'], "[your-message]") === false ){
|
626 |
-
$mail['body'] = $mail['body'] ."\nThe downloaded file name: $title;";
|
627 |
-
$cf7->posted_data['your-message'] = $title;
|
628 |
-
}
|
629 |
-
else{
|
630 |
-
$mbody = $mail['body'];
|
631 |
-
$mail['body'] = str_replace("[your-message]", 'The downloaded file name(s): ' . $title, $mbody);
|
632 |
-
}
|
633 |
-
$cf7->set_properties( array( 'mail' => $mail ) );
|
634 |
-
|
635 |
-
}
|
636 |
-
else{
|
637 |
-
if(strpos($cf7->mail['body'], "[your-message]") === false ){
|
638 |
-
$cf7->posted_data['your-message'] = $title;
|
639 |
-
$cf7->mail['body'] = $cf7->mail['body'] ."\nThe downloaded file name: [your-message]";
|
640 |
-
|
641 |
-
}
|
642 |
-
}
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
$target = get_option('email_before_download_link_target');
|
647 |
-
$html_before = get_option('email_before_download_html_before_link');
|
648 |
-
$html_after = get_option('email_before_download_html_after_link');
|
649 |
-
|
650 |
-
|
651 |
-
//if multiple files are downloaded ???
|
652 |
-
$message = '';
|
653 |
-
if(count($dl_items) > 0){
|
654 |
-
$email_template = get_option('email_before_download_email_template_mult');
|
655 |
-
if(strlen(trim($email_template)) > 0){
|
656 |
-
$message = str_replace(array('[requesting_name]', '[file_urls]'), array($cf7->posted_data['your-name'], $innerHtml), trim($email_template));
|
657 |
-
}
|
658 |
-
else $message = $innerHtml;
|
659 |
-
}
|
660 |
-
else {
|
661 |
-
$email_template = get_option('email_before_download_email_template');
|
662 |
-
if(strlen(trim($email_template)) > 0){
|
663 |
-
if(isset($_POST['format']) && $ebd_item->download_id != NULL)
|
664 |
-
$message = 'You requested: ' .$innerHtml;
|
665 |
-
else
|
666 |
-
$message = str_replace(array('[requesting_name]', '[file_url]', '[file_name]'), array($cf7->posted_data['your-name'], $url, $title), trim($email_template));
|
667 |
-
}
|
668 |
-
else {
|
669 |
-
if(isset($_POST['format']) && $ebd_item->download_id != NULL)
|
670 |
-
$message = 'You requested: ' .$innerHtml;
|
671 |
-
else
|
672 |
-
$message = '<a class="icon-button download-icon" target="' . $target . '" href="' . $url .'">' . $title . '</a>';
|
673 |
-
}
|
674 |
-
}
|
675 |
-
|
676 |
-
|
677 |
-
$innerHtml = $html_before . $innerHtml . $html_after;
|
678 |
-
|
679 |
-
|
680 |
-
if($delivered_as == 'Send Email') {
|
681 |
-
// $attachments = NULL;
|
682 |
-
if($use_attachments && count($dl_items) == 0) {
|
683 |
-
$dirs = wp_upload_dir();
|
684 |
-
$uploadpath = trailingslashit( $dirs['baseurl'] );
|
685 |
-
$absuploadpath = trailingslashit( $dirs['basedir'] );
|
686 |
-
$attachment = NULL;
|
687 |
-
if ( $uploadpath && ( strstr ( $d->filename, $uploadpath ) || strstr ( $d->filename, $absuploadpath )) ) {
|
688 |
-
|
689 |
-
$file = str_replace( $uploadpath , "" , $d->filename);
|
690 |
-
if(is_file($absuploadpath.$file)){
|
691 |
-
$attachment = $absuploadpath.$file;
|
692 |
-
}
|
693 |
-
}
|
694 |
-
$attachments = array($attachment);
|
695 |
-
}
|
696 |
-
if(count($attachments) == 0) $attachments = NULL;
|
697 |
-
$email_subject = get_option('email_before_download_subject');
|
698 |
-
if(strlen(trim($email_subject)) > 0){
|
699 |
-
$email_subject = str_replace('[files]', $title, $email_subject);
|
700 |
-
}
|
701 |
-
else $email_subject = 'Requested URL for the file(s): '. $title;
|
702 |
-
//email_before_download_subject
|
703 |
-
@wp_mail( $cf7->posted_data['your-email'], $email_subject , stripslashes($message), $emailFrom . "Content-Type: text/html\n", $attachments);
|
704 |
-
if($is_new_cf7){
|
705 |
-
$additional_settings = $cf7->prop( 'additional_settings' );
|
706 |
-
$additional_settings .= "\n". "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='The link to the file(s) has been emailed to you.'; \"";
|
707 |
-
$cf7->set_properties( array( 'additional_settings' => $additional_settings ) );
|
708 |
-
}
|
709 |
-
else
|
710 |
-
$cf7->additional_settings .= "\n". "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='The link to the file(s) has been emailed to you.'; \"";
|
711 |
-
}
|
712 |
-
else if ($delivered_as == 'Both'){
|
713 |
-
//$attachments = NULL;
|
714 |
-
if($use_attachments && count($dl_items) == 0) {
|
715 |
-
$dirs = wp_upload_dir();
|
716 |
-
$uploadpath = trailingslashit( $dirs['baseurl'] );
|
717 |
-
$absuploadpath = trailingslashit( $dirs['basedir'] );
|
718 |
-
$attachment = NULL;
|
719 |
-
if ( $uploadpath && ( strstr ( $d->filename, $uploadpath ) || strstr ( $d->filename, $absuploadpath )) ) {
|
720 |
-
|
721 |
-
$file = str_replace( $uploadpath , "" , $d->filename);
|
722 |
-
if(is_file($absuploadpath.$file)){
|
723 |
-
$attachment = $absuploadpath.$file;
|
724 |
-
}
|
725 |
-
}
|
726 |
-
$attachments = array($attachment);
|
727 |
-
}
|
728 |
-
if(count($attachments) == 0) $attachments = NULL;
|
729 |
-
$email_subject = get_option('email_before_download_subject');
|
730 |
-
if(strlen(trim($email_subject)) > 0){
|
731 |
-
$email_subject = str_replace('[files]', $title, $email_subject);
|
732 |
-
}
|
733 |
-
else $email_subject = 'Requested URL for the file(s): '. $title;
|
734 |
-
@wp_mail( $cf7->posted_data['your-email'], $email_subject , $message, $emailFrom . "Content-Type: text/html\n", $attachments);
|
735 |
-
if($is_new_cf7){
|
736 |
-
$additional_settings = $cf7->prop( 'additional_settings' );
|
737 |
-
$additional_settings .= "\n". "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='$innerHtml'; \"";
|
738 |
-
$cf7->set_properties( array( 'additional_settings' => $additional_settings ) );
|
739 |
-
}
|
740 |
-
else
|
741 |
-
$cf7->additional_settings .= "\n". "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='$innerHtml'; \"";
|
742 |
-
}
|
743 |
-
else{
|
744 |
-
if($is_new_cf7){
|
745 |
-
$additional_settings = $cf7->prop( 'additional_settings' );
|
746 |
-
$additional_settings .= "\n". "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='$innerHtml'; \"";
|
747 |
-
$cf7->set_properties( array( 'additional_settings' => $additional_settings ) );
|
748 |
-
}
|
749 |
-
else
|
750 |
-
$cf7->additional_settings .= "\n". "on_sent_ok: \"document.getElementById('wpm_download_$dId').style.display = 'inline'; document.getElementById('wpm_download_$dId').innerHTML='$innerHtml'; \"";
|
751 |
-
}
|
752 |
-
// save the extra form information into the xml
|
753 |
-
$xml = new SimpleXMLElement('<posted_data></posted_data>');
|
754 |
-
|
755 |
-
foreach ($cf7->posted_data as $key => $value){
|
756 |
-
if (is_array($value))
|
757 |
-
$value = implode(',', $value);
|
758 |
-
$xml->addChild($key, htmlentities($value, ENT_QUOTES,'utf-8'));//encode some chars like '&'
|
759 |
-
}
|
760 |
-
$posted_data = array();
|
761 |
-
$posted_data['time_requested'] = $time_requested;
|
762 |
-
$posted_data['posted_data'] = $xml->asXML();
|
763 |
-
$posted_data['email'] = $cf7->posted_data['your-email'];
|
764 |
-
$posted_data['user_name'] = $cf7->posted_data['your-name'];
|
765 |
-
$wpdb->insert( $table_posted_data, $posted_data );
|
766 |
-
}
|
767 |
-
|
768 |
-
return $cf7;
|
769 |
}
|
770 |
-
add_action( 'wpcf7_before_send_mail', 'ebd_process_email_form' );
|
771 |
-
|
772 |
-
add_action('admin_menu', 'ebd_plugin_menu');
|
773 |
|
774 |
-
function ebd_plugin_menu() {
|
775 |
|
776 |
-
|
777 |
-
add_action( 'admin_init', 'register_email_before_download_settings' );
|
778 |
|
|
|
|
|
|
|
779 |
}
|
780 |
|
781 |
-
|
782 |
-
|
783 |
-
function ebd_plugin_action_links( $links, $file ) {
|
784 |
-
if ( $file != plugin_basename( __FILE__ ))
|
785 |
-
return $links;
|
786 |
-
|
787 |
-
$settings_link = '<a href="options-general.php?page=email-before-download">' . __( 'Settings', 'email-before-download' ) . '</a>';
|
788 |
|
789 |
-
|
790 |
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
function register_email_before_download_settings() {
|
795 |
-
register_setting( 'email-before-download-group', 'email_before_download_link_target' );
|
796 |
-
register_setting( 'email-before-download-group', 'email_before_download_wrap_in_div' );
|
797 |
-
register_setting( 'email-before-download-group', 'email_before_download_html_before_link' );
|
798 |
-
register_setting( 'email-before-download-group', 'email_before_download_html_after_link' );
|
799 |
-
register_setting( 'email-before-download-group', 'email_before_download_send_email' );
|
800 |
-
register_setting( 'email-before-download-group', 'email_before_download_email_template' );
|
801 |
-
register_setting( 'email-before-download-group', 'email_before_download_email_template_mult' );
|
802 |
-
register_setting( 'email-before-download-group', 'email_before_download_expire_time' );
|
803 |
-
register_setting( 'email-before-download-group', 'email_before_download_hide' );
|
804 |
-
register_setting( 'email-before-download-group', 'email_before_download_attachment' );
|
805 |
-
register_setting( 'email-before-download-group', 'email_before_download_subject' );
|
806 |
-
register_setting( 'email-before-download-group', 'email_before_download_chekboxes_state' );
|
807 |
-
register_setting( 'email-before-download-group', 'email_before_download_forbidden_domains' );
|
808 |
-
register_setting( 'email-before-download-group', 'email_before_download_email_from' );
|
809 |
-
register_setting( 'email-before-download-group', 'email_before_download_hidden_form' );
|
810 |
-
register_setting( 'email-before-download-group', 'email_before_hidden_div_css' );
|
811 |
-
register_setting( 'email-before-download-group', 'email_before_download_is_radio' );
|
812 |
-
|
813 |
-
}
|
814 |
-
|
815 |
-
function email_before_download_options() {
|
816 |
-
|
817 |
-
if (!current_user_can('manage_options')) {
|
818 |
-
wp_die( __('You do not have sufficient permissions to access this page.') );
|
819 |
-
}
|
820 |
-
|
821 |
-
?>
|
822 |
-
<style type="text/css">
|
823 |
-
.ebd th, .ebd td
|
824 |
-
{
|
825 |
-
vertical-align:top;
|
826 |
-
}
|
827 |
-
.ebd th
|
828 |
-
{
|
829 |
-
text-align: left;
|
830 |
-
padding-right:8px;
|
831 |
-
}
|
832 |
-
.ebd .alert
|
833 |
-
{
|
834 |
-
padding:8px;
|
835 |
-
font:bold 12pt Arial;
|
836 |
-
border:1px dashed red;
|
837 |
-
}
|
838 |
-
</style>
|
839 |
-
|
840 |
-
<div class="wrap">
|
841 |
-
<strong style="font:bold 18pt Arial;">Email Before Download Options</strong><br/>
|
842 |
-
<br/>
|
843 |
-
<strong style="font:bold 14pt Arial;">Email Before Download Log:</strong><br/>
|
844 |
-
<a style="font:bold 12pt Arial;" href="<?php echo WP_PLUGIN_URL."/email-before-download/export.php"; ?>" target="_blank">Click to export the Email Before Download log as a .CSV file</a><br/>
|
845 |
-
<br/>
|
846 |
-
<a href="#" target="_blank" onclick="clearLog();return false;">Click to clear Email Before Download log</a><br/><em>Note: This will permanently delete all Email Before Download log entries from the database.</em><br/>
|
847 |
-
<script type="text/javascript">
|
848 |
-
function clearLog(){
|
849 |
-
var answer = confirm ("Are you sure you want to clear the log?")
|
850 |
-
if(answer){
|
851 |
-
jQuery.ajax({
|
852 |
-
type: "POST",
|
853 |
-
url: "<?php echo WP_PLUGIN_URL."/email-before-download/clearlog.php"; ?>",
|
854 |
-
success: function(data){
|
855 |
-
alert(data);
|
856 |
-
}
|
857 |
-
});
|
858 |
-
return false;
|
859 |
-
}
|
860 |
-
//else
|
861 |
-
//alert ("NO");
|
862 |
-
|
863 |
-
}
|
864 |
-
</script>
|
865 |
-
<br/>
|
866 |
-
<strong style="font:bold 14pt Arial;">Support Links:</strong><br/>
|
867 |
-
|
868 |
-
<ul>
|
869 |
-
<li><a href="http://www.mandsconsulting.com/products/wp-email-before-download" target="_blank">Plugin Homepage at M&S Consulting with Live Demos and Test Download</a></li>
|
870 |
-
<li><a href="http://bit.ly/dF9AxV" target="_blank">Plugin Homepage at WordPress</a></li>
|
871 |
-
<li><a href="http://bit.ly/lBo3HN" target="_blank">Plugin Changelog: Current and Past Releases</a></li>
|
872 |
-
<li><a href="http://bit.ly/lU7Tdt" target="_blank">Plugin Support Forums</a></li>
|
873 |
-
</ul>
|
874 |
-
|
875 |
-
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
|
876 |
-
<input type="hidden" name="cmd" value="_s-xclick" />
|
877 |
-
<input type="hidden" name="hosted_button_id" value="47FLSBA363KAU" />
|
878 |
-
<input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" alt="PayPal - The safer, easier way to pay online!" />
|
879 |
-
<img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" width="1" height="1" border="0" />
|
880 |
-
</form>
|
881 |
-
<br/>
|
882 |
-
<strong style="font:bold 14pt Arial;">Configuration Options:</strong><br/>
|
883 |
-
<br/>
|
884 |
-
<form method="post" action="options.php">
|
885 |
-
<?php settings_fields( 'email-before-download-group' ); ?>
|
886 |
-
<table class="optiontable ebd">
|
887 |
-
<tr valign="top">
|
888 |
-
<th scope="row"><p>1. Delivery Format</p></th>
|
889 |
-
<td><p>
|
890 |
-
<select name="email_before_download_send_email">
|
891 |
-
<option value="Inline Link" <?php if(get_option('email_before_download_send_email') == 'Inline Link') echo 'selected="selected"'; ?> >Inline Link</option>
|
892 |
-
<option value="Send Email" <?php if(get_option('email_before_download_send_email') == 'Send Email') echo 'selected="selected"'; ?> >Send Email</option>
|
893 |
-
<option value="Both" <?php if(get_option('email_before_download_send_email') == 'Both') echo 'selected="selected"'; ?> >Both</option>
|
894 |
-
</select><br />
|
895 |
-
</p>
|
896 |
-
</td>
|
897 |
-
</tr>
|
898 |
-
|
899 |
-
|
900 |
-
<tr valign="top">
|
901 |
-
<th scope="row"><p>2. Hide/Mask Real Link</p></th>
|
902 |
-
<td><p><input type="checkbox" size="40" name="email_before_download_hide" value="1" <?php if(get_option('email_before_download_hide')) echo 'checked="checked"'; ?> />
|
903 |
-
<br /> <font size="-1"><i>Hide/mask the real file link from the user. It requires the cURL php extention to be enabled, which is done by uncommenting it from the php.ini file. <a href="#"
|
904 |
-
onclick="window.open('<?php echo WP_PLUGIN_URL."/email-before-download/checkcurl.php" ?>','Check cURL','menubar=no,width=430,height=360,toolbar=no'); return false;">Check if cURL is enabled</a>.</i></font>
|
905 |
-
</p>
|
906 |
-
</td>
|
907 |
-
</tr>
|
908 |
-
|
909 |
-
<tr valign="top">
|
910 |
-
<th scope="row"><p>3. Link Expiration Time (only applies if #2 is checked)</p></th>
|
911 |
-
<td><p>
|
912 |
-
<select name="email_before_download_expire_time">
|
913 |
-
<option value="0" <?php if(get_option('email_before_download_expire_time') == '0') echo 'selected="selected"'; ?> >Never</option>
|
914 |
-
<option value="+1 minute" <?php if(get_option('email_before_download_expire_time') == '+1 minute') echo 'selected="selected"'; ?> >1 min</option>
|
915 |
-
<option value="+3 minute" <?php if(get_option('email_before_download_expire_time') == '+3 minute') echo 'selected="selected"'; ?> >3 min</option>
|
916 |
-
<option value="+10 minute" <?php if(get_option('email_before_download_expire_time') == '+10 minute') echo 'selected="selected"'; ?> >10 min</option>
|
917 |
-
<option value="+30 minute" <?php if(get_option('email_before_download_expire_time') == '+30 minute') echo 'selected="selected"'; ?> >30 min</option>
|
918 |
-
<option value="+1 hour" <?php if(get_option('email_before_download_expire_time') == '+1 hour') echo 'selected="selected"'; ?> >1 hr</option>
|
919 |
-
<option value="+12 hour" <?php if(get_option('email_before_download_expire_time') == '+12 hour') echo 'selected="selected"'; ?> >12 hr</option>
|
920 |
-
<option value="+1 day" <?php if(get_option('email_before_download_expire_time') == '+1 day') echo 'selected="selected"'; ?> >1 day</option>
|
921 |
-
<option value="+1 week" <?php if(get_option('email_before_download_expire_time') == '+1 week') echo 'selected="selected"'; ?> >1 week</option>
|
922 |
-
</select>
|
923 |
-
<br /> <font size="-1"><i>If you are masking the link by checking #2, this option will expire the link sent the user so if they click it again (or send it to someone else who tries) after the specified period, they will have to submit a new form.</i></font>
|
924 |
-
</p>
|
925 |
-
</td>
|
926 |
-
</tr>
|
927 |
-
|
928 |
-
<tr valign="top">
|
929 |
-
<th scope="row"><p>4. Forbidden Email Domains</p></th>
|
930 |
-
<td><p><textarea cols="40" rows="10" name="email_before_download_forbidden_domains" ><?php echo get_option('email_before_download_forbidden_domains'); ?></textarea>
|
931 |
-
<br />
|
932 |
-
<font size="-1"><i> You can enter here the comma separated list of the forbidden domains </i><br />
|
933 |
-
<i> </i><br /></font>
|
934 |
-
</p>
|
935 |
-
</td>
|
936 |
-
</tr>
|
937 |
-
|
938 |
-
|
939 |
-
<tr valign="top"><td colspan="2"><p class="alert">#5 through #8 only apply if you selected "Inline Link" or "Both" as the Delivery Format in #1</p></td></tr>
|
940 |
-
<tr valign="top">
|
941 |
-
<th scope="row"><p>5. Inline Link Target</p></th>
|
942 |
-
<td><p>
|
943 |
-
<select name="email_before_download_link_target">
|
944 |
-
<option value="_blank" <?php if(get_option('email_before_download_link_target') == '_blank') echo 'selected="selected"'; ?> >_blank</option>
|
945 |
-
<option value="_self" <?php if(get_option('email_before_download_link_target') == '_self') echo 'selected="selected"'; ?> >_self</option>
|
946 |
-
</select> <br />
|
947 |
-
<font size="-1"><i>If "_self" is selected link will open in the same browser window/tab, if "_blank" is selected the link will open in the new browser window/tab</i></font>
|
948 |
-
</p>
|
949 |
-
</td>
|
950 |
-
</tr>
|
951 |
-
|
952 |
-
<tr valign="top">
|
953 |
-
<th scope="row"><p>6. Inline Link Custom CSS</p></th>
|
954 |
-
<td><p><input type="text" size="40" name="email_before_download_wrap_in_div" value="<?php echo get_option('email_before_download_wrap_in_div'); ?>" />
|
955 |
-
<br /> <font size="-1"><i>CSS class used to render the div and the link (this is only used if you choose to display the link inline in #5)</i></font>
|
956 |
-
</td>
|
957 |
-
</tr>
|
958 |
-
|
959 |
-
<tr valign="top">
|
960 |
-
<th scope="row"><p>7. HTML Before Inline Link</p></th>
|
961 |
-
<td><p><input type="text" name="email_before_download_html_before_link" size="40" value="<?php echo get_option('email_before_download_html_before_link'); ?>" /><br />
|
962 |
-
<font size="-1"><i>HTML you want to be added before the link</i></font>
|
963 |
-
</p>
|
964 |
-
</td>
|
965 |
-
</tr>
|
966 |
-
|
967 |
-
<tr valign="top">
|
968 |
-
<th scope="row"><p>8. HTML After Inline Link</p></th>
|
969 |
-
<td> <p><input type="text" size="40" name="email_before_download_html_after_link" value="<?php echo get_option('email_before_download_html_after_link'); ?>" />
|
970 |
-
<br /><font size="-1"><i>HTML you want to be added after the link</i></font>
|
971 |
-
</p>
|
972 |
-
</td>
|
973 |
-
</tr>
|
974 |
-
|
975 |
-
<tr valign="top" class="alert"><td colspan="2"><p class="alert">#9 through #11 only apply if you selected "Send Email" or "Both" as the Delivery Format in #1</p></td></tr>
|
976 |
-
<tr valign="top">
|
977 |
-
<th scope="row"><p>9. Email Template</p> 9.1 - single url</th>
|
978 |
-
<td><textarea cols="40" rows="10" name="email_before_download_email_template"><?php echo get_option('email_before_download_email_template'); ?> </textarea><br />
|
979 |
-
<i>You can use the following placeholders: [requesting_name], [file_url] and [file_name]. </i><br />
|
980 |
-
<i>So if you, for example, don't provide the [file_url] placeholder, the
|
981 |
-
<br />user will not receive any link. Here is an example of the template:<br /><br />
|
982 |
-
<b> Hello [requesting_name], <br />
|
983 |
-
|
984 |
-
Here is the download for <a href="[file_url]">[file_name]</a> that you requested.<br />
|
985 |
-
|
986 |
-
Sincerely,<br />
|
987 |
-
|
988 |
-
My Company name </b>
|
989 |
-
<br /><br /> Note. If you leave this field empty, an email containing only the file URL will be sent.
|
990 |
-
|
991 |
-
</i>
|
992 |
-
<br />
|
993 |
-
</td>
|
994 |
-
</tr>
|
995 |
-
<tr valign="top">
|
996 |
-
<th scope="row"> 9.2 - multiple urls</th>
|
997 |
-
<td>
|
998 |
-
<textarea cols="40" rows="10" name="email_before_download_email_template_mult"><?php echo get_option('email_before_download_email_template_mult'); ?> </textarea><br />
|
999 |
-
<i>You can use the following placeholders for multiple urls: [file_urls] </i><br />
|
1000 |
-
</td>
|
1001 |
-
</tr>
|
1002 |
-
|
1003 |
-
<tr valign="top">
|
1004 |
-
<th scope="row"><p>10. Attachment</p></th>
|
1005 |
-
<td><p><input type="checkbox" size="40" name="email_before_download_attachment" value="1" <?php if(get_option('email_before_download_attachment')) echo 'checked="checked"'; ?> />
|
1006 |
-
<br />
|
1007 |
-
<font size="-1"><i>"Attachment" can only be applied to the files uploaded using Download Monitor plugin.</i></font>
|
1008 |
-
</p>
|
1009 |
-
</td>
|
1010 |
-
</tr>
|
1011 |
-
|
1012 |
-
|
1013 |
-
<tr valign="top">
|
1014 |
-
<th scope="row"><p>11. Email Subject</p></th>
|
1015 |
-
<td><p><input type="test" size="40" name="email_before_download_subject" value="<?php echo get_option('email_before_download_subject'); ?>" />
|
1016 |
-
<br />
|
1017 |
-
<font size="-1"><i> If this field is left blank, the default subject is: "Requested URL for the file(s): < file titles >".</i><br />
|
1018 |
-
<i>Note: When populating, you can use the following placeholder if you want the file titles to appear in the email subject: [files]. </i><br /></font>
|
1019 |
-
</p>
|
1020 |
-
</td>
|
1021 |
-
</tr>
|
1022 |
-
|
1023 |
-
<tr valign="top" class="alert"><td colspan="2"><p class="alert">#12 through #15 only apply if you have multiple urls in you shortcode</p></td></tr>
|
1024 |
-
<tr valign="top">
|
1025 |
-
<th scope="row"><p>12. Multiple Checkboxes' Default State</p></th>
|
1026 |
-
<td><p><input type="checkbox" size="40" name="email_before_download_chekboxes_state" value="no" <?php if(get_option('email_before_download_chekboxes_state')) echo 'checked="checked"'; ?> />
|
1027 |
-
<br />
|
1028 |
-
<font size="-1"><i>Select this if you want the default state of the Multiple Checkboxes to be "not checked"</i></font>
|
1029 |
-
</p>
|
1030 |
-
</td>
|
1031 |
-
</tr>
|
1032 |
-
|
1033 |
-
<tr valign="top">
|
1034 |
-
<th scope="row"><p>13. Hidden Form</p></th>
|
1035 |
-
<td><p><input type="checkbox" size="40" name="email_before_download_hidden_form" value="no" <?php if(get_option('email_before_download_hidden_form')) echo 'checked="checked"'; ?> />
|
1036 |
-
<br />
|
1037 |
-
<font size="-1"><i>Select this if you want the form to be hidden untill user checks one of the Multiple Checkboxes</i></font>
|
1038 |
-
</p>
|
1039 |
-
</td>
|
1040 |
-
</tr>
|
1041 |
-
|
1042 |
-
<tr valign="top">
|
1043 |
-
<th scope="row"><p>14. 'Hidden Form Div Style</p></th>
|
1044 |
-
<td><p><input type="test" size="40" name="email_before_hidden_div_css" value="<?php echo get_option('email_before_hidden_div_css'); ?>" />
|
1045 |
-
<br />
|
1046 |
-
<font size="-1"><i> You can customize the appearance of the hidden form.</i><br />
|
1047 |
-
<i>Default is: display:none; . </i><br /></font>
|
1048 |
-
</p>
|
1049 |
-
</td>
|
1050 |
-
</tr>
|
1051 |
-
|
1052 |
-
<tr valign="top">
|
1053 |
-
<th scope="row"><p>15. Downloads as Radio Buttons</p></th>
|
1054 |
-
<td><p><input type="checkbox" size="40" name="email_before_download_is_radio" value="yes" <?php if(get_option('email_before_download_is_radio')) echo 'checked="checked"'; ?> />
|
1055 |
-
<br />
|
1056 |
-
<font size="-1"><i>Select this if you want the Multiple Checkboxes to be turned into Radio buttons</i></font>
|
1057 |
-
</p>
|
1058 |
-
</td>
|
1059 |
-
</tr>
|
1060 |
-
|
1061 |
-
<!--<tr valign="top">
|
1062 |
-
<th scope="row"><p>12. Email From</p></th>
|
1063 |
-
<td><p><input type="test" size="40" name="email_before_download_email_from" value="<?php //echo get_option('email_before_download_email_from'); ?>" />
|
1064 |
-
<br />
|
1065 |
-
<font size="-1"><i> If this field is left blank, the default wordpress email will be used. Use the following format:My Name <myname@mydomain.com>".</i><br />
|
1066 |
-
</i><br /></font>
|
1067 |
-
</p>
|
1068 |
-
</td>
|
1069 |
-
</tr>
|
1070 |
-
--></table>
|
1071 |
-
|
1072 |
-
<p class="submit">
|
1073 |
-
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
1074 |
-
</p>
|
1075 |
-
|
1076 |
-
</form>
|
1077 |
-
</div>
|
1078 |
-
Email Before Download started as a plugin we developed for personal in house needs. We realized this could be useful to other WordPress users. At that point, we made the decision to release the plugin for anyone to use. Offering free support has been the only option, but with the increase in popularity our plugin has seen, offering a paid support option will improve our ability to help you as the user. The WordPress forums will continue to be monitored and updated when we have the chance. If you have a problem or need assistance more rapidly, now offer that paid support option, at a price of $10.00. With paid support, you will get a personal response from us within 24 hours of submitting a help request. We will work with you to get your issue to resolution, but can.t spend more than 1 hr for the $10. Beyond that, we offer consulting services you can inquire about as well. Click below to pay the $10.00 for our paid support and email us at ebd.support@mandsconsulting.com with your PayPal confirmation number and we will get started.
|
1079 |
-
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
1080 |
-
<input type="hidden" name="cmd" value="_s-xclick">
|
1081 |
-
<input type="hidden" name="hosted_button_id" value="FQTJLT67MLLN6">
|
1082 |
-
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
1083 |
-
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
1084 |
-
</form>
|
1085 |
-
|
1086 |
-
<?php
|
1087 |
|
1088 |
}
|
1089 |
-
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
/**
|
4 |
+
* The plugin bootstrap file
|
5 |
+
*
|
6 |
+
*
|
7 |
+
* @link mandsconsulting.com
|
8 |
+
* @since 5.0.0
|
9 |
+
* @package Email_Before_Download
|
10 |
+
*
|
11 |
+
* @wordpress-plugin
|
12 |
+
* Plugin Name: Email Before Download
|
13 |
+
* Plugin URI: mandsconsulting.com
|
14 |
+
* Version: 5.0.0
|
15 |
+
* Author: M & S Consulting
|
16 |
+
* Author URI: mandsconsulting.com
|
17 |
+
* License: GPL-2.0+
|
18 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
19 |
+
* Text Domain: email-before-download
|
20 |
+
* Domain Path: /languages
|
21 |
+
*/
|
22 |
|
23 |
+
if ( ! defined( 'WPINC' ) ) {
|
24 |
+
die;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
|
|
|
|
|
|
26 |
|
|
|
27 |
|
28 |
+
define( 'PLUGIN_NAME_VERSION', '5.0.0' );
|
|
|
29 |
|
30 |
+
function activate_email_before_download() {
|
31 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-email-before-download-activator.php';
|
32 |
+
Email_Before_Download_Activator::activate();
|
33 |
}
|
34 |
|
35 |
+
register_activation_hook( __FILE__, 'activate_email_before_download' );
|
36 |
+
require plugin_dir_path( __FILE__ ) . 'includes/class-email-before-download.php';
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
+
function run_email_before_download() {
|
39 |
|
40 |
+
$plugin = new Email_Before_Download();
|
41 |
+
$plugin->run();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
}
|
44 |
+
run_email_before_download();
|
export.php
DELETED
@@ -1,90 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
//wordpress
|
3 |
-
define('WP_USE_THEMES', false);
|
4 |
-
$wp_root = dirname(__FILE__) .'/../../../';
|
5 |
-
if(file_exists($wp_root . 'wp-load.php')) {
|
6 |
-
require_once($wp_root . "wp-load.php");
|
7 |
-
} else if(file_exists($wp_root . 'wp-config.php')) {
|
8 |
-
require_once($wp_root . "wp-config.php");
|
9 |
-
} else {
|
10 |
-
exit;
|
11 |
-
}
|
12 |
-
|
13 |
-
if ( !current_user_can('manage_options') ) {
|
14 |
-
exit(0);
|
15 |
-
}
|
16 |
-
|
17 |
-
global $wpdb,$wp_dlm_root, $wp_dlm_db;
|
18 |
-
$table_item = $wpdb->prefix . "ebd_item";
|
19 |
-
$table_link = $wpdb->prefix . "ebd_link";
|
20 |
-
$table_posted_data = $wpdb->prefix . "ebd_posted_data";
|
21 |
-
$title_sql = "d.title";
|
22 |
-
|
23 |
-
$is_new_dm = false;
|
24 |
-
|
25 |
-
$old_rep = error_reporting(E_ERROR | E_PARSE);;
|
26 |
-
|
27 |
-
$pd = &get_file_data( WP_PLUGIN_DIR . "/download-monitor/download-monitor.php", array("Version"=>"Version"), 'plugin');
|
28 |
-
if(!($pd['Version'])) {
|
29 |
-
}
|
30 |
-
else $is_new_dm = true;
|
31 |
-
|
32 |
-
$new = error_reporting($old_rep);
|
33 |
-
|
34 |
-
if ($is_new_dm){
|
35 |
-
$wp_dlm_db = $wpdb->prefix . "posts";
|
36 |
-
$title_sql = "d.post_title";
|
37 |
-
}
|
38 |
-
|
39 |
-
$sql = "SELECT l.item_id as item_id,
|
40 |
-
l.is_downloaded as is_downloaded,
|
41 |
-
l.email as email,
|
42 |
-
p.user_name as user_name,
|
43 |
-
l.delivered_as as delivered_as,
|
44 |
-
l.selected_id as selected_id,
|
45 |
-
i.file as filename,
|
46 |
-
i.download_id as download_id,
|
47 |
-
$title_sql as title,
|
48 |
-
p.posted_data as posted_data,
|
49 |
-
i.title as item_title,
|
50 |
-
l.time_requested as time_requested
|
51 |
-
from
|
52 |
-
$table_item i
|
53 |
-
left outer join
|
54 |
-
$table_link l
|
55 |
-
left outer join
|
56 |
-
$wp_dlm_db d
|
57 |
-
on l.selected_id = d.id
|
58 |
-
left outer join
|
59 |
-
$table_posted_data p
|
60 |
-
on l.time_requested = p.time_requested
|
61 |
-
on l.item_id = i.id
|
62 |
-
order by l.time_requested desc";
|
63 |
-
$downloads = $wpdb->get_results($sql);
|
64 |
-
|
65 |
-
$csv = "item_id,email,user_name,download_id,selected_id,filename,item_title,time_requested,posted_data,delivered_as\n";
|
66 |
-
|
67 |
-
$clean_csv_search = array("\n","\r","\t", ",");
|
68 |
-
$clean_csv_replace = array(" "," "," ", ";");
|
69 |
-
|
70 |
-
if($downloads){
|
71 |
-
foreach($downloads as $d){
|
72 |
-
$csv .= $d->item_id . "," .
|
73 |
-
$d->email . "," .
|
74 |
-
$d->user_name . "," .
|
75 |
-
str_replace(',', ';', $d->download_id ). "," .
|
76 |
-
$d->selected_id . "," .
|
77 |
-
$d->filename . "," .
|
78 |
-
$d->item_title . "," .
|
79 |
-
date("Y-m-d G:i", $d->time_requested). "," .
|
80 |
-
str_replace($clean_csv_search, $clean_csv_replace, $d->posted_data). "," .
|
81 |
-
$d->delivered_as . "\n" ;
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
-
$size = strlen($csv);
|
86 |
-
header("Content-type: text/csv");
|
87 |
-
header("Content-Disposition: attachment; filename=download_log_" . date("Y-m-d") . ".csv; size=$size");
|
88 |
-
|
89 |
-
print $csv;
|
90 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-email-before-download-activator.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fired during plugin activation.
|
4 |
+
*
|
5 |
+
* This class defines all code necessary to run during the plugin's activation.
|
6 |
+
*
|
7 |
+
* @since 5.0.0
|
8 |
+
* @package Email_Before_Download
|
9 |
+
* @subpackage Email_Before_Download/includes
|
10 |
+
* @author M & S Consulting
|
11 |
+
*/
|
12 |
+
class Email_Before_Download_Activator
|
13 |
+
{
|
14 |
+
|
15 |
+
public static function activate()
|
16 |
+
{
|
17 |
+
if (!is_plugin_active('download-monitor/download-monitor.php'))
|
18 |
+
$plugins[] = "Download Monitor";
|
19 |
+
if (!is_plugin_active('contact-form-7/wp-contact-form-7.php'))
|
20 |
+
$plugins[] = "Contact Form 7";
|
21 |
+
|
22 |
+
if (!empty($plugins)) {
|
23 |
+
echo("Missing the following plugin(s):<br>");
|
24 |
+
foreach ($plugins as $plugin) {
|
25 |
+
echo("<strong>$plugin</strong><br>");
|
26 |
+
}
|
27 |
+
@trigger_error(__('missing dependencies', 'ap'), E_USER_ERROR);
|
28 |
+
}
|
29 |
+
global $wpdb;
|
30 |
+
|
31 |
+
$tables = array(
|
32 |
+
"CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "ebd_item (
|
33 |
+
`id` int(11) NOT NULL auto_increment,
|
34 |
+
`download_id` varchar(128) NULL,
|
35 |
+
`file` varchar(255) NULL,
|
36 |
+
`title` varchar(255) NULL,
|
37 |
+
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
38 |
+
PRIMARY KEY (`id`)
|
39 |
+
);",
|
40 |
+
"CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "ebd_link (
|
41 |
+
`id` mediumint(9) NOT NULL AUTO_INCREMENT,
|
42 |
+
`item_id` int(11) NOT NULL,
|
43 |
+
`is_downloaded` smallint(3) NOT NULL DEFAULT '0',
|
44 |
+
`email` varchar(128) NOT NULL,
|
45 |
+
`expire_time` bigint(11) DEFAULT NULL,
|
46 |
+
`time_requested` bigint(11) DEFAULT NULL,
|
47 |
+
`uid` varchar(255) NOT NULL,
|
48 |
+
`selected_id` bigint(20) NOT NULL,
|
49 |
+
`delivered_as` varchar(255) DEFAULT NULL,
|
50 |
+
`is_masked` varchar(4) DEFAULT NULL,
|
51 |
+
`is_force_download` varchar(4) DEFAULT NULL,
|
52 |
+
UNIQUE KEY `id` (`id`)
|
53 |
+
) ENGINE=MyISAM AUTO_INCREMENT=18 DEFAULT CHARSET=utf8
|
54 |
+
;",
|
55 |
+
"CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "ebd_posted_data (
|
56 |
+
time_requested bigint(20),
|
57 |
+
email VARCHAR(128) NULL,
|
58 |
+
user_name VARCHAR(128)CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL,
|
59 |
+
posted_data text(2000) NOT NULL,
|
60 |
+
UNIQUE KEY id (time_requested)
|
61 |
+
);",
|
62 |
+
|
63 |
+
);
|
64 |
+
$charset_collate = $wpdb->get_charset_collate();
|
65 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
66 |
+
foreach ($tables as $table) {
|
67 |
+
dbDelta($table . $charset_collate);
|
68 |
+
}
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
}
|
includes/class-email-before-download-db.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Used for plugin specific database actions.
|
4 |
+
*
|
5 |
+
* This class defines most code necessary to read and write
|
6 |
+
* links, items, and logs to the database.
|
7 |
+
*
|
8 |
+
* @since 5.0.0
|
9 |
+
* @package Email_Before_Download
|
10 |
+
* @subpackage Email_Before_Download/includes
|
11 |
+
* @author M & S Consulting
|
12 |
+
*/
|
13 |
+
|
14 |
+
class Email_Before_Download_DB
|
15 |
+
{
|
16 |
+
private $db;
|
17 |
+
private $item_table;
|
18 |
+
private $link_table;
|
19 |
+
private $posted_table;
|
20 |
+
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
global $wpdb;
|
24 |
+
$this->db = $wpdb;
|
25 |
+
$this->item_table = $this->db->prefix . "ebd_item";
|
26 |
+
$this->link_table = $this->db->prefix . "ebd_link";
|
27 |
+
$this->posted_table = $this->db->prefix . "ebd_posted_data";
|
28 |
+
}
|
29 |
+
|
30 |
+
public function select_item($data)
|
31 |
+
{
|
32 |
+
return $this->db->get_row("SELECT * FROM $this->item_table WHERE download_id = '$data'");
|
33 |
+
}
|
34 |
+
|
35 |
+
public function create_item($atts)
|
36 |
+
{
|
37 |
+
$item = $this->item_exists($atts);
|
38 |
+
if ($item) {
|
39 |
+
return $item;
|
40 |
+
} else {
|
41 |
+
$this->db->insert($this->item_table,
|
42 |
+
[
|
43 |
+
'download_id' => $atts['download_id'],
|
44 |
+
'title' => sanitize_text_field($atts['title']),
|
45 |
+
'file' => esc_url($atts['file'])
|
46 |
+
]);
|
47 |
+
return $this->db->insert_id;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
public function item_exists($data)
|
52 |
+
{
|
53 |
+
//check if item exists and if it needs updated
|
54 |
+
$query = $this->db->get_row("SELECT * FROM $this->item_table WHERE download_id = '" . $data['download_id'] . "'");
|
55 |
+
if (count($query) > 0) {
|
56 |
+
if ($query->file != $data['file']) {
|
57 |
+
$this->db->update($this->item_table,
|
58 |
+
['file' => $data['file']],
|
59 |
+
['id' => $query->id]);
|
60 |
+
}
|
61 |
+
if ($query->title != $data['title']) {
|
62 |
+
$this->db->update($this->item_table,
|
63 |
+
['title' => $data['title']],
|
64 |
+
['id' => $query->id]);
|
65 |
+
}
|
66 |
+
return $query->id;
|
67 |
+
}
|
68 |
+
return false;
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
public function create_link($data)
|
73 |
+
{
|
74 |
+
$data['expire_time'] = $this->expired($data['expire_time']);
|
75 |
+
$this->db->insert($this->link_table, $data);
|
76 |
+
$id = $this->db->insert_id;
|
77 |
+
$link = $this->db->get_row("SELECT * FROM $this->link_table WHERE id = '$id'");
|
78 |
+
return $link;
|
79 |
+
}
|
80 |
+
|
81 |
+
public function select_link($column, $data)
|
82 |
+
{
|
83 |
+
$query = $this->db->get_row("SELECT * FROM $this->link_table WHERE $column = '$data'");
|
84 |
+
return $query;
|
85 |
+
}
|
86 |
+
|
87 |
+
public function mark_downloaded($id)
|
88 |
+
{
|
89 |
+
|
90 |
+
return $this->db->update(
|
91 |
+
$this->link_table,
|
92 |
+
['is_downloaded' => 1],
|
93 |
+
['ID' => $id]
|
94 |
+
);
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
public function create_log($data)
|
99 |
+
{
|
100 |
+
return $this->db->insert($this->posted_table, $data);
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
public function expired($option)
|
105 |
+
{
|
106 |
+
if ($option != 0) {
|
107 |
+
$duration = [
|
108 |
+
'minute' => 60,
|
109 |
+
'hour' => 3600,
|
110 |
+
'day' => 172800,
|
111 |
+
'week' => 604800
|
112 |
+
];
|
113 |
+
|
114 |
+
$expired = explode(" ", $option);
|
115 |
+
$expiration = $expired[0] * $duration[$expired[1]];
|
116 |
+
$option = time() + $expiration;
|
117 |
+
}
|
118 |
+
return $option;
|
119 |
+
}
|
120 |
+
|
121 |
+
public function clean_up($table)
|
122 |
+
{
|
123 |
+
|
124 |
+
if ($table == $this->db->prefix . "ebd_link") {
|
125 |
+
$now = time();
|
126 |
+
$query = "DELETE FROM $table WHERE expire_time < $now";
|
127 |
+
$page = 'links';
|
128 |
+
} else {
|
129 |
+
$query = "DELETE FROM $table";
|
130 |
+
$page = "logs";
|
131 |
+
}
|
132 |
+
$this->db->query($query);
|
133 |
+
session_start();
|
134 |
+
$_SESSION['success'] = "$page have been purged.";
|
135 |
+
wp_redirect(admin_url("/options-general.php?page=email-before-download-$page"));
|
136 |
+
|
137 |
+
}
|
138 |
+
public function export($table){
|
139 |
+
$csv = "";
|
140 |
+
foreach ( $this->db->get_col( "DESC " . $table, 0 ) as $column_name ) {
|
141 |
+
$csv .= $column_name.",";
|
142 |
+
}
|
143 |
+
$csv = substr($csv, 0, -1). "\n";
|
144 |
+
foreach( $this->db->get_results("SELECT * FROM $table") as $key => $row) {
|
145 |
+
foreach ($row as $key2 => $value){
|
146 |
+
$csv .= $value. ",";
|
147 |
+
}
|
148 |
+
$csv = substr($csv, 0, -1). "\n";
|
149 |
+
}
|
150 |
+
return $csv;
|
151 |
+
}
|
152 |
+
}
|
includes/class-email-before-download-downloader.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @since 5.0.0
|
4 |
+
* @package Email_Before_Download
|
5 |
+
* @subpackage Email_Before_Download/includes
|
6 |
+
* @author M & S Consulting
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Email_Before_download_Downloader
|
10 |
+
{
|
11 |
+
private $plugin_name;
|
12 |
+
private $version;
|
13 |
+
|
14 |
+
public function __construct($plugin_name, $version)
|
15 |
+
{
|
16 |
+
|
17 |
+
$this->plugin_name = $plugin_name;
|
18 |
+
$this->version = $version;
|
19 |
+
|
20 |
+
}
|
21 |
+
|
22 |
+
public function parse($wp)
|
23 |
+
{
|
24 |
+
if (isset($wp->query_vars['pagename'])) {
|
25 |
+
$pagename = $wp->query_vars['pagename'];
|
26 |
+
} else {
|
27 |
+
return;
|
28 |
+
}
|
29 |
+
if (($pagename == 'ebd-file') && (isset($_GET['uid']))) {
|
30 |
+
$uid = sanitize_text_field($_GET['uid']);
|
31 |
+
$this->serve_file($uid);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
public function serve_file($uid)
|
37 |
+
{
|
38 |
+
$db = new Email_Before_Download_DB();
|
39 |
+
$link = $db->select_link('uid', $uid);
|
40 |
+
if ($this->expired($link)) {
|
41 |
+
wp_die(__('This download has expired. Please fill out a new form to generate a new link.', 'email-before-download'));
|
42 |
+
}
|
43 |
+
if($link->file){
|
44 |
+
$file = $link->file;
|
45 |
+
}else{
|
46 |
+
$file = do_shortcode("[download_data id=\"$link->selected_id\" data=\"download_link\"]");
|
47 |
+
|
48 |
+
}
|
49 |
+
$db->mark_downloaded($link->id);
|
50 |
+
wp_redirect($file);
|
51 |
+
exit();
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
public function expired($link)
|
56 |
+
{
|
57 |
+
if ($link->expire_time)
|
58 |
+
if ($link->expire_time < time()) return true;
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
}
|
includes/class-email-before-download-form.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @since 5.0.0
|
4 |
+
* @package Email_Before_Download
|
5 |
+
* @subpackage Email_Before_Download/includes
|
6 |
+
* @author M & S Consulting
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Email_Before_Download_Form
|
10 |
+
{
|
11 |
+
public $form_id;
|
12 |
+
public $download_id;
|
13 |
+
public $titles;
|
14 |
+
public $atts;
|
15 |
+
|
16 |
+
public function __construct($atts)
|
17 |
+
{
|
18 |
+
$this->atts = $atts;
|
19 |
+
$this->form_id = $atts['contact_form_id'];
|
20 |
+
$this->download_id = $this->att_to_array($atts['download_id']);
|
21 |
+
$this->titles = $this->att_to_array($atts['title']);
|
22 |
+
unset($this->atts['contact_form_id']);
|
23 |
+
unset($this->atts['download_id']);
|
24 |
+
}
|
25 |
+
|
26 |
+
public function html()
|
27 |
+
{
|
28 |
+
$raw = "<div id='ebdForm'>".do_shortcode("[contact-form-7 id=\"$this->form_id\" ]")."</div>";
|
29 |
+
$form = new DOMDocument;
|
30 |
+
$form->formatOutput = true;
|
31 |
+
$form->loadHTML($raw);
|
32 |
+
$parent = $form->getElementsByTagName('form')->item(0);
|
33 |
+
$children = $parent->getElementsByTagName('input');
|
34 |
+
$paragraphs = $parent->getElementsByTagName('p');
|
35 |
+
foreach ($paragraphs as $p){
|
36 |
+
$p->setAttribute('class','cf7_input');
|
37 |
+
}
|
38 |
+
$paragraph = $parent->getElementsByTagName('p')->item(0);
|
39 |
+
if($this->atts['hide_form'] != 'no') {
|
40 |
+
$paragraph->setAttribute('id','downloadinputform');
|
41 |
+
}
|
42 |
+
foreach ($this->download_id as $key => $id) {
|
43 |
+
$item = $this->download_dom_obj($id, $key);
|
44 |
+
$item = $form->importNode($item, true);
|
45 |
+
$paragraph->parentNode->insertBefore($item, $paragraph);
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
foreach ($this->atts as $name => $value) {
|
50 |
+
if($value){
|
51 |
+
$item = $this->hidden_dom_obj($name,$value);
|
52 |
+
$item = $form->importNode($item, true);
|
53 |
+
$children->item(0)->parentNode->insertBefore($item, $children->item(0));
|
54 |
+
}
|
55 |
+
}
|
56 |
+
return $form->saveHTML();
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
private function hide_form($form){
|
61 |
+
$userCss = get_option('email_before_download_hidden_form_css');
|
62 |
+
if($userCss == ''){
|
63 |
+
$form->setAttribute('style','display:none');
|
64 |
+
}else{
|
65 |
+
$class = $form->getAttribute('class');
|
66 |
+
$class = $class . " ". $userCss;
|
67 |
+
$form->setAttribute('class',$class);
|
68 |
+
}
|
69 |
+
return $form;
|
70 |
+
}
|
71 |
+
private function download_dom_obj($id, $key){
|
72 |
+
|
73 |
+
$formObject = new DOMDocument();
|
74 |
+
$formObject->formatOutput = true;
|
75 |
+
$title = $this->titles[$key];
|
76 |
+
$isChecked = get_option('email_before_download_multi_check');
|
77 |
+
$isRadio = $this->atts['radio'];
|
78 |
+
if ($isRadio != "yes" ) {
|
79 |
+
$input = 'checkbox';
|
80 |
+
} else {
|
81 |
+
$input = 'radio';
|
82 |
+
}
|
83 |
+
$formObject->loadHTML("<label class='ebd_input'><input type=\"$input\" $isChecked name=\"ebd_downloads[]\" value=\"$id:$title\"> $title</label>");
|
84 |
+
$node = $formObject->getElementsByTagName("label");
|
85 |
+
return $node->item(0);
|
86 |
+
}
|
87 |
+
private function hidden_dom_obj($name, $value){
|
88 |
+
$formObject = new DOMDocument();
|
89 |
+
$formObject->formatOutput = true;
|
90 |
+
$formObject->loadHTML("<input type=\"hidden\" class=\"ebd_setting\" name =\"ebd_settings[]\" value=\"$name:$value\">");
|
91 |
+
$node = $formObject->getElementsByTagName("input");
|
92 |
+
return $node->item(0);
|
93 |
+
}
|
94 |
+
private function att_to_array($data){
|
95 |
+
$formatted = [];
|
96 |
+
if (stripos($data, ',')) {
|
97 |
+
$formatted = explode(',', $data);
|
98 |
+
} else {
|
99 |
+
$formatted[] = $data;
|
100 |
+
}
|
101 |
+
return $formatted;
|
102 |
+
}
|
103 |
+
}
|
includes/class-email-before-download-i18n.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Define the internationalization functionality
|
5 |
+
*
|
6 |
+
* Loads and defines the internationalization files for this plugin
|
7 |
+
* so that it is ready for translation.
|
8 |
+
*
|
9 |
+
* @link mandsconsulting.com
|
10 |
+
* @since 1.0.0
|
11 |
+
*
|
12 |
+
* @package Email_Before_Download
|
13 |
+
* @subpackage Email_Before_Download/includes
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Define the internationalization functionality.
|
18 |
+
*
|
19 |
+
* Loads and defines the internationalization files for this plugin
|
20 |
+
* so that it is ready for translation.
|
21 |
+
*
|
22 |
+
* @since 5.0.0
|
23 |
+
* @package Email_Before_Download
|
24 |
+
* @subpackage Email_Before_Download/includes
|
25 |
+
* @author M & S Consulting
|
26 |
+
*/
|
27 |
+
class Email_Before_Download_i18n {
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Load the plugin text domain for translation.
|
32 |
+
*
|
33 |
+
* @since 1.0.0
|
34 |
+
*/
|
35 |
+
public function load_plugin_textdomain() {
|
36 |
+
|
37 |
+
load_plugin_textdomain(
|
38 |
+
'email-before-download',
|
39 |
+
false,
|
40 |
+
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
|
41 |
+
);
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
}
|
includes/class-email-before-download-loader.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Register all actions and filters for the plugin
|
5 |
+
*
|
6 |
+
* @since 5.0.0
|
7 |
+
* @package Email_Before_Download
|
8 |
+
* @subpackage Email_Before_Download/includes
|
9 |
+
* @author M & S Consulting
|
10 |
+
*/
|
11 |
+
class Email_Before_Download_Loader {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The array of actions registered with WordPress.
|
15 |
+
*
|
16 |
+
* @since 1.0.0
|
17 |
+
* @access protected
|
18 |
+
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
|
19 |
+
*/
|
20 |
+
protected $actions;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* The array of filters registered with WordPress.
|
24 |
+
*
|
25 |
+
* @since 1.0.0
|
26 |
+
* @access protected
|
27 |
+
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
|
28 |
+
*/
|
29 |
+
protected $filters;
|
30 |
+
|
31 |
+
public function __construct() {
|
32 |
+
|
33 |
+
$this->actions = array();
|
34 |
+
$this->filters = array();
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
39 |
+
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
|
40 |
+
}
|
41 |
+
|
42 |
+
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
43 |
+
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
44 |
+
}
|
45 |
+
|
46 |
+
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
47 |
+
|
48 |
+
$hooks[] = array(
|
49 |
+
'hook' => $hook,
|
50 |
+
'component' => $component,
|
51 |
+
'callback' => $callback,
|
52 |
+
'priority' => $priority,
|
53 |
+
'accepted_args' => $accepted_args
|
54 |
+
);
|
55 |
+
|
56 |
+
return $hooks;
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
public function run() {
|
61 |
+
|
62 |
+
foreach ( $this->filters as $hook ) {
|
63 |
+
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
64 |
+
}
|
65 |
+
|
66 |
+
foreach ( $this->actions as $hook ) {
|
67 |
+
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
68 |
+
}
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
}
|
includes/class-email-before-download-process.php
ADDED
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @since 5.0.0
|
4 |
+
* @package Email_Before_Download
|
5 |
+
* @subpackage Email_Before_Download/includes
|
6 |
+
* @author M & S Consulting
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Email_Before_Download_Process
|
10 |
+
{
|
11 |
+
|
12 |
+
private $plugin_name;
|
13 |
+
private $version;
|
14 |
+
private $db;
|
15 |
+
|
16 |
+
public function __construct($plugin_name, $version)
|
17 |
+
{
|
18 |
+
$this->plugin_name = $plugin_name;
|
19 |
+
$this->version = $version;
|
20 |
+
$this->db = new Email_Before_Download_DB();
|
21 |
+
}
|
22 |
+
|
23 |
+
public function process_cf7($form_obj)
|
24 |
+
{
|
25 |
+
if (!isset($_POST['ebd_settings'])) {
|
26 |
+
return $form_obj; // make sure this only fires when there is EBD info
|
27 |
+
}
|
28 |
+
$post_data = $_POST;
|
29 |
+
$user_input = [];
|
30 |
+
$settings = $this->parse_post_array($post_data['ebd_settings']);
|
31 |
+
$downloads = $this->parse_post_array($post_data['ebd_downloads']);
|
32 |
+
foreach ($post_data as $key => $value) {
|
33 |
+
if (!is_array($value))
|
34 |
+
$user_input[$key] = $value;
|
35 |
+
}
|
36 |
+
$this->log($post_data, $user_input);
|
37 |
+
$links = $this->generate_links($downloads, $settings, $user_input);
|
38 |
+
if (($settings['delivered_as'] == 'inline link') || ($settings['delivered_as'] == "both")) {
|
39 |
+
if (isset($settings['force_download'])) {
|
40 |
+
if (count($links) == 1) {
|
41 |
+
foreach ($links as $link) {
|
42 |
+
$linkURL = $this->link_url($link);
|
43 |
+
$additional_settings = $form_obj->prop('additional_settings');
|
44 |
+
$additional_settings .= "\n" . "on_sent_ok: \"window.location.href = '$linkURL';\"";
|
45 |
+
$form_obj->set_properties(array('additional_settings' => $additional_settings));
|
46 |
+
}
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
} else {
|
51 |
+
$form_obj = $this->inline_links($links, $form_obj);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
if (($settings['delivered_as'] == 'send email') || ($settings['delivered_as'] == 'both')) {
|
56 |
+
$this->send_email($user_input, $links, $settings);
|
57 |
+
}
|
58 |
+
return $form_obj;
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
private function parse_post_array($post_array)
|
63 |
+
{
|
64 |
+
$new_array = [];
|
65 |
+
$delimiter = ":";
|
66 |
+
foreach ($post_array as $item) {
|
67 |
+
if (strpos($item, '|')) {
|
68 |
+
$delimiter = "|";
|
69 |
+
}
|
70 |
+
$tmp = explode($delimiter, $item);
|
71 |
+
$new_array[$tmp[0]] = strtolower($tmp[1]);
|
72 |
+
}
|
73 |
+
return $new_array;
|
74 |
+
}
|
75 |
+
|
76 |
+
private function generate_email($body, $data, $links)
|
77 |
+
{
|
78 |
+
//build email to send to user
|
79 |
+
$files = $this->email_links($links);
|
80 |
+
foreach ($data as $key => $value) {
|
81 |
+
if (!is_array($value)) {
|
82 |
+
$tagToReplace = "[$key]";
|
83 |
+
$body = str_replace($tagToReplace, $value, $body);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
$urls = "";
|
87 |
+
foreach ($files as $key => $value) {
|
88 |
+
if (count($files) == 1) {
|
89 |
+
$body = str_replace('[file_url]', $value, $body);
|
90 |
+
$body = str_replace('[file_name]', $key, $body);
|
91 |
+
} else {
|
92 |
+
$urls .= $value . "\n";
|
93 |
+
}
|
94 |
+
}
|
95 |
+
$body = str_replace('[file_urls]', $urls, $body);
|
96 |
+
|
97 |
+
|
98 |
+
return $body;
|
99 |
+
}
|
100 |
+
|
101 |
+
private function send_email($user_input, $links, $settings)
|
102 |
+
{
|
103 |
+
$headers = "MIME-Version: 1.0\r\n";
|
104 |
+
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
|
105 |
+
$from = get_option("email_before_download_from_email", "");
|
106 |
+
if(is_email($from)){
|
107 |
+
$headers .= "From: $from" . "\r\n";
|
108 |
+
}
|
109 |
+
$attachments = [];
|
110 |
+
if (count($links) > 1) {
|
111 |
+
$template = get_option("email_before_download_multi_email");
|
112 |
+
if (!$template) $template = "[file_urls]";
|
113 |
+
} else {
|
114 |
+
$template = get_option("email_before_download_single_email");
|
115 |
+
if (!$template) $template = __("Here is the download for <a href=\"[file_url]\">[file_name]</a> that you requested.",'email-before-download');
|
116 |
+
|
117 |
+
}
|
118 |
+
$subject = get_option("email_before_download_subject");
|
119 |
+
if (!$subject) $subject = __("Your Requested File(s)", 'email-before-download');
|
120 |
+
|
121 |
+
$body = $this->generate_email($template, $user_input, $links);
|
122 |
+
if ( (isset($settings['attachment']) ) && ($settings['attachment'] == 1) ) {
|
123 |
+
$attachments = $this->email_attachments($links);
|
124 |
+
}
|
125 |
+
wp_mail($user_input['your-email'], $subject, $body, $headers, $attachments);
|
126 |
+
return true;
|
127 |
+
}
|
128 |
+
|
129 |
+
private function generate_links($downloads, $settings, $user_input)
|
130 |
+
{
|
131 |
+
|
132 |
+
$links = [];
|
133 |
+
$default_link_data = [
|
134 |
+
"expire_time" => "",
|
135 |
+
"delivered_as" => "",
|
136 |
+
"force_download" => ""
|
137 |
+
];
|
138 |
+
$settings = array_merge($default_link_data, $settings);
|
139 |
+
|
140 |
+
foreach ($downloads as $id => $title) {
|
141 |
+
$linkdata = [
|
142 |
+
"item_id" => $settings['item_id'],
|
143 |
+
"selected_id" => $id,
|
144 |
+
"is_force_download" => $settings['force_download'],
|
145 |
+
"email" => sanitize_email($user_input['your-email']),
|
146 |
+
"delivered_as" => $settings['delivered_as'],
|
147 |
+
'uid' => substr(md5(uniqid(mt_rand(), true)), 0, 10),
|
148 |
+
'time_requested' => time(),
|
149 |
+
|
150 |
+
];
|
151 |
+
|
152 |
+
$linkdata = array_filter($linkdata);
|
153 |
+
$linkdata["expire_time"] = get_option('email_before_download_expire',"");
|
154 |
+
$link = $this->db->create_link($linkdata);
|
155 |
+
$links[$link->id] = $link;
|
156 |
+
}
|
157 |
+
return $links;
|
158 |
+
}
|
159 |
+
|
160 |
+
private function inline_links($links, $form_obj)
|
161 |
+
{
|
162 |
+
$linkHTML = "<div>" . get_option('email_before_download_html_before',"");
|
163 |
+
foreach ($links as $link) {
|
164 |
+
$downloadURL = $this->link_url($link);
|
165 |
+
$linkCSS = get_option('email_before_download_link_css',"");
|
166 |
+
$target = get_option('email_before_download_link_format','_self');
|
167 |
+
$html = "<a href=\"$downloadURL\" class=\"ebd_link $linkCSS\" target=\"$target\">";
|
168 |
+
$html .= do_shortcode("[download_data id=\"$link->selected_id\" data=\"title\"]");
|
169 |
+
$html .= "</a>";
|
170 |
+
$linkHTML .= $html;
|
171 |
+
}
|
172 |
+
$linkHTML .= get_option('email_before_download_html_after','') . "</div>";
|
173 |
+
$additional_settings = $form_obj->prop('additional_settings');
|
174 |
+
$additional_settings .= "\n" . "on_sent_ok: \"jQuery('.ebd_input').hide();jQuery('.cf7_input').hide(); jQuery('#ebdForm').append('$linkHTML'); \"";
|
175 |
+
$form_obj->set_properties(array('additional_settings' => $additional_settings));
|
176 |
+
return $form_obj;
|
177 |
+
}
|
178 |
+
|
179 |
+
private function email_links($links)
|
180 |
+
{
|
181 |
+
|
182 |
+
$files = [];
|
183 |
+
foreach ($links as $link) {
|
184 |
+
$title = do_shortcode("[download_data id=\"$link->selected_id\" data=\"title\"]");
|
185 |
+
$files[$title] = $this->link_url($link);
|
186 |
+
}
|
187 |
+
return $files;
|
188 |
+
}
|
189 |
+
|
190 |
+
private function email_attachments($links)
|
191 |
+
{
|
192 |
+
|
193 |
+
$filePaths = [];
|
194 |
+
foreach ($links as $link) {
|
195 |
+
$fileName = do_shortcode("[download_data id=\"$link->selected_id\" data=\"filename\"]");
|
196 |
+
$fileDate = do_shortcode("[download_data id=\"$link->selected_id\" data=\"file_date\"]");
|
197 |
+
$fileDate = date('Y/m', strtotime($fileDate));
|
198 |
+
$filePaths[] = WP_CONTENT_DIR . "/uploads/dlm_uploads/$fileDate/$fileName";
|
199 |
+
}
|
200 |
+
return $filePaths;
|
201 |
+
}
|
202 |
+
|
203 |
+
public function check_blacklist($result, $tag)
|
204 |
+
{
|
205 |
+
if (!isset($_POST['ebd_settings'])) {
|
206 |
+
return $result; // make sure this is an EBD form
|
207 |
+
}
|
208 |
+
$email = strtolower(sanitize_email($_POST['your-email']));
|
209 |
+
if ($this->blacklist($email)) {
|
210 |
+
$result->invalidate('your-email', __('addresses from this domain are not allowed.', 'email-before-download'));
|
211 |
+
}
|
212 |
+
return $result;
|
213 |
+
}
|
214 |
+
|
215 |
+
public function blacklist($email)
|
216 |
+
{
|
217 |
+
$blacklist = strtolower(get_option('email_before_download_forbidden',""));
|
218 |
+
if ($blacklist == "") return false;
|
219 |
+
$blacklist = str_replace(array("\r", "\n"), '', $blacklist);
|
220 |
+
$email = explode('@', $email);
|
221 |
+
$domain = $email[1];
|
222 |
+
if (strpos($blacklist, ',')) {
|
223 |
+
$blacklist = explode(',', $blacklist);
|
224 |
+
if (in_array($domain, $blacklist))
|
225 |
+
return true;
|
226 |
+
} else {
|
227 |
+
if ($domain == $blacklist) return true;
|
228 |
+
}
|
229 |
+
|
230 |
+
return false;
|
231 |
+
}
|
232 |
+
|
233 |
+
public function link_url($link)
|
234 |
+
{
|
235 |
+
return get_site_url() . "/ebd-file?uid=$link->uid";
|
236 |
+
}
|
237 |
+
|
238 |
+
public function log($post_data, $user_data)
|
239 |
+
{
|
240 |
+
$xml = $this->xml($post_data);
|
241 |
+
$data = [
|
242 |
+
'email' => sanitize_email($user_data['your-email']),
|
243 |
+
'user_name' => sanitize_text_field($user_data['your-name']),
|
244 |
+
'posted_data' => $xml,
|
245 |
+
'time_requested' => time()
|
246 |
+
];
|
247 |
+
|
248 |
+
return $this->db->create_log($data);
|
249 |
+
}
|
250 |
+
|
251 |
+
public function xml($data)
|
252 |
+
{
|
253 |
+
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><posted_data>";
|
254 |
+
foreach ($data as $key => $value) {
|
255 |
+
$xml .= "<$key>";
|
256 |
+
if (is_array($value)) {
|
257 |
+
foreach ($value as $key2 => $item) {
|
258 |
+
$xml .= "<item-$key2>";
|
259 |
+
$xml .= $item;
|
260 |
+
$xml .= "</item-$key2>";
|
261 |
+
}
|
262 |
+
} else {
|
263 |
+
$xml .= $value;
|
264 |
+
}
|
265 |
+
$xml .= "</$key>";
|
266 |
+
}
|
267 |
+
|
268 |
+
$xml .= "</posted_data>";
|
269 |
+
return $xml;
|
270 |
+
}
|
271 |
+
|
272 |
+
}
|
includes/class-email-before-download-shortcode.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @since 5.0.0
|
4 |
+
* @package Email_Before_Download
|
5 |
+
* @subpackage Email_Before_Download/includes
|
6 |
+
* @author M & S Consulting
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Email_Before_Download_Shortcode {
|
10 |
+
|
11 |
+
private $plugin_name;
|
12 |
+
private $version;
|
13 |
+
private $option_name = 'email_before_download';
|
14 |
+
private $db;
|
15 |
+
|
16 |
+
public function __construct( $plugin_name, $version ) {
|
17 |
+
global $wpdb;
|
18 |
+
$this->plugin_name = $plugin_name;
|
19 |
+
$this->version = $version;
|
20 |
+
$this->db = $wpdb;
|
21 |
+
|
22 |
+
}
|
23 |
+
public function init_shortcode($user_atts = [], $content = null, $tag = 'email-download')
|
24 |
+
{
|
25 |
+
$user_atts = array_change_key_case((array)$user_atts, CASE_LOWER);
|
26 |
+
if(isset($user_atts['checked'])){
|
27 |
+
if($user_atts['checked'] == 'no'){
|
28 |
+
$user_atts['checked'] = '';
|
29 |
+
}else{
|
30 |
+
$user_atts['checked'] = 'checked';
|
31 |
+
}
|
32 |
+
}
|
33 |
+
$default_titles = $this->generate_dl_title($user_atts['download_id']);
|
34 |
+
$default_atts = [
|
35 |
+
'download_id' => NULL,
|
36 |
+
'contact_form_id' => get_option($this->option_name.'_default_cf7'),
|
37 |
+
'title' => $default_titles,
|
38 |
+
'file' => NULL,
|
39 |
+
'delivered_as' => get_option($this->option_name.'_delivery_format',"inline link"),
|
40 |
+
'attachment' => get_option($this->option_name.'_attachment'),
|
41 |
+
'force_download' => '0',
|
42 |
+
'checked' => get_option($this->option_name.'_multi_check'),
|
43 |
+
'hide_form' => get_option($this->option_name.'_hidden_form','yes'),
|
44 |
+
'radio' => get_option($this->option_name.'_radio','no'),
|
45 |
+
'expire_time' => get_option($this->option_name.'_expire')
|
46 |
+
];
|
47 |
+
$atts = shortcode_atts($default_atts, $user_atts, $tag);
|
48 |
+
$atts['item_id'] = $this->add_item($atts);
|
49 |
+
$form = new Email_Before_Download_Form($atts);
|
50 |
+
$content = $form->html();
|
51 |
+
return $content;
|
52 |
+
}
|
53 |
+
private function add_item($atts)
|
54 |
+
{
|
55 |
+
$db = new Email_Before_Download_DB();
|
56 |
+
return $db->create_item($atts);
|
57 |
+
}
|
58 |
+
|
59 |
+
private function generate_dl_title($data){
|
60 |
+
$title ="";
|
61 |
+
if(strpos($data,',')){
|
62 |
+
$ids = explode(',',$data);
|
63 |
+
}else{
|
64 |
+
$ids[] = $data;
|
65 |
+
}
|
66 |
+
foreach ($ids as $id){
|
67 |
+
$title .= do_shortcode("[download_data id=\"$id\" data=\"title\"]"). ",";
|
68 |
+
}
|
69 |
+
$title = substr($title,0,-1);
|
70 |
+
return $title;
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
}
|
includes/class-email-before-download.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The core plugin class.
|
4 |
+
*
|
5 |
+
* This is used to define internationalization, admin-specific hooks,
|
6 |
+
* public-facing site hooks, and processing hooks.
|
7 |
+
*
|
8 |
+
* Also maintains the unique identifier of this plugin as well as the current
|
9 |
+
* version of the plugin.
|
10 |
+
*
|
11 |
+
* @since 5.0.0
|
12 |
+
* @package Email_Before_Download
|
13 |
+
* @subpackage Email_Before_Download/includes
|
14 |
+
* @author M & S Consulting
|
15 |
+
*/
|
16 |
+
class Email_Before_Download {
|
17 |
+
|
18 |
+
protected $loader;
|
19 |
+
protected $plugin_name;
|
20 |
+
protected $version;
|
21 |
+
|
22 |
+
public function __construct() {
|
23 |
+
if ( defined( 'PLUGIN_NAME_VERSION' ) ) {
|
24 |
+
$this->version = PLUGIN_NAME_VERSION;
|
25 |
+
} else {
|
26 |
+
$this->version = '1.0.0';
|
27 |
+
}
|
28 |
+
$this->plugin_name = 'email-before-download';
|
29 |
+
|
30 |
+
$this->load_dependencies();
|
31 |
+
$this->set_locale();
|
32 |
+
$this->define_admin_hooks();
|
33 |
+
$this->define_public_hooks();
|
34 |
+
$this->define_process_hooks();
|
35 |
+
$this->define_downloader_hooks();
|
36 |
+
$this->build_shortcode();
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
private function load_dependencies() {
|
41 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-loader.php';
|
42 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-i18n.php';
|
43 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-email-before-download-admin.php';
|
44 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-email-before-download-table.php';
|
45 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-email-before-download-public.php';
|
46 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-shortcode.php';
|
47 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-downloader.php';
|
48 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-process.php';
|
49 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-form.php';
|
50 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-db.php';
|
51 |
+
$this->loader = new Email_Before_Download_Loader();
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
private function set_locale() {
|
57 |
+
$plugin_i18n = new Email_Before_Download_i18n();
|
58 |
+
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
private function define_admin_hooks() {
|
63 |
+
$plugin_admin = new Email_Before_Download_Admin( $this->get_plugin_name(), $this->get_version() );
|
64 |
+
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
|
65 |
+
$this->loader->add_action( 'admin_menu', $plugin_admin, 'add_options_page' );
|
66 |
+
$this->loader->add_action( 'admin_init', $plugin_admin, 'build_settings' );
|
67 |
+
$this->loader->add_action( 'admin_init', $plugin_admin, 'register_settings' );
|
68 |
+
$this->loader->add_action( 'admin_post_ebd.csv',$plugin_admin, 'print_csv' );
|
69 |
+
$this->loader->add_action( 'admin_post_ebd.purge',$plugin_admin, 'purge_data' );
|
70 |
+
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
private function define_public_hooks() {
|
76 |
+
|
77 |
+
$plugin_public = new Email_Before_Download_Public( $this->get_plugin_name(), $this->get_version() );
|
78 |
+
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
|
79 |
+
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
|
80 |
+
|
81 |
+
}
|
82 |
+
private function define_process_hooks(){
|
83 |
+
$plugin_process = new Email_Before_Download_Process( $this->get_plugin_name(), $this->get_version() );
|
84 |
+
$this->loader->add_action( 'wpcf7_before_send_mail',$plugin_process, 'process_cf7' );
|
85 |
+
$this->loader->add_filter('wpcf7_validate', $plugin_process, 'check_blacklist',10,2);
|
86 |
+
}
|
87 |
+
|
88 |
+
private function define_downloader_hooks(){
|
89 |
+
$plugin_downloader = new Email_Before_download_Downloader( $this->get_plugin_name(), $this->get_version() );
|
90 |
+
$this->loader->add_action('parse_request', $plugin_downloader, 'parse');
|
91 |
+
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
public function build_shortcode(){
|
96 |
+
add_shortcode('email-download' ,[new Email_Before_Download_Shortcode( $this->get_plugin_name(), $this->get_version()),'init_shortcode']);
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
public function run() {
|
101 |
+
$this->loader->run();
|
102 |
+
}
|
103 |
+
|
104 |
+
public function get_plugin_name() {
|
105 |
+
return $this->plugin_name;
|
106 |
+
}
|
107 |
+
|
108 |
+
public function get_loader() {
|
109 |
+
return $this->loader;
|
110 |
+
}
|
111 |
+
|
112 |
+
public function get_version() {
|
113 |
+
return $this->version;
|
114 |
+
}
|
115 |
+
|
116 |
+
}
|
includes/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
public/class-email-before-download-public.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The public-facing functionality of the plugin.
|
5 |
+
*
|
6 |
+
* Defines the plugin name, version, and hooks.
|
7 |
+
*
|
8 |
+
* @since 5.0.0
|
9 |
+
* @package Email_Before_Download
|
10 |
+
* @subpackage Email_Before_Download/public
|
11 |
+
* @author M & S Consulting
|
12 |
+
*/
|
13 |
+
class Email_Before_Download_Public
|
14 |
+
{
|
15 |
+
|
16 |
+
private $plugin_name;
|
17 |
+
private $version;
|
18 |
+
|
19 |
+
public function __construct($plugin_name, $version)
|
20 |
+
{
|
21 |
+
|
22 |
+
$this->plugin_name = $plugin_name;
|
23 |
+
$this->version = $version;
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
+
public function enqueue_styles()
|
28 |
+
{
|
29 |
+
wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/email-before-download-public.css', array(), $this->version, 'all');
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
public function enqueue_scripts()
|
34 |
+
{
|
35 |
+
wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/email-before-download-public.js', array('jquery'), $this->version, false);
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
public/css/email-before-download-public.css
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* All of the CSS for your public-facing functionality should be
|
3 |
+
* included in this file.
|
4 |
+
*/
|
5 |
+
.ebd_link {
|
6 |
+
display: inline-block;
|
7 |
+
padding: 10px 40px;
|
8 |
+
margin: 10px;
|
9 |
+
text-align: center;
|
10 |
+
border: 1px solid #555;
|
11 |
+
border-radius: 3px;
|
12 |
+
}
|
13 |
+
.ebd_link:hover {
|
14 |
+
border: 1px solid #0A246A;
|
15 |
+
}
|
public/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
public/js/email-before-download-public.js
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
jQuery(document).ready(function(){
|
3 |
+
if (jQuery("#downloadinputform").length === 1) {
|
4 |
+
var atLeastOneIsChecked = jQuery('input:checked[name*=ebd_downloads]:checked').length;
|
5 |
+
if(atLeastOneIsChecked < 1){
|
6 |
+
jQuery( ".cf7_input" ).hide();
|
7 |
+
}
|
8 |
+
jQuery( "input[name*=ebd_downloads]" ).on( "click", function () {
|
9 |
+
var n = jQuery( "input:checked[name*=ebd_downloads]" ).length;
|
10 |
+
if(n > 0) jQuery( ".cf7_input" ).show();
|
11 |
+
else jQuery( ".cf7_input" ).hide();
|
12 |
+
} );
|
13 |
+
}
|
14 |
+
});
|
readme.txt
CHANGED
@@ -1,223 +1,245 @@
|
|
1 |
-
=== Plugin Name ===
|
2 |
-
Contributors: mandsconsulting
|
3 |
-
Donate link: http://www.mandsconsulting.com/
|
4 |
-
Tags: email, download
|
5 |
-
Requires at least: 3.x
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: trunk
|
8 |
-
|
9 |
-
Email Before Download presents your users with a form where they submit information, like their name and email address, prior to receiving a download.
|
10 |
-
|
11 |
-
Plugin homepage: http://www.mandsconsulting.com/products/wp-email-before-download
|
12 |
-
|
13 |
-
== Description ==
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
1.
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
1.
|
37 |
-
1.
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
1.
|
52 |
-
1.
|
53 |
-
1.
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
*
|
84 |
-
*
|
85 |
-
*
|
86 |
-
*
|
87 |
-
* delivered_as - possible values: "Send Email", "Both", "Inline Link"
|
88 |
-
*
|
89 |
-
*
|
90 |
-
*
|
91 |
-
*
|
92 |
-
*
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
*
|
111 |
-
|
112 |
-
|
113 |
-
*
|
114 |
-
|
115 |
-
|
116 |
-
*
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
=
|
129 |
-
*
|
130 |
-
|
131 |
-
=
|
132 |
-
*
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
*
|
145 |
-
|
146 |
-
|
147 |
-
*
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
* Added
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
*
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
*
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
*
|
180 |
-
*
|
181 |
-
*
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
*
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
=
|
199 |
-
*
|
200 |
-
*
|
201 |
-
* Added
|
202 |
-
*
|
203 |
-
* Updates to
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
*
|
208 |
-
*
|
209 |
-
*
|
210 |
-
*
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
=
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: mandsconsulting
|
3 |
+
Donate link: http://www.mandsconsulting.com/
|
4 |
+
Tags: email, download
|
5 |
+
Requires at least: 3.x
|
6 |
+
Tested up to: 4.7.4
|
7 |
+
Stable tag: trunk
|
8 |
+
|
9 |
+
Email Before Download presents your users with a form where they submit information, like their name and email address, prior to receiving a download.
|
10 |
+
|
11 |
+
Plugin homepage: http://www.mandsconsulting.com/products/wp-email-before-download
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
------------
|
16 |
+
5.0 Release is Here!
|
17 |
+
We've completely rewritten EBD from the ground up. Since the plugin was built many years ago, we decided to implement the latest architecture and features that WordPress offers to plugin developers. In addition to testing as much as possible that this is backwards compatible with the original EBD version -- while also retaining a familiar experience for our existing admins/users -- we have added some popular requests such as the ability to change the from email address as well as support for Download Monitor's latest major release (4.0+).
|
18 |
+
-------------
|
19 |
+
|
20 |
+
Email Before Download presents your users with a form where they submit information, like their name and email address, prior to receiving a download. This plugin integrates with the popular [Contact Form 7](http://bit.ly/dNzVJd) and [WordPress Download Monitor](http://bit.ly/ifff4y) plugins, allowing you to create any form you like and manage/monitor your file downloads. You can also EXPORT a list of users that have downloaded files from the plug-in's settings page. Prior to installing Email Before Download, please confirm each of the dependent plugins is already installed and working independently.
|
21 |
+
We recently updated the deprecated WPDB escape functionality to new one. You can download the version compatible with older version of WordPress at [Email Before Download](http://bit.ly/1uThydb)
|
22 |
+
|
23 |
+
As an option, you can configure Email Before Download to:
|
24 |
+
|
25 |
+
1. Display a link to your file directly under the contact form once it is submitted. This happens dynamically, inline of your post/page.
|
26 |
+
1. Send the user an email with a link and/or attachment to download your file.
|
27 |
+
1. Both #1 and #2
|
28 |
+
|
29 |
+
[Plugin Homepage with Live Demos and Test Download](http://www.mandsconsulting.com/products/wp-email-before-download) | [Support Forums](http://bit.ly/lU7Tdt)
|
30 |
+
|
31 |
+
|
32 |
+
Usage
|
33 |
+
|
34 |
+
Note: You can see screenshots at [http://wordpress.org/extend/plugins/email-before-download/screenshots/](http://bit.ly/g4r1w2)
|
35 |
+
|
36 |
+
1. Create a contact form used by Email Before Download using Contact Form 7 and note the Contact Form ID
|
37 |
+
1. Upload a file using Download Monitor and note the Download ID
|
38 |
+
1. Navigate to the Post (or Page) you wish to include
|
39 |
+
1. Add the following short code using the IDs collected in the first two steps
|
40 |
+
[email-download download_id="X" contact_form_id="Y"]
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
Plugin Homepage with Live Demos and Test Download: [http://www.mandsconsulting.com/products/wp-email-before-download](http://www.mandsconsulting.com/products/wp-email-before-download)
|
45 |
+
|
46 |
+
Please use the [Support Forums](http://bit.ly/lU7Tdt) for any questions and issues. Sometimes other users can help you as well.
|
47 |
+
|
48 |
+
|
49 |
+
== Installation ==
|
50 |
+
|
51 |
+
1. Download from [http://wordpress.org/extend/plugins/email-before-download/](http://bit.ly/dF9AxV)
|
52 |
+
1. Upload the entire email-before-download folder to the /wp-content/plugins/ directory.
|
53 |
+
1. Activate the plugin through the "Plugins" menu in WordPress.
|
54 |
+
1. Locate the "Email Before Download" menu item in your WordPress Admin panel under "Settings" to configure.
|
55 |
+
|
56 |
+
|
57 |
+
== Frequently Asked Questions ==
|
58 |
+
|
59 |
+
= Can I see a list of download requests people have made? =
|
60 |
+
|
61 |
+
Yes. We store a log of the form submissions and generated links. You can view and export a CSV file of them from the Email Before Download settings page in your admin screens.
|
62 |
+
|
63 |
+
= What if I don't use the Contact Form 7 and/or Download Monitor Plugins? =
|
64 |
+
|
65 |
+
You will not be able to use this version of Email Before Download without these dependent plugins. If you have specific reasons to avoid using the dependent plugins, please contact us and let us know the reason so we can take it into consideration.
|
66 |
+
|
67 |
+
= Anything special I need to do with my contact form? =
|
68 |
+
|
69 |
+
If you decide to configure the Email Before Download option to send the user an email with a link to the download, then you will want to name the email field "your-email" as shown in the example screenshots. Outside of that, nothing special.
|
70 |
+
|
71 |
+
= What happens after the user completes the form? =
|
72 |
+
|
73 |
+
By default, the user is presented with a link or links to download their file(s). There is also an option to email the user (with a link to the file and/or attachment) if you choose that route. You can even provide both the inline link as well as the email if you choose.
|
74 |
+
|
75 |
+
= Are you changing any of my file or directory permissions? =
|
76 |
+
|
77 |
+
WordPress allows direct access to files in your upload directories using a direct URL and we do not change those permissions. We do provide an option to mask the URL to your downloads if you have cURL enabled.
|
78 |
+
|
79 |
+
= What are the available shortcode options? =
|
80 |
+
|
81 |
+
This is the list of all short code attributes that can be used. Some of them override the global admin settings.
|
82 |
+
|
83 |
+
* download_id - either one single download id from Wordpress Download Monitor, or a comma separated list of such ids, eg. '1,2,3'
|
84 |
+
* contact_form_id - Contact Form 7 ID. Overrides default contact for id from settings if used.
|
85 |
+
* title - this attribute overrides the title from Download Monitor. if multiple, put them in a comma separated list in the same order as your download_ids.
|
86 |
+
* file - use to point to external url
|
87 |
+
* delivered_as - possible values: "Send Email", "Both", "Inline Link"
|
88 |
+
* attachment - "yes", "no" Attachments only work if files were uploaded with Download Monitor.
|
89 |
+
* force_download - any value that is passed considered as "yes" (we don't have a global menu item for that) only works with a single download_id.
|
90 |
+
* checked - Loads form with item checked. If you are using checkboxes and hhave multiple ites, the will all be checked, Accepts "no", any other value is "yes"
|
91 |
+
* hidden_form - "yes", "no"
|
92 |
+
* radio - "yes", "no"
|
93 |
+
|
94 |
+
|
95 |
+
== Screenshots ==
|
96 |
+
|
97 |
+
1. Note the ID of a file you have uploaded to Download Monitor.
|
98 |
+
2. Note the ID of a contact form you have created using Contact Form 7.
|
99 |
+
3. Use the following shortcode in your page or post: [email-download download_id="X" contact_form_id="Y"].
|
100 |
+
4. Upon installation and use of the plugin on a post/page, an end-user will see your contact form.
|
101 |
+
5. User will be required to enter valid data in accordance with Contact Form 7 validation rules.
|
102 |
+
6. Upon submission, user will either see a direct link below the form. (Note: there is also an option to only email the link to the user.)
|
103 |
+
7. Example Contact Form 7 form code, including tag required to display multiple download selection checkboxes.
|
104 |
+
|
105 |
+
|
106 |
+
== Changelog ==
|
107 |
+
|
108 |
+
=5.0=
|
109 |
+
* Complete tear down and rewrite of entire EBD plugin.
|
110 |
+
* Better integration with Wordpress.
|
111 |
+
* Added admin view, export, and purge of download links and posted data.
|
112 |
+
* Added better integration with Contact Form 7 and Download Monitor.
|
113 |
+
* Removed masked option from settings as this is pretty much done by default now.
|
114 |
+
* Added option for default contact form id.
|
115 |
+
* Added some CSS to the generated inline links to make them look a little better by default. Can be overwritten easily if needed.
|
116 |
+
* generates shorter URLs.
|
117 |
+
* More settings available in shortcode.
|
118 |
+
* Can override multiple titles now, as long as they are in the same order as the download ids.
|
119 |
+
|
120 |
+
=4.1=
|
121 |
+
* Made a few more modifications at the request of email from "plugins@wordpress.org".
|
122 |
+
|
123 |
+
=4.0=
|
124 |
+
* Made modifications to address items requested by "plugins@wordpress.org" such as ensuring further sanitization of email addresses and database inserts. Also, removed ability to access files directly from within the plugin folder. Finally, while making these changes, changed the URL for downloads to use "ebd_dl" instead of "dl" just in case another plugin were to begin using the "dl" parameter in order to prevent possible conflicts. Due to these changes, download links from prior to EBD v4.0 will no longer work with EBD v4.0+.
|
125 |
+
=3.6=
|
126 |
+
* Made modifications to shorten the download URL and potentially improve email deliverability by removing "download.php" from the download link
|
127 |
+
|
128 |
+
=3.5=
|
129 |
+
* Made minor changes to support PHP 7.
|
130 |
+
|
131 |
+
=3.4.2=
|
132 |
+
* Fixed issue regarding the download button on some themes where download button would display in wrong format.
|
133 |
+
|
134 |
+
=3.4.1=
|
135 |
+
* Fixed issue related to SQL functions used in code.
|
136 |
+
|
137 |
+
=3.4=
|
138 |
+
* Updated deprecated WPDB escape functionality to new one.
|
139 |
+
|
140 |
+
=3.3=
|
141 |
+
* Updated to be compatible with Contact Form Version 3.9
|
142 |
+
|
143 |
+
= 3.2.9 =
|
144 |
+
* Fixed issues related to a recent release of Contact Form 7 version 3.9
|
145 |
+
|
146 |
+
= 3.2.8 =
|
147 |
+
* Fixed the issue with multiple download ids checkboxes when user selects hidden contact form option.
|
148 |
+
The checkbox can now be to the left or right, depending on the custom tag (<ebd /> or <ebd left/>)"
|
149 |
+
|
150 |
+
= 3.2.7 =
|
151 |
+
* Fixed the issue with loading contact form as XML to DOM parser, when html entities were breaking the validity of XML.
|
152 |
+
|
153 |
+
= 3.2.6 =
|
154 |
+
* Added new option that allows user to hide contact form until user selects at least one downloads (for multiple download ids )
|
155 |
+
* Added option that turns checkboxes to radio buttons (for multiple download ids)
|
156 |
+
|
157 |
+
= 3.2.5 =
|
158 |
+
* Fixed bug with single quotes that led to javascript error.
|
159 |
+
|
160 |
+
= 3.2.4 =
|
161 |
+
* Added support to new version of the Download monitor
|
162 |
+
* Modified download logic: If the masked option is turned on and Internet Explorer is detected, download will be forced.
|
163 |
+
|
164 |
+
= 3.2.3 =
|
165 |
+
* Two new fields added to the plugin: user_name and email
|
166 |
+
* CSV export now includes new fields
|
167 |
+
* Added checks for the existence of the new fields, adds them if needed
|
168 |
+
* In admin settings, added new option that changes Multiple Checkboxes' default state
|
169 |
+
* Added new short code attribute that overrides admin settings for Multiple Checkboxes' default state
|
170 |
+
|
171 |
+
= 3.2.2 =
|
172 |
+
* Removed extra spacing in multiple download output
|
173 |
+
|
174 |
+
= 3.2.1 =
|
175 |
+
* Create table SQL script updated (now the title column has utf8 character set and utf8_unicode_ci collation)
|
176 |
+
* Added a patch that checks this specific column and alters it if needed
|
177 |
+
|
178 |
+
= 3.2 =
|
179 |
+
* Fixed bug related to logging multiple downloads correctly
|
180 |
+
* Added field to CSV export
|
181 |
+
* Added PayPal button in Admin Panel
|
182 |
+
* Added character encoding in case it helps to support languages other than English
|
183 |
+
|
184 |
+
|
185 |
+
= 3.1.7 =
|
186 |
+
* Default multiple file downloads to pre-selected (checked) by default
|
187 |
+
|
188 |
+
= 3.1.6 =
|
189 |
+
* Minor fix for various multi-file issues and logging
|
190 |
+
|
191 |
+
= 3.1.5 =
|
192 |
+
* fixed event handling
|
193 |
+
* stubbed email_from, though it is not active
|
194 |
+
|
195 |
+
= 3.1 =
|
196 |
+
* New modification to help support for Contact Form 7 v3.0+
|
197 |
+
|
198 |
+
= 3.0 =
|
199 |
+
* Modification to help support for Contact Form 7 v3.0+
|
200 |
+
* Added ability to force a file download using attribute in shortcode [email-download download_id="X" contact_form_id="Y" force-download="true"]; Download Monitor Force Download Option is recommended for files stored in Download Monitor
|
201 |
+
* Added option in admin panel to clear Email Before Download log entries
|
202 |
+
* Minor fomatting updates to admin panel
|
203 |
+
* Updates to allow Download Monitor to track clicks/downloads of files accessed using various scenarios of the Email Before Download plugin; Download Monitor still does not track clicks when using the masked URL option of Email Before Download, but the Email Before Download log does track these
|
204 |
+
|
205 |
+
= 2.6 =
|
206 |
+
* Bigger export link
|
207 |
+
* Support for special characters in filenames like "&"
|
208 |
+
* Fix for empty page interaction
|
209 |
+
* Change of function name to avoid conflict with other plugins
|
210 |
+
* Support for left checkboxes on multiple file download form using "<ebd_left />"
|
211 |
+
|
212 |
+
= 2.5.1 =
|
213 |
+
* Minor cleanup of admin panel
|
214 |
+
|
215 |
+
= 2.5 =
|
216 |
+
* Added ability to prevent specific domain names
|
217 |
+
* Fixed download filename issue for .zip files
|
218 |
+
|
219 |
+
|
220 |
+
= 2.0 =
|
221 |
+
* Support multiple download selection (within shortcut code, use comma-separated list of download IDs: download_id="1,2,3" -- within the contact form 7 form used for multiple download selection, ensure you place the tag "<ebd />" where you want to checkbox list to be generated) as shown in [screenshot 7](http://wordpress.org/extend/plugins/email-before-download/screenshots/)
|
222 |
+
* Add more information in the download history EXPORT .csv file
|
223 |
+
* Added support for Download Monitor format code for the inline link that is displayed (within shortcut code, specify the format code: format="1")
|
224 |
+
* Allow overriding the default settings with the shortcode (i.e. within shortcode, use delivered_as="Inline Link" even though the general setting in admin panel is setup for "Both" -- options are "Inline Link", "Send Email", "Both")
|
225 |
+
* Updates to avoid potential conflicts with other plugins
|
226 |
+
* Added ability to customize subject line when emailing file download
|
227 |
+
|
228 |
+
= 1.0 =
|
229 |
+
* Added ability to export log in CSV format from admin settings page.
|
230 |
+
* Added ability to mask download file's URL if cURL is enabled.
|
231 |
+
* Added ability to expire the download link after a given timeframe.
|
232 |
+
* In addition to emailing a link to the file, added ability to email the file as an attachment.
|
233 |
+
* Added ability to download files outside of Download Monitor (within shortcode, use file="http://mydomain.com/file.pdf" -- no need to include download_id="X" in this case).
|
234 |
+
|
235 |
+
= 0.5 =
|
236 |
+
* First release.
|
237 |
+
|
238 |
+
== Upgrade Notice ==
|
239 |
+
|
240 |
+
= 1.0 =
|
241 |
+
Automatically upgrade the plugin and all previous settings should remain intact.
|
242 |
+
|
243 |
+
= 0.5 =
|
244 |
+
First release.
|
245 |
+
|
uninstall.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Fired when the plugin is uninstalled.
|
5 |
+
*
|
6 |
+
* @since 5.0.0
|
7 |
+
* @package Email_Before_Download
|
8 |
+
* @author M & S Consulting
|
9 |
+
*/
|
10 |
+
|
11 |
+
// If uninstall not called from WordPress, then exit.
|
12 |
+
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) )exit;
|
13 |
+
$option_prefix = "email_before_download";
|
14 |
+
$options = [
|
15 |
+
'_delivery_format',
|
16 |
+
'_expire',
|
17 |
+
'_forbidden',
|
18 |
+
'_link_format',
|
19 |
+
'_link_css',
|
20 |
+
'_html_before',
|
21 |
+
'_html_after',
|
22 |
+
'_single_email',
|
23 |
+
'_multi_email',
|
24 |
+
'_attachment',
|
25 |
+
'_subject',
|
26 |
+
'_from_email',
|
27 |
+
'_multi_check',
|
28 |
+
'_hidden_form',
|
29 |
+
'_radio',
|
30 |
+
'_default_cf7'
|
31 |
+
];
|
32 |
+
foreach ( $options as $option ) {
|
33 |
+
if ( get_option( $option_prefix.$option ) ) {
|
34 |
+
delete_option($option_prefix.$option );
|
35 |
+
}
|
36 |
+
}
|
37 |
+
global $wpdb;
|
38 |
+
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ebd_link");
|
39 |
+
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ebd_item");
|
40 |
+
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ebd_posted_data");
|