-
Notifications
You must be signed in to change notification settings - Fork 20
/
subscribe.php
77 lines (68 loc) · 2.38 KB
/
subscribe.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
<?php
require 'common.php';
head("Subscribe to a group");
echo '<section class="content">';
// No error found yet
$error = "";
// Check email address
if (
empty($_POST['email']) ||
$_POST['email'] == '[email protected]' ||
$_POST['email'] == '[email protected]' ||
!is_emailable_address($_POST['email'])
) {
$error = "You forgot to specify an email address to be added to the list, or specified an invalid address." .
"<br>Please go back and try again.";
// Check if any mailing list was selected
} elseif (empty($_POST['group'])) {
$error = "You need to select a group subscribe to." .
"<br>Please go back and try again.";
// Check if type of subscription makes sense
} elseif (!in_array($_POST['type'], [ '', 'digest', 'nomail' ])) {
$error = "The subscription type you specified is not valid." .
"<br>Please go back and try again.";
// Seems to be a valid email address
} else {
$remote_addr = i2c_realip();
$maillist = get_list_address($_POST['group']);
if ($_POST['type'] != '') {
$maillist .= '-' . $_POST['type'];
}
if ($maillist) {
// Get in contact with main server to subscribe the user
$result = posttohost(
"https://main.php.net/entry/subscribe.php",
[
"request" => 'subscribe',
"email" => $_POST['email'],
"maillist" => $maillist,
"remoteip" => $remote_addr,
"referer"
=> 'http' . (@$_SERVER['HTTPS'] ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] .
'/' . $_POST['group'],
],
);
// Provide error if unable to subscribe
if ($result) {
$error = "We were unable to subscribe you due to some technical problems.<br>" .
"Please try again later.";
}
} else {
$error = "That's not a group that we can handle.<br>" .
"Please try again later.";
}
}
// Give error information or success report
if (!empty($error)) {
echo "<p class=\"formerror\">$error</p>";
} else {
?>
<p>
A request has been entered into the mailing list processing queue.
You should receive an email at <?php echo clean($_POST['email']); ?> shortly
describing how to complete your request.
</p>
<?php
}
echo '</section>';
foot();