Subversion Repositories oidplus

Rev

Rev 504 | Rev 561 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 504 Rev 511
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * OIDplus 2.0
4
 * OIDplus 2.0
5
 * Copyright 2019 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
6
 *
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with 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
9
 * You may obtain a copy of the License at
10
 *
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
17
 * limitations under the License.
18
 */
18
 */
19
 
19
 
20
require_once __DIR__ . '/../includes/oidplus.inc.php';
20
require_once __DIR__ . '/../includes/oidplus.inc.php';
21
 
21
 
22
OIDplus::handleLangArgument();
22
OIDplus::handleLangArgument();
23
 
23
 
24
echo '<!DOCTYPE html>';
24
echo '<!DOCTYPE html>';
25
echo '<html lang="'.substr(OIDplus::getCurrentLang(),0,2).'">';
25
echo '<html lang="'.substr(OIDplus::getCurrentLang(),0,2).'">';
26
 
26
 
27
echo '<head>';
27
echo '<head>';
28
echo '  <title>'._L('OIDplus Setup').'</title>';
28
echo '  <title>'._L('OIDplus Setup').'</title>';
29
echo '  <meta name="robots" content="noindex">';
29
echo '  <meta name="robots" content="noindex">';
30
echo '  <meta name="viewport" content="width=device-width, initial-scale=1.0">';
30
echo '  <meta name="viewport" content="width=device-width, initial-scale=1.0">';
31
echo '  <link rel="stylesheet" href="setup.min.css.php">';
31
echo '  <link rel="stylesheet" href="setup.min.css.php">';
32
echo '  <link rel="shortcut icon" type="image/x-icon" href="../favicon.ico.php">';
32
echo '  <link rel="shortcut icon" type="image/x-icon" href="../favicon.ico.php">';
33
echo '  <script src="setup.min.js.php" type="text/javascript"></script>';
33
echo '  <script src="setup.min.js.php" type="text/javascript"></script>';
34
echo '</head>';
34
echo '</head>';
35
 
35
 
36
echo '<body>';
36
echo '<body>';
37
 
37
 
38
echo '<h1>'._L('OIDplus Setup - Configuration File Generator').'</h1>';
38
echo '<h1>'._L('OIDplus Setup - Configuration File Generator').'</h1>';
39
 
39
 
40
echo OIDplusGui::getLanguageBox(null, false);
40
echo OIDplusGui::getLanguageBox(null, false);
41
 
41
 
42
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>';
42
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>';
43
 
43
 
44
echo '<h2 id="systemCheckCaption" style="display:none">'._L('System check').'</h2>';
44
echo '<h2 id="systemCheckCaption" style="display:none">'._L('System check').'</h2>';
45
echo '<div id="dirAccessWarning"></div>';
45
echo '<div id="dirAccessWarning"></div>';
46
 
46
 
47
echo '<div id="step1">';
47
echo '<div id="step1">';
48
echo '<h2>'._L('Step %1: Enter setup information',1).'</h2>';
48
echo '<h2>'._L('Step %1: Enter setup information',1).'</h2>';
49
 
49
 
50
echo '<h3>'._L('Administrator password').'</h3>';
50
echo '<h3>'._L('Administrator password').'</h3>';
51
 
51
 
52
echo '<form id="step1_form">';
52
echo '<form id="step1_form">';
53
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>';
53
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>';
54
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>';
54
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>';
55
 
55
 
56
echo '<h3>'._L('Database connectivity').'</h3>';
56
echo '<h3>'._L('Database connectivity').'</h3>';
57
 
57
 
58
if (file_exists(__DIR__ . '/../doc/database_connectivity_diagram.png')) {
58
if (file_exists(__DIR__ . '/../doc/database_connectivity_diagram.png')) {
59
        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>';
59
        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>';
60
}
60
}
61
 
61
 
62
echo _L('Database plugin').': <select name="db_plugin" onChange="dbplugin_changed()" id="db_plugin">';
62
echo _L('Database plugin').': <select name="db_plugin" onChange="dbplugin_changed()" id="db_plugin">';
63
 
63
 
64
OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin'));
64
OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin'));
65
foreach (OIDplus::getDatabasePlugins() as $plugin) {
65
foreach (OIDplus::getDatabasePlugins() as $plugin) {
66
        $selected = $plugin::id() == 'MySQL' ? ' selected="true"' : '';
66
        $selected = $plugin::id() == 'MySQL' ? ' selected="true"' : '';
67
        echo '<option value="'.htmlentities($plugin::id()).'"'.$selected.'>'.htmlentities($plugin::id()).'</option>';
67
        echo '<option value="'.htmlentities($plugin::id()).'"'.$selected.'>'.htmlentities($plugin::id()).'</option>';
68
}
68
}
69
 
69
 
70
echo '</select>';
70
echo '</select>';
71
 
71
 
72
echo '<div style="margin-left:50px">';
72
echo '<div style="margin-left:50px">';
73
 
73
 
74
OIDplus::registerAllPlugins('sqlSlang', 'OIDplusSqlSlangPlugin', array('OIDplus','registerSqlSlangPlugin'));
74
OIDplus::registerAllPlugins('sqlSlang', 'OIDplusSqlSlangPlugin', array('OIDplus','registerSqlSlangPlugin'));
75
$sql_slang_selection = array();
75
$sql_slang_selection = array();
76
foreach (OIDplus::getSqlSlangPlugins() as $plugin) {
76
foreach (OIDplus::getSqlSlangPlugins() as $plugin) {
77
        $slang_id = $plugin::id();
77
        $slang_id = $plugin::id();
78
        $pluginManifest = $plugin->getManifest();
78
        $pluginManifest = $plugin->getManifest();
79
        $human_friendly_name = empty($pluginManifest->getName()) ? get_class($plugin) : $pluginManifest->getName();
79
        $human_friendly_name = empty($pluginManifest->getName()) ? get_class($plugin) : $pluginManifest->getName();
80
        $sql_slang_selection[] = '<option value="'.$slang_id.'">'.$human_friendly_name.'</option>';
80
        $sql_slang_selection[] = '<option value="'.$slang_id.'">'.$human_friendly_name.'</option>';
81
}
81
}
82
$sql_slang_selection = implode("\n", $sql_slang_selection);
82
$sql_slang_selection = implode("\n", $sql_slang_selection);
83
 
83
 
84
$found_db_plugins = 0;
84
$found_db_plugins = 0;
85
//OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin'));
85
//OIDplus::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin'));
86
foreach (OIDplus::getDatabasePlugins() as $plugin) {
86
foreach (OIDplus::getDatabasePlugins() as $plugin) {
87
        $found_db_plugins++;
87
        $found_db_plugins++;
88
        $cont = $plugin->setupHTML();
88
        $cont = $plugin->setupHTML();
89
        $cont = str_replace('<!-- %SQL_SLANG_SELECTION% -->', $sql_slang_selection, $cont);
89
        $cont = str_replace('<!-- %SQL_SLANG_SELECTION% -->', $sql_slang_selection, $cont);
90
        echo $cont;
90
        echo $cont;
91
}
91
}
92
 
92
 
93
if ($found_db_plugins == 0) {
93
if ($found_db_plugins == 0) {
94
        echo '<p><font color="red">'._L('ERROR: No database plugins were found! You CANNOT use OIDplus without database connection.').'</font></p>';
94
        echo '<p><font color="red">'._L('ERROR: No database plugins were found! You CANNOT use OIDplus without database connection.').'</font></p>';
95
}
95
}
96
 
96
 
97
echo '</div>';
97
echo '</div>';
98
 
98
 
99
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>';
99
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>';
100
 
100
 
101
echo '<h3>'._L('ReCAPTCHA').'</h3>';
101
echo '<h3>'._L('ReCAPTCHA').'</h3>';
102
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>';
102
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>';
103
echo '<p>'._L('reCAPTCHA Public key').'<br><input id="recaptcha_public" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>';
103
echo '<p>'._L('reCAPTCHA Public key').'<br><input id="recaptcha_public" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>';
104
echo '<p>'._L('reCAPTCHA Private key').'<br><input id="recaptcha_private" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>';
104
echo '<p>'._L('reCAPTCHA Private key').'<br><input id="recaptcha_private" type="text" onkeypress="rebuild()" onkeyup="rebuild()"></p>';
105
 
105
 
106
echo '<h3>'._L('TLS').'</h3>';
106
echo '<h3>'._L('TLS').'</h3>';
107
echo '<p>'._L('SSL enforcement').'<br><select name="enforce_ssl" id="enforce_ssl" onclick="rebuild()">';
107
echo '<p>'._L('SSL enforcement').'<br><select name="enforce_ssl" id="enforce_ssl" onclick="rebuild()">';
108
echo '<option value="0">'._L('No SSL available (don\'t redirect)').'</option>';
108
echo '<option value="0">'._L('No SSL available (don\'t redirect)').'</option>';
109
echo '<option value="1">'._L('Enforce SSL (always redirect)').'</option>';
109
echo '<option value="1">'._L('Enforce SSL (always redirect)').'</option>';
110
echo '<option value="2" selected>'._L('Intelligent SSL detection (redirect if port 443 is open)').'</option>';
110
echo '<option value="2" selected>'._L('Intelligent SSL detection (redirect if port 443 is open)').'</option>';
111
echo '</select></p>';
111
echo '</select></p>';
112
echo '</form>';
112
echo '</form>';
113
echo '</div>';
113
echo '</div>';
114
 
114
 
115
echo '<div id="step2">';
115
echo '<div id="step2">';
116
echo '<h2>'._L('Step %1: Initialize database',2).'</h2>';
116
echo '<h2>'._L('Step %1: Initialize database',2).'</h2>';
117
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>';
117
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>';
118
echo '<p>'._L('Otherwise, import one of the following SQL dumps in your database:').'</p>';
118
echo '<p>'._L('Otherwise, import one of the following SQL dumps in your database:').'</p>';
119
echo '<p><ul>';
119
echo '<p><ul>';
120
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>';
120
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>';
121
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>';
121
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>';
122
echo '</ul></p>';
122
echo '</ul></p>';
123
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>';
123
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>';
124
echo '</div>';
124
echo '</div>';
125
 
125
 
126
echo '<div id="step3">';
126
echo '<div id="step3">';
127
echo '<h2>'._L('Step %1: Save %2 file',3,'userdata/baseconfig/config.inc.php').'</h2>';
127
echo '<h2>'._L('Step %1: Save %2 file',3,'userdata/baseconfig/config.inc.php').'</h2>';
128
echo '<p>'._L('Save following contents into the file <b>%1</b>','userdata/baseconfig/config.inc.php').'</p>';
128
echo '<p>'._L('Save following contents into the file <b>%1</b>','userdata/baseconfig/config.inc.php').'</p>';
129
echo '<code><font color="darkblue"><div id="config"></div></font></code>';
129
echo '<code><font color="darkblue"><div id="config"></div></font></code>';
130
echo '</div>';
130
echo '</div>';
131
 
131
 
132
echo '<div id="step4">';
132
echo '<div id="step4">';
133
echo '<h2>'._L('Step %1: Continue to next step',4).'</h2>';
133
echo '<h2>'._L('Step %1: Continue to next step',4).'</h2>';
134
echo '<p><input type="button" onclick="window.location.href=\'../\'" value="'._L('Continue').'"></p>';
134
echo '<p><input type="button" onclick="window.location.href=\'../\'" value="'._L('Continue').'"></p>';
135
// echo '<p><a href="../">Run the OIDplus system</a></p>';
135
// echo '<p><a href="../">Run the OIDplus system</a></p>';
136
echo '</div>';
136
echo '</div>';
137
 
137
 
138
echo '<br><br><br>'; // because of iPhone Safari
138
echo '<br><br><br>'; // because of iPhone Safari
139
 
139
 
140
echo '</body>';
140
echo '</body>';
141
echo '</html>';
141
echo '</html>';
142
 
142