Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 361 → Rev 362

/trunk/setup/index.php
17,82 → 17,48
* limitations under the License.
*/
 
// TODO: TRANSLATE
 
require_once __DIR__ . '/../includes/oidplus.inc.php';
 
?><!DOCTYPE html>
<html lang="en">
OIDplus::handleLangArgument();
 
<head>
<title>OIDplus Setup</title>
<meta name="robots" content="noindex">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="setup.css">
<script src="../3p/sha3_js/sha3.js"></script><!-- https://github.com/emn178/js-sha3 -->
<script src="setup.js"></script>
</head>
echo '<!DOCTYPE html>';
echo '<html lang="en">';
 
<body onload="rebuild()">
echo '<head>';
echo ' <title>'._L('OIDplus Setup').'</title>';
echo ' <meta name="robots" content="noindex">';
echo ' <meta name="viewport" content="width=device-width, initial-scale=1.0">';
echo ' <link rel="stylesheet" href="setup.css">';
echo ' <script src="../3p/sha3_js/sha3.js"></script>'; // https://github.com/emn178/js-sha3
echo ' <script src="setup.js.php" type="text/javascript"></script>';
echo '</head>';
 
<h1>OIDplus Setup - Configuration File Generator</h1>
echo '<body>';
 
<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>.
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.</p>
echo '<h1>'._L('OIDplus Setup - Configuration File Generator').'</h1>';
 
<h2 id="systemCheckCaption" style="display:none">System check</h2>
echo OIDplusGui::getLanguageBox(null, false);
 
<div id="dirAccessWarning"></div>
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>';
 
<script>
function RemoveLastDirectoryPartOf(the_url) {
var the_arr = the_url.split('/');
if (the_arr.pop() == '') the_arr.pop();
return( the_arr.join('/') );
}
function checkAccess(dir) {
var url = '../' + dir;
var visibleUrl = RemoveLastDirectoryPartOf(window.location.href) + '/' + dir; // xhr.responseURL not available in IE
echo '<h2 id="systemCheckCaption" style="display:none">'._L('System check').'</h2>';
echo '<div id="dirAccessWarning"></div>';
 
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
document.getElementById('systemCheckCaption').style.display = 'block';
document.getElementById('dirAccessWarning').innerHTML = document.getElementById('dirAccessWarning').innerHTML + 'Attention: The following directory is world-readable: <a target="_blank" href="'+url+'">'+visibleUrl+'</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>';
}
}
};
echo '<div id="step1">';
echo '<h2>'._L('Step %1: Enter setup information',1).'</h2>';
 
xhr.open('GET', url);
xhr.send();
}
echo '<h3>'._L('Administrator password').'</h3>';
 
document.getElementById('dirAccessWarning').innerHTML = "";
checkAccess('userdata/index.html');
checkAccess('dev/index.html');
checkAccess('includes/index.html');
//checkAccess('plugins/publicPages/100_whois/whois/cli/index.html');
</script>
echo '<form id="step1_form">';
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>';
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>';
 
<div id="step1">
<h2>Step 1: Enter setup information</h2>
echo '<h3>'._L('Database connectivity').'</h3>';
 
<h3>Administrator password</h3>
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>';
 
<form id="step1_form">
<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>
<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>
echo _L('Database plugin').': <select name="db_plugin" onChange="dbplugin_changed()" id="db_plugin">';
 
<h3>Database connectivity</h3>
 
<p><a href="../doc/database_connectivity_diagram.png" target="_blank"><img src="../doc/database_connectivity_diagram.png" width="20%" alt="Database connectivity diagram" title="Database connectivity diagram"></a></p>
 
Database plugin: <select name="db_plugin" onChange="dbplugin_changed()" id="db_plugin">
 
<?php
 
OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', null);
foreach (get_declared_classes() as $c) {
if (is_subclass_of($c, 'OIDplusDatabasePlugin')) {
101,34 → 67,10
}
}
 
?>
</select>
echo '</select>';
 
<script>
echo '<div style="margin-left:50px">';
 
setupdir = '<?php echo (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER["HTTP_HOST"] . $_SERVER['REQUEST_URI']; ?>';
rebuild_callbacks = [];
rebuild_config_callbacks = [];
plugin_combobox_change_callbacks = [];
 
function dbplugin_changed() {
var e = document.getElementById("db_plugin");
var strPlugin = e.options[e.selectedIndex].value;
 
for (var i = 0; i < plugin_combobox_change_callbacks.length; i++) {
var f = plugin_combobox_change_callbacks[i];
f(strPlugin);
}
 
rebuild();
}
 
</script>
 
<div style="margin-left:50px">
 
<?php
 
OIDplus::registerAllPlugins('sqlSlang', 'OIDplusSqlSlangPlugin', null);
$sql_slang_selection = array();
foreach (get_declared_classes() as $c) {
154,59 → 96,49
}
 
if ($found_db_plugins == 0) {
echo '<p><font color="red">ERROR: No database plugins were found! You CANNOT use OIDplus without database connection.</font></p>';
echo '<p><font color="red">'._L('ERROR: No database plugins were found! You CANNOT use OIDplus without database connection.').'</font></p>';
}
 
?>
echo '</div>';
 
</div>
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>';
 
<script>
dbplugin_changed();
</script>
echo '<h3>'._L('ReCAPTCHA').'</h3>';
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>';
echo '<p>'._L('reCAPTCHA Public key').'<br><input id="recaptcha_public" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>';
echo '<p>'._L('reCAPTCHA Private key').'<br><input id="recaptcha_private" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>';
 
<p>Tablename prefix (e.g. <b>oidplus_</b>):<br><input id="tablename_prefix" type="text" value="oidplus_" onkeypress="rebuild()" onkeyup="rebuild()"></p>
echo '<h3>'._L('TLS').'</h3>';
echo '<p>'._L('SSL enforcement').'<br><select name="enforce_ssl" id="enforce_ssl" onclick="rebuild()">';
echo '<option value="0">'._L('No SSL available (don\'t redirect)').'</option>';
echo '<option value="1">'._L('Enforce SSL (always redirect)').'</option>';
echo '<option value="2" selected>'._L('Intelligent SSL detection (redirect if port 443 is open)').'</option>';
echo '</select></p>';
echo '</form>';
echo '</div>';
 
<h3>ReCAPTCHA</h3>
echo '<div id="step2">';
echo '<h2>'._L('Step %1: Initialize database',2).'</h2>';
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>';
echo '<p>'._L('Otherwise, import one of the following SQL dumps in your database:').'</p>';
echo '<p><ul>';
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>';
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>';
echo '</ul></p>';
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>';
echo '</div>';
 
<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>
<p>reCAPTCHA Public key<br><input id="recaptcha_public" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>
<p>reCAPTCHA Private key<br><input id="recaptcha_private" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>
echo '<div id="step3">';
echo '<h2>'._L('Step %1: Save %2 file',3,'userdata/baseconfig/config.inc.php').'</h2>';
echo '<p>'._L('Save following contents into the file <b>%1</b>:','userdata/baseconfig/config.inc.php').'</p>';
echo '<code><font color="darkblue"><div id="config"></div></font></code>';
echo '</div>';
 
<h3>TLS</h3>
echo '<div id="step4">';
echo '<h2>'._L('Step %1: Continue to next step',4).'</h2>';
echo '<p><input type="button" onclick="window.location.href=\'../\'" value="'._L('Continue').'"></p>';
// echo '<p><a href="../">Run the OIDplus system</a></p>';
echo '</div>';
 
<p>SSL enforcement<br><select name="enforce_ssl" id="enforce_ssl" onclick="rebuild()">
<option value="0">No SSL available (don't redirect)</option>
<option value="1">Enforce SSL (always redirect)</option>
<option value="2" selected>Intelligent SSL detection (redirect if port 443 is open)</option>
</select></p>
</form>
</div>
 
<div id="step2">
<h2>Step 2: Initialize database</h2>
<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>
<p>Otherwise, import one of the following MySQL dumps in your database:</p>
<p><ul>
<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>
<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>
 
</ul></p>
<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>
 
</div>
 
<div id="step3">
<h2>Step 3: Save userdata/baseconfig/config.inc.php file</h2>
<p>Save following contents into the file <b>userdata/baseconfig/config.inc.php</b>:</p>
<code><font color="darkblue"><div id="config"></div></font></code>
</div>
 
<div id="step4">
<h2>Step 4: Continue to next step</h2>
<p><input type="button" onclick="window.location.href='../'" value="Continue"></p>
<!-- <p><a href="../">Run the OIDplus system</a></p> -->
</div>
 
</body>
</html>
echo '</body>';
echo '</html>';