Subversion Repositories oidplus

Rev

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

  1. <?php
  2.  
  3. require_once __DIR__ . '/../includes/oidplus.inc.php';
  4.  
  5. ?><!DOCTYPE html>
  6. <html lang="en">
  7.  
  8. <head>
  9.         <title>OIDplus Setup</title>
  10.         <meta name="robots" content="noindex">
  11.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  12.         <link rel="stylesheet" href="setup.css">
  13.         <script src="../3p/sha3_js/sha3.js"></script><!-- https://github.com/emn178/js-sha3 -->
  14.         <script src="setup.js"></script>
  15. </head>
  16.  
  17. <body onload="rebuild()">
  18.  
  19. <h1>OIDplus Setup - Configuration File Generator</h1>
  20.  
  21. <p>Thank you very much for choosing OIDplus! This setup assistant will help you creating or updating the file <b>userdata/baseconfig/config.inc.php</b>.
  22. Setup does not automatically write to this file. Instead, you need to copy-paste the contents into the file.
  23. Once OIDplus setup is finished, you can change the config file by hand, or run this setup assistant again.</p>
  24.  
  25. <div id="step1">
  26. <h2>Step 1: Enter setup information</h2>
  27.  
  28. <h3>Administrator password</h3>
  29.  
  30. <form id="step1_form">
  31. <p>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>
  32. <p>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>
  33.  
  34. <h3>Database connectivity</h3>
  35.  
  36. <p><a href="../plugins/database/database_connectivity_diagram.png" target="_blank"><img src="../plugins/database/database_connectivity_diagram.png" width="20%" alt="Database connectivity diagram" title="Database connectivity diagram"></a></p>
  37.  
  38. Database plugin: <select name="db_plugin" onChange="dbplugin_changed()" id="db_plugin">
  39.  
  40. <?php
  41.  
  42. OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', null);
  43. foreach (get_declared_classes() as $c) {
  44.         if (is_subclass_of($c, 'OIDplusDatabasePlugin')) {
  45.                 $selected = $c::id() == 'MySQL' ? ' selected="true"' : '';
  46.                 echo '<option value="'.htmlentities($c::id()).'"'.$selected.'>'.htmlentities($c::id()).'</option>';
  47.         }
  48. }
  49.  
  50. ?>
  51. </select>
  52.  
  53. <script>
  54.  
  55. setupdir = '<?php echo (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER["HTTP_HOST"] . $_SERVER['REQUEST_URI']; ?>';
  56. rebuild_callbacks = [];
  57. rebuild_config_callbacks = [];
  58. plugin_combobox_change_callbacks = [];
  59.  
  60. function dbplugin_changed() {
  61.         var e = document.getElementById("db_plugin");
  62.         var strPlugin = e.options[e.selectedIndex].value;
  63.  
  64.         for (var i = 0; i < plugin_combobox_change_callbacks.length; i++) {
  65.                 var f = plugin_combobox_change_callbacks[i];
  66.                 f(strPlugin);
  67.         }
  68.  
  69.         rebuild();
  70. }
  71.  
  72. </script>
  73.  
  74. <div style="margin-left:50px">
  75.  
  76. <?php
  77.  
  78. OIDplus::registerAllPlugins('sqlSlang', 'OIDplusSqlSlangPlugin', null);
  79. $sql_slang_selection = array();
  80. foreach (get_declared_classes() as $c) {
  81.         if (is_subclass_of($c, 'OIDplusSqlSlangPlugin')) {
  82.                 $obj = new $c;
  83.                 $slang_id = $obj::id();
  84.                 $pluginInfo = OIDplus::getPluginInfo($obj);
  85.                 $human_friendly_name = isset($pluginInfo['name']) ? $pluginInfo['name'] : get_class($obj);
  86.                 $sql_slang_selection[] = '<option value="'.$slang_id.'">'.$human_friendly_name.'</option>';
  87.         }
  88. }
  89. $sql_slang_selection = implode("\n", $sql_slang_selection);
  90.  
  91. $files = array();
  92.  
  93. $ary = OIDplus::getAllPluginManifests('database');
  94. foreach ($ary as $plugintype_folder => $bry) {
  95.         foreach ($bry as $pluginname_folder => $cry) {
  96.                 if (!isset($cry['Setup'])) continue;
  97.                 foreach ($cry['Setup'] as $dry_name => $dry) {
  98.                         if ($dry_name != 'htmlpart') continue;
  99.                         foreach ($dry as $html_file) {
  100.                                 $files[] = OIDplus::basePath().'/plugins/'.$plugintype_folder.'/'.$pluginname_folder.'/'.$html_file;
  101.                         }
  102.                 }
  103.         }
  104. }
  105.  
  106. foreach ($files as $file) {
  107.         $cont = file_get_contents($file);
  108.         $cont = str_replace('<!-- %SQL_SLANG_SELECTION% -->', $sql_slang_selection, $cont);
  109.         echo $cont;
  110. }
  111. if (count($files) == 0) {
  112.         echo '<p><font color="red">ERROR: No database plugins were found! You CANNOT use OIDplus without database connection.</font></p>';
  113. }
  114.  
  115. ?>
  116.  
  117. </div>
  118.  
  119. <script>
  120. dbplugin_changed();
  121. </script>
  122.  
  123. <p>Tablename prefix (e.g. <b>oidplus_</b>):<br><input id="tablename_prefix" type="text" value="oidplus_" onkeypress="rebuild()" onkeyup="rebuild()"></p>
  124.  
  125. <h3>ReCAPTCHA</h3>
  126.  
  127. <p><input id="recaptcha_enabled" type="checkbox" onclick="rebuild()"> <label for="recaptcha_enabled">reCAPTCHA enabled</label> (<a href="https://developers.google.com/recaptcha/intro" target="_blank">more information and obtain key</a>)</p>
  128. <p>reCAPTCHA Public key<br><input id="recaptcha_public" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>
  129. <p>reCAPTCHA Private key<br><input id="recaptcha_private" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>
  130.  
  131. <h3>TLS</h3>
  132.  
  133. <p>SSL enforcement<br><select name="enforce_ssl" id="enforce_ssl" onclick="rebuild()">
  134. <option value="0">No SSL available (don't redirect)</option>
  135. <option value="1">Enforce SSL (always redirect)</option>
  136. <option value="2" selected>Intelligent SSL detection (redirect if port 443 is open)</option>
  137. </select></p>
  138. </form>
  139. </div>
  140.  
  141. <div id="step2">
  142. <h2>Step 2: Initialize database</h2>
  143. <p><font color="red"><b>If you already have an OIDplus database and just want to rebuild the config file, please skip this step.</b></font></p>
  144. <p>Otherwise, import one of the following MySQL dumps in your database:</p>
  145. <p><ul>
  146.         <li><a href="struct_empty.sql.php" id="struct_1" target="_blank">Empty OIDplus database without example data</a><span id="struct_cli_1"></span><br><br></li>
  147.         <li><a href="struct_with_examples.sql.php" id="struct_2" target="_blank">OIDplus database with example data</a><span id="struct_cli_2"></span><br><br></li>
  148.  
  149. </ul></p>
  150. <p><font color="red">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>
  151.  
  152. </div>
  153.  
  154. <div id="step3">
  155. <h2>Step 3: Save userdata/baseconfig/config.inc.php file</h2>
  156. <p>Save following contents into the file <b>userdata/baseconfig/config.inc.php</b>:</p>
  157. <code><font color="darkblue"><div id="config"></div></font></code>
  158. </div>
  159.  
  160. <div id="step4">
  161. <h2>Step 4: Continue to next step</h2>
  162. <p><input type="button" onclick="window.location.href='../'" value="Continue"></p>
  163. <!-- <p><a href="../">Run the OIDplus system</a></p> -->
  164. </div>
  165.  
  166. </body>
  167. </html>
  168.