Subversion Repositories oidplus

Rev

Rev 309 | Rev 362 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
82 daniel-mar 1
<?php
2
 
360 daniel-mar 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
// TODO: TRANSLATE
21
 
236 daniel-mar 22
require_once __DIR__ . '/../includes/oidplus.inc.php';
82 daniel-mar 23
 
24
?><!DOCTYPE html>
2 daniel-mar 25
<html lang="en">
26
 
27
<head>
157 daniel-mar 28
        <title>OIDplus Setup</title>
104 daniel-mar 29
        <meta name="robots" content="noindex">
157 daniel-mar 30
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
2 daniel-mar 31
        <link rel="stylesheet" href="setup.css">
32
        <script src="../3p/sha3_js/sha3.js"></script><!-- https://github.com/emn178/js-sha3 -->
33
        <script src="setup.js"></script>
34
</head>
35
 
104 daniel-mar 36
<body onload="rebuild()">
2 daniel-mar 37
 
157 daniel-mar 38
<h1>OIDplus Setup - Configuration File Generator</h1>
2 daniel-mar 39
 
294 daniel-mar 40
<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>.
157 daniel-mar 41
Setup does not automatically write to this file. Instead, you need to copy-paste the contents into the file.
42
Once OIDplus setup is finished, you can change the config file by hand, or run this setup assistant again.</p>
43
 
299 daniel-mar 44
<h2 id="systemCheckCaption" style="display:none">System check</h2>
45
 
46
<div id="dirAccessWarning"></div>
47
 
48
<script>
301 daniel-mar 49
function RemoveLastDirectoryPartOf(the_url) {
50
        var the_arr = the_url.split('/');
51
        if (the_arr.pop() == '') the_arr.pop();
52
        return( the_arr.join('/') );
53
}
299 daniel-mar 54
function checkAccess(dir) {
305 daniel-mar 55
        var url = '../' + dir;
56
        var visibleUrl = RemoveLastDirectoryPartOf(window.location.href) + '/' + dir; // xhr.responseURL not available in IE
301 daniel-mar 57
 
299 daniel-mar 58
        var xhr = new XMLHttpRequest();
59
        xhr.onreadystatechange = function() {
60
                if (xhr.readyState === 4) {
61
                        if (xhr.status === 200) {
62
                                document.getElementById('systemCheckCaption').style.display = 'block';
301 daniel-mar 63
                                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>';
299 daniel-mar 64
                        }
65
                }
66
        };
67
 
301 daniel-mar 68
        xhr.open('GET', url);
299 daniel-mar 69
        xhr.send();
70
}
71
 
72
document.getElementById('dirAccessWarning').innerHTML = "";
305 daniel-mar 73
checkAccess('userdata/index.html');
74
checkAccess('dev/index.html');
75
checkAccess('includes/index.html');
76
//checkAccess('plugins/publicPages/100_whois/whois/cli/index.html');
299 daniel-mar 77
</script>
78
 
2 daniel-mar 79
<div id="step1">
80
<h2>Step 1: Enter setup information</h2>
157 daniel-mar 81
 
82
<h3>Administrator password</h3>
83
 
2 daniel-mar 84
<form id="step1_form">
104 daniel-mar 85
<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>
86
<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>
150 daniel-mar 87
 
157 daniel-mar 88
<h3>Database connectivity</h3>
150 daniel-mar 89
 
309 daniel-mar 90
<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>
250 daniel-mar 91
 
150 daniel-mar 92
Database plugin: <select name="db_plugin" onChange="dbplugin_changed()" id="db_plugin">
236 daniel-mar 93
 
94
<?php
95
 
277 daniel-mar 96
OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', null);
236 daniel-mar 97
foreach (get_declared_classes() as $c) {
246 daniel-mar 98
        if (is_subclass_of($c, 'OIDplusDatabasePlugin')) {
275 daniel-mar 99
                $selected = $c::id() == 'MySQL' ? ' selected="true"' : '';
100
                echo '<option value="'.htmlentities($c::id()).'"'.$selected.'>'.htmlentities($c::id()).'</option>';
236 daniel-mar 101
        }
102
}
103
 
104
?>
150 daniel-mar 105
</select>
106
 
107
<script>
108
 
236 daniel-mar 109
setupdir = '<?php echo (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER["HTTP_HOST"] . $_SERVER['REQUEST_URI']; ?>';
150 daniel-mar 110
rebuild_callbacks = [];
111
rebuild_config_callbacks = [];
112
plugin_combobox_change_callbacks = [];
113
 
114
function dbplugin_changed() {
115
        var e = document.getElementById("db_plugin");
116
        var strPlugin = e.options[e.selectedIndex].value;
117
 
118
        for (var i = 0; i < plugin_combobox_change_callbacks.length; i++) {
119
                var f = plugin_combobox_change_callbacks[i];
120
                f(strPlugin);
121
        }
122
 
123
        rebuild();
124
}
125
 
126
</script>
127
 
128
<div style="margin-left:50px">
129
 
130
<?php
131
 
294 daniel-mar 132
OIDplus::registerAllPlugins('sqlSlang', 'OIDplusSqlSlangPlugin', null);
274 daniel-mar 133
$sql_slang_selection = array();
134
foreach (get_declared_classes() as $c) {
135
        if (is_subclass_of($c, 'OIDplusSqlSlangPlugin')) {
136
                $obj = new $c;
137
                $slang_id = $obj::id();
307 daniel-mar 138
                $pluginManifest = OIDplus::getpluginManifest($obj);
139
                $human_friendly_name = empty($pluginManifest->getName()) ? $pluginManifest->getName() : get_class($obj);
274 daniel-mar 140
                $sql_slang_selection[] = '<option value="'.$slang_id.'">'.$human_friendly_name.'</option>';
141
        }
142
}
143
$sql_slang_selection = implode("\n", $sql_slang_selection);
144
 
305 daniel-mar 145
$found_db_plugins = 0;
146
OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', null);
147
foreach (get_declared_classes() as $c) {
148
        if (is_subclass_of($c, 'OIDplusDatabasePlugin')) {
149
                $found_db_plugins++;
150
                $cont = $c::setupHTML();
151
                $cont = str_replace('<!-- %SQL_SLANG_SELECTION% -->', $sql_slang_selection, $cont);
152
                echo $cont;
277 daniel-mar 153
        }
154
}
155
 
305 daniel-mar 156
if ($found_db_plugins == 0) {
236 daniel-mar 157
        echo '<p><font color="red">ERROR: No database plugins were found! You CANNOT use OIDplus without database connection.</font></p>';
150 daniel-mar 158
}
159
 
160
?>
161
 
162
</div>
163
 
164
<script>
165
dbplugin_changed();
166
</script>
167
 
104 daniel-mar 168
<p>Tablename prefix (e.g. <b>oidplus_</b>):<br><input id="tablename_prefix" type="text" value="oidplus_" onkeypress="rebuild()" onkeyup="rebuild()"></p>
157 daniel-mar 169
 
170
<h3>ReCAPTCHA</h3>
171
 
172
<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>
173
<p>reCAPTCHA Public key<br><input id="recaptcha_public" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>
174
<p>reCAPTCHA Private key<br><input id="recaptcha_private" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>
175
 
176
<h3>TLS</h3>
177
 
104 daniel-mar 178
<p>SSL enforcement<br><select name="enforce_ssl" id="enforce_ssl" onclick="rebuild()">
80 daniel-mar 179
<option value="0">No SSL available (don't redirect)</option>
180
<option value="1">Enforce SSL (always redirect)</option>
82 daniel-mar 181
<option value="2" selected>Intelligent SSL detection (redirect if port 443 is open)</option>
80 daniel-mar 182
</select></p>
2 daniel-mar 183
</form>
184
</div>
185
 
186
<div id="step2">
237 daniel-mar 187
<h2>Step 2: Initialize database</h2>
239 daniel-mar 188
<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>
81 daniel-mar 189
<p>Otherwise, import one of the following MySQL dumps in your database:</p>
2 daniel-mar 190
<p><ul>
150 daniel-mar 191
        <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>
192
        <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>
193
 
2 daniel-mar 194
</ul></p>
150 daniel-mar 195
<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>
80 daniel-mar 196
 
2 daniel-mar 197
</div>
198
 
199
<div id="step3">
294 daniel-mar 200
<h2>Step 3: Save userdata/baseconfig/config.inc.php file</h2>
201
<p>Save following contents into the file <b>userdata/baseconfig/config.inc.php</b>:</p>
2 daniel-mar 202
<code><font color="darkblue"><div id="config"></div></font></code>
203
</div>
204
 
205
<div id="step4">
80 daniel-mar 206
<h2>Step 4: Continue to next step</h2>
154 daniel-mar 207
<p><input type="button" onclick="window.location.href='../'" value="Continue"></p>
80 daniel-mar 208
<!-- <p><a href="../">Run the OIDplus system</a></p> -->
2 daniel-mar 209
</div>
210
 
211
</body>
360 daniel-mar 212
</html>