Subversion Repositories oidplus

Rev

Rev 364 | Rev 379 | 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 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="en">';
  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 '  <script src="setup.min.js.php" type="text/javascript"></script>';
  33. echo '</head>';
  34.  
  35. echo '<body>';
  36.  
  37. echo '<h1>'._L('OIDplus Setup - Configuration File Generator').'</h1>';
  38.  
  39. echo OIDplusGui::getLanguageBox(null, false);
  40.  
  41. 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>';
  42.  
  43. echo '<h2 id="systemCheckCaption" style="display:none">'._L('System check').'</h2>';
  44. echo '<div id="dirAccessWarning"></div>';
  45.  
  46. echo '<div id="step1">';
  47. echo '<h2>'._L('Step %1: Enter setup information',1).'</h2>';
  48.  
  49. echo '<h3>'._L('Administrator password').'</h3>';
  50.  
  51. echo '<form id="step1_form">';
  52. 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>';
  53. 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>';
  54.  
  55. echo '<h3>'._L('Database connectivity').'</h3>';
  56.  
  57. 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>';
  58.  
  59. echo _L('Database plugin').': <select name="db_plugin" onChange="dbplugin_changed()" id="db_plugin">';
  60.  
  61. OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', null);
  62. foreach (get_declared_classes() as $c) {
  63.         if (is_subclass_of($c, 'OIDplusDatabasePlugin')) {
  64.                 $selected = $c::id() == 'MySQL' ? ' selected="true"' : '';
  65.                 echo '<option value="'.htmlentities($c::id()).'"'.$selected.'>'.htmlentities($c::id()).'</option>';
  66.         }
  67. }
  68.  
  69. echo '</select>';
  70.  
  71. echo '<div style="margin-left:50px">';
  72.  
  73. OIDplus::registerAllPlugins('sqlSlang', 'OIDplusSqlSlangPlugin', null);
  74. $sql_slang_selection = array();
  75. foreach (get_declared_classes() as $c) {
  76.         if (is_subclass_of($c, 'OIDplusSqlSlangPlugin')) {
  77.                 $obj = new $c;
  78.                 $slang_id = $obj::id();
  79.                 $pluginManifest = OIDplus::getpluginManifest($obj);
  80.                 $human_friendly_name = empty($pluginManifest->getName()) ? $pluginManifest->getName() : get_class($obj);
  81.                 $sql_slang_selection[] = '<option value="'.$slang_id.'">'.$human_friendly_name.'</option>';
  82.         }
  83. }
  84. $sql_slang_selection = implode("\n", $sql_slang_selection);
  85.  
  86. $found_db_plugins = 0;
  87. OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', null);
  88. foreach (get_declared_classes() as $c) {
  89.         if (is_subclass_of($c, 'OIDplusDatabasePlugin')) {
  90.                 $found_db_plugins++;
  91.                 $cont = $c::setupHTML();
  92.                 $cont = str_replace('<!-- %SQL_SLANG_SELECTION% -->', $sql_slang_selection, $cont);
  93.                 echo $cont;
  94.         }
  95. }
  96.  
  97. if ($found_db_plugins == 0) {
  98.         echo '<p><font color="red">'._L('ERROR: No database plugins were found! You CANNOT use OIDplus without database connection.').'</font></p>';
  99. }
  100.  
  101. echo '</div>';
  102.  
  103. 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>';
  104.  
  105. echo '<h3>'._L('ReCAPTCHA').'</h3>';
  106. 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>';
  107. echo '<p>'._L('reCAPTCHA Public key').'<br><input id="recaptcha_public" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>';
  108. echo '<p>'._L('reCAPTCHA Private key').'<br><input id="recaptcha_private" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>';
  109.  
  110. echo '<h3>'._L('TLS').'</h3>';
  111. echo '<p>'._L('SSL enforcement').'<br><select name="enforce_ssl" id="enforce_ssl" onclick="rebuild()">';
  112. echo '<option value="0">'._L('No SSL available (don\'t redirect)').'</option>';
  113. echo '<option value="1">'._L('Enforce SSL (always redirect)').'</option>';
  114. echo '<option value="2" selected>'._L('Intelligent SSL detection (redirect if port 443 is open)').'</option>';
  115. echo '</select></p>';
  116. echo '</form>';
  117. echo '</div>';
  118.  
  119. echo '<div id="step2">';
  120. echo '<h2>'._L('Step %1: Initialize database',2).'</h2>';
  121. 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>';
  122. echo '<p>'._L('Otherwise, import one of the following SQL dumps in your database:').'</p>';
  123. echo '<p><ul>';
  124. 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>';
  125. 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>';
  126. echo '</ul></p>';
  127. 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>';
  128. echo '</div>';
  129.  
  130. echo '<div id="step3">';
  131. echo '<h2>'._L('Step %1: Save %2 file',3,'userdata/baseconfig/config.inc.php').'</h2>';
  132. echo '<p>'._L('Save following contents into the file <b>%1</b>:','userdata/baseconfig/config.inc.php').'</p>';
  133. echo '<code><font color="darkblue"><div id="config"></div></font></code>';
  134. echo '</div>';
  135.  
  136. echo '<div id="step4">';
  137. echo '<h2>'._L('Step %1: Continue to next step',4).'</h2>';
  138. echo '<p><input type="button" onclick="window.location.href=\'../\'" value="'._L('Continue').'"></p>';
  139. // echo '<p><a href="../">Run the OIDplus system</a></p>';
  140. echo '</div>';
  141.  
  142. echo '<br><br><br>';
  143.  
  144. echo '</body>';
  145. echo '</html>';
  146.