Version Description
Download this release
Release Info
Developer | mandsconsulting |
Plugin | Email Before Download |
Version | 3.4.1 |
Comparing to | |
See all releases |
Code changes from version 2.0 to 3.4.1
- clearlog.php +31 -0
- download.php +183 -22
- email-before-download.php +491 -88
- export.php +23 -3
- readme.txt +119 -5
- screenshot-7.png +0 -0
clearlog.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
CHANGED
@@ -16,49 +16,94 @@
|
|
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 = '"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
if($ebd_link->expire_time != NULL && $ebd_link->expire_time != 0 && $ebd_link->expire_time < time()){
|
21 |
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
22 |
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"));
|
23 |
}
|
24 |
-
|
25 |
if($ebd_link->selected_id != NULL && $ebd_link->selected_id != 0){
|
26 |
-
$dl = $wpdb->get_row( "SELECT * FROM $wp_dlm_db WHERE id = "
|
27 |
-
$
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
header("Location: $file");
|
31 |
exit(0);
|
32 |
}
|
33 |
-
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE id = "
|
|
|
|
|
|
|
|
|
|
|
34 |
|
|
|
|
|
|
|
35 |
$file = '';
|
36 |
if($ebd_item->file){
|
37 |
$file = $ebd_item->file;
|
38 |
}
|
39 |
if($ebd_item->download_id){
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
44 |
-
$wpdb->update( $table_link, array("is_downloaded"=>1), array("uid"
|
|
|
45 |
|
46 |
//Check if the cUrl functions are available and the url hide option is enabled.
|
47 |
//If not, just rederect to real file url.
|
48 |
-
$is_masked = get_option('email_before_download_hide');
|
49 |
-
//is the "hide" option overriden for the individual download
|
50 |
-
if($ebd_link->is_masked != NULL)
|
51 |
-
$is_masked = $ebd_link->is_masked == 'yes';
|
52 |
|
53 |
if ($is_masked && function_exists('curl_init')) {
|
|
|
|
|
54 |
$curl = curl_init();
|
55 |
-
$url = $file;
|
56 |
$options = array
|
57 |
(
|
58 |
CURLOPT_URL=>$url,
|
59 |
CURLOPT_HEADER=>true,
|
60 |
CURLOPT_RETURNTRANSFER=>true,
|
61 |
-
|
62 |
);
|
63 |
curl_setopt_array($curl,$options);
|
64 |
$r = curl_exec ($curl);
|
@@ -67,15 +112,131 @@ if ($is_masked && function_exists('curl_init')) {
|
|
67 |
$body = substr( $r, $header_size );
|
68 |
|
69 |
curl_close ($curl);
|
70 |
-
// $my_headers = http_parse_headers ( $header );
|
71 |
-
$my_headers = parse_headers ( $header );
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
foreach($my_headers as $key=>$value){
|
|
|
74 |
header("$key: $value");
|
|
|
|
|
75 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
-
|
78 |
-
echo $body;
|
79 |
exit(0);
|
80 |
|
81 |
}
|
@@ -83,7 +244,7 @@ else {
|
|
83 |
header("Location: $file");
|
84 |
}
|
85 |
|
86 |
-
function
|
87 |
{
|
88 |
$retVal = array();
|
89 |
$fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header));
|
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);
|
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 |
}
|
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));
|
email-before-download.php
CHANGED
@@ -4,7 +4,7 @@ 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:
|
8 |
Author URI: http://www.mandsconsulting.com
|
9 |
|
10 |
============================================================================================================
|
@@ -69,21 +69,45 @@ 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_var("SHOW TABLES LIKE '$table_posted_data'") != $table_posted_data) {
|
79 |
|
80 |
$sql = "CREATE TABLE " . $table_posted_data . " (
|
81 |
time_requested bigint(20),
|
|
|
|
|
82 |
posted_data text(2000) NOT NULL,
|
83 |
UNIQUE KEY id (time_requested)
|
84 |
);";
|
85 |
$wpdb->query($sql);
|
86 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
//Shortcode function
|
88 |
function emailreqtag_func($atts) {
|
89 |
extract(shortcode_atts(array(
|
@@ -95,42 +119,89 @@ function emailreqtag_func($atts) {
|
|
95 |
'delivered_as' => NULL,
|
96 |
'masked'=>NULL,
|
97 |
'attachment'=>NULL,
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
), $atts));
|
99 |
|
100 |
global $wpdb,$wp_dlm_root,$wp_dlm_db,$wp_dlm_db_taxonomies, $def_format, $dlm_url, $downloadurl, $downloadtype, $wp_dlm_db_meta;
|
101 |
|
102 |
$str = '';
|
103 |
$chekboxes = "";
|
|
|
104 |
//$title = '';
|
105 |
|
106 |
$url = '';
|
107 |
$hf = '';
|
108 |
$dldArray = array();
|
109 |
$table_item = $wpdb->prefix . "ebd_item";
|
|
|
110 |
if($download_id != NULL){
|
111 |
-
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE download_id = '$download_id'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
$dldArray = explode(",", $download_id);
|
113 |
$title_tmp = '';
|
114 |
foreach ($dldArray as $dl_id) {
|
115 |
-
$
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
-
$d = new downloadable_file($dl);
|
119 |
-
|
120 |
if (!empty($d)) {
|
121 |
-
|
122 |
if ($title == NULL || $title == '') $title_tmp .= $d->title . '|';
|
123 |
-
|
124 |
-
$chekboxes .= '<br />' . $d->title. ' <input type="checkbox" name="ebd_downloads[]" value="'. $dl_id . '"
|
|
|
125 |
}
|
126 |
-
|
127 |
}
|
128 |
if(count($title_tmp) > 0) $title = rtrim($title_tmp, '|');
|
129 |
-
|
130 |
if (empty($ebd_item)){
|
131 |
$wpdb->insert( $table_item, array("download_id"=>$download_id, "title"=>$title) );
|
132 |
$download_id = $wpdb->insert_id;
|
133 |
-
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE id = "
|
134 |
}
|
135 |
else $download_id = $ebd_item->id;
|
136 |
//update title if needed
|
@@ -141,13 +212,13 @@ function emailreqtag_func($atts) {
|
|
141 |
|
142 |
if ($title == NULL || $title == '') $title = basename($file);
|
143 |
|
144 |
-
|
145 |
-
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE file = '"
|
146 |
|
147 |
if (empty($ebd_item)){
|
148 |
-
$wpdb->insert( $table_item, array("file"
|
149 |
$download_id = $wpdb->insert_id;
|
150 |
-
$ebd_item = $wpdb->get_row( "SELECT * FROM $table_item WHERE file = '"
|
151 |
|
152 |
}
|
153 |
else $download_id = $ebd_item->id;
|
@@ -156,25 +227,96 @@ function emailreqtag_func($atts) {
|
|
156 |
$wpdb->update( $table_item, array("title"=>$title), array("id"=>$download_id) );
|
157 |
|
158 |
}
|
159 |
-
$contact_form = do_shortcode("[contact-form $contact_form_id \"$title\"]");
|
|
|
|
|
|
|
160 |
// add checkboxes if count is more than one
|
161 |
-
|
162 |
-
|
163 |
-
$
|
164 |
-
|
165 |
-
else $contact_form = str_replace("<ebd />", "", $contact_form);
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
if($delivered_as != NULL)
|
168 |
$hf .= '<input type="hidden" name="delivered_as" value="' . $delivered_as. '" />';
|
169 |
-
//masked
|
170 |
if($masked != NULL)
|
171 |
$hf .= '<input type="hidden" name="masked" value="' . $masked. '" />';
|
172 |
-
|
|
|
|
|
|
|
173 |
if($attachment != NULL)
|
174 |
$hf .= '<input type="hidden" name="attachment" value="' . $attachment. '" />';
|
175 |
if($format != NULL)
|
176 |
$hf .= '<input type="hidden" name="format" value="' . $format. '" />';
|
177 |
-
|
|
|
|
|
178 |
|
179 |
$hf .= '<input type="hidden" name="_wpcf7_download_id" value="' . $download_id. '" /></form>';
|
180 |
|
@@ -185,25 +327,106 @@ function emailreqtag_func($atts) {
|
|
185 |
if(strlen(trim($wrap_in_div)) > 0 ){
|
186 |
$div_class = 'class="' . trim($wrap_in_div) . '"';
|
187 |
}
|
188 |
-
|
|
|
189 |
}
|
190 |
add_shortcode('emailreq', 'emailreqtag_func');
|
191 |
add_shortcode('email-download', 'emailreqtag_func');
|
192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
/*Function that processes contact form 7, generates links, sends emails */
|
194 |
function ebd_process_email_form( $cf7 ) {
|
195 |
if(isset( $_POST['_wpcf7_download_id'] )){
|
196 |
global $wpdb,$wp_dlm_root,$wp_dlm_db,$wp_dlm_db_taxonomies, $def_format, $dlm_url, $downloadurl, $downloadtype, $wp_dlm_db_meta;
|
197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
//table names
|
199 |
$table_item = $wpdb->prefix . "ebd_item";
|
200 |
$table_link = $wpdb->prefix . "ebd_link";
|
201 |
$table_posted_data = $wpdb->prefix . "ebd_posted_data";
|
202 |
-
|
203 |
$delivered_as = get_option('email_before_download_send_email');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
$use_attachments = get_option('email_before_download_attachment');
|
205 |
if(isset($_POST['delivered_as'])) $delivered_as = $_POST['delivered_as'];
|
206 |
-
if(isset($_POST['attachment'])) $use_attachments = trim($_POST['attachment']) == 'yes';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
|
208 |
//get selected downloads
|
209 |
$dIds = $_POST['ebd_downloads'];
|
@@ -218,27 +441,49 @@ function ebd_process_email_form( $cf7 ) {
|
|
218 |
//get all download monitor objects
|
219 |
if($dIds)
|
220 |
foreach($dIds as $id){
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
}
|
225 |
-
|
226 |
//get edb items: it's common for all
|
227 |
$dId = $_POST['_wpcf7_download_id'];
|
228 |
-
|
229 |
-
|
230 |
|
|
|
|
|
231 |
//get single download, multible are comma separated so the $dl for this will be NULL
|
232 |
-
|
233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
//variable for the title it wll be used only for the single downloads and the email subject
|
239 |
$title = '';
|
240 |
-
|
241 |
-
//print_r($ebd_item);
|
242 |
$title = $ebd_item->title;
|
243 |
|
244 |
if($title == NULL || $title == '')
|
@@ -265,12 +510,12 @@ function ebd_process_email_form( $cf7 ) {
|
|
265 |
foreach($dl_items as $dl_item){
|
266 |
//generate unique id for the file (link)
|
267 |
$uid = md5(uniqid(rand(), true));
|
268 |
-
|
269 |
//expiration date if needed if it's 0 or NULL the link will never expire
|
270 |
$expireAt = 0;
|
271 |
if(get_option('email_before_download_expire_time') != NULL && get_option('email_before_download_expire_time') != "0")
|
272 |
$expireAt = strtotime(get_option('email_before_download_expire_time'));
|
273 |
-
|
274 |
$link_data = array();
|
275 |
$link_data['uid'] = $uid;
|
276 |
$link_data['selected_id'] = $dl_item->id;
|
@@ -281,7 +526,7 @@ function ebd_process_email_form( $cf7 ) {
|
|
281 |
$link_data['delivered_as'] = $delivered_as;
|
282 |
if(isset($_POST['masked'])) $link_data['is_masked'] = $_POST['masked'];
|
283 |
$wpdb->insert( $table_link, $link_data );
|
284 |
-
|
285 |
//
|
286 |
$url = WP_PLUGIN_URL."/email-before-download/download.php?dl=".$uid;
|
287 |
$titles[] = $dl_item->title ;
|
@@ -291,7 +536,7 @@ function ebd_process_email_form( $cf7 ) {
|
|
291 |
$innerHtml .= $link . '<br />';
|
292 |
}
|
293 |
else
|
294 |
-
$innerHtml .= '<a class="icon-button download-icon" target="' . $target . '" href="' . $url .'"><span class="et-icon"><span>' . $dl_item->title . '</span></span></a><br
|
295 |
|
296 |
// if(get_option('email_before_download_send_email') == 'Send Email' || get_option('email_before_download_send_email') == 'Both'){
|
297 |
// }
|
@@ -302,7 +547,7 @@ function ebd_process_email_form( $cf7 ) {
|
|
302 |
$absuploadpath = trailingslashit( $dirs['basedir'] );
|
303 |
$attachment = NULL;
|
304 |
if ( $uploadpath && ( strstr ( $dl_item->filename, $uploadpath ) || strstr ( $dl_item->filename, $absuploadpath )) ) {
|
305 |
-
|
306 |
$file = str_replace( $uploadpath , "" , $dl_item->filename);
|
307 |
if(is_file($absuploadpath.$file)){
|
308 |
$attachment = $absuploadpath.$file;
|
@@ -314,7 +559,7 @@ function ebd_process_email_form( $cf7 ) {
|
|
314 |
}
|
315 |
}
|
316 |
// single download for the download monitor file or file lnk
|
317 |
-
else if(!empty($
|
318 |
//generate unique id for the file (link)
|
319 |
$uid = md5(uniqid(rand(), true));
|
320 |
|
@@ -330,27 +575,35 @@ function ebd_process_email_form( $cf7 ) {
|
|
330 |
$link_data['email'] = $cf7->posted_data['your-email'];
|
331 |
$link_data['item_id'] = $_POST['_wpcf7_download_id'];
|
332 |
$link_data['delivered_as'] = $delivered_as;
|
|
|
333 |
if(isset($_POST['masked'])) $link_data['is_masked'] = $_POST['masked'];
|
|
|
334 |
$wpdb->insert( $table_link, $link_data );
|
335 |
-
|
336 |
if(isset($_POST['format']) && $ebd_item->download_id != NULL){
|
337 |
$link = do_shortcode('[download id="' . $ebd_item->download_id. '" format="' .$_POST['format'].'"]');
|
338 |
$innerHtml .= $link . '<br />';
|
339 |
}
|
340 |
else {
|
341 |
$url = WP_PLUGIN_URL."/email-before-download/download.php?dl=".$uid;
|
342 |
-
$innerHtml = '<a class="icon-button download-icon" target="' . $target . '" href="' . $url .'"><span class="et-icon"><span>' . $title . '</span></span></a><br
|
343 |
}
|
344 |
}
|
345 |
//nothing is selected for the download
|
346 |
else {
|
347 |
-
//we don't sent an email and throw an error
|
348 |
$cf7->skip_mail = true;
|
349 |
//this message doesn't seem to appear but we leave it for now
|
350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
$id = (int) $_POST['_wpcf7'];
|
352 |
$unit_tag = $_POST['_wpcf7_unit_tag'];
|
353 |
-
|
354 |
$items = array(
|
355 |
'mailSent' => false,
|
356 |
'into' => '#' . $unit_tag,
|
@@ -366,18 +619,34 @@ function ebd_process_email_form( $cf7 ) {
|
|
366 |
die();
|
367 |
}
|
368 |
$cf7->posted_data['your-message'] = 'The downloaded file name(s): ' . $title;
|
369 |
-
if(
|
370 |
-
|
371 |
-
$cf7->mail['body'] = $cf7->mail['body'] ."\nThe downloaded file name: [your-message]";
|
372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
}
|
374 |
|
375 |
-
|
376 |
|
377 |
$target = get_option('email_before_download_link_target');
|
378 |
$html_before = get_option('email_before_download_html_before_link');
|
379 |
$html_after = get_option('email_before_download_html_after_link');
|
380 |
-
|
381 |
|
382 |
//if multiple files are downloaded ???
|
383 |
$message = '';
|
@@ -393,20 +662,20 @@ function ebd_process_email_form( $cf7 ) {
|
|
393 |
if(strlen(trim($email_template)) > 0){
|
394 |
if(isset($_POST['format']) && $ebd_item->download_id != NULL)
|
395 |
$message = 'You requested: ' .$innerHtml;
|
396 |
-
else
|
397 |
$message = str_replace(array('[requesting_name]', '[file_url]', '[file_name]'), array($cf7->posted_data['your-name'], $url, $title), trim($email_template));
|
398 |
}
|
399 |
else {
|
400 |
if(isset($_POST['format']) && $ebd_item->download_id != NULL)
|
401 |
$message = 'You requested: ' .$innerHtml;
|
402 |
-
else
|
403 |
$message = '<a class="icon-button download-icon" target="' . $target . '" href="' . $url .'">' . $title . '</a>';
|
404 |
}
|
405 |
}
|
406 |
-
|
407 |
-
|
408 |
$innerHtml = $html_before . $innerHtml . $html_after;
|
409 |
-
|
410 |
|
411 |
if($delivered_as == 'Send Email') {
|
412 |
// $attachments = NULL;
|
@@ -431,8 +700,14 @@ function ebd_process_email_form( $cf7 ) {
|
|
431 |
}
|
432 |
else $email_subject = 'Requested URL for the file(s): '. $title;
|
433 |
//email_before_download_subject
|
434 |
-
@wp_mail( $cf7->posted_data['your-email'], $email_subject , $message, "Content-Type: text/html\n", $attachments);
|
435 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
436 |
}
|
437 |
else if ($delivered_as == 'Both'){
|
438 |
//$attachments = NULL;
|
@@ -456,23 +731,40 @@ function ebd_process_email_form( $cf7 ) {
|
|
456 |
$email_subject = str_replace('[files]', $title, $email_subject);
|
457 |
}
|
458 |
else $email_subject = 'Requested URL for the file(s): '. $title;
|
459 |
-
@wp_mail( $cf7->posted_data['your-email'], $email_subject , $message, "Content-Type: text/html\n", $attachments);
|
460 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
461 |
}
|
462 |
-
else{
|
463 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
}
|
465 |
// save the extra form information into the xml
|
466 |
$xml = new SimpleXMLElement('<posted_data></posted_data>');
|
|
|
467 |
foreach ($cf7->posted_data as $key => $value){
|
468 |
-
|
|
|
|
|
469 |
}
|
470 |
$posted_data = array();
|
471 |
$posted_data['time_requested'] = $time_requested;
|
472 |
$posted_data['posted_data'] = $xml->asXML();
|
|
|
|
|
473 |
$wpdb->insert( $table_posted_data, $posted_data );
|
474 |
}
|
475 |
-
|
476 |
return $cf7;
|
477 |
}
|
478 |
add_action( 'wpcf7_before_send_mail', 'ebd_process_email_form' );
|
@@ -511,6 +803,12 @@ function register_email_before_download_settings() {
|
|
511 |
register_setting( 'email-before-download-group', 'email_before_download_hide' );
|
512 |
register_setting( 'email-before-download-group', 'email_before_download_attachment' );
|
513 |
register_setting( 'email-before-download-group', 'email_before_download_subject' );
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
|
515 |
}
|
516 |
|
@@ -540,10 +838,49 @@ vertical-align:top;
|
|
540 |
</style>
|
541 |
|
542 |
<div class="wrap">
|
543 |
-
<
|
544 |
-
<
|
545 |
-
<
|
546 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
547 |
<form method="post" action="options.php">
|
548 |
<?php settings_fields( 'email-before-download-group' ); ?>
|
549 |
<table class="optiontable ebd">
|
@@ -588,10 +925,20 @@ vertical-align:top;
|
|
588 |
</td>
|
589 |
</tr>
|
590 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
591 |
|
592 |
-
<tr valign="top"><td colspan="2"><p class="alert">#
|
593 |
<tr valign="top">
|
594 |
-
<th scope="row"><p>
|
595 |
<td><p>
|
596 |
<select name="email_before_download_link_target">
|
597 |
<option value="_blank" <?php if(get_option('email_before_download_link_target') == '_blank') echo 'selected="selected"'; ?> >_blank</option>
|
@@ -603,14 +950,14 @@ vertical-align:top;
|
|
603 |
</tr>
|
604 |
|
605 |
<tr valign="top">
|
606 |
-
<th scope="row"><p>
|
607 |
<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'); ?>" />
|
608 |
<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>
|
609 |
</td>
|
610 |
</tr>
|
611 |
|
612 |
<tr valign="top">
|
613 |
-
<th scope="row"><p>
|
614 |
<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 />
|
615 |
<font size="-1"><i>HTML you want to be added before the link</i></font>
|
616 |
</p>
|
@@ -618,16 +965,16 @@ vertical-align:top;
|
|
618 |
</tr>
|
619 |
|
620 |
<tr valign="top">
|
621 |
-
<th scope="row"><p>
|
622 |
<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'); ?>" />
|
623 |
<br /><font size="-1"><i>HTML you want to be added after the link</i></font>
|
624 |
</p>
|
625 |
</td>
|
626 |
</tr>
|
627 |
|
628 |
-
<tr valign="top" class="alert"><td colspan="2"><p class="alert">#
|
629 |
<tr valign="top">
|
630 |
-
<th scope="row"><p>
|
631 |
<td><textarea cols="40" rows="10" name="email_before_download_email_template"><?php echo get_option('email_before_download_email_template'); ?> </textarea><br />
|
632 |
<i>You can use the following placeholders: [requesting_name], [file_url] and [file_name]. </i><br />
|
633 |
<i>So if you, for example, don't provide the [file_url] placeholder, the
|
@@ -646,7 +993,7 @@ My Company name </b>
|
|
646 |
</td>
|
647 |
</tr>
|
648 |
<tr valign="top">
|
649 |
-
<th scope="row">
|
650 |
<td>
|
651 |
<textarea cols="40" rows="10" name="email_before_download_email_template_mult"><?php echo get_option('email_before_download_email_template_mult'); ?> </textarea><br />
|
652 |
<i>You can use the following placeholders for multiple urls: [file_urls] </i><br />
|
@@ -654,7 +1001,7 @@ My Company name </b>
|
|
654 |
</tr>
|
655 |
|
656 |
<tr valign="top">
|
657 |
-
<th scope="row"><p>
|
658 |
<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"'; ?> />
|
659 |
<br />
|
660 |
<font size="-1"><i>"Attachment" can only be applied to the files uploaded using Download Monitor plugin.</i></font>
|
@@ -662,17 +1009,65 @@ My Company name </b>
|
|
662 |
</td>
|
663 |
</tr>
|
664 |
|
665 |
-
|
666 |
-
|
667 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
668 |
<br />
|
669 |
-
<font size="-1"><i>
|
670 |
-
<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>
|
671 |
</p>
|
672 |
</td>
|
673 |
</tr>
|
674 |
|
675 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
676 |
|
677 |
<p class="submit">
|
678 |
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
@@ -680,6 +1075,14 @@ My Company name </b>
|
|
680 |
|
681 |
</form>
|
682 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
683 |
<?php
|
684 |
|
685 |
}
|
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 |
============================================================================================================
|
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(
|
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
|
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;
|
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 |
|
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'];
|
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 == '')
|
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;
|
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 ;
|
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 |
// }
|
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;
|
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 |
|
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,
|
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 = '';
|
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;
|
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;
|
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' );
|
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 |
|
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">
|
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>
|
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>
|
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
|
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 />
|
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>
|
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') ?>" />
|
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 |
}
|
export.php
CHANGED
@@ -18,15 +18,33 @@
|
|
18 |
$table_item = $wpdb->prefix . "ebd_item";
|
19 |
$table_link = $wpdb->prefix . "ebd_link";
|
20 |
$table_posted_data = $wpdb->prefix . "ebd_posted_data";
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
$sql = "SELECT l.item_id as item_id,
|
24 |
l.is_downloaded as is_downloaded,
|
25 |
l.email as email,
|
|
|
26 |
l.delivered_as as delivered_as,
|
|
|
27 |
i.file as filename,
|
28 |
i.download_id as download_id,
|
29 |
-
|
30 |
p.posted_data as posted_data,
|
31 |
i.title as item_title,
|
32 |
l.time_requested as time_requested
|
@@ -44,7 +62,7 @@
|
|
44 |
order by l.time_requested desc";
|
45 |
$downloads = $wpdb->get_results($sql);
|
46 |
|
47 |
-
$csv = "item_id,email,download_id,filename,item_title,time_requested,posted_data,delivered_as\n";
|
48 |
|
49 |
$clean_csv_search = array("\n","\r","\t", ",");
|
50 |
$clean_csv_replace = array(" "," "," ", ";");
|
@@ -53,7 +71,9 @@
|
|
53 |
foreach($downloads as $d){
|
54 |
$csv .= $d->item_id . "," .
|
55 |
$d->email . "," .
|
|
|
56 |
str_replace(',', ';', $d->download_id ). "," .
|
|
|
57 |
$d->filename . "," .
|
58 |
$d->item_title . "," .
|
59 |
date("Y-m-d G:i", $d->time_requested). "," .
|
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
|
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(" "," "," ", ";");
|
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). "," .
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: mandsconsulting
|
|
3 |
Donate link: http://www.mandsconsulting.com/
|
4 |
Tags: email, download
|
5 |
Requires at least: 3.x
|
6 |
-
Tested up to:
|
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.
|
@@ -12,7 +12,11 @@ Plugin homepage: http://www.mandsconsulting.com/products/wp-email-before-downloa
|
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
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 [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
|
|
|
|
|
|
|
|
|
16 |
|
17 |
As an option, you can configure Email Before Download to:
|
18 |
|
@@ -20,6 +24,8 @@ As an option, you can configure Email Before Download to:
|
|
20 |
1. Send the user an email with a link and/or attachment to download your file.
|
21 |
1. Both #1 and #2
|
22 |
|
|
|
|
|
23 |
|
24 |
Usage
|
25 |
|
@@ -33,12 +39,15 @@ Note: You can see screenshots at [http://wordpress.org/extend/plugins/email-befo
|
|
33 |
|
34 |
|
35 |
|
36 |
-
Plugin
|
37 |
|
|
|
|
|
|
|
38 |
|
39 |
== Installation ==
|
40 |
|
41 |
-
1. Download from [http://wordpress.org/extend/plugins/email-before-download/]
|
42 |
1. Upload the entire email-before-download folder to the /wp-content/plugins/ directory.
|
43 |
1. Activate the plugin through the "Plugins" menu in WordPress.
|
44 |
1. Locate the "Email Before Download" menu item in your WordPress Admin panel under "Settings" to configure.
|
@@ -66,6 +75,22 @@ By default, the user is presented with a link to download their file. There is
|
|
66 |
|
67 |
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.
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
|
71 |
== Screenshots ==
|
@@ -76,13 +101,102 @@ WordPress allows direct access to files in your upload directories using a direc
|
|
76 |
4. Upon installation and use of the plugin on a post/page, an end-user will see your contact form.
|
77 |
5. User will be required to enter valid data in accordance with Contact Form 7 validation rules.
|
78 |
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.)
|
|
|
79 |
|
80 |
|
81 |
== Changelog ==
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
= 2.0 =
|
85 |
-
* Support multiple
|
86 |
* Add more information in the download history EXPORT .csv file
|
87 |
* Added support for Download Monitor format code for the inline link that is displayed (within shortcut code, specify the format code: format="1")
|
88 |
* 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")
|
3 |
Donate link: http://www.mandsconsulting.com/
|
4 |
Tags: email, download
|
5 |
Requires at least: 3.x
|
6 |
+
Tested up to: 4.0.1
|
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.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
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.
|
16 |
+
We recently updated the deprecated WPDB escape functionality to new one. EBD Version 3.4+ is compatible with WordPress 3.6+. You can download the version compatible with older version of WordPress at [Email Before Dwonload](http://bit.ly/1uThydb)
|
17 |
+
Short note about [WordPress Download Monitor](http://bit.ly/ifff4y). The author has done a complete rewrite of the plugin. But we decided to to keep Email Before Download compatible with the old version of WordPress Download Monitor which can still be downloaded from this url http://downloads.wordpress.org/plugin/download-monitor.3.3.6.zip
|
18 |
+
|
19 |
+
**NOTE:** Email Before Download version 3.2.9 or above is required for Contact Form 7 version 3.9 and above. Thank you for using our plugin.
|
20 |
|
21 |
As an option, you can configure Email Before Download to:
|
22 |
|
24 |
1. Send the user an email with a link and/or attachment to download your file.
|
25 |
1. Both #1 and #2
|
26 |
|
27 |
+
[Plugin Homepage with Live Demos and Test Download](http://www.mandsconsulting.com/products/wp-email-before-download) | [Support Forums](http://bit.ly/lU7Tdt)
|
28 |
+
|
29 |
|
30 |
Usage
|
31 |
|
39 |
|
40 |
|
41 |
|
42 |
+
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)
|
43 |
|
44 |
+
Please use the [Support Forums](http://bit.ly/lU7Tdt) for any questions and issues. We try to monitor that area the best we can and sometimes other users can help you as well.
|
45 |
+
|
46 |
+
If you have a problem or need assistance more rapidly, we now offer a 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 here](http://www.mandsconsulting.com/vendor-solutions/products/wp-email-before-download) to be taken to our website where you can 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.
|
47 |
|
48 |
== Installation ==
|
49 |
|
50 |
+
1. Download from [http://wordpress.org/extend/plugins/email-before-download/](http://bit.ly/dF9AxV)
|
51 |
1. Upload the entire email-before-download folder to the /wp-content/plugins/ directory.
|
52 |
1. Activate the plugin through the "Plugins" menu in WordPress.
|
53 |
1. Locate the "Email Before Download" menu item in your WordPress Admin panel under "Settings" to configure.
|
75 |
|
76 |
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.
|
77 |
|
78 |
+
= What are the available shortcode options? =
|
79 |
+
|
80 |
+
This is the list of all short code attributes that can be used. Some of them override the global admin settings.
|
81 |
+
|
82 |
+
* download_id - either one single download id from Wordpress Download Monitor, or a comma separated list of such ids, eg. '1,2,3'
|
83 |
+
* contact_form_id - Contact Form 7 ID
|
84 |
+
* title - this attribute overrides the download title from Download Monitor (works only with single id)
|
85 |
+
* file - use to point to external url (don't use masked with this attribute)
|
86 |
+
* format - used pass format of the url, this option works only with old version of Download Monitor
|
87 |
+
* delivered_as - possible values: "Send Email", "Both", "Inline Link"
|
88 |
+
* masked - "yes", "true", "no"
|
89 |
+
* attachment - "yes", "no"
|
90 |
+
* force_download - any value that is passed considered as "yes" (we don't have a global menu item for that)
|
91 |
+
* checked - "no", any other value is "yes"
|
92 |
+
* hidden_form - "yes", "no"
|
93 |
+
* use_radio - "yes", "no"
|
94 |
|
95 |
|
96 |
== Screenshots ==
|
101 |
4. Upon installation and use of the plugin on a post/page, an end-user will see your contact form.
|
102 |
5. User will be required to enter valid data in accordance with Contact Form 7 validation rules.
|
103 |
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.)
|
104 |
+
7. Example Contact Form 7 form code, including tag required to display multiple download selection checkboxes.
|
105 |
|
106 |
|
107 |
== Changelog ==
|
108 |
|
109 |
+
=3.4.2=
|
110 |
+
* Fixed issue regarding the download button where letters would display down the screen.
|
111 |
+
|
112 |
+
=3.4.1=
|
113 |
+
* Fixed issue related to SQL functions used in code.
|
114 |
+
|
115 |
+
=3.4=
|
116 |
+
* Updated deprecated WPDB escape functionality to new one.
|
117 |
+
|
118 |
+
=3.3=
|
119 |
+
* Updated to be compatible with Contact Form Version 3.9
|
120 |
+
|
121 |
+
= 3.2.9 =
|
122 |
+
* Fixed issues related to a recent release of Contact Form 7 version 3.9
|
123 |
+
|
124 |
+
= 3.2.8 =
|
125 |
+
* Fixed the issue with multiple download ids checkboxes when user selects hidden contact form option.
|
126 |
+
The checkbox can now be to the left or right, depending on the custom tag (<ebd /> or <ebd left/>)"
|
127 |
+
|
128 |
+
= 3.2.7 =
|
129 |
+
* Fixed the issue with loading contact form as XML to DOM parser, when html entities were breaking the validity of XML.
|
130 |
+
|
131 |
+
= 3.2.6 =
|
132 |
+
* Added new option that allows user to hide contact form until user selects at least one downloads (for multiple download ids )
|
133 |
+
* Added option that turns checkboxes to radio buttons (for multiple download ids)
|
134 |
+
|
135 |
+
= 3.2.5 =
|
136 |
+
* Fixed bug with single quotes that led to javascript error.
|
137 |
+
|
138 |
+
= 3.2.4 =
|
139 |
+
* Added support to new version of the Download monitor
|
140 |
+
* Modified download logic: If the masked option is turned on and Internet Explorer is detected, download will be forced.
|
141 |
+
|
142 |
+
= 3.2.3 =
|
143 |
+
* Two new fields added to the plugin: user_name and email
|
144 |
+
* CSV export now includes new fields
|
145 |
+
* Added checks for the existence of the new fields, adds them if needed
|
146 |
+
* In admin settings, added new option that changes Multiple Checkboxes' default state
|
147 |
+
* Added new short code attribute that overrides admin settings for Multiple Checkboxes' default state
|
148 |
+
|
149 |
+
= 3.2.2 =
|
150 |
+
* Removed extra spacing in multiple download output
|
151 |
+
|
152 |
+
= 3.2.1 =
|
153 |
+
* Create table SQL script updated (now the title column has utf8 character set and utf8_unicode_ci collation)
|
154 |
+
* Added a patch that checks this specific column and alters it if needed
|
155 |
+
|
156 |
+
= 3.2 =
|
157 |
+
* Fixed bug related to logging multiple downloads correctly
|
158 |
+
* Added field to CSV export
|
159 |
+
* Added PayPal button in Admin Panel
|
160 |
+
* Added character encoding in case it helps to support languages other than English
|
161 |
+
|
162 |
+
|
163 |
+
= 3.1.7 =
|
164 |
+
* Default multiple file downloads to pre-selected (checked) by default
|
165 |
+
|
166 |
+
= 3.1.6 =
|
167 |
+
* Minor fix for various multi-file issues and logging
|
168 |
+
|
169 |
+
= 3.1.5 =
|
170 |
+
* fixed event handling
|
171 |
+
* stubbed email_from, though it is not active
|
172 |
+
|
173 |
+
= 3.1 =
|
174 |
+
* New modification to help support for Contact Form 7 v3.0+
|
175 |
+
|
176 |
+
= 3.0 =
|
177 |
+
* Modification to help support for Contact Form 7 v3.0+
|
178 |
+
* 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
|
179 |
+
* Added option in admin panel to clear Email Before Download log entries
|
180 |
+
* Minor fomatting updates to admin panel
|
181 |
+
* 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
|
182 |
+
|
183 |
+
= 2.6 =
|
184 |
+
* Bigger export link
|
185 |
+
* Support for special characters in filenames like "&"
|
186 |
+
* Fix for empty page interaction
|
187 |
+
* Change of function name to avoid conflict with other plugins
|
188 |
+
* Support for left checkboxes on multiple file download form using "<ebd_left />"
|
189 |
+
|
190 |
+
= 2.5.1 =
|
191 |
+
* Minor cleanup of admin panel
|
192 |
+
|
193 |
+
= 2.5 =
|
194 |
+
* Added ability to prevent specific domain names
|
195 |
+
* Fixed download filename issue for .zip files
|
196 |
+
|
197 |
|
198 |
= 2.0 =
|
199 |
+
* 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/)
|
200 |
* Add more information in the download history EXPORT .csv file
|
201 |
* Added support for Download Monitor format code for the inline link that is displayed (within shortcut code, specify the format code: format="1")
|
202 |
* 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")
|
screenshot-7.png
ADDED
Binary file
|