blob: bfd6318c70db85be995c85fba1f8983f56bf33ca [file] [log] [blame]
Marc Kupietz77434282023-02-24 12:04:47 +01001<h1>Sign up for
2 <?php echo $SERVICE_NAME;?>
3</h1>
matheusfillipeabd513e2021-05-11 03:29:11 -03004
Marc Kupietz1f2b2e92023-02-24 13:04:40 +01005<form class="needs-validation" novalidate action="" method="POST">
matheusfillipeabd513e2021-05-11 03:29:11 -03006 <!-- Username input -->
7 <div class="form-outline mb-3">
8 <label class="form-label font-weight-bold" for="form3Example3">Username*</label>
Marc Kupietz77434282023-02-24 12:04:47 +01009 <input pattern="[^\s]{<?php echo $VAL_USER->min_username.','.$VAL_USER->max_username;?>}" required
10 title="At least 5 not whitespace characters" name="username" type="text" id="form3Example0"
matheusfillipeabd513e2021-05-11 03:29:11 -030011 class="form-control <?php if(isset($error) && $error && !isset($_POST['username'])){echo 'border-danger';}?>"
Marc Kupietzb527e642023-02-23 10:04:21 +010012 placeholder="johndoe"
matheusfillipeabd513e2021-05-11 03:29:11 -030013 value="<?php echo isset($_POST['username']) ? htmlspecialchars($_POST['username']) : '' ?>" />
Marc Kupietz1f2b2e92023-02-24 13:04:40 +010014 <div class="invalid-feedback">
15 Please choose a username with at least 5 not whitespace characters.
16 </div>
matheusfillipeabd513e2021-05-11 03:29:11 -030017 </div>
18 <!-- 2 column grid layout with text inputs for the first and last names -->
19 <div class="row mb-3">
20 <div class="col">
21 <div class="form-outline">
22 <label class="form-label font-weight-bold" for="form3Example1">First name*</label>
Marc Kupietz77434282023-02-24 12:04:47 +010023 <input pattern="[^\s]{<?php echo $VAL_USER->min_first_name.','.$VAL_USER->max_first_name;?>}" required
Marc Kupietz1f2b2e92023-02-24 13:04:40 +010024 title="At least 2 not whitespace characters" name="name" type="text" id="form3Example1"
matheusfillipeabd513e2021-05-11 03:29:11 -030025 class="form-control <?php if(isset($error) && $error && !isset($_POST['name'])){echo 'border-danger';}?>"
Marc Kupietzb527e642023-02-23 10:04:21 +010026 placeholder="John"
matheusfillipeabd513e2021-05-11 03:29:11 -030027 value="<?php echo isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '' ?>" />
28 </div>
Marc Kupietz1f2b2e92023-02-24 13:04:40 +010029 <div class="invalid-feedback">
30 Please provide a first name with at least 2 not whitespace characters.
31 </div>
matheusfillipeabd513e2021-05-11 03:29:11 -030032 </div>
33 <div class="col">
34 <div class="form-outline">
35 <label class="form-label font-weight-bold" for="form3Example2">Last name*</label>
Marc Kupietz77434282023-02-24 12:04:47 +010036 <input pattern="[^\s]{<?php echo $VAL_USER->min_last_name.','.$VAL_USER->max_last_name;?>}" required
Marc Kupietz1f2b2e92023-02-24 13:04:40 +010037 title="At least 2 not whitespace characters" name="last_name" type="text" id="form3Example2"
matheusfillipeabd513e2021-05-11 03:29:11 -030038 class="form-control <?php if(isset($error) && $error && !isset($_POST['last_name'])){echo 'border-danger';}?>"
39 placeholder="Doe"
40 value="<?php echo isset($_POST['last_name']) ? htmlspecialchars($_POST['last_name']) : '' ?>" />
41 </div>
Marc Kupietz1f2b2e92023-02-24 13:04:40 +010042 <div class="invalid-feedback">
43 Please provide a last name with at least 2 not whitespace characters.
44 </div>
matheusfillipeabd513e2021-05-11 03:29:11 -030045 </div>
46 </div>
47
48 <!-- Email input -->
49 <div class="form-outline mb-3">
50 <label class="form-label font-weight-bold" for="form3Example3">Email address*</label>
51 <input required name="email" type="email" id="form3Example3"
52 class="form-control <?php if(isset($error) && $error && !isset($_POST['email'])){echo 'border-danger';}?>"
53 placeholder="myemail@example.com"
54 value="<?php echo isset($_POST['email']) ? htmlspecialchars($_POST['email']) : '' ?>" />
Marc Kupietz1f2b2e92023-02-24 13:04:40 +010055 <div class="invalid-feedback">
56 Please provide a valid email address.
57 </div>
matheusfillipeabd513e2021-05-11 03:29:11 -030058 </div>
59
60 <!-- Password input -->
61 <div class="form-outline mb-3">
Marc Kupietz1f2b2e92023-02-24 13:04:40 +010062 <label class="form-label font-weight-bold" for="pw1">Password*</label>
Marc Kupietz77434282023-02-24 12:04:47 +010063 <input pattern="[^\s]{<?php echo $VAL_USER->min_password.','.$VAL_USER->max_password;?>}" required
Marc Kupietz1f2b2e92023-02-24 13:04:40 +010064 title="At least 8 not whitespace characters" name="password" type="password" id="pw1"
matheusfillipeabd513e2021-05-11 03:29:11 -030065 class="form-control <?php if(isset($error) && $error && !isset($_POST['password'])){echo 'border-danger';}?>"
Marc Kupietz21fa9bb2023-02-24 19:44:16 +010066 placeholder="********" oninput="passUpdated()"
matheusfillipeabd513e2021-05-11 03:29:11 -030067 value="<?php echo isset($_POST['password']) ? htmlspecialchars($_POST['password']) : '' ?>" />
Marc Kupietz21fa9bb2023-02-24 19:44:16 +010068 <div class="progress mt-2">
69 <div class="progress-bar bg-danger" role="progressbar" id="pwqbar" aria-valuenow="0" aria-valuemin="0"
70 aria-valuemax="100"></div>
71 </div>
matheusfillipeabd513e2021-05-11 03:29:11 -030072 </div>
Marc Kupietz21fa9bb2023-02-24 19:44:16 +010073 <!--
74 <div class="form-group">
75 <label for="pwqinfo">Password rating</label>
76 <input class="form-control" type="text" name="pwqinfo" id="pwqinfo" readonly>
77 <div class="progress mt-2">
78 <div class="progress-bar bg-danger" role="progressbar" id="pwqbar2" aria-valuenow="0" aria-valuemin="0"
79 aria-valuemax="100"></div>
80 </div>
81 </div>
82 -->
matheusfillipeabd513e2021-05-11 03:29:11 -030083 <!-- Password input -->
84 <div class="form-outline mb-3">
Marc Kupietz1f2b2e92023-02-24 13:04:40 +010085 <label class="form-label font-weight-bold" for="pw2">Confirm your Password*</label>
Marc Kupietz77434282023-02-24 12:04:47 +010086 <input pattern="[^\s]{<?php echo $VAL_USER->min_password.','.$VAL_USER->max_password;?>}" required
Marc Kupietz1f2b2e92023-02-24 13:04:40 +010087 title="At least 8 not whitespace characters" name="password_confirm" type="password" id="pw2"
matheusfillipeabd513e2021-05-11 03:29:11 -030088 class="form-control <?php if(isset($error) && $error && !isset($_POST['password_confirm'])){echo 'border-danger';}?>"
Marc Kupietz21fa9bb2023-02-24 19:44:16 +010089 placeholder="********" oninput="validate_pw2(this)" />
90 </div> <hr class="mt-2 mb-3" />
Marc Kupietz77434282023-02-24 12:04:47 +010091 <div class="form-outline mb-3">
92 <label class="form-label font-weight-bold" for="eula">End User License Agreement*</label>
93 <div class="form-group form-check">
94 <input type="checkbox" class="form-check-input" id="eula" required
95 title="You need to agree to the EULA in order to proceed">
96 <label class="form-check-label" for="eula">I have read and agree to to the
97 <?php echo $SERVICE_NAME; ?> <a
98 href="https://www2.ids-mannheim.de/cosmas2/projekt/register/license_agreement.html">End User License
99 Agreement</a> and will use
100 <?php echo $SERVICE_NAME; ?> only for academic and non-commercial purposes.
101 </label>
102 <div class="invalid-feedback">
103 You need to agree to the EULA in order to proceed.
104 </div>
105 </div>
106 </div>
107 <hr class="mt-2 mb-3" />
108 <div class="form-outline mb-3">
109 <label class="form-label font-weight-bold" for="privacy_policy">Privacy Policy*</label>
110 <div class="form-group form-check">
111 <input type="checkbox" class="form-check-input" name="privacy_policy" id="privacy_policy" required
112 title="You need to agree to the privacy policy in order to proceed">
113 <label class="form-check-label" for="privacy_policy">I have read and agree
114 to to the
115 <?php echo $SERVICE_NAME; ?> <a
116 href="https://www2.ids-mannheim.de/cosmas2/web-app/datenschutz.html">Privacy Policy</a>.
117 </label>
118 <div class="invalid-feedback">
Marc Kupietz1f2b2e92023-02-24 13:04:40 +0100119 You need to agree to the privacy policy in order to proceed.
Marc Kupietz77434282023-02-24 12:04:47 +0100120 </div>
121 </div>
122 </div>
123
124 <hr class="mt-2 mb-3" />
matheusfillipeabd513e2021-05-11 03:29:11 -0300125 <!--captcha here-->
126 <div class="form-outline mb-3">
127
128 <label class="form-label font-weight-bold" for="form3Example4">Captcha:</label>
129 <div class="container mb-2 offset-md-2">
130 <img id="captcha" src="<?php echo $BASE_URL.'/captcha.php?token='.$_SESSION['captcha_token']; ?>" />
131 <div id="reload_captcha">
Marc Kupietz77434282023-02-24 12:04:47 +0100132 <button id="reload" class="btn btn-outline-info" type="button"> <span
133 class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button>
matheusfillipeabd513e2021-05-11 03:29:11 -0300134 </div>
135 </div>
Marc Kupietz77434282023-02-24 12:04:47 +0100136 <input pattern="[^\s]{<?php echo $CAPTCHA_LENGTH; ?>,}" required
137 title="Please fill the captcha. It has 5 characters" name="captcha" type="text" id="form3Example6"
138 class="form-control" placeholder="Type what you see on the image above" />
matheusfillipeabd513e2021-05-11 03:29:11 -0300139 </div>
140
141 <!-- Submit button -->
142 <button name="type" value="register" type="submit" class="btn btn-primary float-right btn-md">Sign up</button>
143
144</form>
Marc Kupietz1f2b2e92023-02-24 13:04:40 +0100145</div>
146
147<script>
148 // Example starter JavaScript for disabling form submissions if there are invalid fields
149 (function () {
150 'use strict';
151 window.addEventListener('load', function () {
152 // Fetch all the forms we want to apply custom Bootstrap validation styles to
153 var forms = document.getElementsByClassName('needs-validation');
154 // Loop over them and prevent submission
155 var validation = Array.prototype.filter.call(forms, function (form) {
156 form.addEventListener('submit', function (event) {
157 if (form.checkValidity() === false) {
158 event.preventDefault();
159 event.stopPropagation();
160 }
161 form.classList.add('was-validated');
162 }, false);
163 });
164 }, false);
165 })();
166 function validate_pw2(pw2) {
167 if (pw2.value !== $("#pw1").val()) {
168 pw2.setCustomValidity("Passwords do not match");
169 } else {
170 pw2.setCustomValidity(""); // is valid
171 }
172 }
Marc Kupietz21fa9bb2023-02-24 19:44:16 +0100173
174 TOO_SHORT ='Password too short, still %% characters needed';
175 TOO_LONG ='Password too long, please remove %% characters';
176 INVALID_CHARS ='Password contains invalid characters';
177 QUAL_NONE ='Password is very weak'
178 QUAL_LOW ='Password is weak';
179 QUAL_MEDIUM ='Password is average'
180 QUAL_GOOD ='Password is good';
181 QUAL_STRONG ='Password is strong';
182 REP_OK ='Repetition ok';
183 REP_NE ='Passwords not identical';
184 PWNED ='Password found in public password list';
185
186 String.prototype.strReverse=function() {
187 var newstring='';
188 for (var s=0; s < this.length; s++)
189 newstring=this.charAt(s)+newstring;
190 return newstring;
191 };
192
193 //var checkTimer;
194
195 function passUpdated() {
196 var nScore=0;
197 var message='';
198
199 var pass=$('#pw1').val();
200 var pass2=$('#pw2').val();
201
202 //clearTimeout(checkTimer);
203
204 try {
205 if (!pass)
206 throw '';
207
208 if (pass.match(/[^a-zA-Z0-9!@#$%()_+=:;",.?/-]/))
209 throw INVALID_CHARS;
210
211 var nLength=pass.length;
212 if (nLength < 8)
213 throw TOO_SHORT.replace('%%', 8-nLength);
214 if (nLength > 20)
215 throw TOO_LONG.replace('%%', nLength-20);
216
217 nScore=4*nLength;
218
219 // check for upper-/lowercase, numeric and special chars pattern matches
220 var nAlphaUC=0, nAlphaLC=0, nNumber=0, nSpecial=0;
221 var nMidChar=0, nRepChar=0, nRepInc=0;
222 var nConsecAlphaUC=0, nConsecAlphaLC=0, nConsecNumber=0;
223 var nTmpAlphaUC='', nTmpAlphaLC='', nTmpNumber='';
224 for (var i=0; i < nLength; i++) {
225 if (pass[i].match(/[A-Z]/g)) { // uppercase characters
226 if (nTmpAlphaUC !== '' && (nTmpAlphaUC+1) == i) {
227 nConsecAlphaUC++;
228 }
229 nTmpAlphaUC=i;
230 nAlphaUC++;
231 } else if (pass[i].match(/[a-z]/g)) { // lowercase characters
232 if (nTmpAlphaLC !== '' && (nTmpAlphaLC+1) == i) {
233 nConsecAlphaLC++;
234 }
235 nTmpAlphaLC=i;
236 nAlphaLC++;
237 } else if (pass[i].match(/[0-9]/g)) { // numbers
238 if (i > 0 && i < (nLength-1)) {
239 nMidChar++;
240 }
241 if (nTmpNumber !== '' && (nTmpNumber+1) == i) {
242 nConsecNumber++;
243 }
244 nTmpNumber=i;
245 nNumber++;
246 } else { // special characters
247 if (i > 0 && i < (nLength-1)) {
248 nMidChar++;
249 }
250 nSpecial++;
251 }
252
253 // check for repeated characters
254 var bCharExists=false;
255 for (var j=0; j < nLength; j++) {
256 if (pass[i] == pass[j] && i != j) {
257 bCharExists=true;
258 nRepInc+=Math.abs(nLength/(j-i));
259 }
260 }
261 if (bCharExists) {
262 nRepChar++;
263 var nUnqChar=nLength-nRepChar;
264 nRepInc=(nUnqChar) ? Math.ceil(nRepInc/nUnqChar) : Math.ceil(nRepInc);
265 }
266 }
267
268 // check for sequential alpha string patterns (forward and reverse)
269 var sAlphas="abcdefghijklmnopqrstuvwxyz";
270 var nSeqAlpha=0;
271 for (var i=0; i < 23; i++) {
272 var sFwd=sAlphas.substring(i, i+3);
273 var sRev=sFwd.strReverse();
274 if (pass.toLowerCase().indexOf(sFwd) != -1
275 || pass.toLowerCase().indexOf(sRev) != -1)
276 nSeqAlpha++;
277 }
278
279 // check for sequential numeric string patterns (forward and reverse)
280 var sNumerics="01234567890";
281 var nSeqNumber=0;
282 for (var i=0; i < 8; i++) {
283 var sFwd=sNumerics.substring(i, i+3);
284 var sRev=sFwd.strReverse();
285 if (pass.toLowerCase().indexOf(sFwd) != -1
286 || pass.toLowerCase().indexOf(sRev) != -1)
287 nSeqNumber++;
288 }
289
290 // general point assignment
291 if (nAlphaUC > 0 && nAlphaUC < nLength) // uppercase characters
292 nScore+=2*(nLength-nAlphaUC);
293 if (nAlphaLC > 0 && nAlphaLC < nLength) // lowercase characters
294 nScore+=2*(nLength-nAlphaLC);
295 if (nNumber > 0 && nNumber < nLength) // numbers
296 nScore+=2*nNumber;
297 if (nSpecial > 0) // special characters
298 nScore+=4*nSpecial;
299 if (nMidChar > 0) // mid numbers/special characters
300 nScore+=2*nMidChar;
301
302 // point deductions for poor practices
303 if ((nAlphaLC > 0 || nAlphaUC > 0)
304 && nSpecial === 0 && nNumber === 0) // characters only
305 nScore-=nLength;
306 if (nAlphaLC === 0 && nAlphaUC === 0
307 && nSpecial === 0 && nNumber > 0) // numbers only
308 nScore-=nLength;
309 if (nRepChar > 0) // same character exists more than once
310 nScore-=nRepInc;
311 if (nConsecAlphaUC > 0) // consecutive uppercase letters exist
312 nScore-=2*nConsecAlphaUC;
313 if (nConsecAlphaLC > 0) // consecutive lowercase letters exist
314 nScore-=2*nConsecAlphaLC;
315 if (nConsecNumber > 0) // consecutive numbers exist
316 nScore-=2*nConsecNumber;
317 if (nSeqAlpha > 0) // sequential alpha strings exist (3 chars or more)
318 nScore-=3*nSeqAlpha;
319 if (nSeqNumber > 0) // sequential numeric strings exist (3 chars or more)
320 nScore-=3*nSeqNumber;
321
322 // determine if mandatory requirements have been met
323 var arrChars=[nAlphaUC, nAlphaLC, nNumber, nSpecial];
324 var nReqChar=0;
325 for (var i=0; i < arrChars.length; i++) {
326 if (arrChars[i]) {
327 nReqChar++;
328 }
329 }
330 if (nReqChar >= arrChars.length)
331 nScore+=2*nReqChar;
332 else if (nReqChar < arrChars.length-1)
333 nScore-=2*nReqChar;
334
335 // limit points to 3..100
336 nScore=Math.max(3, Math.min(nScore, 100));
337
338 // set message according to points
339 if (nScore >= 80)
340 message=QUAL_STRONG;
341 else if (nScore >= 60)
342 message=QUAL_GOOD;
343 else if (nScore >= 40)
344 message=QUAL_MEDIUM;
345 else if (nScore >= 20)
346 message=QUAL_LOW;
347 else
348 message=QUAL_NONE;
349 } catch (error) {
350 nScore=3;
351 message=error;
352 }
353/*
354 if (pass.length > 0 && pass2.length > 0) {
355 message+=' / ';
356 message+=(pass == pass2) ? REP_OK : REP_NE;
357 }
358*/
359 $('#pwqinfo').val(message);
360
361 var progress=$('#pwqbar');
362 progress.width(nScore + '%');
363 progress.attr('aria-valuenow', nScore);
364 if (nScore >= 60)
365 progress.removeClass('bg-danger bg-warning').addClass('bg-success');
366 else if (nScore >= 40)
367 progress.removeClass('bg-danger bg-success').addClass('bg-warning');
368 else
369 progress.removeClass('bg-warning bg-success').addClass('bg-danger');
370
371 if (nScore > 60) {
372 $('#btn_change').prop('disabled', pass !== pass2);
373 } else {
374 $('#btn_change').prop('disabled', 1);
375 }
376/*
377 if (nScore >= 60) {
378 checkTimer=setTimeout(function() {
379 $.post('checkpass.php', 'pass='+pass, function(ret) {
380 if (ret !== 'PWNED') {
381 $('#btn_change').prop('disabled', pass !== pass2);
382 return;
383 }
384 $('#pwqinfo').val(PWNED);
385 progress.removeClass().addClass('low');
386 progress.val(3);
387 });
388 }, 300);
389 }
390*/
391 }
Marc Kupietz1f2b2e92023-02-24 13:04:40 +0100392</script>