Rev 511 | Rev 564 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
82 | daniel-mar | 1 | <?php |
2 | |||
360 | daniel-mar | 3 | /* |
4 | * OIDplus 2.0 |
||
511 | daniel-mar | 5 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
360 | daniel-mar | 6 | * |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
8 | * you may not use this file except in compliance with the License. |
||
9 | * You may obtain a copy of the License at |
||
10 | * |
||
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
12 | * |
||
13 | * Unless required by applicable law or agreed to in writing, software |
||
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
16 | * See the License for the specific language governing permissions and |
||
17 | * limitations under the License. |
||
18 | */ |
||
19 | |||
236 | daniel-mar | 20 | require_once __DIR__ . '/../includes/oidplus.inc.php'; |
82 | daniel-mar | 21 | |
362 | daniel-mar | 22 | OIDplus::handleLangArgument(); |
2 | daniel-mar | 23 | |
362 | daniel-mar | 24 | echo '<!DOCTYPE html>'; |
504 | daniel-mar | 25 | echo '<html lang="'.substr(OIDplus::getCurrentLang(),0,2).'">'; |
2 | daniel-mar | 26 | |
362 | daniel-mar | 27 | echo '<head>'; |
28 | echo ' <title>'._L('OIDplus Setup').'</title>'; |
||
29 | echo ' <meta name="robots" content="noindex">'; |
||
30 | echo ' <meta name="viewport" content="width=device-width, initial-scale=1.0">'; |
||
364 | daniel-mar | 31 | echo ' <link rel="stylesheet" href="setup.min.css.php">'; |
504 | daniel-mar | 32 | echo ' <link rel="shortcut icon" type="image/x-icon" href="../favicon.ico.php">'; |
364 | daniel-mar | 33 | echo ' <script src="setup.min.js.php" type="text/javascript"></script>'; |
362 | daniel-mar | 34 | echo '</head>'; |
2 | daniel-mar | 35 | |
362 | daniel-mar | 36 | echo '<body>'; |
2 | daniel-mar | 37 | |
362 | daniel-mar | 38 | echo '<h1>'._L('OIDplus Setup - Configuration File Generator').'</h1>'; |
157 | daniel-mar | 39 | |
561 | daniel-mar | 40 | echo '<noscript>'; |
41 | echo '<h2>'._L('Please enable JavaScript in order to use setup!').'</h2>'; |
||
42 | echo '</noscript>'; |
||
43 | |||
44 | echo '<span id="setupPageContent" style="display:None">'; |
||
45 | |||
362 | daniel-mar | 46 | echo OIDplusGui::getLanguageBox(null, false); |
299 | daniel-mar | 47 | |
362 | daniel-mar | 48 | echo '<p>'._L('Thank you very much for choosing OIDplus! This setup assistant will help you creating or updating the file <b>%1</b>. Setup does not automatically write to this file. Instead, you need to copy-paste the contents into the file. Once OIDplus setup is finished, you can change the config file by hand, or run this setup assistant again.','userdata/baseconfig/config.inc.php').'</p>'; |
299 | daniel-mar | 49 | |
362 | daniel-mar | 50 | echo '<h2 id="systemCheckCaption" style="display:none">'._L('System check').'</h2>'; |
51 | echo '<div id="dirAccessWarning"></div>'; |
||
301 | daniel-mar | 52 | |
362 | daniel-mar | 53 | echo '<div id="step1">'; |
54 | echo '<h2>'._L('Step %1: Enter setup information',1).'</h2>'; |
||
299 | daniel-mar | 55 | |
362 | daniel-mar | 56 | echo '<h3>'._L('Administrator password').'</h3>'; |
299 | daniel-mar | 57 | |
362 | daniel-mar | 58 | echo '<form id="step1_form">'; |
59 | echo '<p>'._L('Which admin password do you want?').'<br><input id="admin_password" type="password" autocomplete="new-password" onkeypress="rebuild()" onkeyup="rebuild()"> <span id="password_warn"></span></p>'; |
||
60 | echo '<p>'._L('Please repeat the password input:').'<br><input id="admin_password2" type="password" autocomplete="new-password" onkeypress="rebuild()" onkeyup="rebuild()"> <span id="password_warn2"></span></p>'; |
||
299 | daniel-mar | 61 | |
362 | daniel-mar | 62 | echo '<h3>'._L('Database connectivity').'</h3>'; |
157 | daniel-mar | 63 | |
479 | daniel-mar | 64 | if (file_exists(__DIR__ . '/../doc/database_connectivity_diagram.png')) { |
65 | echo '<p><a href="../doc/database_connectivity_diagram.png" target="_blank"><img src="../doc/database_connectivity_diagram.png" width="20%" alt="'._L('Database connectivity diagram').'" title="'._L('Database connectivity diagram').'"></a></p>'; |
||
66 | } |
||
157 | daniel-mar | 67 | |
362 | daniel-mar | 68 | echo _L('Database plugin').': <select name="db_plugin" onChange="dbplugin_changed()" id="db_plugin">'; |
150 | daniel-mar | 69 | |
380 | daniel-mar | 70 | OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin')); |
71 | foreach (OIDplus::getDatabasePlugins() as $plugin) { |
||
72 | $selected = $plugin::id() == 'MySQL' ? ' selected="true"' : ''; |
||
73 | echo '<option value="'.htmlentities($plugin::id()).'"'.$selected.'>'.htmlentities($plugin::id()).'</option>'; |
||
236 | daniel-mar | 74 | } |
75 | |||
362 | daniel-mar | 76 | echo '</select>'; |
150 | daniel-mar | 77 | |
362 | daniel-mar | 78 | echo '<div style="margin-left:50px">'; |
150 | daniel-mar | 79 | |
380 | daniel-mar | 80 | OIDplus::registerAllPlugins('sqlSlang', 'OIDplusSqlSlangPlugin', array('OIDplus','registerSqlSlangPlugin')); |
274 | daniel-mar | 81 | $sql_slang_selection = array(); |
380 | daniel-mar | 82 | foreach (OIDplus::getSqlSlangPlugins() as $plugin) { |
83 | $slang_id = $plugin::id(); |
||
84 | $pluginManifest = $plugin->getManifest(); |
||
502 | daniel-mar | 85 | $human_friendly_name = empty($pluginManifest->getName()) ? get_class($plugin) : $pluginManifest->getName(); |
380 | daniel-mar | 86 | $sql_slang_selection[] = '<option value="'.$slang_id.'">'.$human_friendly_name.'</option>'; |
274 | daniel-mar | 87 | } |
88 | $sql_slang_selection = implode("\n", $sql_slang_selection); |
||
89 | |||
305 | daniel-mar | 90 | $found_db_plugins = 0; |
380 | daniel-mar | 91 | //OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin')); |
92 | foreach (OIDplus::getDatabasePlugins() as $plugin) { |
||
93 | $found_db_plugins++; |
||
94 | $cont = $plugin->setupHTML(); |
||
95 | $cont = str_replace('<!-- %SQL_SLANG_SELECTION% -->', $sql_slang_selection, $cont); |
||
96 | echo $cont; |
||
277 | daniel-mar | 97 | } |
98 | |||
305 | daniel-mar | 99 | if ($found_db_plugins == 0) { |
362 | daniel-mar | 100 | echo '<p><font color="red">'._L('ERROR: No database plugins were found! You CANNOT use OIDplus without database connection.').'</font></p>'; |
150 | daniel-mar | 101 | } |
102 | |||
362 | daniel-mar | 103 | echo '</div>'; |
150 | daniel-mar | 104 | |
362 | daniel-mar | 105 | echo '<p>'._L('Table name prefix (e.g. <b>oidplus_</b>)').':<br><input id="tablename_prefix" type="text" value="oidplus_" onkeypress="rebuild()" onkeyup="rebuild()"></p>'; |
150 | daniel-mar | 106 | |
362 | daniel-mar | 107 | echo '<h3>'._L('ReCAPTCHA').'</h3>'; |
108 | echo '<p><input id="recaptcha_enabled" type="checkbox" onclick="rebuild()"> <label for="recaptcha_enabled">'._L('reCAPTCHA enabled').'</label> (<a href="https://developers.google.com/recaptcha/intro" target="_blank">'._L('more information and obtain key').'</a>)</p>'; |
||
109 | echo '<p>'._L('reCAPTCHA Public key').'<br><input id="recaptcha_public" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>'; |
||
110 | echo '<p>'._L('reCAPTCHA Private key').'<br><input id="recaptcha_private" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>'; |
||
150 | daniel-mar | 111 | |
362 | daniel-mar | 112 | echo '<h3>'._L('TLS').'</h3>'; |
113 | echo '<p>'._L('SSL enforcement').'<br><select name="enforce_ssl" id="enforce_ssl" onclick="rebuild()">'; |
||
114 | echo '<option value="0">'._L('No SSL available (don\'t redirect)').'</option>'; |
||
115 | echo '<option value="1">'._L('Enforce SSL (always redirect)').'</option>'; |
||
116 | echo '<option value="2" selected>'._L('Intelligent SSL detection (redirect if port 443 is open)').'</option>'; |
||
117 | echo '</select></p>'; |
||
118 | echo '</form>'; |
||
119 | echo '</div>'; |
||
157 | daniel-mar | 120 | |
362 | daniel-mar | 121 | echo '<div id="step2">'; |
122 | echo '<h2>'._L('Step %1: Initialize database',2).'</h2>'; |
||
123 | echo '<p><font color="red"><b>'._L('If you already have an OIDplus database and just want to rebuild the config file, please skip this step.').'</b></font></p>'; |
||
124 | echo '<p>'._L('Otherwise, import one of the following SQL dumps in your database:').'</p>'; |
||
125 | echo '<p><ul>'; |
||
126 | echo ' <li><a href="struct_empty.sql.php" id="struct_1" target="_blank">'._L('Empty OIDplus database without example data').'</a><span id="struct_cli_1"></span><br><br></li>'; |
||
127 | echo ' <li><a href="struct_with_examples.sql.php" id="struct_2" target="_blank">'._L('OIDplus database with example data').'</a><span id="struct_cli_2"></span><br><br></li>'; |
||
128 | echo '</ul></p>'; |
||
129 | echo '<p><font color="red">'._L('Warning: All data from the previous OIDplus instance will be deleted during the import.<br>If you already have an OIDplus database, skip to Step 3.').'</font></p>'; |
||
130 | echo '</div>'; |
||
157 | daniel-mar | 131 | |
362 | daniel-mar | 132 | echo '<div id="step3">'; |
133 | echo '<h2>'._L('Step %1: Save %2 file',3,'userdata/baseconfig/config.inc.php').'</h2>'; |
||
410 | daniel-mar | 134 | echo '<p>'._L('Save following contents into the file <b>%1</b>','userdata/baseconfig/config.inc.php').'</p>'; |
362 | daniel-mar | 135 | echo '<code><font color="darkblue"><div id="config"></div></font></code>'; |
136 | echo '</div>'; |
||
157 | daniel-mar | 137 | |
362 | daniel-mar | 138 | echo '<div id="step4">'; |
139 | echo '<h2>'._L('Step %1: Continue to next step',4).'</h2>'; |
||
140 | echo '<p><input type="button" onclick="window.location.href=\'../\'" value="'._L('Continue').'"></p>'; |
||
141 | // echo '<p><a href="../">Run the OIDplus system</a></p>'; |
||
142 | echo '</div>'; |
||
157 | daniel-mar | 143 | |
379 | daniel-mar | 144 | echo '<br><br><br>'; // because of iPhone Safari |
366 | daniel-mar | 145 | |
561 | daniel-mar | 146 | echo '</span>'; |
147 | echo '<script> $("#setupPageContent")[0].style.display = "Block"; </script>'; |
||
148 | |||
362 | daniel-mar | 149 | echo '</body>'; |
410 | daniel-mar | 150 | echo '</html>'; |