Version Description
(30/09/09) = * Added a new feature where you can mention the name of the recipient of the email within the email by using the %NAME% string * Better default title & text for the WP Email Capture Widget * Fixed a bug that dropped the last character of the "From" name.
Download this release
Release Info
Developer | rhyswynne |
Plugin | WordPress Email Marketing Plugin – WP Email Capture |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 2.0 to 1.3
- inc/checks.php +179 -0
- inc/core.php +15 -0
- inc/dashboard.php +28 -0
- inc/display.php +95 -0
- inc/exportcsv.php +27 -0
- inc/functions.php +24 -0
- inc/install.php +38 -0
- inc/options.php +233 -0
- inc/pagedresults.php +183 -0
- inc/process.php +283 -0
- inc/security.php +61 -0
- inc/tabledata.php +28 -0
- inc/tempdata.php +19 -0
- inc/widget.php +153 -0
- readme.txt +6 -27
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
- screenshot-3.jpg +0 -0
- wp-email-capture.php +1 -1
inc/checks.php
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
|
5 |
+
Validate an email address.
|
6 |
+
|
7 |
+
Provide email address (raw input)
|
8 |
+
|
9 |
+
Returns true if the email address has the email
|
10 |
+
|
11 |
+
address format and the domain exists.
|
12 |
+
|
13 |
+
*/
|
14 |
+
|
15 |
+
if(!function_exists('checkdnsrr'))
|
16 |
+
{
|
17 |
+
function checkdnsrr($hostName, $recType = '')
|
18 |
+
{
|
19 |
+
if(!empty($hostName)) {
|
20 |
+
if( $recType == '' ) $recType = "MX";
|
21 |
+
exec("nslookup -type=$recType $hostName", $result);
|
22 |
+
// check each line to find the one that starts with the host
|
23 |
+
// name. If it exists then the function succeeded.
|
24 |
+
foreach ($result as $line) {
|
25 |
+
if(eregi("^$hostName",$line)) {
|
26 |
+
return true;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
// otherwise there was no mail handler for the domain
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
return false;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
function addLastCharacter($url)
|
37 |
+
{
|
38 |
+
$last = $url[strlen($url)-1];
|
39 |
+
if ($last != "/")
|
40 |
+
{
|
41 |
+
$url = $url . "/";
|
42 |
+
}
|
43 |
+
return $url;
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
function validEmail($email)
|
48 |
+
|
49 |
+
{
|
50 |
+
|
51 |
+
$isValid = true;
|
52 |
+
|
53 |
+
$atIndex = strrpos($email, "@");
|
54 |
+
|
55 |
+
if (is_bool($atIndex) && !$atIndex)
|
56 |
+
|
57 |
+
{
|
58 |
+
|
59 |
+
$isValid = false;
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
else
|
64 |
+
|
65 |
+
{
|
66 |
+
|
67 |
+
$domain = substr($email, $atIndex+1);
|
68 |
+
|
69 |
+
$local = substr($email, 0, $atIndex);
|
70 |
+
|
71 |
+
$localLen = strlen($local);
|
72 |
+
|
73 |
+
$domainLen = strlen($domain);
|
74 |
+
|
75 |
+
if ($localLen < 1 || $localLen > 64)
|
76 |
+
|
77 |
+
{
|
78 |
+
|
79 |
+
// local part length exceeded
|
80 |
+
|
81 |
+
$isValid = false;
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
else if ($domainLen < 1 || $domainLen > 255)
|
86 |
+
|
87 |
+
{
|
88 |
+
|
89 |
+
// domain part length exceeded
|
90 |
+
|
91 |
+
$isValid = false;
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
else if ($local[0] == '.' || $local[$localLen-1] == '.')
|
96 |
+
|
97 |
+
{
|
98 |
+
|
99 |
+
// local part starts or ends with '.'
|
100 |
+
|
101 |
+
$isValid = false;
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
else if (preg_match('/\\.\\./', $local))
|
106 |
+
|
107 |
+
{
|
108 |
+
|
109 |
+
// local part has two consecutive dots
|
110 |
+
|
111 |
+
$isValid = false;
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
|
116 |
+
|
117 |
+
{
|
118 |
+
|
119 |
+
// character not valid in domain part
|
120 |
+
|
121 |
+
$isValid = false;
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
else if (preg_match('/\\.\\./', $domain))
|
126 |
+
|
127 |
+
{
|
128 |
+
|
129 |
+
// domain part has two consecutive dots
|
130 |
+
|
131 |
+
$isValid = false;
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
else if
|
136 |
+
|
137 |
+
(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
|
138 |
+
|
139 |
+
str_replace("\\\\","",$local)))
|
140 |
+
|
141 |
+
{
|
142 |
+
|
143 |
+
// character not valid in local part unless
|
144 |
+
|
145 |
+
// local part is quoted
|
146 |
+
|
147 |
+
if (!preg_match('/^"(\\\\"|[^"])+"$/',
|
148 |
+
|
149 |
+
str_replace("\\\\","",$local)))
|
150 |
+
|
151 |
+
{
|
152 |
+
|
153 |
+
$isValid = false;
|
154 |
+
|
155 |
+
}
|
156 |
+
|
157 |
+
}
|
158 |
+
|
159 |
+
if ($isValid && !(checkdnsrr($domain,"MX") ||
|
160 |
+
|
161 |
+
checkdnsrr($domain,"A")))
|
162 |
+
|
163 |
+
{
|
164 |
+
|
165 |
+
// domain not found in DNS
|
166 |
+
|
167 |
+
$isValid = false;
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
return $isValid;
|
174 |
+
|
175 |
+
}
|
176 |
+
|
177 |
+
|
178 |
+
|
179 |
+
?>
|
inc/core.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/functions.php');
|
3 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/install.php');
|
4 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/pagedresults.php');
|
5 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/tabledata.php');
|
6 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/options.php');
|
7 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/exportcsv.php');
|
8 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/tempdata.php');
|
9 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/display.php');
|
10 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/process.php');
|
11 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/widget.php');
|
12 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/security.php');
|
13 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/dashboard.php');
|
14 |
+
require_once(WP_EMAIL_CAPTURE_PATH . '/inc/checks.php');
|
15 |
+
?>
|
inc/dashboard.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function wp_email_capture_dashboard_widget() {
|
4 |
+
// Display whatever it is you want to show
|
5 |
+
wp_email_capture_writetable(3, "<strong>Last Three Members To Join</strong><br/><br/>");
|
6 |
+
$tempemails = wp_email_capture_count_temp();
|
7 |
+
echo '<br/><br/><a name="list"></a><strong>Export</strong>';
|
8 |
+
echo '<form name="wp_email_capture_export" action="'. $_SERVER["REQUEST_URI"] . '#list" method="post">';
|
9 |
+
echo '<label>Use the button below to export your list as a CSV to use in software such as <a href="http://www.gospelrhys.co.uk/go/aweber.php" title="Email Marketing">Aweber</a>.</label>';
|
10 |
+
echo '<input type="hidden" name="wp_email_capture_export" />';
|
11 |
+
echo '<div class="submit"><input type="submit" value="Export List" /></div>';
|
12 |
+
echo "</form><br/><br/";
|
13 |
+
$tempemails = wp_email_capture_count_temp();
|
14 |
+
echo "<a name='truncate'></a><strong>Temporary e-mails</strong>\n";
|
15 |
+
echo '<form name="wp_email_capture_truncate" action="'. $_SERVER["REQUEST_URI"] . '#truncate" method="post">';
|
16 |
+
echo '<label>There are '. $tempemails . ' e-mail addresses that have been unconfirmed. Delete them to save space below.</label>';
|
17 |
+
echo '<input type="hidden" name="wp_email_capture_truncate"/>';
|
18 |
+
echo '<div class="submit"><input type="submit" value="Delete Unconfirmed e-mail Addresses" /></div>';
|
19 |
+
echo "</form>";
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function wp_email_capture_add_dashboard_widgets() {
|
24 |
+
wp_add_dashboard_widget('wp_email_capture_dashboard_widget', 'WP Email Capture - At A Glance', 'wp_email_capture_dashboard_widget');
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
?>
|
inc/display.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
function wp_email_capture_form($error = 0)
|
6 |
+
|
7 |
+
{
|
8 |
+
|
9 |
+
$url = get_option('home');
|
10 |
+
$url = addLastCharacter($url);
|
11 |
+
|
12 |
+
?> <div id="wp_email_capture"><form name="wp_email_capture" method="post" action="<?php echo $url; ?>">
|
13 |
+
|
14 |
+
<?php if (isset($_GET["wp_email_capture_error"])) {
|
15 |
+
|
16 |
+
$error = sanitize($_GET["wp_email_capture_error"]);
|
17 |
+
|
18 |
+
echo "<div style='width:80%;background-color: #FFCCCC; margin: 5px;font-weight'>Error: ". $error ."</div>";
|
19 |
+
|
20 |
+
} ?>
|
21 |
+
|
22 |
+
<label class="wp-email-capture-name">Name:</label> <input name="wp-email-capture-name" type="text" class="wp-email-capture-name"><br/>
|
23 |
+
|
24 |
+
<label class="wp-email-capture-email">Email:</label> <input name="wp-email-capture-email" type="text" class="wp-email-capture-email"><br/>
|
25 |
+
|
26 |
+
<input type="hidden" name="wp_capture_action" value="1">
|
27 |
+
|
28 |
+
<input name="Submit" type="submit" value="Submit" class="wp-email-capture-submit">
|
29 |
+
|
30 |
+
</form></div>
|
31 |
+
|
32 |
+
<?php if (get_option("wp_email_capture_link") == 1) {
|
33 |
+
|
34 |
+
echo "<p style='font-size:10px;'>Powered by <a href='http://www.gospelrhys.co.uk/plugins/wordpress-plugins/wordpress-email-capture-plugin' target='_blank'>WP Email Capture</a></p>\n";
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
function wp_email_capture_form_page($error = 0)
|
43 |
+
|
44 |
+
{
|
45 |
+
|
46 |
+
$url = get_option('home');
|
47 |
+
$url = addLastCharacter($url);
|
48 |
+
|
49 |
+
$display .= "<div id='wp_email_capture_2'><form name='wp_email_capture_display' method='post' action='" . $url ."'>\n";
|
50 |
+
|
51 |
+
if (isset($_GET["wp_email_capture_error"])) {
|
52 |
+
|
53 |
+
$error = sanitize($_GET["wp_email_capture_error"]);
|
54 |
+
|
55 |
+
$display .= "<div style='width:80%;background-color: #FFCCCC; margin: 5px;font-weight'>Error: ". $error ."</div>\n";
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
$display .= "<label class='wp-email-capture-name'>Name:</label> <input name='wp-email-capture-name' type='text' class='wp-email-capture-name'><br/>\n";
|
60 |
+
|
61 |
+
$display .= "<label class='wp-email-capture-email'>Email:</label> <input name='wp-email-capture-email' type='text' class='wp-email-capture-email'><br/>\n";
|
62 |
+
|
63 |
+
$display .= "<input type='hidden' name='wp_capture_action' value='1'>\n";
|
64 |
+
|
65 |
+
$display .= "<input name='Submit' type='submit' value='Submit' class='wp-email-capture-submit'></form></div>\n";
|
66 |
+
|
67 |
+
if (get_option("wp_email_capture_link") == 1) {
|
68 |
+
|
69 |
+
$display .= "<p style='font-size:10px;'>Powered by <a href='http://www.gospelrhys.co.uk/plugins/wordpress-plugins/wordpress-email-capture-plugin' target='_blank'>WP Email Capture</a></p>\n";
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
return $display;
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
function wp_email_capture_display_form_in_post($content)
|
80 |
+
|
81 |
+
{
|
82 |
+
|
83 |
+
$get_form = wp_email_capture_form_page();
|
84 |
+
|
85 |
+
$content = str_replace("[wp_email_capture_form]", $get_form, $content);
|
86 |
+
|
87 |
+
return $content;
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
|
95 |
+
?>
|
inc/exportcsv.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
function wp_email_capture_export()
|
5 |
+
{
|
6 |
+
global $wpdb;
|
7 |
+
|
8 |
+
$csv_output .= "Name,Email";
|
9 |
+
$csv_output .= "\n";
|
10 |
+
|
11 |
+
|
12 |
+
$table_name = $wpdb->prefix . "wp_email_capture_registered_members";
|
13 |
+
$sql = "SELECT name, email FROM " . $table_name;
|
14 |
+
$results = $wpdb->get_results($wpdb->prepare($sql));
|
15 |
+
foreach ($results as $result) {
|
16 |
+
$csv_output .= $result->name ."," . $result->email ."\n";
|
17 |
+
}
|
18 |
+
|
19 |
+
$filename = $file."_".date("Y-m-d_H-i",time());
|
20 |
+
header("Content-type: application/vnd.ms-excel");
|
21 |
+
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
|
22 |
+
header( "Content-disposition: filename=".$filename.".csv");
|
23 |
+
print $csv_output;
|
24 |
+
exit;
|
25 |
+
}
|
26 |
+
|
27 |
+
?>
|
inc/functions.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
function sanitize($string)
|
3 |
+
{
|
4 |
+
$string = mysql_real_escape_string($string);
|
5 |
+
$string = htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
|
6 |
+
return $string;
|
7 |
+
}
|
8 |
+
|
9 |
+
function checkIfPresent($email){
|
10 |
+
global $wpdb;
|
11 |
+
$table_name = $wpdb->prefix . "wp_email_capture_temp_members";
|
12 |
+
$sql = 'SELECT COUNT(*)
|
13 |
+
FROM '. $table_name;
|
14 |
+
$prep = $wpdb->prepare($sql);
|
15 |
+
$result = $wpdb->get_var($prep);
|
16 |
+
if($count=='1')
|
17 |
+
{
|
18 |
+
return true;
|
19 |
+
}else{
|
20 |
+
return false;
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
?>
|
inc/install.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function wp_email_capture_install() {
|
4 |
+
global $wpdb;
|
5 |
+
global $wp_email_capture_db_version;
|
6 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
7 |
+
$table_name = $wpdb->prefix . "wp_email_capture_registered_members";
|
8 |
+
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
|
9 |
+
|
10 |
+
$sql = "CREATE TABLE " . $table_name . " (
|
11 |
+
id INT( 255 ) NOT NULL AUTO_INCREMENT ,
|
12 |
+
name TINYTEXT NOT NULL ,
|
13 |
+
email TEXT NOT NULL ,
|
14 |
+
PRIMARY KEY (id)
|
15 |
+
);";
|
16 |
+
dbDelta($sql);
|
17 |
+
}
|
18 |
+
$table_name = $wpdb->prefix . "wp_email_capture_temp_members";
|
19 |
+
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
|
20 |
+
|
21 |
+
$sql = "CREATE TABLE " . $table_name . " (
|
22 |
+
id INT( 255 ) NOT NULL AUTO_INCREMENT ,
|
23 |
+
name TINYTEXT NOT NULL ,
|
24 |
+
email TEXT NOT NULL ,
|
25 |
+
|
26 |
+
confirm_code TEXT NOT NULL,
|
27 |
+
PRIMARY KEY (id)
|
28 |
+
);";
|
29 |
+
|
30 |
+
dbDelta($sql);
|
31 |
+
|
32 |
+
|
33 |
+
}
|
34 |
+
add_option('wp_email_capture_link', 1);
|
35 |
+
add_option("wp_email_capture_db_version", $wp_email_capture_db_version);
|
36 |
+
}
|
37 |
+
|
38 |
+
?>
|
inc/options.php
ADDED
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function wp_email_capture_menus() {
|
4 |
+
|
5 |
+
add_options_page('WP Email Capture Options', 'WP Email Capture', 8, 'wpemailcaptureoptions', 'wp_email_capture_options');
|
6 |
+
|
7 |
+
}
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
function wp_email_capture_options() {
|
12 |
+
|
13 |
+
echo '<div class="wrap">';
|
14 |
+
|
15 |
+
echo '<h2>WP Email Capture Options</h2>';
|
16 |
+
|
17 |
+
?>
|
18 |
+
|
19 |
+
<h3>Recommendations</h3>
|
20 |
+
|
21 |
+
<p>We recommend <a href="http://www.gospelrhys.co.uk/go/aweber.php" title="Email Marketing">Aweber</a> to run your email campaigns. We have tested this plugin with it.
|
22 |
+
|
23 |
+
</p>
|
24 |
+
|
25 |
+
<table width="75%" border="0">
|
26 |
+
|
27 |
+
<tr>
|
28 |
+
|
29 |
+
<td><div style="text-align:center;">
|
30 |
+
|
31 |
+
<a href="http://www.gospelrhys.co.uk/go/aweber.php" title="Email Marketing">
|
32 |
+
|
33 |
+
<img src="http://www.aweber.com/banners/email_marketing_easy/726x90.gif" alt="AWeber - Email Marketing Made Easy" style="border:none;" /></a>
|
34 |
+
|
35 |
+
</div></td>
|
36 |
+
|
37 |
+
</tr>
|
38 |
+
|
39 |
+
</table>
|
40 |
+
|
41 |
+
<p>
|
42 |
+
|
43 |
+
<?php
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
echo '<h3>Options</h3>';
|
48 |
+
|
49 |
+
?>
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
</p>
|
54 |
+
|
55 |
+
<form method="post" action="options.php">
|
56 |
+
|
57 |
+
<?php wp_nonce_field('update-options'); ?>
|
58 |
+
|
59 |
+
<?php settings_fields( 'wp-email-capture-group' ); ?>
|
60 |
+
|
61 |
+
<table class="form-table">
|
62 |
+
|
63 |
+
<tbody>
|
64 |
+
|
65 |
+
<tr valign="top">
|
66 |
+
|
67 |
+
<th scope="row" style="width:400px">Page to redirect to on sign up (full web address ie: http://www.domain.com/this-page/)</th>
|
68 |
+
|
69 |
+
<td><input type="text" name="wp_email_capture_signup" class="regular-text code" value="<?php echo get_option('wp_email_capture_signup'); ?>" /></td>
|
70 |
+
|
71 |
+
</tr>
|
72 |
+
|
73 |
+
<tr valign="top">
|
74 |
+
|
75 |
+
<th scope="row" style="width:400px"><label>Page to redirect to on confirmation of email address (full web address ie: http://www.domain.com/this-other-page/)</label></th>
|
76 |
+
|
77 |
+
<td><input type="text" name="wp_email_capture_redirection" class="regular-text code" value="<?php echo get_option('wp_email_capture_redirection'); ?>" /></td>
|
78 |
+
|
79 |
+
</tr>
|
80 |
+
|
81 |
+
<tr valign="top">
|
82 |
+
|
83 |
+
<th scope="row" style="width:400px"><label>From Which Email Address</label></th>
|
84 |
+
|
85 |
+
<td><input type="text" name="wp_email_capture_from" class="regular-text code" value="<?php echo get_option('wp_email_capture_from'); ?>" /></td>
|
86 |
+
|
87 |
+
</tr>
|
88 |
+
|
89 |
+
<tr valign="top">
|
90 |
+
|
91 |
+
<th scope="row" style="width:400px"><label>From Which Name</label></th>
|
92 |
+
|
93 |
+
<td><input type="text" name="wp_email_capture_from_name" class="regular-text code" value="<?php echo get_option('wp_email_capture_from_name'); ?>" /></td>
|
94 |
+
|
95 |
+
</tr>
|
96 |
+
|
97 |
+
<tr valign="top">
|
98 |
+
|
99 |
+
<th scope="row" style="width:400px">Subject of Email</th>
|
100 |
+
|
101 |
+
<td><input type="text" name="wp_email_capture_subject" class="regular-text code" value="<?php echo get_option('wp_email_capture_subject'); ?>" /></td>
|
102 |
+
|
103 |
+
</tr>
|
104 |
+
|
105 |
+
<tr valign="top">
|
106 |
+
|
107 |
+
<th scope="row" style="width:400px"><label>Body of Email<br>
|
108 |
+
(use %NAME% to use the form's "Name" field in their welcome email) </label></th>
|
109 |
+
|
110 |
+
<td><textarea name="wp_email_capture_body" style="width: 25em;"><?php echo get_option('wp_email_capture_body'); ?></textarea></td>
|
111 |
+
|
112 |
+
</tr>
|
113 |
+
|
114 |
+
<tr valign="top">
|
115 |
+
|
116 |
+
<th scope="row" style="width:400px"><label>Link to us (optional, but appreciated)</label></th>
|
117 |
+
|
118 |
+
<td><input type="checkbox" name="wp_email_capture_link" value="1"
|
119 |
+
|
120 |
+
<?php
|
121 |
+
|
122 |
+
if (get_option('wp_email_capture_link') == 1) { echo "checked"; } ?>
|
123 |
+
|
124 |
+
></td>
|
125 |
+
|
126 |
+
</tr>
|
127 |
+
|
128 |
+
</tbody>
|
129 |
+
|
130 |
+
</table>
|
131 |
+
|
132 |
+
|
133 |
+
|
134 |
+
<input type="hidden" name="action" value="update" />
|
135 |
+
|
136 |
+
<input type="hidden" name="page_options" value="wp_email_capture_redirection,wp_email_capture_from,wp_email_capture_subject,wp_email_capture_signup,wp_email_capture_body,wp_email_capture_from_name,wp_email_capture_link" />
|
137 |
+
|
138 |
+
<p class="submit">
|
139 |
+
|
140 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
141 |
+
|
142 |
+
</p>
|
143 |
+
|
144 |
+
</form>
|
145 |
+
|
146 |
+
|
147 |
+
|
148 |
+
<?php
|
149 |
+
|
150 |
+
wp_email_capture_writetable();
|
151 |
+
|
152 |
+
echo '<a name="list"></a><h3>Export</h3>';
|
153 |
+
|
154 |
+
echo '<form name="wp_email_capture_export" action="'. $_SERVER["REQUEST_URI"] . '#list" method="post">';
|
155 |
+
|
156 |
+
echo '<label>Use the button below to export your list as a CSV to use in software such as <a href="http://www.gospelrhys.co.uk/go/aweber.php" title="Email Marketing">Aweber</a> or <a href="http://www.gospelrhys.co.uk/go/mailchimp.php">Mailchimp</a></label>';
|
157 |
+
|
158 |
+
echo '<input type="hidden" name="wp_email_capture_export" />';
|
159 |
+
|
160 |
+
echo '<div class="submit"><input type="submit" value="Export List" /></div>';
|
161 |
+
|
162 |
+
echo "</form>";
|
163 |
+
|
164 |
+
$tempemails = wp_email_capture_count_temp();
|
165 |
+
|
166 |
+
echo "<a name='truncate'></a><h3>Temporary e-mails</h3>\n";
|
167 |
+
|
168 |
+
echo '<form name="wp_email_capture_truncate" action="'. $_SERVER["REQUEST_URI"] . '#truncate" method="post">';
|
169 |
+
|
170 |
+
echo '<label>There are '. $tempemails . ' e-mail addresses that have been unconfirmed. Delete them to save space below.</label>';
|
171 |
+
|
172 |
+
echo '<input type="hidden" name="wp_email_capture_truncate"/>';
|
173 |
+
|
174 |
+
echo '<div class="submit"><input type="submit" value="Delete Unconfirmed e-mail Addresses" /></div>';
|
175 |
+
|
176 |
+
echo "</form>";
|
177 |
+
|
178 |
+
echo '</div>';
|
179 |
+
?>
|
180 |
+
<h3>Donations</h3>
|
181 |
+
|
182 |
+
<p>If you like this plugin, please consider a small donation to help with future versions & plugins. Donators are thanked on each specific plugin page!</p>
|
183 |
+
|
184 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
185 |
+
<input type="hidden" name="cmd" value="_s-xclick">
|
186 |
+
<input type="hidden" name="hosted_button_id" value="8590914">
|
187 |
+
<input type="image" src="https://www.paypal.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
|
188 |
+
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
|
189 |
+
</form>
|
190 |
+
|
191 |
+
|
192 |
+
|
193 |
+
<?php }
|
194 |
+
|
195 |
+
|
196 |
+
|
197 |
+
function wp_email_capture_options_process() { // whitelist options
|
198 |
+
|
199 |
+
register_setting( 'wp-email-capture-group', 'wp_email_capture_signup' );
|
200 |
+
|
201 |
+
register_setting( 'wp-email-capture-group', 'wp_email_capture_redirection' );
|
202 |
+
|
203 |
+
register_setting( 'wp-email-capture-group', 'wp_email_capture_from' );
|
204 |
+
|
205 |
+
register_setting( 'wp-email-capture-group', 'wp_email_capture_subject' );
|
206 |
+
|
207 |
+
register_setting( 'wp-email-capture-group', 'wp_email_capture_body' );
|
208 |
+
|
209 |
+
register_setting( 'wp-email-capture-group', 'wp_email_capture_link');
|
210 |
+
|
211 |
+
register_setting( 'wp-email-capture-group', 'wp_email_capture_from_name' );
|
212 |
+
|
213 |
+
if(isset($_REQUEST['wp_email_capture_export'])) {
|
214 |
+
|
215 |
+
wp_email_capture_export();
|
216 |
+
|
217 |
+
}
|
218 |
+
|
219 |
+
|
220 |
+
|
221 |
+
|
222 |
+
|
223 |
+
if(isset($_REQUEST['wp_email_capture_truncate'])) {
|
224 |
+
|
225 |
+
|
226 |
+
|
227 |
+
wp_email_capture_truncate();
|
228 |
+
|
229 |
+
}
|
230 |
+
|
231 |
+
}
|
232 |
+
|
233 |
+
?>
|
inc/pagedresults.php
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
class MySQLPagedResultSet
|
6 |
+
|
7 |
+
{
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
var $results;
|
12 |
+
|
13 |
+
var $pageSize;
|
14 |
+
|
15 |
+
var $page;
|
16 |
+
|
17 |
+
var $row;
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
function MySQLPagedResultSet($query,$pageSize)
|
22 |
+
|
23 |
+
{
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
$resultpage = $_GET['resultpage'];
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
$this->results = mysql_query($query);
|
32 |
+
|
33 |
+
$this->pageSize = $pageSize;
|
34 |
+
|
35 |
+
if ((int)$resultpage <= 0) $resultpage = 1;
|
36 |
+
|
37 |
+
if ($resultpage > $this->getNumPages())
|
38 |
+
|
39 |
+
$resultpage = $this->getNumPages();
|
40 |
+
|
41 |
+
$this->setPageNum($resultpage);
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
function getNumPages()
|
48 |
+
|
49 |
+
{
|
50 |
+
|
51 |
+
if (!$this->results) return FALSE;
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
return ceil(mysql_num_rows($this->results) /
|
56 |
+
|
57 |
+
(float)$this->pageSize);
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
|
63 |
+
function setPageNum($pageNum)
|
64 |
+
|
65 |
+
{
|
66 |
+
|
67 |
+
if ($pageNum > $this->getNumPages() or
|
68 |
+
|
69 |
+
$pageNum <= 0) return FALSE;
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
$this->page = $pageNum;
|
74 |
+
|
75 |
+
$this->row = 0;
|
76 |
+
|
77 |
+
mysql_data_seek($this->results,($pageNum-1) * $this->pageSize);
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
|
83 |
+
function getPageNum()
|
84 |
+
|
85 |
+
{
|
86 |
+
|
87 |
+
return $this->page;
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
|
93 |
+
function isLastPage()
|
94 |
+
|
95 |
+
{
|
96 |
+
|
97 |
+
return ($this->page >= $this->getNumPages());
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
function isFirstPage()
|
104 |
+
|
105 |
+
{
|
106 |
+
|
107 |
+
return ($this->page <= 1);
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
|
113 |
+
function fetchArray()
|
114 |
+
|
115 |
+
{
|
116 |
+
|
117 |
+
if (!$this->results) return FALSE;
|
118 |
+
|
119 |
+
if ($this->row >= $this->pageSize) return FALSE;
|
120 |
+
|
121 |
+
$this->row++;
|
122 |
+
|
123 |
+
return mysql_fetch_array($this->results);
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
|
128 |
+
|
129 |
+
function getPageNav($queryvars = '')
|
130 |
+
|
131 |
+
{
|
132 |
+
|
133 |
+
$nav = '';
|
134 |
+
|
135 |
+
if (!$this->isFirstPage())
|
136 |
+
|
137 |
+
{
|
138 |
+
|
139 |
+
$nav .= "<a href=\"?resultpage=".
|
140 |
+
|
141 |
+
($this->getPageNum()-1).'&'.$queryvars.'">Prev</a> ';
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
if ($this->getNumPages() > 1)
|
146 |
+
|
147 |
+
for ($i=1; $i<=$this->getNumPages(); $i++)
|
148 |
+
|
149 |
+
{
|
150 |
+
|
151 |
+
if ($i==$this->page)
|
152 |
+
|
153 |
+
$nav .= "$i ";
|
154 |
+
|
155 |
+
else
|
156 |
+
|
157 |
+
$nav .= "<a href=\"?resultpage={$i}&".
|
158 |
+
|
159 |
+
$queryvars."\">{$i}</a> ";
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
if (!$this->isLastPage())
|
164 |
+
|
165 |
+
{
|
166 |
+
|
167 |
+
$nav .= "<a href=\"?resultpage=".
|
168 |
+
|
169 |
+
($this->getPageNum()+1).'&'.$queryvars.'">Next</a> ';
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
|
174 |
+
|
175 |
+
return $nav;
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
|
182 |
+
|
183 |
+
?>
|
inc/process.php
ADDED
@@ -0,0 +1,283 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
function wp_email_capture_process()
|
6 |
+
|
7 |
+
{
|
8 |
+
|
9 |
+
if(isset($_REQUEST['wp_capture_action'])) {
|
10 |
+
wp_email_capture_signup();
|
11 |
+
}
|
12 |
+
|
13 |
+
if(isset($_GET['wp_email_confirm']) || isset($_REQUEST['wp_email_confirm'])) {
|
14 |
+
wp_capture_email_confirm();
|
15 |
+
}
|
16 |
+
|
17 |
+
}
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
function wp_email_capture_double_check_everything($name, $email)
|
22 |
+
|
23 |
+
{
|
24 |
+
|
25 |
+
if (wp_email_injection_chars($name) || wp_email_injection_chars($email) || wp_email_injection_chars($name) || wp_email_injection_chars($email))
|
26 |
+
|
27 |
+
{
|
28 |
+
|
29 |
+
return FALSE;
|
30 |
+
|
31 |
+
} else {
|
32 |
+
|
33 |
+
return TRUE;
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
function wp_email_capture_signup()
|
41 |
+
|
42 |
+
{
|
43 |
+
|
44 |
+
global $wpdb;
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
// Random confirmation code
|
49 |
+
|
50 |
+
$confirm_code=md5(uniqid(rand()));
|
51 |
+
|
52 |
+
$name = $_REQUEST['wp-email-capture-name'];
|
53 |
+
|
54 |
+
$email = $_REQUEST['wp-email-capture-email'];
|
55 |
+
|
56 |
+
|
57 |
+
if (!validEmail($email))
|
58 |
+
|
59 |
+
{
|
60 |
+
|
61 |
+
$url = $_SERVER['PHP_SELF'] . "?wp_email_capture_error=Not%20a%20valid%20email";
|
62 |
+
|
63 |
+
header("Location: $url");
|
64 |
+
|
65 |
+
die();
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
|
71 |
+
if (wp_email_capture_double_check_everything($name, $email))
|
72 |
+
|
73 |
+
{
|
74 |
+
|
75 |
+
// values sent from form
|
76 |
+
|
77 |
+
$name = sanitize($name);
|
78 |
+
|
79 |
+
$email= sanitize($email);
|
80 |
+
|
81 |
+
$name = wp_email_injection_test($name);
|
82 |
+
|
83 |
+
$email = wp_email_injection_test($email);
|
84 |
+
|
85 |
+
$name = wp_email_stripslashes($name);
|
86 |
+
|
87 |
+
$email = wp_email_stripslashes($email);
|
88 |
+
|
89 |
+
|
90 |
+
|
91 |
+
$sqlcheck = checkIfPresent($email);
|
92 |
+
|
93 |
+
|
94 |
+
|
95 |
+
if ($sqlcheck){
|
96 |
+
|
97 |
+
|
98 |
+
|
99 |
+
$url = $_SERVER['PHP_SELF'] . "?wp_email_capture_error=User%20already%20present";
|
100 |
+
|
101 |
+
header("Location: $url");
|
102 |
+
|
103 |
+
die();
|
104 |
+
|
105 |
+
}
|
106 |
+
|
107 |
+
|
108 |
+
|
109 |
+
// Insert data into database
|
110 |
+
|
111 |
+
$table_name = $wpdb->prefix . "wp_email_capture_temp_members";
|
112 |
+
|
113 |
+
|
114 |
+
|
115 |
+
|
116 |
+
|
117 |
+
$sql="INSERT INTO ".$table_name."(confirm_code, name, email)VALUES('$confirm_code', '$name', '$email')";
|
118 |
+
|
119 |
+
$result=$wpdb->query($wpdb->prepare($sql));
|
120 |
+
|
121 |
+
|
122 |
+
|
123 |
+
// if suceesfully inserted data into database, send confirmation link to email
|
124 |
+
|
125 |
+
if($result){
|
126 |
+
|
127 |
+
|
128 |
+
|
129 |
+
// ---------------- SEND MAIL FORM ----------------
|
130 |
+
|
131 |
+
|
132 |
+
|
133 |
+
// send e-mail to ...
|
134 |
+
|
135 |
+
$to=$email;
|
136 |
+
|
137 |
+
$siteurl = get_option('home');
|
138 |
+
$siteurl = addLastCharacter($siteurl);
|
139 |
+
|
140 |
+
// Your subject
|
141 |
+
|
142 |
+
$subject=get_option('wp_email_capture_subject');
|
143 |
+
|
144 |
+
// From
|
145 |
+
$header = "MIME-Version: 1.0\n" . "From: " . get_option('wp_email_capture_from_name') . " <" . get_option('wp_email_capture_from') . ">\n";
|
146 |
+
$header .= "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n";
|
147 |
+
// Your message
|
148 |
+
|
149 |
+
$message.= get_option('wp_email_capture_body') . "\n\n";
|
150 |
+
|
151 |
+
$message.= $siteurl ."?wp_email_confirm=1&wp_email_capture_passkey=$confirm_code";
|
152 |
+
|
153 |
+
$message = str_replace("%NAME%", $name, $message);
|
154 |
+
|
155 |
+
// send email
|
156 |
+
|
157 |
+
$sentmail = wp_mail($to,$subject,$message,$header);
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
|
164 |
+
|
165 |
+
// if not found
|
166 |
+
|
167 |
+
else {
|
168 |
+
|
169 |
+
echo "Not found your email in our database";
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
|
174 |
+
|
175 |
+
// if your email succesfully sent
|
176 |
+
|
177 |
+
if($sentmail){
|
178 |
+
|
179 |
+
$halfreg = get_option('wp_email_capture_signup');
|
180 |
+
|
181 |
+
header("Location: $halfreg");
|
182 |
+
|
183 |
+
die();
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
else {
|
188 |
+
|
189 |
+
$url = $_SERVER['PHP_SELF'] . "?wp_email_capture_error=Email%20unable%20to%20be%sent";
|
190 |
+
|
191 |
+
header("Location: $url");
|
192 |
+
|
193 |
+
die();
|
194 |
+
|
195 |
+
//echo "<meta http-equiv='refresh' content='0;". $url . "?wp_email_capture_error=Email%20unable%20to%20be%sent'>";
|
196 |
+
|
197 |
+
}
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
|
202 |
+
|
203 |
+
|
204 |
+
|
205 |
+
function wp_capture_email_confirm()
|
206 |
+
|
207 |
+
{
|
208 |
+
|
209 |
+
global $wpdb;
|
210 |
+
|
211 |
+
// Passkey that got from link
|
212 |
+
|
213 |
+
$passkey=sanitize($_GET['wp_email_capture_passkey']);
|
214 |
+
|
215 |
+
$table_name = $wpdb->prefix . "wp_email_capture_temp_members";
|
216 |
+
|
217 |
+
$sql1="SELECT id FROM $table_name WHERE confirm_code ='$passkey'";
|
218 |
+
|
219 |
+
$result=$wpdb->get_var($wpdb->prepare($sql1));
|
220 |
+
|
221 |
+
if ($result != '')
|
222 |
+
|
223 |
+
{
|
224 |
+
|
225 |
+
$table_name2 = $wpdb->prefix . "wp_email_capture_registered_members";
|
226 |
+
|
227 |
+
$sql2="SELECT * FROM $table_name WHERE confirm_code ='$passkey'";
|
228 |
+
|
229 |
+
$rowresults = $wpdb->get_results($wpdb->prepare($sql2));
|
230 |
+
|
231 |
+
foreach ($rowresults as $rowresult) {
|
232 |
+
|
233 |
+
$name = $rowresult->name;
|
234 |
+
|
235 |
+
$email = $rowresult->email;
|
236 |
+
|
237 |
+
$sql3="INSERT INTO $table_name2(name, email)VALUES('$name', '$email')";
|
238 |
+
|
239 |
+
$result3=$wpdb->query($wpdb->prepare($sql3));
|
240 |
+
|
241 |
+
}
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
else {
|
246 |
+
|
247 |
+
$url = $url . "?wp_email_capture_error=Wrong%20confirmation%20code";
|
248 |
+
|
249 |
+
header("Location: $url");
|
250 |
+
|
251 |
+
}
|
252 |
+
|
253 |
+
// if successfully moved data from table"temp_members_db" to table "registered_members" displays message "Your account has been activated" and don't forget to delete confirmation code from table "temp_members_db"
|
254 |
+
|
255 |
+
|
256 |
+
|
257 |
+
if($result3){
|
258 |
+
|
259 |
+
$sql4="DELETE FROM $table_name WHERE confirm_code = '$passkey'";
|
260 |
+
|
261 |
+
$result4=$wpdb->query($wpdb->prepare($sql4));
|
262 |
+
|
263 |
+
$fullreg = get_option('wp_email_capture_redirection');
|
264 |
+
|
265 |
+
|
266 |
+
|
267 |
+
//echo "<meta http-equiv='refresh' content='0;". $fullreg ."'>";
|
268 |
+
|
269 |
+
header("Location: $fullreg");
|
270 |
+
|
271 |
+
}
|
272 |
+
|
273 |
+
|
274 |
+
|
275 |
+
|
276 |
+
|
277 |
+
}
|
278 |
+
|
279 |
+
|
280 |
+
|
281 |
+
|
282 |
+
|
283 |
+
?>
|
inc/security.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
/* Check for injection characters */
|
6 |
+
|
7 |
+
function wp_email_injection_chars($s) {
|
8 |
+
|
9 |
+
return (eregi("\r", $s) || eregi("\n", $s) || eregi("%0a", $s) || eregi("%0d", $s)) ? TRUE : FALSE;
|
10 |
+
|
11 |
+
}
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
/* Make output safe for the browser */
|
18 |
+
|
19 |
+
function wp_email_capture_bsafe($input) {
|
20 |
+
|
21 |
+
return htmlspecialchars(stripslashes($input));
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
function wp_email_stripslashes($s) {
|
34 |
+
|
35 |
+
if (defined('TEMPLATEPATH') || (get_magic_quotes_gpc())) {
|
36 |
+
|
37 |
+
return stripslashes($s);
|
38 |
+
|
39 |
+
} else {
|
40 |
+
|
41 |
+
return $s;
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
|
51 |
+
function wp_email_injection_test($str) {
|
52 |
+
|
53 |
+
$tests = array("/bcc\:/i", "/Content\-Type\:/i", "/Mime\-Version\:/i", "/cc\:/i", "/from\:/i", "/to\:/i", "/Content\-Transfer\-Encoding\:/i");
|
54 |
+
|
55 |
+
return preg_replace($tests, "", $str);
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
?>
|
inc/tabledata.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function wp_email_capture_writetable($limit = 0, $header = '')
|
4 |
+
{
|
5 |
+
global $wpdb;
|
6 |
+
$table_name = $wpdb->prefix . "wp_email_capture_registered_members";
|
7 |
+
$sql = "SELECT id, name, email FROM " . $table_name;
|
8 |
+
if ($limit != 0) {
|
9 |
+
$sql .= " ORDER BY id DESC LIMIT 3";
|
10 |
+
}
|
11 |
+
$results = $wpdb->get_results($wpdb->prepare($sql));
|
12 |
+
|
13 |
+
if ($header == '') {
|
14 |
+
$header = "<h3>Members</h3>";
|
15 |
+
}
|
16 |
+
echo $header;
|
17 |
+
?>
|
18 |
+
<table>
|
19 |
+
<tr><td><strong>Name</strong></td><td><strong>Email</strong></td></tr>
|
20 |
+
<?php foreach ($results as $result) {
|
21 |
+
echo "<tr><td style='width: 400px;'>" . $result->name ."</td><td style='width: 400px;'>" . $result->email ."</td></tr>";
|
22 |
+
}
|
23 |
+
?>
|
24 |
+
</table>
|
25 |
+
<?php
|
26 |
+
}
|
27 |
+
|
28 |
+
?>
|
inc/tempdata.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
function wp_email_capture_truncate()
|
3 |
+
{
|
4 |
+
global $wpdb;
|
5 |
+
$table_name = $wpdb->prefix . "wp_email_capture_temp_members";
|
6 |
+
$sql = "TRUNCATE " . $table_name;
|
7 |
+
$result = $wpdb->query($wpdb->prepare($sql));
|
8 |
+
}
|
9 |
+
function wp_email_capture_count_temp()
|
10 |
+
{
|
11 |
+
global $wpdb;
|
12 |
+
$table_name = $wpdb->prefix . "wp_email_capture_temp_members";
|
13 |
+
$sql = 'SELECT COUNT(*)
|
14 |
+
FROM '. $table_name;
|
15 |
+
$prep = $wpdb->prepare($sql);
|
16 |
+
$result = $wpdb->get_var($prep);
|
17 |
+
return $result;
|
18 |
+
}
|
19 |
+
?>
|
inc/widget.php
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function wp_email_capture_widget_init() {
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
// Check to see required Widget API functions are defined...
|
8 |
+
|
9 |
+
if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') )
|
10 |
+
|
11 |
+
return; // ...and if not, exit gracefully from the script.
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
// This function prints the sidebar widget--the cool stuff!
|
16 |
+
|
17 |
+
function wp_email_capture_widget($args) {
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
// $args is an array of strings which help your widget
|
22 |
+
|
23 |
+
// conform to the active theme: before_widget, before_title,
|
24 |
+
|
25 |
+
// after_widget, and after_title are the array keys.
|
26 |
+
|
27 |
+
extract($args);
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
// Collect our widget's options, or define their defaults.
|
32 |
+
|
33 |
+
$options = get_option('wp_email_capture_widget');
|
34 |
+
|
35 |
+
$title = empty($options['title']) ? 'Subscribe!' : $options['title'];
|
36 |
+
|
37 |
+
$text = empty($options['text']) ? 'Subscribe to my blog for updates' : $options['text'];
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
// It's important to use the $before_widget, $before_title,
|
42 |
+
|
43 |
+
// $after_title and $after_widget variables in your output.
|
44 |
+
|
45 |
+
echo $before_widget;
|
46 |
+
|
47 |
+
echo $before_title . $title . $after_title;
|
48 |
+
|
49 |
+
echo $text;
|
50 |
+
|
51 |
+
wp_email_capture_form();
|
52 |
+
|
53 |
+
echo $after_widget;
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
// This is the function that outputs the form to let users edit
|
60 |
+
|
61 |
+
// the widget's title and so on. It's an optional feature, but
|
62 |
+
|
63 |
+
// we'll use it because we can!
|
64 |
+
|
65 |
+
function wp_email_capture_widget_control() {
|
66 |
+
|
67 |
+
|
68 |
+
|
69 |
+
// Collect our widget's options.
|
70 |
+
|
71 |
+
$options = get_option('wp_email_capture_widget');
|
72 |
+
|
73 |
+
$newoptions = get_option('wp_email_capture_widget');
|
74 |
+
|
75 |
+
// This is for handing the control form submission.
|
76 |
+
|
77 |
+
if ( $_POST['wp-email-capture-submit'] ) {
|
78 |
+
|
79 |
+
// Clean up control form submission options
|
80 |
+
|
81 |
+
$newoptions['title'] = strip_tags(stripslashes($_POST['wp-email-capture-title']));
|
82 |
+
|
83 |
+
$newoptions['text'] = strip_tags(stripslashes($_POST['wp-email-capture-text']));
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
|
89 |
+
// If original widget options do not match control form
|
90 |
+
|
91 |
+
// submission options, update them.
|
92 |
+
|
93 |
+
if ( $options != $newoptions ) {
|
94 |
+
|
95 |
+
$options = $newoptions;
|
96 |
+
|
97 |
+
update_option('wp_email_capture_widget', $options);
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
// Format options as valid HTML. Hey, why not.
|
104 |
+
|
105 |
+
$title = htmlspecialchars($options['title'], ENT_QUOTES);
|
106 |
+
|
107 |
+
$text = htmlspecialchars($options['text'], ENT_QUOTES);
|
108 |
+
|
109 |
+
|
110 |
+
|
111 |
+
// The HTML below is the control form for editing options.
|
112 |
+
|
113 |
+
?>
|
114 |
+
|
115 |
+
<div>
|
116 |
+
|
117 |
+
<label for="wp-email-capture-title" style="line-height:35px;display:block;">Widget title: <input type="text" id="wp-email-capture-title" name="wp-email-capture-title" value="<?php echo $title; ?>" /></label>
|
118 |
+
|
119 |
+
<label for="wp-email-capture-text" style="line-height:35px;display:block;">Widget text: <input type="text" id="wp-email-capture-text" name="wp-email-capture-text" value="<?php echo $text; ?>" /></label>
|
120 |
+
|
121 |
+
<input type="hidden" name="wp-email-capture-submit" id="wp-email-capture-submit" value="1" />
|
122 |
+
|
123 |
+
</div>
|
124 |
+
|
125 |
+
<?php
|
126 |
+
|
127 |
+
// end of widget_mywidget_control()
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
|
132 |
+
|
133 |
+
// This registers the widget. About time.
|
134 |
+
|
135 |
+
register_sidebar_widget('WP Email Capture', 'wp_email_capture_widget');
|
136 |
+
|
137 |
+
|
138 |
+
|
139 |
+
// This registers the (optional!) widget control form.
|
140 |
+
|
141 |
+
register_widget_control('WP Email Capture', 'wp_email_capture_widget_control');
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
|
146 |
+
|
147 |
+
// Delays plugin execution until Dynamic Sidebar has loaded first.
|
148 |
+
|
149 |
+
add_action('plugins_loaded', 'wp_email_capture_widget_init');
|
150 |
+
|
151 |
+
|
152 |
+
|
153 |
+
?>
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== WP Email Capture ===
|
2 |
Tags: email, marketing, capture, form, affiliates, mailing lists, email marketing, widget ready
|
3 |
-
Requires at least:
|
4 |
-
Tested up to:
|
5 |
-
Version:
|
6 |
-
Stable tag:
|
7 |
Contributors: rhyswynne
|
8 |
Donate link: http://www.gospelrhys.co.uk/donations/
|
9 |
|
@@ -102,30 +102,9 @@ To donate to this plugin, please visit:
|
|
102 |
http://www.gospelrhys.co.uk/donations
|
103 |
|
104 |
== Change Log ==
|
105 |
-
= 2.0 (3/10/10) =
|
106 |
-
* Switched functions to use the non depreciated functions
|
107 |
-
* Compatible with Spam Free
|
108 |
-
* Added a "Delete entire list" button in Wordpress.
|
109 |
-
|
110 |
-
= 1.9 (20/01/10) =
|
111 |
-
* Fixed a small bug that resulted in the display for [The plugin does not have a valid header.]
|
112 |
-
* Fixed a small phpmail bug
|
113 |
-
|
114 |
-
= 1.8.1 (13/01/10) =
|
115 |
-
* Included more information in sent mail including IP, Date & Referral Page
|
116 |
-
|
117 |
-
= 1.6 (18/10/09) =
|
118 |
-
* You can now delete people from the confirmed members list (requested update!)
|
119 |
-
|
120 |
-
= 1.5 (04/10/09) =
|
121 |
-
* Fixed small error on the error checking form.
|
122 |
-
|
123 |
-
= 1.4 (03/10/09) =
|
124 |
-
* Added a check for duplicate emails.
|
125 |
-
|
126 |
= 1.3 (30/09/09) =
|
127 |
-
* Added a new feature where you can mention the name of the recipient of the email within the email by using the %NAME% string
|
128 |
-
* Better default title & text for the WP Email Capture Widget
|
129 |
* Fixed a bug that dropped the last character of the "From" name.
|
130 |
|
131 |
= 1.2 (27/09/09) =
|
1 |
=== WP Email Capture ===
|
2 |
Tags: email, marketing, capture, form, affiliates, mailing lists, email marketing, widget ready
|
3 |
+
Requires at least: 2.8
|
4 |
+
Tested up to: 2.8.4
|
5 |
+
Version: 1.3
|
6 |
+
Stable tag: 1.3
|
7 |
Contributors: rhyswynne
|
8 |
Donate link: http://www.gospelrhys.co.uk/donations/
|
9 |
|
102 |
http://www.gospelrhys.co.uk/donations
|
103 |
|
104 |
== Change Log ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
= 1.3 (30/09/09) =
|
106 |
+
* Added a new feature where you can mention the name of the recipient of the email within the email by using the %NAME% string
|
107 |
+
* Better default title & text for the WP Email Capture Widget
|
108 |
* Fixed a bug that dropped the last character of the "From" name.
|
109 |
|
110 |
= 1.2 (27/09/09) =
|
screenshot-1.jpg
ADDED
Binary file
|
screenshot-2.jpg
ADDED
Binary file
|
screenshot-3.jpg
ADDED
Binary file
|
wp-email-capture.php
CHANGED
@@ -8,7 +8,7 @@ Plugin URI: http://www.gospelrhys.co.uk/plugins/wordpress-plugins/wordpress-emai
|
|
8 |
|
9 |
Description: Captures email addresses for insertion into software such as <a href="http://www.gospelrhys.co.uk/go/aweber.php" title="Email Marketing">Aweber</a> or <a href="http://www.gospelrhys.co.uk/go/mailchimp.php">Mailchimp</a>
|
10 |
|
11 |
-
Version:
|
12 |
|
13 |
Author: Rhys Wynne
|
14 |
|
8 |
|
9 |
Description: Captures email addresses for insertion into software such as <a href="http://www.gospelrhys.co.uk/go/aweber.php" title="Email Marketing">Aweber</a> or <a href="http://www.gospelrhys.co.uk/go/mailchimp.php">Mailchimp</a>
|
10 |
|
11 |
+
Version: 1.3
|
12 |
|
13 |
Author: Rhys Wynne
|
14 |
|