Rev 1050 | Rev 1116 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
635 | daniel-mar | 1 | <?php |
2 | |||
3 | /* |
||
4 | * OIDplus 2.0 |
||
1086 | daniel-mar | 5 | * Copyright 2019 - 2023 Daniel Marschall, ViaThinkSoft |
635 | 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 | |||
1050 | daniel-mar | 20 | namespace ViaThinkSoft\OIDplus; |
635 | daniel-mar | 21 | |
1086 | daniel-mar | 22 | // phpcs:disable PSR1.Files.SideEffects |
23 | \defined('INSIDE_OIDPLUS') or die; |
||
24 | // phpcs:enable PSR1.Files.SideEffects |
||
25 | |||
635 | daniel-mar | 26 | class OIDplusPageAdminVNagVersionCheck extends OIDplusPagePluginAdmin { |
27 | |||
28 | public function init($html=true) { |
||
29 | OIDplus::config()->prepareConfigKey('vnag_version_check_password_protected', 'If set to 1 ("on"), the VNag version check is password protected', '1', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
||
30 | if (($value != '0') && ($value != '1')) { |
||
31 | throw new OIDplusException(_L('Please enter either 0 ("off") or 1 ("on").')); |
||
32 | } |
||
33 | }); |
||
34 | } |
||
35 | |||
36 | public function action($actionID, $params) { |
||
37 | } |
||
38 | |||
39 | public function gui($id, &$out, &$handled) { |
||
40 | $parts = explode('.',$id,2); |
||
41 | if (!isset($parts[1])) $parts[1] = ''; |
||
42 | if ($parts[0] == 'oidplus:vnag_version_check') { |
||
43 | @set_time_limit(0); |
||
44 | |||
45 | |||
46 | $handled = true; |
||
47 | $out['title'] = _L('VNag version check'); |
||
801 | daniel-mar | 48 | $out['icon'] = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png'; |
635 | daniel-mar | 49 | |
50 | if (!OIDplus::authUtils()->isAdminLoggedIn()) { |
||
800 | daniel-mar | 51 | $out['icon'] = 'img/error.png'; |
635 | daniel-mar | 52 | $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>'; |
53 | return; |
||
54 | } |
||
55 | |||
56 | if (file_exists(__DIR__ . '/tutorial$'.OIDplus::getCurrentLang().'.html')) { |
||
57 | $cont = file_get_contents(__DIR__ . '/tutorial$'.OIDplus::getCurrentLang().'.html'); |
||
58 | } else if (file_exists(__DIR__ . '/tutorial.html')) { |
||
59 | $cont = file_get_contents(__DIR__ . '/tutorial.html'); |
||
60 | } else { |
||
61 | $cont = ''; |
||
62 | } |
||
63 | |||
64 | $cont = str_replace('%%SYSTEM_URL%%',OIDplus::localpath(),$cont); |
||
65 | $cont = str_replace('%%REL_LOC_PATH%%',OIDplus::localpath(__DIR__,true),$cont); |
||
801 | daniel-mar | 66 | $cont = str_replace('%%REL_WEB_PATH%%',OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE),$cont); |
635 | daniel-mar | 67 | $cont = str_replace('%%ABS_LOC_PATH%%',OIDplus::localpath(__DIR__,false),$cont); |
801 | daniel-mar | 68 | $cont = str_replace('%%ABS_WEB_PATH%%',OIDplus::webpath(__DIR__,OIDplus::PATH_ABSOLUTE_CANONICAL),$cont); |
635 | daniel-mar | 69 | if (OIDplus::config()->getValue('vnag_version_check_password_protected','1') == '1') { |
70 | $cont = str_replace('%%WEBREADER_PASSWORD%%',self::vnag_password(),$cont); |
||
71 | } else { |
||
72 | $cont = str_replace('%%WEBREADER_PASSWORD%%','',$cont); |
||
73 | } |
||
74 | if (OIDplus::getPkiStatus()) { |
||
830 | daniel-mar | 75 | $pubkey = trim(OIDplus::getSystemPublicKey()); |
635 | daniel-mar | 76 | $pubkey = str_replace("\\","\\\\",$pubkey); |
77 | $pubkey = str_replace("\r","\\r",$pubkey); |
||
78 | $pubkey = str_replace("\n","\\n",$pubkey); |
||
79 | } else { |
||
80 | $pubkey = ""; |
||
81 | } |
||
82 | $cont = str_replace('%%WEBREADER_PUBKEY%%',$pubkey,$cont); |
||
83 | |||
84 | $out['text'] .= $cont; |
||
85 | } else { |
||
86 | $handled = false; |
||
87 | } |
||
88 | } |
||
89 | |||
90 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
||
91 | if (!OIDplus::authUtils()->isAdminLoggedIn()) return false; |
||
92 | |||
800 | daniel-mar | 93 | if (file_exists(__DIR__.'/img/main_icon16.png')) { |
801 | daniel-mar | 94 | $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png'; |
635 | daniel-mar | 95 | } else { |
96 | $tree_icon = null; // default icon (folder) |
||
97 | } |
||
98 | |||
99 | $json[] = array( |
||
100 | 'id' => 'oidplus:vnag_version_check', |
||
101 | 'icon' => $tree_icon, |
||
102 | 'text' => _L('VNag version check') |
||
103 | ); |
||
104 | |||
105 | return true; |
||
106 | } |
||
107 | |||
108 | public function tree_search($request) { |
||
109 | return false; |
||
110 | } |
||
111 | |||
112 | public static function vnag_password() { |
||
113 | return sha3_512(OIDplus::baseConfig()->getValue('SERVER_SECRET').'/VNAG'); |
||
114 | } |
||
115 | |||
116 | } |