Subversion Repositories oidplus

Rev

Rev 1020 | Rev 1031 | 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
1030 daniel-mar 5
 * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
360 daniel-mar 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
 
236 daniel-mar 20
require_once __DIR__ . '/../includes/oidplus.inc.php';
82 daniel-mar 21
 
1030 daniel-mar 22
define('BASECONFIG_FILE', 'userdata/baseconfig/config.inc.php');
23
$already_setup = file_exists(__DIR__.'/../'.BASECONFIG_FILE);
24
 
362 daniel-mar 25
OIDplus::handleLangArgument();
2 daniel-mar 26
 
362 daniel-mar 27
echo '<!DOCTYPE html>';
504 daniel-mar 28
echo '<html lang="'.substr(OIDplus::getCurrentLang(),0,2).'">';
2 daniel-mar 29
 
362 daniel-mar 30
echo '<head>';
31
echo '  <title>'._L('OIDplus Setup').'</title>';
32
echo '  <meta name="robots" content="noindex">';
33
echo '  <meta name="viewport" content="width=device-width, initial-scale=1.0">';
364 daniel-mar 34
echo '  <link rel="stylesheet" href="setup.min.css.php">';
504 daniel-mar 35
echo '  <link rel="shortcut icon" type="image/x-icon" href="../favicon.ico.php">';
364 daniel-mar 36
echo '  <script src="setup.min.js.php" type="text/javascript"></script>';
362 daniel-mar 37
echo '</head>';
2 daniel-mar 38
 
362 daniel-mar 39
echo '<body>';
2 daniel-mar 40
 
362 daniel-mar 41
echo '<h1>'._L('OIDplus Setup - Configuration File Generator').'</h1>';
157 daniel-mar 42
 
561 daniel-mar 43
echo '<noscript>';
44
echo '<h2>'._L('Please enable JavaScript in order to use setup!').'</h2>';
45
echo '</noscript>';
46
 
47
echo '<span id="setupPageContent" style="display:None">';
48
 
564 daniel-mar 49
echo OIDplus::gui()->getLanguageBox(null, false);
299 daniel-mar 50
 
1030 daniel-mar 51
echo '<p>';
52
if ($already_setup) {
53
        echo _L('This assistant will help you updating the file <b>%1</b>.',BASECONFIG_FILE);
54
} else {
55
        echo _L('Thank you very much for choosing OIDplus!');
56
        echo ' ';
57
        echo _L('This setup assistant will help you creating the file <b>%1</b>.',BASECONFIG_FILE);
58
}
59
echo ' ';
60
echo _L('This assistant 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>';
61
echo '</p>';
299 daniel-mar 62
 
362 daniel-mar 63
echo '<h2 id="systemCheckCaption" style="display:none">'._L('System check').'</h2>';
64
echo '<div id="dirAccessWarning"></div>';
301 daniel-mar 65
 
362 daniel-mar 66
echo '<div id="step1">';
67
echo '<h2>'._L('Step %1: Enter setup information',1).'</h2>';
299 daniel-mar 68
 
702 daniel-mar 69
// ----------------------------------------
70
 
362 daniel-mar 71
echo '<h3>'._L('Administrator password').'</h3>';
299 daniel-mar 72
 
362 daniel-mar 73
echo '<form id="step1_form">';
74
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>';
75
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>';
299 daniel-mar 76
 
702 daniel-mar 77
// ----------------------------------------
78
 
362 daniel-mar 79
echo '<h3>'._L('Database connectivity').'</h3>';
157 daniel-mar 80
 
479 daniel-mar 81
if (file_exists(__DIR__ . '/../doc/database_connectivity_diagram.png')) {
82
        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>';
83
}
157 daniel-mar 84
 
362 daniel-mar 85
echo _L('Database plugin').': <select name="db_plugin" onChange="dbplugin_changed()" id="db_plugin">';
150 daniel-mar 86
 
380 daniel-mar 87
OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin'));
88
foreach (OIDplus::getDatabasePlugins() as $plugin) {
89
        $selected = $plugin::id() == 'MySQL' ? ' selected="true"' : '';
90
        echo '<option value="'.htmlentities($plugin::id()).'"'.$selected.'>'.htmlentities($plugin::id()).'</option>';
236 daniel-mar 91
}
92
 
362 daniel-mar 93
echo '</select>';
150 daniel-mar 94
 
362 daniel-mar 95
echo '<div style="margin-left:50px">';
150 daniel-mar 96
 
380 daniel-mar 97
OIDplus::registerAllPlugins('sqlSlang', 'OIDplusSqlSlangPlugin', array('OIDplus','registerSqlSlangPlugin'));
274 daniel-mar 98
$sql_slang_selection = array();
380 daniel-mar 99
foreach (OIDplus::getSqlSlangPlugins() as $plugin) {
100
        $slang_id = $plugin::id();
101
        $pluginManifest = $plugin->getManifest();
502 daniel-mar 102
        $human_friendly_name = empty($pluginManifest->getName()) ? get_class($plugin) : $pluginManifest->getName();
380 daniel-mar 103
        $sql_slang_selection[] = '<option value="'.$slang_id.'">'.$human_friendly_name.'</option>';
274 daniel-mar 104
}
105
$sql_slang_selection = implode("\n", $sql_slang_selection);
106
 
305 daniel-mar 107
$found_db_plugins = 0;
380 daniel-mar 108
//OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin'));
109
foreach (OIDplus::getDatabasePlugins() as $plugin) {
110
        $found_db_plugins++;
111
        $cont = $plugin->setupHTML();
112
        $cont = str_replace('<!-- %SQL_SLANG_SELECTION% -->', $sql_slang_selection, $cont);
113
        echo $cont;
277 daniel-mar 114
}
115
 
305 daniel-mar 116
if ($found_db_plugins == 0) {
362 daniel-mar 117
        echo '<p><font color="red">'._L('ERROR: No database plugins were found! You CANNOT use OIDplus without database connection.').'</font></p>';
150 daniel-mar 118
}
119
 
362 daniel-mar 120
echo '</div>';
150 daniel-mar 121
 
362 daniel-mar 122
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>';
150 daniel-mar 123
 
702 daniel-mar 124
// ----------------------------------------
150 daniel-mar 125
 
702 daniel-mar 126
echo '<h3>'._L('CAPTCHA').'</h3>';
127
 
703 daniel-mar 128
// TODO: Add a small explanation here, in case somebody does not know what CAPTCHA is
129
 
702 daniel-mar 130
echo _L('CAPTCHA plugin').': <select name="captcha_plugin" onChange="captchaplugin_changed()" id="captcha_plugin">';
131
 
132
OIDplus::registerAllPlugins('captcha', 'OIDplusCaptchaPlugin', array('OIDplus','registerCaptchaPlugin'));
133
foreach (OIDplus::getCaptchaPlugins() as $plugin) {
1020 daniel-mar 134
        $selected = strtolower($plugin::id()) === strtolower('None') ? ' selected="true"' : ''; // select "None" by default
702 daniel-mar 135
        echo '<option value="'.htmlentities($plugin::id()).'"'.$selected.'>'.htmlentities($plugin::id()).'</option>';
136
}
137
 
138
echo '</select>';
139
 
140
echo '<div style="margin-left:50px">';
141
 
142
$found_captcha_plugins = 0;
143
foreach (OIDplus::getCaptchaPlugins() as $plugin) {
144
        $found_captcha_plugins++;
145
        $cont = $plugin->setupHTML();
146
        echo $cont;
147
}
148
 
149
if ($found_captcha_plugins == 0) {
150
        echo '<p><font color="red">'._L('ERROR: No CAPTCHA plugins were found! You CANNOT use OIDplus without the "%1" CAPTCHA plugin.','None').'</font></p>';
151
}
152
 
153
echo '</div>';
154
 
155
// ----------------------------------------
156
 
974 daniel-mar 157
$is_ssl = OIDplus::isSSL();
158
echo '<h3>'._L('Secure connection (HTTPS)').'</h3>';
985 daniel-mar 159
echo '<p>'._L('Enforcement of a secure connection:').'<br><select name="enforce_ssl" id="enforce_ssl" onchange="rebuild()">';
974 daniel-mar 160
echo '<option value="OIDplus::ENFORCE_SSL_NO">'._L('No SSL available (don\'t redirect)').'</option>';
161
echo '<option value="OIDplus::ENFORCE_SSL_YES"'.($is_ssl ? ' selected' : '').'>'._L('Enforce SSL (always redirect)').'</option>';
162
echo '<option value="OIDplus::ENFORCE_SSL_AUTO"'.(!$is_ssl ? ' selected' : '').'>'._L('Intelligent SSL detection (redirect if port 443 is open)').'</option>';
362 daniel-mar 163
echo '</select></p>';
1020 daniel-mar 164
 
165
// ----------------------------------------
166
 
167
echo '<h3>'._L('Public URL of this system (Canonical URL)').'</h3>';
168
 
169
echo '<p><input id="canonical_url" type="text" value="'.htmlentities(OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL)).'" onkeypress="rebuild()" onkeyup="rebuild()" style="width:550px"></p>';
170
 
171
// ----------------------------------------
172
 
362 daniel-mar 173
echo '</form>';
174
echo '</div>';
157 daniel-mar 175
 
362 daniel-mar 176
echo '<div id="step2">';
177
echo '<h2>'._L('Step %1: Initialize database',2).'</h2>';
1030 daniel-mar 178
if ($already_setup) {
179
        echo '<p><input type="checkbox" id="step2_enable"> <label for="step2_enable"><font color="red">'._L('Re-Install database (all data will be deleted)').'</font></label></p>';
180
}
181
echo '<div id="step2_inner">';
182
echo '<p>'._L('Please import one of the following SQL dumps in your database:').'</p>';
362 daniel-mar 183
echo '<p><ul>';
184
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>';
185
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>';
186
echo '</ul></p>';
1030 daniel-mar 187
echo '<p><font color="red">'._L('Warning: Existing OIDplus data will be deleted during the initialization of the database.').'</font></p>';
362 daniel-mar 188
echo '</div>';
1030 daniel-mar 189
if ($already_setup) {
190
        echo '<script>';
191
        echo '$("#step2_enable").click(function() {';
192
        echo '    if ($(this).is(":checked")) {';
193
        echo '        $("#step2_inner").show();';
194
        echo '    } else {';
195
        echo '        $("#step2_inner").hide();';
196
        echo '    }';
197
        echo '});';
198
        echo '$("#step2_inner").hide();';
199
        echo '</script>';
200
}
201
echo '</div>';
157 daniel-mar 202
 
702 daniel-mar 203
// ----------------------------------------
204
 
362 daniel-mar 205
echo '<div id="step3">';
1030 daniel-mar 206
echo '<h2>'._L('Step %1: Save %2 file',3,BASECONFIG_FILE).'</h2>';
207
echo '<p>'._L('Save following contents into the file <b>%1</b>',BASECONFIG_FILE).'</p>';
362 daniel-mar 208
echo '<code><font color="darkblue"><div id="config"></div></font></code>';
982 daniel-mar 209
echo '<p><input type="button" value="'._L('Copy to clipboard').'" onClick="copyToClipboard(config)"></p>';
362 daniel-mar 210
echo '</div>';
157 daniel-mar 211
 
702 daniel-mar 212
// ----------------------------------------
213
 
362 daniel-mar 214
echo '<div id="step4">';
1030 daniel-mar 215
if ($already_setup) {
216
        echo '<h2>'._L('Step %1: Start OIDplus',4).'</h2>';
217
} else {
218
        echo '<h2>'._L('Step %1: Continue to next step',4).'</h2>';
219
}
362 daniel-mar 220
echo '<p><input type="button" onclick="window.location.href=\'../\'" value="'._L('Continue').'"></p>';
221
echo '</div>';
157 daniel-mar 222
 
379 daniel-mar 223
echo '<br><br><br>'; // because of iPhone Safari
366 daniel-mar 224
 
561 daniel-mar 225
echo '</span>';
226
echo '<script> $("#setupPageContent")[0].style.display = "Block"; </script>';
227
 
362 daniel-mar 228
echo '</body>';
410 daniel-mar 229
echo '</html>';