Rev 149 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 149 | Rev 150 | ||
---|---|---|---|
Line 60... | Line 60... | ||
60 | }; |
60 | }; |
61 | 61 | ||
62 | function rebuild() { |
62 | function rebuild() { |
63 | var error = false; |
63 | var error = false; |
64 | 64 | ||
- | 65 | if (document.getElementById('config') == null) return; |
|
- | 66 | ||
65 | // Check 1: Has the password the correct length? |
67 | // Check 1: Has the password the correct length? |
66 | if (document.getElementById('admin_password').value.length < min_password_length) |
68 | if (document.getElementById('admin_password').value.length < min_password_length) |
67 | { |
69 | { |
68 | document.getElementById('password_warn').innerHTML = '<font color="red">Password must be at least '+min_password_length+' characters long</font>'; |
70 | document.getElementById('password_warn').innerHTML = '<font color="red">Password must be at least '+min_password_length+' characters long</font>'; |
69 | document.getElementById('config').innerHTML = '<b><?php</b><br><br><i>// ERROR: Password must be at least '+min_password_length+' characters long</i>'; |
71 | document.getElementById('config').innerHTML = '<b><?php</b><br><br><i>// ERROR: Password must be at least '+min_password_length+' characters long</i>'; |
Line 78... | Line 80... | ||
78 | error = true; |
80 | error = true; |
79 | } else { |
81 | } else { |
80 | document.getElementById('password_warn2').innerHTML = ''; |
82 | document.getElementById('password_warn2').innerHTML = ''; |
81 | } |
83 | } |
82 | 84 | ||
83 | // Check 3: host must not be empty |
85 | // Check 3: Ask the database plugins for verification of their data |
84 | if (document.getElementById('mysql_host').value.length == 0) |
86 | for (var i = 0; i < rebuild_callbacks.length; i++) { |
- | 87 | var f = rebuild_callbacks[i]; |
|
85 | { |
88 | if (!f()) { |
86 | document.getElementById('mysql_host_warn').innerHTML = '<font color="red">Please specify a host name!</font>'; |
- | |
87 | document.getElementById('config').innerHTML = '<b><?php</b><br><br><i>// ERROR: Please specify a host name!</i>'; |
- | |
88 | error = true; |
89 | error = true; |
89 | } else { |
- | |
90 | document.getElementById('mysql_host_warn').innerHTML = ''; |
- | |
91 | } |
90 | } |
92 | - | ||
93 | // Check 4: Username must not be empty |
- | |
94 | if (document.getElementById('mysql_username').value.length == 0) |
- | |
95 | { |
- | |
96 | document.getElementById('mysql_username_warn').innerHTML = '<font color="red">Please specify a username name!</font>'; |
- | |
97 | document.getElementById('config').innerHTML = '<b><?php</b><br><br><i>// ERROR: Please specify a username name!</i>'; |
- | |
98 | error = true; |
- | |
99 | } else { |
- | |
100 | document.getElementById('mysql_username_warn').innerHTML = ''; |
- | |
101 | } |
- | |
102 | - | ||
103 | // Check 5: Database name must not be empty |
- | |
104 | if (document.getElementById('mysql_database').value.length == 0) |
- | |
105 | { |
- | |
106 | document.getElementById('mysql_database_warn').innerHTML = '<font color="red">Please specify a database name!</font>'; |
- | |
107 | document.getElementById('config').innerHTML = '<b><?php</b><br><br><i>// ERROR: Please specify a database name!</i>'; |
- | |
108 | error = true; |
- | |
109 | } else { |
- | |
110 | document.getElementById('mysql_database_warn').innerHTML = ''; |
- | |
111 | } |
91 | } |
112 | 92 | ||
113 | // Continue |
93 | // Continue |
114 | if (!error) |
94 | if (!error) |
115 | { |
95 | { |
- | 96 | var e = document.getElementById("db_plugin"); |
|
- | 97 | var strPlugin = e.options[e.selectedIndex].value; |
|
- | 98 | ||
116 | document.getElementById('config').innerHTML = '<b><?php</b><br><br>' + |
99 | document.getElementById('config').innerHTML = '<b><?php</b><br><br>' + |
117 | '<i>// To renew this file, please run setup/ in your browser.</i><br>' + |
100 | '<i>// To renew this file, please run setup/ in your browser.</i><br>' + |
118 | '<i>// If you don\'t want to run setup again, you can also change most of the settings directly in this file.</i><br>' + |
101 | '<i>// If you don\'t want to run setup again, you can also change most of the settings directly in this file.</i><br>' + |
119 | '<br>' + |
102 | '<br>' + |
120 | '<b>define</b>(\'OIDPLUS_CONFIG_VERSION\', 2.0);<br>' + |
103 | '<b>define</b>(\'OIDPLUS_CONFIG_VERSION\', 2.0);<br>' + |
121 | '<br>' + |
104 | '<br>' + |
- | 105 | // Passwords are Base64 encoded to avoid that passwords can be read upon first sight, |
|
- | 106 | // e.g. if collegues are looking over your shoulder while you accidently open (and quickly close) config.inc.php |
|
122 | '<b>define</b>(\'OIDPLUS_ADMIN_PASSWORD\', \'' + hexToBase64(sha3_512(document.getElementById('admin_password').value)) + '\'); // base64 encoded SHA3-512 hash<br>' + |
107 | '<b>define</b>(\'OIDPLUS_ADMIN_PASSWORD\', \'' + hexToBase64(sha3_512(document.getElementById('admin_password').value)) + '\'); // base64 encoded SHA3-512 hash<br>' + |
123 | '<br>' + |
108 | '<br>' + |
124 | '<b>define</b>(\'OIDPLUS_MYSQL_HOST\', \''+document.getElementById('mysql_host').value+'\');<br>' + |
109 | '<b>define</b>(\'OIDPLUS_DATABASE_PLUGIN\', \''+strPlugin+'\');<br>'; |
125 | '<b>define</b>(\'OIDPLUS_MYSQL_USERNAME\', \''+document.getElementById('mysql_username').value+'\');<br>' + |
110 | for (var i = 0; i < rebuild_config_callbacks.length; i++) { |
- | 111 | var f = rebuild_config_callbacks[i]; |
|
- | 112 | var cont = f(); |
|
- | 113 | if (cont) { |
|
126 | '<b>define</b>(\'OIDPLUS_MYSQL_PASSWORD\', \''+b64EncodeUnicode(document.getElementById('mysql_password').value)+'\'); // base64 encoded<br>' + |
114 | document.getElementById('config').innerHTML = document.getElementById('config').innerHTML + cont; |
- | 115 | } |
|
- | 116 | } |
|
127 | '<b>define</b>(\'OIDPLUS_MYSQL_DATABASE\', \''+document.getElementById('mysql_database').value+'\');<br>' + |
117 | document.getElementById('config').innerHTML = document.getElementById('config').innerHTML + |
128 | '<br>' + |
118 | '<br>' + |
129 | '<b>define</b>(\'OIDPLUS_TABLENAME_PREFIX\', \''+document.getElementById('tablename_prefix').value+'\');<br>' + |
119 | '<b>define</b>(\'OIDPLUS_TABLENAME_PREFIX\', \''+document.getElementById('tablename_prefix').value+'\');<br>' + |
130 | '<br>' + |
120 | '<br>' + |
131 | '<b>define</b>(\'OIDPLUS_SESSION_SECRET\', \''+generateRandomString(32)+'\');<br>' + |
121 | '<b>define</b>(\'OIDPLUS_SESSION_SECRET\', \''+generateRandomString(32)+'\');<br>' + |
132 | '<br>' + |
122 | '<br>' + |
Line 139... | Line 129... | ||
139 | document.getElementById('config').innerHTML = document.getElementById('config').innerHTML.replaceAll(' ', ' '); |
129 | document.getElementById('config').innerHTML = document.getElementById('config').innerHTML.replaceAll(' ', ' '); |
140 | } |
130 | } |
141 | 131 | ||
142 | // In case something is not good, do not allow the user to continue with the other configuration steps: |
132 | // In case something is not good, do not allow the user to continue with the other configuration steps: |
143 | if (error) { |
133 | if (error) { |
144 | document.getElementById('step2').style.visibility='hidden'; |
134 | document.getElementById('step2').style.display = "None"; |
145 | document.getElementById('step3').style.visibility='hidden'; |
135 | document.getElementById('step3').style.display = "None"; |
146 | document.getElementById('step4').style.visibility='hidden'; |
136 | document.getElementById('step4').style.display = "None"; |
147 | } else { |
137 | } else { |
148 | document.getElementById('step2').style.visibility='visible'; |
138 | document.getElementById('step2').style.display = "Block"; |
149 | document.getElementById('step3').style.visibility='visible'; |
139 | document.getElementById('step3').style.display = "Block"; |
150 | document.getElementById('step4').style.visibility='visible'; |
140 | document.getElementById('step4').style.display = "Block"; |
151 | } |
141 | } |
152 | - | ||
153 | document.getElementById('struct_1').href = 'struct_empty.sql.php?prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&database='+encodeURI(document.getElementById('mysql_database').value); |
- | |
154 | document.getElementById('sqlcli_1').innerHTML = 'struct_empty.sql.php?prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&database='+encodeURI(document.getElementById('mysql_database').value); |
- | |
155 | document.getElementById('struct_2').href = 'struct_with_examples.sql.php?prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&database='+encodeURI(document.getElementById('mysql_database').value); |
- | |
156 | document.getElementById('sqlcli_2').innerHTML = 'struct_with_examples.sql.php?prefix='+encodeURI(document.getElementById('tablename_prefix').value)+'&database='+encodeURI(document.getElementById('mysql_database').value); |
- | |
157 | document.getElementById('mysqluser_1').innerHTML = document.getElementById('mysql_username').value; |
- | |
158 | document.getElementById('mysqluser_2').innerHTML = document.getElementById('mysql_username').value; |
- | |
159 | } |
142 | } |