| Marc Kupietz | 7743428 | 2023-02-24 12:04:47 +0100 | [diff] [blame] | 1 | <h1>Sign up for |
| 2 | <?php echo $SERVICE_NAME;?> |
| 3 | </h1> |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 4 | |
| Marc Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 5 | <form class="needs-validation" novalidate action="" method="POST"> |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 6 | <!-- Username input --> |
| 7 | <div class="form-outline mb-3"> |
| 8 | <label class="form-label font-weight-bold" for="form3Example3">Username*</label> |
| Marc Kupietz | 7743428 | 2023-02-24 12:04:47 +0100 | [diff] [blame] | 9 | <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" |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 11 | class="form-control <?php if(isset($error) && $error && !isset($_POST['username'])){echo 'border-danger';}?>" |
| Marc Kupietz | b527e64 | 2023-02-23 10:04:21 +0100 | [diff] [blame] | 12 | placeholder="johndoe" |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 13 | value="<?php echo isset($_POST['username']) ? htmlspecialchars($_POST['username']) : '' ?>" /> |
| Marc Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 14 | <div class="invalid-feedback"> |
| 15 | Please choose a username with at least 5 not whitespace characters. |
| 16 | </div> |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 17 | </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 Kupietz | 7743428 | 2023-02-24 12:04:47 +0100 | [diff] [blame] | 23 | <input pattern="[^\s]{<?php echo $VAL_USER->min_first_name.','.$VAL_USER->max_first_name;?>}" required |
| Marc Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 24 | title="At least 2 not whitespace characters" name="name" type="text" id="form3Example1" |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 25 | class="form-control <?php if(isset($error) && $error && !isset($_POST['name'])){echo 'border-danger';}?>" |
| Marc Kupietz | b527e64 | 2023-02-23 10:04:21 +0100 | [diff] [blame] | 26 | placeholder="John" |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 27 | value="<?php echo isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '' ?>" /> |
| Marc Kupietz | 3186188 | 2023-02-25 08:52:57 +0100 | [diff] [blame^] | 28 | <div class="invalid-feedback"> |
| 29 | Please provide a first name with at least 2 characters. |
| 30 | </div> |
| Marc Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 31 | </div> |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 32 | </div> |
| 33 | <div class="col"> |
| 34 | <div class="form-outline"> |
| 35 | <label class="form-label font-weight-bold" for="form3Example2">Last name*</label> |
| Marc Kupietz | 7743428 | 2023-02-24 12:04:47 +0100 | [diff] [blame] | 36 | <input pattern="[^\s]{<?php echo $VAL_USER->min_last_name.','.$VAL_USER->max_last_name;?>}" required |
| Marc Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 37 | title="At least 2 not whitespace characters" name="last_name" type="text" id="form3Example2" |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 38 | 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 Kupietz | 3186188 | 2023-02-25 08:52:57 +0100 | [diff] [blame^] | 41 | <div class="invalid-feedback"> |
| 42 | Please provide a last name with at least 2 characters. |
| 43 | </div> |
| Marc Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 44 | </div> |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 45 | </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 Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 55 | <div class="invalid-feedback"> |
| 56 | Please provide a valid email address. |
| 57 | </div> |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 58 | </div> |
| 59 | |
| 60 | <!-- Password input --> |
| 61 | <div class="form-outline mb-3"> |
| Marc Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 62 | <label class="form-label font-weight-bold" for="pw1">Password*</label> |
| Marc Kupietz | 7743428 | 2023-02-24 12:04:47 +0100 | [diff] [blame] | 63 | <input pattern="[^\s]{<?php echo $VAL_USER->min_password.','.$VAL_USER->max_password;?>}" required |
| Marc Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 64 | title="At least 8 not whitespace characters" name="password" type="password" id="pw1" |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 65 | class="form-control <?php if(isset($error) && $error && !isset($_POST['password'])){echo 'border-danger';}?>" |
| Marc Kupietz | 3186188 | 2023-02-25 08:52:57 +0100 | [diff] [blame^] | 66 | placeholder="********" oninput="check_password_match()" |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 67 | value="<?php echo isset($_POST['password']) ? htmlspecialchars($_POST['password']) : '' ?>" /> |
| Marc Kupietz | 21fa9bb | 2023-02-24 19:44:16 +0100 | [diff] [blame] | 68 | <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> |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 72 | </div> |
| Marc Kupietz | 21fa9bb | 2023-02-24 19:44:16 +0100 | [diff] [blame] | 73 | <!-- |
| 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 | --> |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 83 | <!-- Password input --> |
| Marc Kupietz | 3186188 | 2023-02-25 08:52:57 +0100 | [diff] [blame^] | 84 | <div id="pwconfirm" class="form-outline mb-3"> |
| Marc Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 85 | <label class="form-label font-weight-bold" for="pw2">Confirm your Password*</label> |
| Marc Kupietz | 7743428 | 2023-02-24 12:04:47 +0100 | [diff] [blame] | 86 | <input pattern="[^\s]{<?php echo $VAL_USER->min_password.','.$VAL_USER->max_password;?>}" required |
| Marc Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 87 | title="At least 8 not whitespace characters" name="password_confirm" type="password" id="pw2" |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 88 | class="form-control <?php if(isset($error) && $error && !isset($_POST['password_confirm'])){echo 'border-danger';}?>" |
| Marc Kupietz | 3186188 | 2023-02-25 08:52:57 +0100 | [diff] [blame^] | 89 | 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 Kupietz | 7743428 | 2023-02-24 12:04:47 +0100 | [diff] [blame] | 95 | <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 Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 123 | You need to agree to the privacy policy in order to proceed. |
| Marc Kupietz | 7743428 | 2023-02-24 12:04:47 +0100 | [diff] [blame] | 124 | </div> |
| 125 | </div> |
| 126 | </div> |
| 127 | |
| 128 | <hr class="mt-2 mb-3" /> |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 129 | <!--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 Kupietz | 7743428 | 2023-02-24 12:04:47 +0100 | [diff] [blame] | 136 | <button id="reload" class="btn btn-outline-info" type="button"> <span |
| 137 | class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button> |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 138 | </div> |
| 139 | </div> |
| Marc Kupietz | 7743428 | 2023-02-24 12:04:47 +0100 | [diff] [blame] | 140 | <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" /> |
| matheusfillipe | abd513e | 2021-05-11 03:29:11 -0300 | [diff] [blame] | 143 | </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 Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 149 | </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 Kupietz | 3186188 | 2023-02-25 08:52:57 +0100 | [diff] [blame^] | 170 | |
| 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 Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 179 | } else { |
| Marc Kupietz | 3186188 | 2023-02-25 08:52:57 +0100 | [diff] [blame^] | 180 | $("#pw2")[0].setCustomValidity(""); // is valid |
| Marc Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 181 | } |
| Marc Kupietz | 3186188 | 2023-02-25 08:52:57 +0100 | [diff] [blame^] | 182 | } else { |
| 183 | $("#pwconfirm")[0].classList.remove('was-validated') |
| Marc Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 184 | } |
| Marc Kupietz | 3186188 | 2023-02-25 08:52:57 +0100 | [diff] [blame^] | 185 | passUpdated(); |
| 186 | } |
| Marc Kupietz | 21fa9bb | 2023-02-24 19:44:16 +0100 | [diff] [blame] | 187 | |
| 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 Kupietz | 3186188 | 2023-02-25 08:52:57 +0100 | [diff] [blame^] | 359 | else if (nScore >= 10) |
| Marc Kupietz | 21fa9bb | 2023-02-24 19:44:16 +0100 | [diff] [blame] | 360 | 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 Kupietz | 1f2b2e9 | 2023-02-24 13:04:40 +0100 | [diff] [blame] | 406 | </script> |