-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
46 lines (40 loc) · 1.49 KB
/
index.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
<?php
// Constants
$sid_url = "http://www.nb.admin.ch/dienstleistungen/swissinfodesk/index.html?lang=de";
$admin_email = "[email protected]";
// Get input
$article_title = $_GET['title'];
$wikipedia_lang = $_GET['lang'];
$back_url = $_GET['back'];
// Check input
if (!$article_title || !$wikipedia_lang || !$back_url) {
echo "Too few info, please et 'title', 'lang' and 'back'.";
exit;
}
// Prepare SID request values
$sid_question = "This is an automated message from Wikipedia.\nA question has been asked about article \"$article_title\".\nHave a look:\nhttps://$wikipedia_lang.wikipedia.org/wiki/Talk:$article_title.";
$sid_subject = "Wikipedia notification about \"$article_title\"";
$sid_name = "Wikipedia automated notification";
$sid_lang = $wikipedia_lang;
$sid_email = $admin_email;
// Send SID request
$data = array('frage_x_not_empty' => $sid_question, 'frage_x_not_empty' => $sid_subject,
'sprache_x_not_empty' => $sid_lang, 'email_x_not_empty' => $sid_email, '_x_no_check' => 'Senden',
'name_x_nocheck' => $sid_name, 'flexindex' => '0_13');
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($sid_url, false, $context);
// Redirect to the back URL
if ($result === FALSE) {
echo "Unable to send to request";
} else {
header("Location: $back_url");
}
exit;
?>