-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
251 lines (227 loc) · 12.1 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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
require_once("php/Db.php");
/* preset variables */
$error = array();
$success = false;
$mobile = "";
$name = "";
$location = "0";
$terms = 0;
$captcha = "";
/* check for location given in the link from pfSense */
if (isset($_GET["location"]))
$location = $_GET["location"];
/* check for form submission */
if (isset($_POST["submit"])) {
if (isset($_POST["mobile"])) $mobile = strval($_POST["mobile"]);
if (isset($_POST["name"])) $name = strval($_POST["name"]);
if (isset($_POST["location"])) $location = $_POST["location"];
if (isset($_POST["terms"])) $terms = $_POST["terms"];
if (isset($_POST["g-recaptcha-response"])) $captcha = $_POST['g-recaptcha-response'];
// Validation
if (($mobile == "") || (!preg_match("/(^\+49)|(^01[5-7][0-9])/", $mobile)) || (strlen($mobile)<11)) { // number format
// "/(^\+49)|(^01[5-7][1-9])/"
// "(?:\+\d+)?\s*(?:\(\d+\)\s*(?:[/–-]\s*)?)?\d+(?:\s*(?:[\s/–-]\s*)?\d+)*"
// "/^\+[0-9]{0,3}[1-9] \([0-9]*[1-9]+\) ([0-9]| - )*[1-9]+$/"
$error[] = 3;
}
if ($location == "0") { // no location selected
$error[] = 2;
}
if ($terms != 1) { // terms not checked
$error[] = 1;
}
if (checkRecaptcha($captcha, $_SERVER['REMOTE_ADDR'])->success != 1) {
$error[] = 6;
}
if (strlen($name) <= 5) {
$error[] = 7;
}
if (count($error) == 0) {
$mobile_tech = "";
// remove everything except numbers
$mobile_tech = preg_replace('/\D/', '', $mobile); // +49 (0) 177 - 2563235 -> 4901772563235
// remove leading "0" and/or leading "49"
$mobile_tech = ltrim($mobile_tech, "0"); // 004901772563235 -> 4901772563235
$mobile_tech = ltrim($mobile_tech, "49"); // 4901772563235 -> 01772563235
$mobile_tech = ltrim($mobile_tech, "0"); // 01772563235 -> 1772563235
// check for already used number
if (usedMobile($mobile_tech)) {
$error[] = 4;
}
else {
$success =
$sended = sendSms($mobile_tech, $location, $name);
if ($sended) {
$success = true;
$mobile = "";
$name = "";
$terms = 0;
} else {
$error[] = 5;
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="publicplan GmbH, https://publicplan.de">
<link rel="icon" href="images/favicon.ico">
<title>Refugees Online e.V. - SMS Voucher for WLAN</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/cover.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="https://www.google.com/recaptcha/api.js"></script>
<?php if ($success == true) { ?>
<meta http-equiv="refresh" content="5; url=http://192.168.99.1:8002/index.php?zone=zone_01&redirurl=http%3A%2F%2Fwww.refugees-online%2F">
<?php } ?>
</head>
<body>
<div class="site-wrapper">
<div class="site-wrapper-inner">
<div class="cover-container">
<div class="masthead clearfix">
<div class="inner">
<h3 class="masthead-brand"><img src="images/logo.png"></h3>
<!--<nav>
<ul class="nav masthead-nav">
<li class="active"><a href="index.php">Home</a></li>
<li><a href="terms.php">Terms of Service</a></li>
</ul>
</nav> -->
</div>
</div>
<div class="inner cover">
<?php if ($success == true) { ?>
<div class="alert alert-success" role="alert"><b>Success:</b> Your voucher has been successfully sent to your mobile number. <a href="http://192.168.99.1:8002/index.php?zone=zone_01&redirurl=http%3A%2F%2Fwww.refugees-online%2F">Click here to login!</a></div>
<?php } ?>
<?php if (in_array(1, $error)) { ?>
<div class="alert alert alert-danger" role="alert"><b>Error:</b> Please accept our Terms of Service!</div>
<?php } ?>
<?php if (in_array(2, $error)) { ?>
<div class="alert alert alert-danger" role="alert"><b>Error:</b> Please choose a location to get access for.</div>
<?php } ?>
<?php if (in_array(3, $error)) { ?>
<div class="alert alert alert-danger" role="alert"><b>Error:</b> Your mobile number is not well formatted or empty, please check.</div>
<?php } ?>
<?php if (in_array(4, $error)) { ?>
<div class="alert alert alert-danger" role="alert"><b>Error:</b> Your mobile number was already used to receive a voucher in the 60 days.</div>
<?php } ?>
<?php if (in_array(5, $error)) { ?>
<div class="alert alert alert-danger" role="alert"><b>Error:</b> There are no more available voucher codes in our database. Please contact <a href="mailto:[email protected]">[email protected]</a>.</div>
<?php } ?>
<?php if (in_array(6, $error)) { ?>
<div class="alert alert alert-danger" role="alert"><b>Error:</b> Please make sure that you are no robot!</div>
<?php } ?>
<?php if (in_array(7, $error)) { ?>
<div class="alert alert alert-danger" role="alert"><b>Error:</b> Please provide your name!</div>
<?php } ?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>" class="form-horizontal">
<h1 class="cover-heading">Get your WiFi voucher by SMS!</h1>
<p>You can obtain a free WiFi voucher for 60 days by filling the form below. You need to have a German mobile number, foreign numbers will not be accepted. The provider of the WiFi service may block your account at its sole discretion if your data is suspect to fraud (e.g. providing an incorrect name).</br>
You must read and agree to the Terms of Service below.<br/>
<a href="#Terms_of_Service">Click here</a> for the Terms of Service in Arabic, French, Urdu, Krio, Tigrinya and many other languages.</p>
<p>
<div class="form-group">
<label for="mobile" class="col-sm-3 control-label">Mobile number:</label>
<div class="col-sm-9">
<input type="text" class="form-control" placeholder="e.g. 0123-1234567" name="mobile"<?php if ($mobile != "") echo ' value="'.$mobile.'"'; ?>>
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-3 control-label">Your full name:</label>
<div class="col-sm-9">
<input type="text" class="form-control" placeholder="Your name" name="name"<?php if ($name != "") echo ' value="'.$name.'"'; ?>>
</div>
</div>
<?php if ((in_array(2, $error)) || ($location == "0")) { ?>
<div class="form-group">
<label for="location" class="col-sm-3 control-label">Choose location:</label>
<div class="col-sm-9">
<select name="location" class="form-control">
<option value="0"<?php if ($location=="0") echo " selected"; ?>>choose...</option>
<?php // echo getLocations(); ?>
<option value="1"<?php if ($location=="1") echo " selected"; ?>>Erstaufnahme Fürstenfeldbruck [Fursty]</option>
<option value="2"<?php if ($location=="2") echo " selected"; ?>>Gemeinschaftsunterkunft Don Bosco, Germering [DonBosco]</option>
<option value="3"<?php if ($location=="3") echo " selected"; ?>>Traglufthalle Grünwald [Grünwald]</option>
</select>
</div>
</div>
<?php } else { ?>
<input type="hidden" name="location" value="<?php echo $location; ?>" />
<?php } ?>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<div class="checkbox" align="left">
<label>
<input type="checkbox" name="terms" value="1"<?php if ($terms==1) echo " checked"; ?>> I agree to the Terms of Service.
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<div class="g-recaptcha" data-sitekey="6LfbBxITAAAAAN4eckOP5VU9EvwF7Dr9FRkTeavb"></div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<button type="submit" name="submit" value="Get Voucher!" class="btn btn-lg btn-default">Get Voucher!</button>
</div>
</div>
</p>
</form>
<br/>
<h1 class="heading"><a name="Terms_of_Service">Terms of Service</a></h1>
<p>By receiving the login information (voucher) you can use the Internet. Please note that the internet is brought to you by third parties. The connection owner is an individual or a private association.<br/>
You agree to observe the following rules: Do not pass the login information to anybody. The use of the connection is only permitted by you personally!<br/>
The usage is subject to the statutory provisions for Internet use in Germany. The operator can save your connection information and make it available to the authorities when a crime is suspected.<br/>
In particular, the following are not allowed:<br/>
<ul>
<li>The call for criminal offenses on the Internet</li>
<li>The organization of crime on the Internet</li>
<li>The publication of defamatory, abusive or hateful content</li>
<li>The distribution of computer viruses or harmful software</li>
<li>Unauthorized downloading and / or sharing copyrighted data such as movies, music or video games</li>
<li>The use of websites with pornographic content</li>
<li>The distribution of pornography</li>
</ul>
In addition, the statutory provisions for Internet use in Germany apply. By checking the box you agree to the above terms and conditions.<br/>
Download: <a href="files/Refugees-Online_Terms_of_Service.pdf" target="_blank">Refugees-Online_Terms_of_Service.pdf (594 kB)</a><br/>
In case of problems or questions send a mail to <a href="mailto:[email protected]">[email protected]</a>.
</p>
</div>
</div>
<div class="mastfoot">
<div class="inner">
<p>Cover template for <a href="http://getbootstrap.com" target="_blank">Bootstrap</a>, by <a href="https://twitter.com/mdo" target="_blank">@mdo</a>. <a href="https://github.com/refugeehackathon/refonlinesms" target="_blank">Help improving refonlinesms on Github.</a></p>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>