forked from stamen/maps.stamen.com
/
feedback.php
111 lines (92 loc) · 3.26 KB
/
feedback.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
<?php
try {
$config = parse_ini_file('config.ini', true, INI_SCANNER_RAW);
} catch (Exception $err) {
}
$valid = true;
// check reCAPTCHA
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($config)) {
require_once('recaptchalib.php');
$resp = recaptcha_check_answer(
$config['recaptcha']['private_key'],
$_SERVER['REMOTE_ADDR'],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]
);
// echo "<pre>", print_r($resp, true), "</pre>";
// die();
if (!$resp->is_valid) {
$valid = false;
$message = "The reCAPTCHA wasn't entered correctly. Please try again.";
}
}
$sent = false;
if ($valid && $_SERVER['REQUEST_METHOD'] == 'POST' || $_GET['test'] == 'send') {
$style = array_key_exists('style', $_POST)
? $_POST['style']
: $_GET['style'];
$center = $_POST['center'];
$description = stripslashes($_POST['description']);
$sender = $_POST['sender'];
if (stristr($sender, "@")) {
$from_email = $sender;
} else {
$sender = 'anonymous';
$from_email = '(no address provided) <maps@stamen.com>';
}
$ip = $_SERVER['REMOTE_ADDR'];
$form_url = sprintf('http://%s%s', $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']);
$subject = "[maps.stamen.com / ${style}]: Bug report @ ${center}";
$message = <<<MESSAGE
Bug report from ${sender} ($ip):
\t${description}
http://maps.stamen.com/${style}/#${center}
--
feedback form @ $form_url
MESSAGE;
$headers = sprintf("From: %s", $from_email);
try {
mail("maps@stamen.com", $subject, $message, $headers);
$sent = true;
} catch (Exception $error) {
$message = $error;
}
} elseif (empty($message)) {
$message = "Please use the feedback forms on each map page to submit bug reports.";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>maps.stamen.com</title>
<style type="text/css">
@import url(css/bootstrap/bootstrap.css);
@import url(css/screen.css);
</style>
</head>
<body>
<div id="header" class="navbar">
<div class="navbar-inner">
<div class="container">
<h1 class="brand"><a href="../">maps.stamen.com</a> / <span id="current-provider">feedback</span></h1>
<a id="stamen" class="brand" href="http://stamen.com">stamen</a>
</div>
</div>
</div>
<div id="content" class="container content">
<?php if ($sent): ?>
<h2>Thanks for your feedback!</h2>
<p>We appreciate your help in tracking down issues with our maps.</p>
<p>— your friends at <a href="http://stamen.com">Stamen</a></p>
<?php else: ?>
<h2>Houston, we have a problem:</h2>
<p class="alert alert-danger"><?php echo htmlspecialchars($message); ?></p>
<p>If you think there’s something wrong on our end, please
<a href="mailto:maps@stamen.com">email us</a> and
let us know what you were doing when you ran into the issue.
Sorry about the mess!</p>
<p>— your friends at <a href="http://stamen.com">Stamen</a></p>
<?php endif; ?>
</div>
</body>
</html>