Rev 1086 | Rev 1125 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1086 | Rev 1116 | ||
---|---|---|---|
Line 28... | Line 28... | ||
28 | /*private*/ const QUERY_REGISTER_V1 = '1.3.6.1.4.1.37476.2.5.2.1.1.1'; |
28 | /*private*/ const QUERY_REGISTER_V1 = '1.3.6.1.4.1.37476.2.5.2.1.1.1'; |
29 | /*private*/ const QUERY_UNREGISTER_V1 = '1.3.6.1.4.1.37476.2.5.2.1.2.1'; |
29 | /*private*/ const QUERY_UNREGISTER_V1 = '1.3.6.1.4.1.37476.2.5.2.1.2.1'; |
30 | /*private*/ const QUERY_LISTALLSYSTEMIDS_V1 = '1.3.6.1.4.1.37476.2.5.2.1.3.1'; |
30 | /*private*/ const QUERY_LISTALLSYSTEMIDS_V1 = '1.3.6.1.4.1.37476.2.5.2.1.3.1'; |
31 | /*private*/ const QUERY_LIVESTATUS_V1 = '1.3.6.1.4.1.37476.2.5.2.1.4.1'; |
31 | /*private*/ const QUERY_LIVESTATUS_V1 = '1.3.6.1.4.1.37476.2.5.2.1.4.1'; |
32 | 32 | ||
- | 33 | /** |
|
- | 34 | * @param string $actionID |
|
- | 35 | * @return bool |
|
- | 36 | */ |
|
33 | public function csrfUnlock($actionID) { |
37 | public function csrfUnlock(string $actionID): bool { |
34 | if ($actionID == 'verify_pubkey') return true; |
38 | if ($actionID == 'verify_pubkey') return true; |
35 | return parent::csrfUnlock($actionID); |
39 | return parent::csrfUnlock($actionID); |
36 | } |
40 | } |
37 | 41 | ||
- | 42 | /** |
|
- | 43 | * @param string $actionID |
|
- | 44 | * @param array $params |
|
- | 45 | * @return array |
|
- | 46 | * @throws OIDplusException |
|
- | 47 | */ |
|
38 | public function action($actionID, $params) { |
48 | public function action(string $actionID, array $params): array { |
39 | if ($actionID == 'verify_pubkey') { |
49 | if ($actionID == 'verify_pubkey') { |
40 | _CheckParamExists($params, 'challenge'); |
50 | _CheckParamExists($params, 'challenge'); |
41 | 51 | ||
42 | $payload = 'oidplus-verify-pubkey:'.sha3_512($params['challenge']); |
52 | $payload = 'oidplus-verify-pubkey:'.sha3_512($params['challenge']); |
43 | 53 | ||
Line 49... | Line 59... | ||
49 | return array( |
59 | return array( |
50 | "status" => 0, |
60 | "status" => 0, |
51 | "response" => base64_encode($signature) |
61 | "response" => base64_encode($signature) |
52 | ); |
62 | ); |
53 | } else { |
63 | } else { |
54 | throw new OIDplusException(_L('Unknown action ID')); |
64 | return parent::action($actionID, $params); |
55 | } |
65 | } |
56 | } |
66 | } |
57 | 67 | ||
- | 68 | /** |
|
- | 69 | * @param string $id |
|
- | 70 | * @param array $out |
|
- | 71 | * @param bool $handled |
|
- | 72 | * @return void |
|
- | 73 | * @throws OIDplusConfigInitializationException |
|
- | 74 | * @throws OIDplusException |
|
- | 75 | */ |
|
58 | public function gui($id, &$out, &$handled) { |
76 | public function gui(string $id, array &$out, bool &$handled) { |
59 | if ($id === 'oidplus:srv_registration') { |
77 | if ($id === 'oidplus:srv_registration') { |
60 | $handled = true; |
78 | $handled = true; |
61 | $out['title'] = _L('System registration settings'); |
79 | $out['title'] = _L('System registration settings'); |
62 | $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : ''; |
80 | $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : ''; |
63 | 81 | ||
Line 206... | Line 224... | ||
206 | $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:srv_registration').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back to registration settings').'</a></p>' . |
224 | $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:srv_registration').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back to registration settings').'</a></p>' . |
207 | $json['content']; |
225 | $json['content']; |
208 | } |
226 | } |
209 | } |
227 | } |
210 | 228 | ||
- | 229 | /** |
|
- | 230 | * @return bool |
|
- | 231 | * @throws OIDplusException |
|
- | 232 | */ |
|
211 | protected function areWeRegistered() { |
233 | protected function areWeRegistered(): bool { |
212 | // To check if we are registered. Check it "anonymously" (i.e. without revealing our system ID) |
234 | // To check if we are registered. Check it "anonymously" (i.e. without revealing our system ID) |
213 | $res = url_get_contents('https://oidplus.viathinksoft.com/reg2/query.php?query='.self::QUERY_LISTALLSYSTEMIDS_V1); |
235 | $res = url_get_contents('https://oidplus.viathinksoft.com/reg2/query.php?query='.self::QUERY_LISTALLSYSTEMIDS_V1); |
214 | 236 | ||
215 | $json = @json_decode($res, true); |
237 | $json = @json_decode($res, true); |
216 | 238 | ||
Line 229... | Line 251... | ||
229 | $list = $json['list']; |
251 | $list = $json['list']; |
230 | 252 | ||
231 | return in_array(OIDplus::getSystemId(false), $list); |
253 | return in_array(OIDplus::getSystemId(false), $list); |
232 | } |
254 | } |
233 | 255 | ||
- | 256 | /** |
|
- | 257 | * @param $privacy_level |
|
- | 258 | * @return false|void |
|
- | 259 | * @throws OIDplusException |
|
- | 260 | */ |
|
234 | public function sendRegistrationQuery($privacy_level=null) { |
261 | public function sendRegistrationQuery($privacy_level=null) { |
235 | 262 | ||
236 | if (is_null($privacy_level)) { |
263 | if (is_null($privacy_level)) { |
237 | $privacy_level = OIDplus::config()->getValue('reg_privacy'); |
264 | $privacy_level = OIDplus::config()->getValue('reg_privacy'); |
238 | } |
265 | } |
Line 295... | Line 322... | ||
295 | if (!$json) { |
322 | if (!$json) { |
296 | return false; // throw new OIDplusException(_L('JSON reply from ViaThinkSoft decoding error: %1',$res)); |
323 | return false; // throw new OIDplusException(_L('JSON reply from ViaThinkSoft decoding error: %1',$res)); |
297 | } |
324 | } |
298 | 325 | ||
299 | if (isset($json['error']) || ($json['status'] < 0)) { |
326 | if (isset($json['error']) || ($json['status'] < 0)) { |
300 | if (isset($json['error'])) { |
- | |
301 | return false; // throw new OIDplusException(_L('Received error status code: %1',$json['error'])); |
- | |
302 | } else { |
- | |
303 | return false; // throw new OIDplusException(_L('Received error status code: %1',$json['status'])); |
327 | return false; // throw new OIDplusException(_L('Received error status code: %1',isset($json['error']) ? $json['error'] : $json['status'])); |
304 | } |
- | |
305 | } |
328 | } |
306 | } |
329 | } |
307 | } else { |
330 | } else { |
308 | if ($privacy_level == 0) { |
331 | if ($privacy_level == 0) { |
309 | $adminExportPlugin = OIDplus::getPluginByOid('1.3.6.1.4.1.37476.2.5.2.4.3.400'); // OIDplusPageAdminOIDInfoExport |
332 | $adminExportPlugin = OIDplus::getPluginByOid('1.3.6.1.4.1.37476.2.5.2.4.3.400'); // OIDplusPageAdminOIDInfoExport |
Line 421... | Line 444... | ||
421 | if (isset($json['vts_ca'])) OIDplus::config()->setValue('vts_ca', $json['vts_ca']); |
444 | if (isset($json['vts_ca'])) OIDplus::config()->setValue('vts_ca', $json['vts_ca']); |
422 | } |
445 | } |
423 | } |
446 | } |
424 | } |
447 | } |
425 | 448 | ||
- | 449 | /** |
|
- | 450 | * @param bool $html |
|
- | 451 | * @return void |
|
- | 452 | * @throws OIDplusException |
|
- | 453 | */ |
|
426 | public function init($html=true) { |
454 | public function init(bool $html=true) { |
427 | if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') { |
455 | if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') { |
428 | throw new OIDplusException(_L('This plugin is only available in the ViaThinkSoft edition of OIDplus')); |
456 | throw new OIDplusException(_L('This plugin is only available in the ViaThinkSoft edition of OIDplus')); |
429 | } |
457 | } |
430 | 458 | ||
431 | // Note: It is important that the default value is '2', otherwise, systems which don't have CURL will fail |
459 | // Note: It is important that the default value is '2', otherwise, systems which don't have CURL will fail |
Line 479... | Line 507... | ||
479 | } |
507 | } |
480 | } |
508 | } |
481 | } |
509 | } |
482 | } |
510 | } |
483 | 511 | ||
- | 512 | /** |
|
- | 513 | * @param array $json |
|
- | 514 | * @param string|null $ra_email |
|
- | 515 | * @param bool $nonjs |
|
- | 516 | * @param string $req_goto |
|
- | 517 | * @return bool |
|
- | 518 | * @throws OIDplusException |
|
- | 519 | */ |
|
484 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
520 | public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool { |
485 | if (!OIDplus::authUtils()->isAdminLoggedIn()) return false; |
521 | if (!OIDplus::authUtils()->isAdminLoggedIn()) return false; |
486 | 522 | ||
487 | if (file_exists(__DIR__.'/img/main_icon16.png')) { |
523 | if (file_exists(__DIR__.'/img/main_icon16.png')) { |
488 | $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png'; |
524 | $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png'; |
489 | } else { |
525 | } else { |
Line 497... | Line 533... | ||
497 | ); |
533 | ); |
498 | 534 | ||
499 | return true; |
535 | return true; |
500 | } |
536 | } |
501 | 537 | ||
- | 538 | /** |
|
- | 539 | * @param string $request |
|
- | 540 | * @return array|false |
|
- | 541 | */ |
|
502 | public function tree_search($request) { |
542 | public function tree_search(string $request) { |
503 | return false; |
543 | return false; |
504 | } |
544 | } |
505 | 545 | ||
- | 546 | /** |
|
- | 547 | * @param string $id |
|
- | 548 | * @return bool |
|
- | 549 | */ |
|
506 | public function implementsFeature($id) { |
550 | public function implementsFeature(string $id): bool { |
507 | if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.1') return true; // oobeEntry, oobeRequested |
551 | if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.1') return true; // oobeEntry, oobeRequested |
508 | if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications() |
552 | if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications() |
509 | return false; |
553 | return false; |
510 | } |
554 | } |
511 | 555 | ||
- | 556 | /** |
|
- | 557 | * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.1 |
|
- | 558 | * @return bool |
|
- | 559 | * @throws OIDplusException |
|
- | 560 | */ |
|
512 | public function oobeRequested(): bool { |
561 | public function oobeRequested(): bool { |
513 | // Interface 1.3.6.1.4.1.37476.2.5.2.3.1 |
- | |
514 | - | ||
515 | return OIDplus::config()->getValue('oobe_registration_done') == '0'; |
562 | return OIDplus::config()->getValue('oobe_registration_done') == '0'; |
516 | } |
563 | } |
517 | 564 | ||
- | 565 | /** |
|
- | 566 | * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.1 |
|
- | 567 | * @param $step |
|
- | 568 | * @param $do_edits |
|
- | 569 | * @param $errors_happened |
|
- | 570 | * @return void |
|
- | 571 | * @throws OIDplusConfigInitializationException |
|
- | 572 | * @throws OIDplusException |
|
- | 573 | */ |
|
518 | public function oobeEntry($step, $do_edits, &$errors_happened)/*: void*/ { |
574 | public function oobeEntry($step, $do_edits, &$errors_happened)/*: void*/ { |
519 | // Interface 1.3.6.1.4.1.37476.2.5.2.3.1 |
- | |
520 | - | ||
521 | echo '<h2>'._L('Step %1: System registration and automatic publishing (optional)',$step).'</h2>'; |
575 | echo '<h2>'._L('Step %1: System registration and automatic publishing (optional)',$step).'</h2>'; |
522 | 576 | ||
523 | if (file_exists(__DIR__ . '/info$'.OIDplus::getCurrentLang().'.html')) { |
577 | if (file_exists(__DIR__ . '/info$'.OIDplus::getCurrentLang().'.html')) { |
524 | $info = file_get_contents(__DIR__ . '/info$'.OIDplus::getCurrentLang().'.html'); |
578 | $info = file_get_contents(__DIR__ . '/info$'.OIDplus::getCurrentLang().'.html'); |
525 | } else { |
579 | } else { |
Line 618... | Line 672... | ||
618 | echo '<p>'._L('<i>Privacy information:</i> This setting can always be changed in the administrator login / control panel.').'<br>'; |
672 | echo '<p>'._L('<i>Privacy information:</i> This setting can always be changed in the administrator login / control panel.').'<br>'; |
619 | echo _L('<a %1>Click here</a> for more information about privacy related topics.','href="../../../../res/OIDplus/privacy_documentation.html" target="_blank"'); |
673 | echo _L('<a %1>Click here</a> for more information about privacy related topics.','href="../../../../res/OIDplus/privacy_documentation.html" target="_blank"'); |
620 | echo '</p>'; |
674 | echo '</p>'; |
621 | } |
675 | } |
622 | 676 | ||
- | 677 | /** |
|
- | 678 | * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8 |
|
- | 679 | * @param $user |
|
- | 680 | * @return array |
|
- | 681 | * @throws OIDplusException |
|
- | 682 | */ |
|
623 | public function getNotifications($user=null): array { |
683 | public function getNotifications($user=null): array { |
624 | // Interface 1.3.6.1.4.1.37476.2.5.2.3.8 |
- | |
625 | $notifications = array(); |
684 | $notifications = array(); |
626 | if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) { |
685 | if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) { |
627 | if (!function_exists('curl_init')) { |
686 | if (!function_exists('curl_init')) { |
628 | $title = _L('System registration'); |
687 | $title = _L('System registration'); |
629 | $notifications[] = array('ERR', _L('OIDplus plugin "%1" is enabled, but the required PHP extension "%2" is not installed.', '<a '.OIDplus::gui()->link('oidplus:srv_registration').'>'.htmlentities($title).'</a>', 'php_curl')); |
688 | $notifications[] = array('ERR', _L('OIDplus plugin "%1" is enabled, but the required PHP extension "%2" is not installed.', '<a '.OIDplus::gui()->link('oidplus:srv_registration').'>'.htmlentities($title).'</a>', 'php_curl')); |