Subversion Repositories oidplus

Rev

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

Rev 1018 Rev 1033
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * OIDplus 2.0
4
 * OIDplus 2.0
5
 * Copyright 2019 - 2021 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
ob_start(); // allow cookie headers to be sent
22
ob_start(); // allow cookie headers to be sent
23
 
23
 
24
header('Content-Type:text/html; charset=UTF-8');
24
header('Content-Type:text/html; charset=UTF-8');
25
 
25
 
26
OIDplus::init(true);
26
OIDplus::init(true);
27
set_exception_handler(array('OIDplusGui', 'html_exception_handler'));
27
set_exception_handler(array('OIDplusGui', 'html_exception_handler'));
28
 
28
 
29
if (OIDplus::baseConfig()->getValue('DISABLE_PLUGIN_OIDplusPageAdminOOBE', false)) {
29
if (OIDplus::baseConfig()->getValue('DISABLE_PLUGIN_OIDplusPageAdminOOBE', false)) {
30
        throw new OIDplusException(_L('This plugin was disabled by the system administrator!'));
30
        throw new OIDplusException(_L('This plugin was disabled by the system administrator!'));
31
}
31
}
32
 
32
 
33
ob_start();
33
ob_start();
34
 
34
 
35
$step = 1;
35
$step = 1;
36
$errors_happened = false;
36
$errors_happened = false;
37
$edits_possible = true;
37
$edits_possible = true;
38
 
38
 
39
echo '<!DOCTYPE html>';
39
echo '<!DOCTYPE html>';
40
echo '<html lang="'.substr(OIDplus::getCurrentLang(),0,2).'">';
40
echo '<html lang="'.substr(OIDplus::getCurrentLang(),0,2).'">';
41
 
41
 
42
echo '<head>';
42
echo '<head>';
43
echo '  <title>'._L('OIDplus Setup').'</title>';
43
echo '  <title>'._L('OIDplus Setup').'</title>';
44
echo '  <meta name="robots" content="noindex">';
44
echo '  <meta name="robots" content="noindex">';
45
echo '  <meta name="viewport" content="width=device-width, initial-scale=1.0">';
45
echo '  <meta name="viewport" content="width=device-width, initial-scale=1.0">';
46
echo '  <script src="../../../../oidplus.min.js.php"></script>';
46
echo '  <script src="../../../../oidplus.min.js.php"></script>';
47
echo '  <script src="../../../../polyfill.min.js.php"></script>';
47
echo '  <script src="../../../../polyfill.min.js.php"></script>';
48
echo '  <link rel="stylesheet" href="../../../../setup/setup.min.css.php">';
48
echo '  <link rel="stylesheet" href="../../../../setup/setup.min.css.php">';
49
echo '  <link rel="shortcut icon" type="image/x-icon" href="../../../../favicon.ico.php">';
49
echo '  <link rel="shortcut icon" type="image/x-icon" href="../../../../favicon.ico.php">';
50
echo '</head>';
50
echo '</head>';
51
 
51
 
52
echo '<body>';
52
echo '<body>';
53
 
53
 
54
echo '<h1>'._L('OIDplus Setup - Initial Settings').'</h1>';
54
echo '<h1>'._L('OIDplus Setup - Initial Settings').'</h1>';
55
 
55
 
56
OIDplus::handleLangArgument();
56
OIDplus::handleLangArgument();
57
echo OIDplus::gui()->getLanguageBox(null, false);
57
echo OIDplus::gui()->getLanguageBox(null, false);
58
 
58
 
59
echo '<p>'._L('If you can read this, then your database login credentials are correct.').'</p>';
59
echo '<p>'._L('If you can read this, then your database login credentials are correct.').'</p>';
60
 
60
 
61
echo '<p>'._L('The following settings need to be configured once.<br>After setup is complete, you can change all these settings through the admin login area, if necessary.').'</p>';
61
echo '<p>'._L('The following settings need to be configured once.<br>After setup is complete, you can change all these settings through the admin login area, if necessary.').'</p>';
62
 
62
 
63
echo '<form method="POST" action="oobe.php">';
63
echo '<form method="POST" action="oobe.php">';
64
echo '<input type="hidden" name="sent" value="1">';
64
echo '<input type="hidden" name="sent" value="1">';
65
 
65
 
66
if (OIDplus::getActiveCaptchaPlugin()->isVisible()) echo '<p><u>'._L('Step %1: Solve CAPTCHA',$step++).'</u></p>';
66
if (OIDplus::getActiveCaptchaPlugin()->isVisible()) echo '<p><u>'._L('Step %1: Solve CAPTCHA',$step++).'</u></p>';
67
if (isset($_REQUEST['sent'])) {
67
if (isset($_POST['sent'])) {
68
        try {
68
        try {
69
                OIDplus::getActiveCaptchaPlugin()->captchaVerify($_POST);
69
                OIDplus::getActiveCaptchaPlugin()->captchaVerify($_POST);
70
        } catch (Exception $e) {
70
        } catch (Exception $e) {
71
                echo '<p><font color="red"><b>'.htmlentities($e->getMessage()).'</b></font></p>';
71
                echo '<p><font color="red"><b>'.htmlentities($e->getMessage()).'</b></font></p>';
72
                $errors_happened = true;
72
                $errors_happened = true;
73
                $edits_possible = false;
73
                $edits_possible = false;
74
        }
74
        }
75
}
75
}
76
echo OIDplus::getActiveCaptchaPlugin()->captchaGenerate(_L('Before logging in, please solve the following CAPTCHA'), _L('If the CAPTCHA does not work (e.g. because of wrong keys, please run <a href="%1">setup part 1</a> again or edit %2 manually).',OIDplus::webpath(null,OIDplus::PATH_RELATIVE).'setup/','userdata/baseconfig/config.inc.php'));
76
echo OIDplus::getActiveCaptchaPlugin()->captchaGenerate(_L('Before logging in, please solve the following CAPTCHA'), _L('If the CAPTCHA does not work (e.g. because of wrong keys, please run <a href="%1">setup part 1</a> again or edit %2 manually).',OIDplus::webpath(null,OIDplus::PATH_RELATIVE).'setup/','userdata/baseconfig/config.inc.php'));
77
 
77
 
78
echo '<p><u>'._L('Step %1: Authenticate',$step++).'</u></p>';
78
echo '<p><u>'._L('Step %1: Authenticate',$step++).'</u></p>';
79
 
79
 
80
if (OIDplus::authUtils()->isAdminLoggedIn()) {
80
if (OIDplus::authUtils()->isAdminLoggedIn()) {
81
 
81
 
82
        echo '<p><font color="green">You are already logged in as administrator.</font></p>';
82
        echo '<p><font color="green">You are already logged in as administrator.</font></p>';
83
 
83
 
84
} else {
84
} else {
85
 
85
 
86
        echo '<p>'._L('Please enter the administrator password you have entered before.').'</p>';
86
        echo '<p>'._L('Please enter the administrator password you have entered before.').'</p>';
87
 
87
 
88
        echo '<p><input type="password" name="admin_password" value=""> (<a href="'.OIDplus::webpath(null,OIDplus::PATH_RELATIVE).'setup/">'._L('Forgot password?').'</a>) ';
88
        echo '<p><input type="password" name="admin_password" value=""> (<a href="'.OIDplus::webpath(null,OIDplus::PATH_RELATIVE).'setup/">'._L('Forgot password?').'</a>) ';
89
 
89
 
90
        if (isset($_REQUEST['sent'])) {
90
        if (isset($_POST['sent'])) {
91
                if (!OIDplus::authUtils()->adminCheckPassword(isset($_REQUEST['admin_password']) ? $_REQUEST['admin_password'] : '')) {
91
                if (!OIDplus::authUtils()->adminCheckPassword(isset($_POST['admin_password']) ? $_POST['admin_password'] : '')) {
92
                        $errors_happened = true;
92
                        $errors_happened = true;
93
                        $edits_possible = false;
93
                        $edits_possible = false;
94
                        echo '<font color="red"><b>'._L('Wrong password').'</b></font>';
94
                        echo '<font color="red"><b>'._L('Wrong password').'</b></font>';
95
                }
95
                }
96
        }
96
        }
97
 
97
 
98
        echo '</p>';
98
        echo '</p>';
99
}
99
}
100
 
100
 
101
#------------------------
101
#------------------------
102
$do_edits = isset($_REQUEST['sent']) && $edits_possible;;
102
$do_edits = isset($_POST['sent']) && $edits_possible;;
103
#------------------------
103
#------------------------
104
 
104
 
105
# ---
105
# ---
106
 
106
 
107
function step_admin_email($step, $do_edits, &$errors_happened) {
107
function step_admin_email($step, $do_edits, &$errors_happened) {
108
        echo '<p><u>'._L('Step %1: Please enter the email address of the system administrator',$step).'</u></p>';
108
        echo '<p><u>'._L('Step %1: Please enter the email address of the system administrator',$step).'</u></p>';
109
        echo '<input type="text" name="admin_email" value="';
109
        echo '<input type="text" name="admin_email" value="';
110
 
110
 
111
        $msg = '';
111
        $msg = '';
112
        if (isset($_REQUEST['sent'])) {
112
        if (isset($_POST['sent'])) {
113
                echo htmlentities(isset($_REQUEST['admin_email']) ? $_REQUEST['admin_email'] : '');
113
                echo htmlentities(isset($_POST['admin_email']) ? $_POST['admin_email'] : '');
114
                if ($do_edits) {
114
                if ($do_edits) {
115
                        try {
115
                        try {
116
                                OIDplus::config()->setValue('admin_email', isset($_REQUEST['admin_email']) ? $_REQUEST['admin_email'] : '');
116
                                OIDplus::config()->setValue('admin_email', isset($_POST['admin_email']) ? $_POST['admin_email'] : '');
117
                        } catch (Exception $e) {
117
                        } catch (Exception $e) {
118
                                $msg = $e->getMessage();
118
                                $msg = $e->getMessage();
119
                                $errors_happened = true;
119
                                $errors_happened = true;
120
                        }
120
                        }
121
                }
121
                }
122
        } else {
122
        } else {
123
                echo htmlentities(OIDplus::config()->getValue('admin_email'));
123
                echo htmlentities(OIDplus::config()->getValue('admin_email'));
124
        }
124
        }
125
 
125
 
126
        echo '" size="25"> <font color="red"><b>'.$msg.'</b></font>';
126
        echo '" size="25"> <font color="red"><b>'.$msg.'</b></font>';
127
}
127
}
128
step_admin_email($step++, $do_edits, $errors_happened);
128
step_admin_email($step++, $do_edits, $errors_happened);
129
 
129
 
130
# ---
130
# ---
131
 
131
 
132
function step_system_title($step, $do_edits, &$errors_happened) {
132
function step_system_title($step, $do_edits, &$errors_happened) {
133
        echo '<p><u>'._L('Step %1: What title should your Registration Authority / OIDplus instance have?',$step).'</u></p>';
133
        echo '<p><u>'._L('Step %1: What title should your Registration Authority / OIDplus instance have?',$step).'</u></p>';
134
        echo '<input type="text" name="system_title" value="';
134
        echo '<input type="text" name="system_title" value="';
135
 
135
 
136
        $msg = '';
136
        $msg = '';
137
        if (isset($_REQUEST['sent'])) {
137
        if (isset($_POST['sent'])) {
138
                echo htmlentities(isset($_REQUEST['system_title']) ? $_REQUEST['system_title'] : '');
138
                echo htmlentities(isset($_POST['system_title']) ? $_POST['system_title'] : '');
139
                if ($do_edits) {
139
                if ($do_edits) {
140
                        try {
140
                        try {
141
                                OIDplus::config()->setValue('system_title', isset($_REQUEST['system_title']) ? $_REQUEST['system_title'] : '');
141
                                OIDplus::config()->setValue('system_title', isset($_POST['system_title']) ? $_POST['system_title'] : '');
142
                        } catch (Exception $e) {
142
                        } catch (Exception $e) {
143
                                $msg = $e->getMessage();
143
                                $msg = $e->getMessage();
144
                                $errors_happened = true;
144
                                $errors_happened = true;
145
                        }
145
                        }
146
                }
146
                }
147
        } else {
147
        } else {
148
                echo htmlentities(OIDplus::config()->getValue('system_title'));
148
                echo htmlentities(OIDplus::config()->getValue('system_title'));
149
        }
149
        }
150
 
150
 
151
        echo '" size="50"> <font color="red"><b>'.$msg.'</b></font>';
151
        echo '" size="50"> <font color="red"><b>'.$msg.'</b></font>';
152
}
152
}
153
step_system_title($step++, $do_edits, $errors_happened);
153
step_system_title($step++, $do_edits, $errors_happened);
154
 
154
 
155
# ---
155
# ---
156
 
156
 
157
foreach (OIDplus::getAllPlugins() as $plugin) {
157
foreach (OIDplus::getAllPlugins() as $plugin) {
158
        if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.1')) {
158
        if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.1')) {
159
                $plugin->oobeEntry($step++, $do_edits, $errors_happened);
159
                $plugin->oobeEntry($step++, $do_edits, $errors_happened);
160
        }
160
        }
161
}
161
}
162
 
162
 
163
# ---
163
# ---
164
 
164
 
165
echo '<p><u>'._L('Step %1: Save settings and start OIDplus',$step).'</u></p>';
165
echo '<p><u>'._L('Step %1: Save settings and start OIDplus',$step).'</u></p>';
166
echo '<input type="submit" value="'._L('Save and start OIDplus!').'">';
166
echo '<input type="submit" value="'._L('Save and start OIDplus!').'">';
167
echo '</form>';
167
echo '</form>';
168
 
168
 
169
$pki_status = OIDplus::getPkiStatus();
169
$pki_status = OIDplus::getPkiStatus();
170
 
170
 
171
if ($pki_status) {
171
if ($pki_status) {
172
 
172
 
173
        echo '<p><u>'._L('Your OIDplus system ID (derived from the public key) is:').'</u></p>';
173
        echo '<p><u>'._L('Your OIDplus system ID (derived from the public key) is:').'</u></p>';
174
 
174
 
175
        echo '<b>';
175
        echo '<b>';
176
        $sysid_oid = OIDplus::getSystemId(true);
176
        $sysid_oid = OIDplus::getSystemId(true);
177
        if (!$sysid_oid) $sysid_oid = _L('Unknown!');
177
        if (!$sysid_oid) $sysid_oid = _L('Unknown!');
178
        echo htmlentities($sysid_oid);
178
        echo htmlentities($sysid_oid);
179
        echo '</b>';
179
        echo '</b>';
180
 
180
 
181
        echo '<p><u>'._L('Your public key is:').'</u></p>';
181
        echo '<p><u>'._L('Your public key is:').'</u></p>';
182
 
182
 
183
        $val = OIDplus::getSystemPublicKey();
183
        $val = OIDplus::getSystemPublicKey();
184
        if ($val) {
184
        if ($val) {
185
                echo '<pre>'.htmlentities($val).'</pre>';
185
                echo '<pre>'.htmlentities($val).'</pre>';
186
        } else {
186
        } else {
187
                echo '<p>'._L('Private/Public key creation failed').'</p>';
187
                echo '<p>'._L('Private/Public key creation failed').'</p>';
188
        }
188
        }
189
 
189
 
190
}
190
}
191
 
191
 
192
echo '<br><br><br>'; // because of iPhone Safari
192
echo '<br><br><br>'; // because of iPhone Safari
193
 
193
 
194
echo '</body>';
194
echo '</body>';
195
 
195
 
196
echo '</html>';
196
echo '</html>';
197
 
197
 
198
$cont = ob_get_contents();
198
$cont = ob_get_contents();
199
ob_end_clean();
199
ob_end_clean();
200
 
200
 
201
if ($do_edits && !$errors_happened)  {
201
if ($do_edits && !$errors_happened)  {
202
        OIDplus::config()->setValue('oobe_main_done', '1');
202
        OIDplus::config()->setValue('oobe_main_done', '1');
203
        OIDplus::invoke_shutdown();
203
        OIDplus::invoke_shutdown();
204
        header('Location:../../../../');
204
        header('Location:../../../../');
205
} else {
205
} else {
206
        OIDplus::invoke_shutdown();
206
        OIDplus::invoke_shutdown();
207
        echo $cont;
207
        echo $cont;
208
}
208
}
209
 
209