Subversion Repositories oidplus

Rev

Rev 974 | Rev 985 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
  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.  
  20. require_once __DIR__ . '/../includes/oidplus.inc.php';
  21.  
  22. OIDplus::handleLangArgument();
  23.  
  24. echo '<!DOCTYPE html>';
  25. echo '<html lang="'.substr(OIDplus::getCurrentLang(),0,2).'">';
  26.  
  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">';
  31. echo '  <link rel="stylesheet" href="setup.min.css.php">';
  32. echo '  <link rel="shortcut icon" type="image/x-icon" href="../favicon.ico.php">';
  33. echo '  <script src="setup.min.js.php" type="text/javascript"></script>';
  34. echo '</head>';
  35.  
  36. echo '<body>';
  37.  
  38. echo '<h1>'._L('OIDplus Setup - Configuration File Generator').'</h1>';
  39.  
  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.  
  46. echo OIDplus::gui()->getLanguageBox(null, false);
  47.  
  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>';
  49.  
  50. echo '<h2 id="systemCheckCaption" style="display:none">'._L('System check').'</h2>';
  51. echo '<div id="dirAccessWarning"></div>';
  52.  
  53. echo '<div id="step1">';
  54. echo '<h2>'._L('Step %1: Enter setup information',1).'</h2>';
  55.  
  56. // ----------------------------------------
  57.  
  58. echo '<h3>'._L('Administrator password').'</h3>';
  59.  
  60. echo '<form id="step1_form">';
  61. 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>';
  62. 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>';
  63.  
  64. // ----------------------------------------
  65.  
  66. echo '<h3>'._L('Database connectivity').'</h3>';
  67.  
  68. if (file_exists(__DIR__ . '/../doc/database_connectivity_diagram.png')) {
  69.         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>';
  70. }
  71.  
  72. echo _L('Database plugin').': <select name="db_plugin" onChange="dbplugin_changed()" id="db_plugin">';
  73.  
  74. OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin'));
  75. foreach (OIDplus::getDatabasePlugins() as $plugin) {
  76.         $selected = $plugin::id() == 'MySQL' ? ' selected="true"' : '';
  77.         echo '<option value="'.htmlentities($plugin::id()).'"'.$selected.'>'.htmlentities($plugin::id()).'</option>';
  78. }
  79.  
  80. echo '</select>';
  81.  
  82. echo '<div style="margin-left:50px">';
  83.  
  84. OIDplus::registerAllPlugins('sqlSlang', 'OIDplusSqlSlangPlugin', array('OIDplus','registerSqlSlangPlugin'));
  85. $sql_slang_selection = array();
  86. foreach (OIDplus::getSqlSlangPlugins() as $plugin) {
  87.         $slang_id = $plugin::id();
  88.         $pluginManifest = $plugin->getManifest();
  89.         $human_friendly_name = empty($pluginManifest->getName()) ? get_class($plugin) : $pluginManifest->getName();
  90.         $sql_slang_selection[] = '<option value="'.$slang_id.'">'.$human_friendly_name.'</option>';
  91. }
  92. $sql_slang_selection = implode("\n", $sql_slang_selection);
  93.  
  94. $found_db_plugins = 0;
  95. //OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin'));
  96. foreach (OIDplus::getDatabasePlugins() as $plugin) {
  97.         $found_db_plugins++;
  98.         $cont = $plugin->setupHTML();
  99.         $cont = str_replace('<!-- %SQL_SLANG_SELECTION% -->', $sql_slang_selection, $cont);
  100.         echo $cont;
  101. }
  102.  
  103. if ($found_db_plugins == 0) {
  104.         echo '<p><font color="red">'._L('ERROR: No database plugins were found! You CANNOT use OIDplus without database connection.').'</font></p>';
  105. }
  106.  
  107. echo '</div>';
  108.  
  109. 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>';
  110.  
  111. // ----------------------------------------
  112.  
  113. echo '<h3>'._L('CAPTCHA').'</h3>';
  114.  
  115. // TODO: Add a small explanation here, in case somebody does not know what CAPTCHA is
  116.  
  117. echo _L('CAPTCHA plugin').': <select name="captcha_plugin" onChange="captchaplugin_changed()" id="captcha_plugin">';
  118.  
  119. OIDplus::registerAllPlugins('captcha', 'OIDplusCaptchaPlugin', array('OIDplus','registerCaptchaPlugin'));
  120. foreach (OIDplus::getCaptchaPlugins() as $plugin) {
  121.         $selected = $plugin::id() === 'None' ? ' selected="true"' : '';
  122.         echo '<option value="'.htmlentities($plugin::id()).'"'.$selected.'>'.htmlentities($plugin::id()).'</option>';
  123. }
  124.  
  125. echo '</select>';
  126.  
  127. echo '<div style="margin-left:50px">';
  128.  
  129. $found_captcha_plugins = 0;
  130. foreach (OIDplus::getCaptchaPlugins() as $plugin) {
  131.         $found_captcha_plugins++;
  132.         $cont = $plugin->setupHTML();
  133.         echo $cont;
  134. }
  135.  
  136. if ($found_captcha_plugins == 0) {
  137.         echo '<p><font color="red">'._L('ERROR: No CAPTCHA plugins were found! You CANNOT use OIDplus without the "%1" CAPTCHA plugin.','None').'</font></p>';
  138. }
  139.  
  140. echo '</div>';
  141.  
  142. // Commented out, because it might confuse people during the OOBE
  143. //echo '<p>'._L('Note: In case you are already operating a system, the users need to reload the webpage in order to receive the new CAPTCHA settings.').'</p>';
  144.  
  145. // ----------------------------------------
  146.  
  147. $is_ssl = OIDplus::isSSL();
  148. echo '<h3>'._L('Secure connection (HTTPS)').'</h3>';
  149. echo '<p>'._L('SSL enforcement').'<br><select name="enforce_ssl" id="enforce_ssl" onchange="rebuild()">';
  150. echo '<option value="OIDplus::ENFORCE_SSL_NO">'._L('No SSL available (don\'t redirect)').'</option>';
  151. echo '<option value="OIDplus::ENFORCE_SSL_YES"'.($is_ssl ? ' selected' : '').'>'._L('Enforce SSL (always redirect)').'</option>';
  152. echo '<option value="OIDplus::ENFORCE_SSL_AUTO"'.(!$is_ssl ? ' selected' : '').'>'._L('Intelligent SSL detection (redirect if port 443 is open)').'</option>';
  153. echo '</select></p>';
  154. echo '</form>';
  155. echo '</div>';
  156.  
  157. // ----------------------------------------
  158.  
  159. echo '<div id="step2">';
  160. echo '<h2>'._L('Step %1: Initialize database',2).'</h2>';
  161. 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>';
  162. echo '<p>'._L('Otherwise, import one of the following SQL dumps in your database:').'</p>';
  163. echo '<p><ul>';
  164. 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>';
  165. 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>';
  166. echo '</ul></p>';
  167. 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>';
  168. echo '</div>';
  169.  
  170. // ----------------------------------------
  171.  
  172. echo '<div id="step3">';
  173. echo '<h2>'._L('Step %1: Save %2 file',3,'userdata/baseconfig/config.inc.php').'</h2>';
  174. echo '<p>'._L('Save following contents into the file <b>%1</b>','userdata/baseconfig/config.inc.php').'</p>';
  175. echo '<code><font color="darkblue"><div id="config"></div></font></code>';
  176. echo '<p><input type="button" value="'._L('Copy to clipboard').'" onClick="copyToClipboard(config)"></p>';
  177. echo '</div>';
  178.  
  179. // ----------------------------------------
  180.  
  181. echo '<div id="step4">';
  182. echo '<h2>'._L('Step %1: Continue to next step',4).'</h2>';
  183. echo '<p><input type="button" onclick="window.location.href=\'../\'" value="'._L('Continue').'"></p>';
  184. // echo '<p><a href="../">Run the OIDplus system</a></p>';
  185. echo '</div>';
  186.  
  187. echo '<br><br><br>'; // because of iPhone Safari
  188.  
  189. echo '</span>';
  190. echo '<script> $("#setupPageContent")[0].style.display = "Block"; </script>';
  191.  
  192. echo '</body>';
  193. echo '</html>';
  194.