blob: 4f116d20fc50be120047e54d9380539ca467d515 [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']) : '' ?>" />
Marc Kupietz31861882023-02-25 08:52:57 +010028 <div class="invalid-feedback">
29 Please provide a first name with at least 2 characters.
30 </div>
Marc Kupietz1f2b2e92023-02-24 13:04:40 +010031 </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']) : '' ?>" />
Marc Kupietz31861882023-02-25 08:52:57 +010041 <div class="invalid-feedback">
42 Please provide a last name with at least 2 characters.
43 </div>
Marc Kupietz1f2b2e92023-02-24 13:04:40 +010044 </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 Kupietz31861882023-02-25 08:52:57 +010066 placeholder="********" oninput="check_password_match()"
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 -->
Marc Kupietz31861882023-02-25 08:52:57 +010084 <div id="pwconfirm" 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 Kupietz31861882023-02-25 08:52:57 +010089 placeholder="********" oninput="check_password_match()" />
90 <div class="invalid-feedback">
91 Passwords do not match.
92 </div>
93 </div>
94 <hr class="mt-2 mb-3" />
Marc Kupietz77434282023-02-24 12:04:47 +010095 <div class="form-outline mb-3">
96 <label class="form-label font-weight-bold" for="eula">End User License Agreement*</label>
97 <div class="form-group form-check">
98 <input type="checkbox" class="form-check-input" id="eula" required
99 title="You need to agree to the EULA in order to proceed">
100 <label class="form-check-label" for="eula">I have read and agree to to the
101 <?php echo $SERVICE_NAME; ?> <a
102 href="https://www2.ids-mannheim.de/cosmas2/projekt/register/license_agreement.html">End User License
103 Agreement</a> and will use
104 <?php echo $SERVICE_NAME; ?> only for academic and non-commercial purposes.
105 </label>
106 <div class="invalid-feedback">
107 You need to agree to the EULA in order to proceed.
108 </div>
109 </div>
110 </div>
111 <hr class="mt-2 mb-3" />
112 <div class="form-outline mb-3">
113 <label class="form-label font-weight-bold" for="privacy_policy">Privacy Policy*</label>
114 <div class="form-group form-check">
115 <input type="checkbox" class="form-check-input" name="privacy_policy" id="privacy_policy" required
116 title="You need to agree to the privacy policy in order to proceed">
117 <label class="form-check-label" for="privacy_policy">I have read and agree
118 to to the
119 <?php echo $SERVICE_NAME; ?> <a
120 href="https://www2.ids-mannheim.de/cosmas2/web-app/datenschutz.html">Privacy Policy</a>.
121 </label>
122 <div class="invalid-feedback">
Marc Kupietz1f2b2e92023-02-24 13:04:40 +0100123 You need to agree to the privacy policy in order to proceed.
Marc Kupietz77434282023-02-24 12:04:47 +0100124 </div>
125 </div>
126 </div>
127
128 <hr class="mt-2 mb-3" />
matheusfillipeabd513e2021-05-11 03:29:11 -0300129 <!--captcha here-->
130 <div class="form-outline mb-3">
131
132 <label class="form-label font-weight-bold" for="form3Example4">Captcha:</label>
133 <div class="container mb-2 offset-md-2">
134 <img id="captcha" src="<?php echo $BASE_URL.'/captcha.php?token='.$_SESSION['captcha_token']; ?>" />
135 <div id="reload_captcha">
Marc Kupietz77434282023-02-24 12:04:47 +0100136 <button id="reload" class="btn btn-outline-info" type="button"> <span
137 class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button>
matheusfillipeabd513e2021-05-11 03:29:11 -0300138 </div>
139 </div>
Marc Kupietz77434282023-02-24 12:04:47 +0100140 <input pattern="[^\s]{<?php echo $CAPTCHA_LENGTH; ?>,}" required
141 title="Please fill the captcha. It has 5 characters" name="captcha" type="text" id="form3Example6"
142 class="form-control" placeholder="Type what you see on the image above" />
matheusfillipeabd513e2021-05-11 03:29:11 -0300143 </div>
144
145 <!-- Submit button -->
146 <button name="type" value="register" type="submit" class="btn btn-primary float-right btn-md">Sign up</button>
147
148</form>
Marc Kupietz1f2b2e92023-02-24 13:04:40 +0100149</div>
150
151<script>
152 // Example starter JavaScript for disabling form submissions if there are invalid fields
153 (function () {
154 'use strict';
155 window.addEventListener('load', function () {
156 // Fetch all the forms we want to apply custom Bootstrap validation styles to
157 var forms = document.getElementsByClassName('needs-validation');
158 // Loop over them and prevent submission
159 var validation = Array.prototype.filter.call(forms, function (form) {
160 form.addEventListener('submit', function (event) {
161 if (form.checkValidity() === false) {
162 event.preventDefault();
163 event.stopPropagation();
164 }
165 form.classList.add('was-validated');
166 }, false);
167 });
168 }, false);
169 })();
Marc Kupietz31861882023-02-25 08:52:57 +0100170
171 function check_password_match() {
172 pass = $("#pw1").val();
173 pass2 = $("#pw2").val();
174
175 if (pass2.length > 0) {
176 $("#pwconfirm")[0].classList.add('was-validated')
177 if (pass != pass2) {
178 $("#pw2")[0].setCustomValidity("Passwords do not match");
Marc Kupietz1f2b2e92023-02-24 13:04:40 +0100179 } else {
Marc Kupietz31861882023-02-25 08:52:57 +0100180 $("#pw2")[0].setCustomValidity(""); // is valid
Marc Kupietz1f2b2e92023-02-24 13:04:40 +0100181 }
Marc Kupietz31861882023-02-25 08:52:57 +0100182 } else {
183 $("#pwconfirm")[0].classList.remove('was-validated')
Marc Kupietz1f2b2e92023-02-24 13:04:40 +0100184 }
Marc Kupietz31861882023-02-25 08:52:57 +0100185 passUpdated();
186 }
Marc Kupietz21fa9bb2023-02-24 19:44:16 +0100187
188 TOO_SHORT ='Password too short, still %% characters needed';
189 TOO_LONG ='Password too long, please remove %% characters';
190 INVALID_CHARS ='Password contains invalid characters';
191 QUAL_NONE ='Password is very weak'
192 QUAL_LOW ='Password is weak';
193 QUAL_MEDIUM ='Password is average'
194 QUAL_GOOD ='Password is good';
195 QUAL_STRONG ='Password is strong';
196 REP_OK ='Repetition ok';
197 REP_NE ='Passwords not identical';
198 PWNED ='Password found in public password list';
199
200 String.prototype.strReverse=function() {
201 var newstring='';
202 for (var s=0; s < this.length; s++)
203 newstring=this.charAt(s)+newstring;
204 return newstring;
205 };
206
207 //var checkTimer;
208
209 function passUpdated() {
210 var nScore=0;
211 var message='';
212
213 var pass=$('#pw1').val();
214 var pass2=$('#pw2').val();
215
216 //clearTimeout(checkTimer);
217
218 try {
219 if (!pass)
220 throw '';
221
222 if (pass.match(/[^a-zA-Z0-9!@#$%()_+=:;",.?/-]/))
223 throw INVALID_CHARS;
224
225 var nLength=pass.length;
226 if (nLength < 8)
227 throw TOO_SHORT.replace('%%', 8-nLength);
228 if (nLength > 20)
229 throw TOO_LONG.replace('%%', nLength-20);
230
231 nScore=4*nLength;
232
233 // check for upper-/lowercase, numeric and special chars pattern matches
234 var nAlphaUC=0, nAlphaLC=0, nNumber=0, nSpecial=0;
235 var nMidChar=0, nRepChar=0, nRepInc=0;
236 var nConsecAlphaUC=0, nConsecAlphaLC=0, nConsecNumber=0;
237 var nTmpAlphaUC='', nTmpAlphaLC='', nTmpNumber='';
238 for (var i=0; i < nLength; i++) {
239 if (pass[i].match(/[A-Z]/g)) { // uppercase characters
240 if (nTmpAlphaUC !== '' && (nTmpAlphaUC+1) == i) {
241 nConsecAlphaUC++;
242 }
243 nTmpAlphaUC=i;
244 nAlphaUC++;
245 } else if (pass[i].match(/[a-z]/g)) { // lowercase characters
246 if (nTmpAlphaLC !== '' && (nTmpAlphaLC+1) == i) {
247 nConsecAlphaLC++;
248 }
249 nTmpAlphaLC=i;
250 nAlphaLC++;
251 } else if (pass[i].match(/[0-9]/g)) { // numbers
252 if (i > 0 && i < (nLength-1)) {
253 nMidChar++;
254 }
255 if (nTmpNumber !== '' && (nTmpNumber+1) == i) {
256 nConsecNumber++;
257 }
258 nTmpNumber=i;
259 nNumber++;
260 } else { // special characters
261 if (i > 0 && i < (nLength-1)) {
262 nMidChar++;
263 }
264 nSpecial++;
265 }
266
267 // check for repeated characters
268 var bCharExists=false;
269 for (var j=0; j < nLength; j++) {
270 if (pass[i] == pass[j] && i != j) {
271 bCharExists=true;
272 nRepInc+=Math.abs(nLength/(j-i));
273 }
274 }
275 if (bCharExists) {
276 nRepChar++;
277 var nUnqChar=nLength-nRepChar;
278 nRepInc=(nUnqChar) ? Math.ceil(nRepInc/nUnqChar) : Math.ceil(nRepInc);
279 }
280 }
281
282 // check for sequential alpha string patterns (forward and reverse)
283 var sAlphas="abcdefghijklmnopqrstuvwxyz";
284 var nSeqAlpha=0;
285 for (var i=0; i < 23; i++) {
286 var sFwd=sAlphas.substring(i, i+3);
287 var sRev=sFwd.strReverse();
288 if (pass.toLowerCase().indexOf(sFwd) != -1
289 || pass.toLowerCase().indexOf(sRev) != -1)
290 nSeqAlpha++;
291 }
292
293 // check for sequential numeric string patterns (forward and reverse)
294 var sNumerics="01234567890";
295 var nSeqNumber=0;
296 for (var i=0; i < 8; i++) {
297 var sFwd=sNumerics.substring(i, i+3);
298 var sRev=sFwd.strReverse();
299 if (pass.toLowerCase().indexOf(sFwd) != -1
300 || pass.toLowerCase().indexOf(sRev) != -1)
301 nSeqNumber++;
302 }
303
304 // general point assignment
305 if (nAlphaUC > 0 && nAlphaUC < nLength) // uppercase characters
306 nScore+=2*(nLength-nAlphaUC);
307 if (nAlphaLC > 0 && nAlphaLC < nLength) // lowercase characters
308 nScore+=2*(nLength-nAlphaLC);
309 if (nNumber > 0 && nNumber < nLength) // numbers
310 nScore+=2*nNumber;
311 if (nSpecial > 0) // special characters
312 nScore+=4*nSpecial;
313 if (nMidChar > 0) // mid numbers/special characters
314 nScore+=2*nMidChar;
315
316 // point deductions for poor practices
317 if ((nAlphaLC > 0 || nAlphaUC > 0)
318 && nSpecial === 0 && nNumber === 0) // characters only
319 nScore-=nLength;
320 if (nAlphaLC === 0 && nAlphaUC === 0
321 && nSpecial === 0 && nNumber > 0) // numbers only
322 nScore-=nLength;
323 if (nRepChar > 0) // same character exists more than once
324 nScore-=nRepInc;
325 if (nConsecAlphaUC > 0) // consecutive uppercase letters exist
326 nScore-=2*nConsecAlphaUC;
327 if (nConsecAlphaLC > 0) // consecutive lowercase letters exist
328 nScore-=2*nConsecAlphaLC;
329 if (nConsecNumber > 0) // consecutive numbers exist
330 nScore-=2*nConsecNumber;
331 if (nSeqAlpha > 0) // sequential alpha strings exist (3 chars or more)
332 nScore-=3*nSeqAlpha;
333 if (nSeqNumber > 0) // sequential numeric strings exist (3 chars or more)
334 nScore-=3*nSeqNumber;
335
336 // determine if mandatory requirements have been met
337 var arrChars=[nAlphaUC, nAlphaLC, nNumber, nSpecial];
338 var nReqChar=0;
339 for (var i=0; i < arrChars.length; i++) {
340 if (arrChars[i]) {
341 nReqChar++;
342 }
343 }
344 if (nReqChar >= arrChars.length)
345 nScore+=2*nReqChar;
346 else if (nReqChar < arrChars.length-1)
347 nScore-=2*nReqChar;
348
349 // limit points to 3..100
350 nScore=Math.max(3, Math.min(nScore, 100));
351
352 // set message according to points
353 if (nScore >= 80)
354 message=QUAL_STRONG;
355 else if (nScore >= 60)
356 message=QUAL_GOOD;
357 else if (nScore >= 40)
358 message=QUAL_MEDIUM;
Marc Kupietz31861882023-02-25 08:52:57 +0100359 else if (nScore >= 10)
Marc Kupietz21fa9bb2023-02-24 19:44:16 +0100360 message=QUAL_LOW;
361 else
362 message=QUAL_NONE;
363 } catch (error) {
364 nScore=3;
365 message=error;
366 }
367/*
368 if (pass.length > 0 && pass2.length > 0) {
369 message+=' / ';
370 message+=(pass == pass2) ? REP_OK : REP_NE;
371 }
372*/
373 $('#pwqinfo').val(message);
374
375 var progress=$('#pwqbar');
376 progress.width(nScore + '%');
377 progress.attr('aria-valuenow', nScore);
378 if (nScore >= 60)
379 progress.removeClass('bg-danger bg-warning').addClass('bg-success');
380 else if (nScore >= 40)
381 progress.removeClass('bg-danger bg-success').addClass('bg-warning');
382 else
383 progress.removeClass('bg-warning bg-success').addClass('bg-danger');
384
385 if (nScore > 60) {
386 $('#btn_change').prop('disabled', pass !== pass2);
387 } else {
388 $('#btn_change').prop('disabled', 1);
389 }
390/*
391 if (nScore >= 60) {
392 checkTimer=setTimeout(function() {
393 $.post('checkpass.php', 'pass='+pass, function(ret) {
394 if (ret !== 'PWNED') {
395 $('#btn_change').prop('disabled', pass !== pass2);
396 return;
397 }
398 $('#pwqinfo').val(PWNED);
399 progress.removeClass().addClass('low');
400 progress.val(3);
401 });
402 }, 300);
403 }
404*/
405 }
Marc Kupietz1f2b2e92023-02-24 13:04:40 +0100406</script>