Subversion Repositories oidplus

Rev

Rev 294 | Rev 301 | 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. <h2 id="systemCheckCaption" style="display:none">System check</h2>
  26.  
  27. <div id="dirAccessWarning"></div>
  28.  
  29. <script>
  30. function checkAccess(dir) {
  31.         var xhr = new XMLHttpRequest();
  32.         xhr.onreadystatechange = function() {
  33.                 if (xhr.readyState === 4) {
  34.                         if (xhr.status === 200) {
  35.                                 document.getElementById('systemCheckCaption').style.display = 'block';
  36.                                 document.getElementById('dirAccessWarning').innerHTML = document.getElementById('dirAccessWarning').innerHTML + 'Attention: The following directory is world-readable: <a target="_blank" href="'+xhr.responseURL+'">'+xhr.responseURL+'</a> ! You need to configure your web server to restrict access to this directory! (For Apache see <i>.htaccess</i>, for Microsoft IIS see <i>web.config</i>, for Nginx see <i>nginx.conf</i>)<br>';
  37.                         }
  38.                 }
  39.         };
  40.  
  41.         xhr.open('GET', dir);
  42.         xhr.send();
  43. }
  44.  
  45. document.getElementById('dirAccessWarning').innerHTML = "";
  46. checkAccess('../userdata/');
  47. checkAccess('../dev/');
  48. checkAccess('../includes/');
  49. //checkAccess('../plugins/publicPages/100_whois/whois/cli/');
  50. </script>
  51.  
  52. <div id="step1">
  53. <h2>Step 1: Enter setup information</h2>
  54.  
  55. <h3>Administrator password</h3>
  56.  
  57. <form id="step1_form">
  58. <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>
  59. <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>
  60.  
  61. <h3>Database connectivity</h3>
  62.  
  63. <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>
  64.  
  65. Database plugin: <select name="db_plugin" onChange="dbplugin_changed()" id="db_plugin">
  66.  
  67. <?php
  68.  
  69. OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', null);
  70. foreach (get_declared_classes() as $c) {
  71.         if (is_subclass_of($c, 'OIDplusDatabasePlugin')) {
  72.                 $selected = $c::id() == 'MySQL' ? ' selected="true"' : '';
  73.                 echo '<option value="'.htmlentities($c::id()).'"'.$selected.'>'.htmlentities($c::id()).'</option>';
  74.         }
  75. }
  76.  
  77. ?>
  78. </select>
  79.  
  80. <script>
  81.  
  82. setupdir = '<?php echo (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER["HTTP_HOST"] . $_SERVER['REQUEST_URI']; ?>';
  83. rebuild_callbacks = [];
  84. rebuild_config_callbacks = [];
  85. plugin_combobox_change_callbacks = [];
  86.  
  87. function dbplugin_changed() {
  88.         var e = document.getElementById("db_plugin");
  89.         var strPlugin = e.options[e.selectedIndex].value;
  90.  
  91.         for (var i = 0; i < plugin_combobox_change_callbacks.length; i++) {
  92.                 var f = plugin_combobox_change_callbacks[i];
  93.                 f(strPlugin);
  94.         }
  95.  
  96.         rebuild();
  97. }
  98.  
  99. </script>
  100.  
  101. <div style="margin-left:50px">
  102.  
  103. <?php
  104.  
  105. OIDplus::registerAllPlugins('sqlSlang', 'OIDplusSqlSlangPlugin', null);
  106. $sql_slang_selection = array();
  107. foreach (get_declared_classes() as $c) {
  108.         if (is_subclass_of($c, 'OIDplusSqlSlangPlugin')) {
  109.                 $obj = new $c;
  110.                 $slang_id = $obj::id();
  111.                 $pluginInfo = OIDplus::getPluginInfo($obj);
  112.                 $human_friendly_name = isset($pluginInfo['name']) ? $pluginInfo['name'] : get_class($obj);
  113.                 $sql_slang_selection[] = '<option value="'.$slang_id.'">'.$human_friendly_name.'</option>';
  114.         }
  115. }
  116. $sql_slang_selection = implode("\n", $sql_slang_selection);
  117.  
  118. $files = array();
  119.  
  120. $ary = OIDplus::getAllPluginManifests('database');
  121. foreach ($ary as $plugintype_folder => $bry) {
  122.         foreach ($bry as $pluginname_folder => $cry) {
  123.                 if (!isset($cry['Setup'])) continue;
  124.                 foreach ($cry['Setup'] as $dry_name => $dry) {
  125.                         if ($dry_name != 'htmlpart') continue;
  126.                         foreach ($dry as $html_file) {
  127.                                 $files[] = OIDplus::basePath().'/plugins/'.$plugintype_folder.'/'.$pluginname_folder.'/'.$html_file;
  128.                         }
  129.                 }
  130.         }
  131. }
  132.  
  133. foreach ($files as $file) {
  134.         $cont = file_get_contents($file);
  135.         $cont = str_replace('<!-- %SQL_SLANG_SELECTION% -->', $sql_slang_selection, $cont);
  136.         echo $cont;
  137. }
  138. if (count($files) == 0) {
  139.         echo '<p><font color="red">ERROR: No database plugins were found! You CANNOT use OIDplus without database connection.</font></p>';
  140. }
  141.  
  142. ?>
  143.  
  144. </div>
  145.  
  146. <script>
  147. dbplugin_changed();
  148. </script>
  149.  
  150. <p>Tablename prefix (e.g. <b>oidplus_</b>):<br><input id="tablename_prefix" type="text" value="oidplus_" onkeypress="rebuild()" onkeyup="rebuild()"></p>
  151.  
  152. <h3>ReCAPTCHA</h3>
  153.  
  154. <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>
  155. <p>reCAPTCHA Public key<br><input id="recaptcha_public" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>
  156. <p>reCAPTCHA Private key<br><input id="recaptcha_private" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>
  157.  
  158. <h3>TLS</h3>
  159.  
  160. <p>SSL enforcement<br><select name="enforce_ssl" id="enforce_ssl" onclick="rebuild()">
  161. <option value="0">No SSL available (don't redirect)</option>
  162. <option value="1">Enforce SSL (always redirect)</option>
  163. <option value="2" selected>Intelligent SSL detection (redirect if port 443 is open)</option>
  164. </select></p>
  165. </form>
  166. </div>
  167.  
  168. <div id="step2">
  169. <h2>Step 2: Initialize database</h2>
  170. <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>
  171. <p>Otherwise, import one of the following MySQL dumps in your database:</p>
  172. <p><ul>
  173.         <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>
  174.         <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>
  175.  
  176. </ul></p>
  177. <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>
  178.  
  179. </div>
  180.  
  181. <div id="step3">
  182. <h2>Step 3: Save userdata/baseconfig/config.inc.php file</h2>
  183. <p>Save following contents into the file <b>userdata/baseconfig/config.inc.php</b>:</p>
  184. <code><font color="darkblue"><div id="config"></div></font></code>
  185. </div>
  186.  
  187. <div id="step4">
  188. <h2>Step 4: Continue to next step</h2>
  189. <p><input type="button" onclick="window.location.href='../'" value="Continue"></p>
  190. <!-- <p><a href="../">Run the OIDplus system</a></p> -->
  191. </div>
  192.  
  193. </body>
  194. </html>
  195.