Rev 224 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 224 | Rev 227 | ||
---|---|---|---|
Line 68... | Line 68... | ||
68 | $out['text'] = '<p>You need to <a '.oidplus_link('oidplus:login').'>log in</a> as administrator.</p>'; |
68 | $out['text'] = '<p>You need to <a '.oidplus_link('oidplus:login').'>log in</a> as administrator.</p>'; |
69 | } else { |
69 | } else { |
70 | $out['text'] = file_get_contents(__DIR__ . '/info.tpl'). |
70 | $out['text'] = file_get_contents(__DIR__ . '/info.tpl'). |
71 | '<p><input type="button" onclick="openOidInPanel(\'oidplus:srvreg_status\');" value="Check status of the registration and collected data"></p>'; |
71 | '<p><input type="button" onclick="openOidInPanel(\'oidplus:srvreg_status\');" value="Check status of the registration and collected data"></p>'; |
72 | 72 | ||
- | 73 | if (defined('REGISTRATION_HIDE_SYSTEM') && REGISTRATION_HIDE_SYSTEM) { |
|
- | 74 | $out['text'] .= '<p><font color="red"><b>Attention!</b> <code>REGISTRATION_HIDE_SYSTEM</code> is set in the local configuration file! Therefore, this system will not register itself, despire the settings below.</font></p>'; |
|
- | 75 | } |
|
- | 76 | ||
73 | if (!function_exists('openssl_sign')) { |
77 | if (!function_exists('openssl_sign')) { |
74 | $out['text'] .= '<p><font color="red">Error: OpenSSL plugin is missing in PHP. You cannot (un)register your OIDplus instance.</font></p>'; |
78 | $out['text'] .= '<p><font color="red">Error: OpenSSL plugin is missing in PHP. You cannot (un)register your OIDplus instance.</font></p>'; |
75 | } else { |
79 | } else { |
76 | $out['text'] .= '<p>You can adjust your privacy level here:</p><p><select name="reg_privacy" id="reg_privacy">'; |
80 | $out['text'] .= '<p>You can adjust your privacy level here:</p><p><select name="reg_privacy" id="reg_privacy">'; |
77 | 81 | ||
Line 120... | Line 124... | ||
120 | 124 | ||
121 | $query = QUERY_LIVESTATUS_V1; |
125 | $query = QUERY_LIVESTATUS_V1; |
122 | 126 | ||
123 | $payload = array( |
127 | $payload = array( |
124 | "query" => $query, // we must repeat the query because we want to sign it |
128 | "query" => $query, // we must repeat the query because we want to sign it |
125 | "system_id" => OIDplus::system_id(false) |
129 | "system_id" => OIDplus::getSystemId(false) |
126 | ); |
130 | ); |
127 | 131 | ||
128 | $signature = ''; |
132 | $signature = ''; |
129 | openssl_sign(json_encode($payload), $signature, OIDplus::config()->getValue('oidplus_private_key')); |
133 | openssl_sign(json_encode($payload), $signature, OIDplus::config()->getValue('oidplus_private_key')); |
130 | 134 | ||
Line 154... | Line 158... | ||
154 | public function sendRegistrationQuery($privacy_level=null) { |
158 | public function sendRegistrationQuery($privacy_level=null) { |
155 | if (is_null($privacy_level)) { |
159 | if (is_null($privacy_level)) { |
156 | $privacy_level = OIDplus::config()->getValue('reg_privacy'); |
160 | $privacy_level = OIDplus::config()->getValue('reg_privacy'); |
157 | } |
161 | } |
158 | 162 | ||
159 | $system_url = OIDplus::system_url(); |
163 | $system_url = OIDplus::getSystemUrl(); |
160 | 164 | ||
161 | // It is very important that we set the ping time NOW, because ViaThinkSoft might contact us during the ping, |
165 | // It is very important that we set the ping time NOW, because ViaThinkSoft might contact us during the ping, |
162 | // and this would cause an endless loop! |
166 | // and this would cause an endless loop! |
163 | OIDplus::config()->setValue('reg_last_ping', time()); |
167 | OIDplus::config()->setValue('reg_last_ping', time()); |
164 | 168 | ||
165 | if ($privacy_level == 2) { |
169 | if ($privacy_level == 2) { |
166 | // The user wants to unregister |
170 | // The user wants to unregister |
167 | // but we only unregister if we are registered. Check this "anonymously" (i.e. without revealing our system ID) |
171 | // but we only unregister if we are registered. Check this "anonymously" (i.e. without revealing our system ID) |
168 | if (in_array(OIDplus::system_id(false), explode(';',file_get_contents('https://oidplus.viathinksoft.com/reg2/query.php?query='.QUERY_LISTALLSYSTEMIDS_V1)))) { |
172 | if (in_array(OIDplus::getSystemId(false), explode(';',file_get_contents('https://oidplus.viathinksoft.com/reg2/query.php?query='.QUERY_LISTALLSYSTEMIDS_V1)))) { |
169 | $query = QUERY_UNREGISTER_V1; |
173 | $query = QUERY_UNREGISTER_V1; |
170 | 174 | ||
171 | $payload = array( |
175 | $payload = array( |
172 | "query" => $query, // we must repeat the query because we want to sign it |
176 | "query" => $query, // we must repeat the query because we want to sign it |
173 | "system_id" => OIDplus::system_id(false) |
177 | "system_id" => OIDplus::getSystemId(false) |
174 | ); |
178 | ); |
175 | 179 | ||
176 | $signature = ''; |
180 | $signature = ''; |
177 | openssl_sign(json_encode($payload), $signature, OIDplus::config()->getValue('oidplus_private_key')); |
181 | openssl_sign(json_encode($payload), $signature, OIDplus::config()->getValue('oidplus_private_key')); |
178 | 182 | ||
Line 208... | Line 212... | ||
208 | } |
212 | } |
209 | 213 | ||
210 | $query = QUERY_REGISTER_V1; |
214 | $query = QUERY_REGISTER_V1; |
211 | 215 | ||
212 | $root_oids = array(); |
216 | $root_oids = array(); |
213 | foreach (OIDplus::getRegisteredObjectTypes() as $ot) { |
217 | foreach (OIDplus::getEnabledObjectTypes() as $ot) { |
214 | if ($ot::ns() == 'oid') { |
218 | if ($ot::ns() == 'oid') { |
215 | $res = OIDplus::db()->query("select id from ".OIDPLUS_TABLENAME_PREFIX."objects where " . |
219 | $res = OIDplus::db()->query("select id from ".OIDPLUS_TABLENAME_PREFIX."objects where " . |
216 | "parent = 'oid:' " . |
220 | "parent = 'oid:' " . |
217 | "order by ".OIDplus::db()->natOrder('id')); |
221 | "order by ".OIDplus::db()->natOrder('id')); |
218 | while ($row = OIDplus::db()->fetch_array($res)) { |
222 | while ($row = OIDplus::db()->fetch_array($res)) { |
Line 221... | Line 225... | ||
221 | } |
225 | } |
222 | } |
226 | } |
223 | $payload = array( |
227 | $payload = array( |
224 | "query" => $query, // we must repeat the query because we want to sign it |
228 | "query" => $query, // we must repeat the query because we want to sign it |
225 | "privacy_level" => $privacy_level, |
229 | "privacy_level" => $privacy_level, |
226 | "system_id" => OIDplus::system_id(false), |
230 | "system_id" => OIDplus::getSystemId(false), |
227 | "public_key" => OIDplus::config()->getValue('oidplus_public_key'), |
231 | "public_key" => OIDplus::config()->getValue('oidplus_public_key'), |
228 | "system_url" => $system_url, |
232 | "system_url" => $system_url, |
229 | "hide_system_url" => 0, |
233 | "hide_system_url" => 0, |
230 | "hide_public_key" => 0, |
234 | "hide_public_key" => 0, |
231 | "admin_email" => OIDplus::config()->getValue('admin_email'), |
235 | "admin_email" => OIDplus::config()->getValue('admin_email'), |
Line 260... | Line 264... | ||
260 | // Delete the system ID since we have a conflict with the 31-bit hash! |
264 | // Delete the system ID since we have a conflict with the 31-bit hash! |
261 | OIDplus::config()->setValue('oidplus_private_key', ''); |
265 | OIDplus::config()->setValue('oidplus_private_key', ''); |
262 | OIDplus::config()->setValue('oidplus_public_key', ''); |
266 | OIDplus::config()->setValue('oidplus_public_key', ''); |
263 | 267 | ||
264 | // Try to generate a new system ID |
268 | // Try to generate a new system ID |
265 | OIDplus::pkiStatus(true); |
269 | OIDplus::getPkiStatus(true); |
266 | 270 | ||
267 | // Enforce a new registration attempt at the next run |
271 | // Enforce a new registration attempt at the next run |
268 | // We will not try again here, because that might lead to an endless loop if the VTS server would always return 'HASH_CONFLCIT' |
272 | // We will not try again here, because that might lead to an endless loop if the VTS server would always return 'HASH_CONFLCIT' |
269 | OIDplus::config()->setValue('reg_last_ping', 0); |
273 | OIDplus::config()->setValue('reg_last_ping', 0); |
270 | } |
274 | } |
Line 280... | Line 284... | ||
280 | OIDplus::config()->prepareConfigKey('reg_ping_interval', 'Registration ping interval (in seconds)', '3600', 0, 0); |
284 | OIDplus::config()->prepareConfigKey('reg_ping_interval', 'Registration ping interval (in seconds)', '3600', 0, 0); |
281 | OIDplus::config()->prepareConfigKey('reg_last_ping', 'Last ping to ViaThinkSoft directory services', '0', 1, 0); |
285 | OIDplus::config()->prepareConfigKey('reg_last_ping', 'Last ping to ViaThinkSoft directory services', '0', 1, 0); |
282 | 286 | ||
283 | // REGISTRATION_HIDE_SYSTEM is an undocumented constant that can be put in the config.inc.php files of a test system accessing the same database as the productive system that is registered. |
287 | // REGISTRATION_HIDE_SYSTEM is an undocumented constant that can be put in the config.inc.php files of a test system accessing the same database as the productive system that is registered. |
284 | // This avoids that the URL of the productive system is overridden with the test system URL (since they use the same database, they also have the same system ID) |
288 | // This avoids that the URL of the productive system is overridden with the test system URL (since they use the same database, they also have the same system ID) |
285 | if (function_exists('openssl_sign') && !defined('REGISTRATION_HIDE_SYSTEM')) { |
289 | if (function_exists('openssl_sign') && (!defined('REGISTRATION_HIDE_SYSTEM') || !REGISTRATION_HIDE_SYSTEM)) { |
286 | // Show registration wizard once |
290 | // Show registration wizard once |
287 | 291 | ||
288 | if ($html && (OIDplus::config()->getValue('reg_wizard_done') != '1')) { |
292 | if ($html && (OIDplus::config()->getValue('reg_wizard_done') != '1')) { |
289 | if (basename($_SERVER['SCRIPT_NAME']) != 'registration.php') { |
293 | if (basename($_SERVER['SCRIPT_NAME']) != 'registration.php') { |
290 | if ($system_url = OIDplus::system_url()) { |
294 | if ($system_url = OIDplus::getSystemUrl()) { |
291 | header('Location:'.$system_url.'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/registration.php'); |
295 | header('Location:'.$system_url.'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/registration.php'); |
292 | } else { |
296 | } else { |
293 | header('Location:plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/registration.php'); |
297 | header('Location:plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/registration.php'); |
294 | } |
298 | } |
295 | die(); |
299 | die(); |