-
Notifications
You must be signed in to change notification settings - Fork 0
/
do.php
45 lines (33 loc) · 1.59 KB
/
do.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
<?php
include '../../../wp-load.php';
$action = $_REQUEST['a'];
if (empty($action)) return;
$user = $newsletter->check_user();
if ($user == null) {
echo 'Subscriber not found, sorry.';
die();
}
$options = get_option('newsletter', array());
$options_main = get_option('newsletter_main', array());
if ($action == 'c') {
setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/');
$wpdb->query("update " . $wpdb->prefix . "newsletter set status='C' where id=" . $user->id);
$newsletter->mail($user->email, $newsletter->replace($options['confirmed_subject'], $user), $newsletter->replace($options['confirmed_message'], $user));
$newsletter->notify_admin($user, 'Newsletter subscription');
$url = $options_main['url'];
if (empty($url)) $url = get_option('home');
header('Location: ' . $newsletter->add_qs($url, 'na=c&ni=' . $user->id . '&nt=' . $user->token, false));
die();
}
if ($action == 'uc') {
$wpdb->query($wpdb->prepare("update " . $wpdb->prefix . "newsletter set status='U' where id=%d and token=%s", $user->id, $user->token));
setcookie("newsletter", "", time() - 3600);
$newsletter->mail($user->email, $newsletter->replace($options['unsubscribed_subject'], $user), $newsletter->replace($options['unsubscribed_message'], $user));
$newsletter->notify_admin($user, 'Newsletter cancellation');
$url = $options_main['url'];
if (empty($url)) $url = get_option('home');
header('Location: ' . $newsletter->add_qs($url, 'na=uc&ni=' . $user->id . '&nt=' . $user->token, false));
die();
}
?>
Unknown action.