|
12 | 12 |
|
13 | 13 | $t = $text['login'];
|
14 | 14 |
|
15 |
| -$settingPW = $ICEcoder["enableRegistration"] && ($ICEcoder["multiUser"] || "" === $ICEcoder["password"]); |
| 15 | +$settingPW = true === $ICEcoder["enableRegistration"] && (true === $ICEcoder["multiUser"] || "" === $ICEcoder["password"]); |
| 16 | + |
| 17 | +// If multiUser, detect which users we have |
| 18 | +if ($ICEcoder["multiUser"]) { |
| 19 | + $configUsernames = []; |
| 20 | + $handle = opendir('../data/'); |
| 21 | + while (false !== ($file = readdir($handle))) { |
| 22 | + if ($file !== "config-global.php" && 0 === strpos($file, "config-")) { |
| 23 | + $configUsernames[explode("-", $file)[1]] = true; |
| 24 | + } |
| 25 | + } |
| 26 | + closedir($handle); |
| 27 | +} |
16 | 28 | ?>
|
17 | 29 | <!DOCTYPE html>
|
18 | 30 |
|
19 | 31 | <html>
|
20 | 32 | <head>
|
21 | 33 | <title>ICEcoder <?php
|
22 | 34 | echo $ICEcoder["versionNo"] . " : ";
|
23 |
| -echo $settingPW ? "Setup" : "Login"; |
| 35 | +echo true === $settingPW ? "Setup" : "Login"; |
24 | 36 | ?></title>
|
25 | 37 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
26 | 38 | <meta name="robots" content="noindex, nofollow">
|
|
30 | 42 | <link rel="icon" type="image/png" href="../assets/images/favicon.png">
|
31 | 43 | </head>
|
32 | 44 |
|
33 |
| -<body style="background-color: #181817" onLoad="<?php if (false === isset($_GET["get"])) {$inputFocus = true === $ICEcoder["multiUser"] ? "username" : "password"; echo "document.settingsUpdate." . $inputFocus . ".focus(); ";}; ?>setTimeout(function(){document.getElementById('screenContainer').style.opacity = '1'}, 50)"> |
| 45 | +<body style="background-color: #181817" onLoad="<?php if (false === isset($_GET["get"])) {$inputFocus = true === $ICEcoder["multiUser"] && (true === $ICEcoder["enableRegistration"] || 1 < count($configUsernames)) ? "username" : "password"; echo "document.settingsUpdate." . $inputFocus . ".focus(); ";}; ?>setTimeout(function(){document.getElementById('screenContainer').style.opacity = '1'}, 50)"> |
34 | 46 |
|
35 | 47 | <div class="screenContainer" id="screenContainer" style="background-color: #181817; opacity: 0; transition: opacity 0.1s ease-out">
|
36 | 48 | <div class="screenVCenter">
|
37 | 49 | <div class="screenCenter">
|
38 | 50 | <img src="../assets/images/icecoder.png" alt="ICEcoder">
|
39 | 51 | <div class="version" style="margin-bottom: 22px"><?php echo $ICEcoder["versionNo"];?></div>
|
40 | 52 |
|
41 |
| - <form name="settingsUpdate" action="login.php" method="POST"<?php if ($settingPW) {?> onsubmit="return checkCanSubmit();"<?php } ?>> |
| 53 | + <form name="settingsUpdate" action="login.php" method="POST"<?php if (true === $settingPW) {?> onsubmit="return checkCanSubmit();"<?php } ?>> |
| 54 | + <?php |
| 55 | + if (true === $settingPW && false === $ICEcoder["multiUser"]) { |
| 56 | + echo '<div class="text adminUser">User: admin</div>'; |
| 57 | + } |
| 58 | + ?> |
42 | 59 | <?php
|
43 |
| - if ($ICEcoder["multiUser"]) {echo '<input type="text" name="username" class="password"><br><br>';}; |
| 60 | + // Display username field if multiUser enabled |
| 61 | + if (true === $ICEcoder["multiUser"]) { |
| 62 | + // Also set value to "admin" if only 1 user (has to be admin) |
| 63 | + $showAdminValue = 1 === count($configUsernames) ? ' value="admin"' : ''; |
| 64 | + echo '<input type="text" name="username"' . $showAdminValue . ' class="password"><br><br>'; |
| 65 | + }; |
44 | 66 | ?>
|
45 | 67 | <input type="password" name="password" class="password" id="password"<?php
|
46 |
| - if ($settingPW) { |
| 68 | + if (true === $settingPW) { |
47 | 69 | ?> onkeyup="checkCase(event); pwStrength(this.value)" onchange="pwStrength(this.value)" onpaste="pwStrength(this.value)"<?php
|
48 | 70 | } else {
|
49 | 71 | ?> onkeyup="checkCase(event)"<?php
|
50 | 72 | }
|
51 | 73 | ?>><div class="iconCapsLock" style="display: none" id="iconCapsLock" title="Caps lock on"><?php echo file_get_contents(dirname(__FILE__) . "/../assets/images/icons/alert-triangle.svg");?></div><br>
|
52 | 74 | <?php
|
53 |
| - if ($settingPW) { |
| 75 | + if (true === $settingPW) { |
54 | 76 | echo '<div id="pwReqs">'.
|
55 | 77 | '<div class="text" style="display: inline-block" id="pwChars">10+</div> ' .
|
56 | 78 | '<div class="text" style="display: inline-block" id="pwUpper">upper</div> ' .
|
|
0 commit comments