forked from e107inc/e107
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unsubscribe.php
148 lines (97 loc) · 2.81 KB
/
unsubscribe.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
if (!defined('e107_INIT'))
{
require_once("class2.php");
}
define('e_IFRAME', true);
require_once(HEADERF);
class unsubscribe
{
function __construct()
{
$mes = e107::getMessage();
$frm = e107::getForm();
$tp = e107::getParser();
// $this->simulation();
$mailoutPlugins = e107::getConfig()->get('e_mailout_list');
if(empty($_GET['id']))
{
return;
}
$tmp = base64_decode($_GET['id']);
parse_str($tmp,$data);
$data['plugin'] = $tp->filter($data['plugin'],'str');
$data['email'] = $tp->filter($data['email'],'email');
e107::getMessage()->addDebug(print_a($data,true));
$plugin = vartrue($data['plugin'],false);
if(empty($data) || !e107::isInstalled($plugin) || !in_array($plugin, $mailoutPlugins))
{
$this->invalidURL();
return;
}
$ml = e107::getAddon($plugin, 'e_mailout');
if(!empty($data['userclass'])) // userclass unsubscribe.
{
$data['userclass'] = intval($data['userclass']);
$listName = e107::getUserClass()->getName($data['userclass']);
}
else
{
$listName = $ml->mailerName;
}
if(vartrue($_POST['remove']) && !empty($data))
{
if($ml->unsubscribe('process',$data)!=false)
{
$text = "<p><b>".$data['email']."</b> has been removed from ".$listName.".</p>";
$mes->addSuccess($text);
}
else
{
$text = "<p>There was a problem when attempting to remove <b>".$data['email']."</b> from ".$listName.".</p>";
$mes->addError($text);
}
echo "<div class='container'>".$mes->render()."</div>";
return;
}
if($ml->unsubscribe('check',$data) != false)
{
$text = "<p>We are very sorry for the inconvenience. <br />Please click the button below to remove <b>".$data['email']."</b> from <i>".$listName."</i>.</p>";
$text .= $frm->open('unsub','post',e_REQUEST_URI);
$text .= $frm->button('remove','Remove ','submit');
$text .= $frm->close();
$mes->setTitle('Unsubscribe',E_MESSAGE_INFO)->addInfo($text);
echo "<div class='container'>".$mes->render()."</div>";
return;
}
else
{
$this->invalidURL();
return;
}
}
function simulation()
{
$row = array();
$row['datestamp'] = time();
$row['email'] = "test@test.com";
$row['id'] = 23;
$unsubscribe = array('date'=>$row['datestamp'],'email'=>$row['email'],'id'=>$row['id'],'plugin'=>'user');
$urlQuery = http_build_query($unsubscribe,null,'&');
$_GET['id'] = base64_encode($urlQuery);
e107::getMessage()->addDebug("urlQuery = ".$urlQuery);
//echo "urlQuery = ".$urlQuery."<br/>";
e107::getMessage()->addDebug(e_SELF."?id=".$_GET['id']);
}
function invalidURL()
{
$mes = e107::getMessage();
$mes->addWarning("Invalid URL");
echo "<div class='container'>".$mes->render()."</div>";
return;
}
}
new unsubscribe;
require_once(FOOTERF);
exit;
?>