Subversion Repositories oidplus

Rev

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

Rev 1008 Rev 1050
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
if (!defined('INSIDE_OIDPLUS')) die();
20
namespace ViaThinkSoft\OIDplus;
21
 
21
 
22
class OIDplusPageAdminOIDInfoExport extends OIDplusPagePluginAdmin {
22
class OIDplusPageAdminOIDInfoExport extends OIDplusPagePluginAdmin {
23
 
23
 
24
        /*private*/ const QUERY_LIST_OIDINFO_OIDS_V1 = '1.3.6.1.4.1.37476.2.5.2.1.5.1';
24
        /*private*/ const QUERY_LIST_OIDINFO_OIDS_V1 = '1.3.6.1.4.1.37476.2.5.2.1.5.1';
25
        /*private*/ const QUERY_GET_OIDINFO_DATA_V1  = '1.3.6.1.4.1.37476.2.5.2.1.6.1';
25
        /*private*/ const QUERY_GET_OIDINFO_DATA_V1  = '1.3.6.1.4.1.37476.2.5.2.1.6.1';
26
 
26
 
27
        public function action($actionID, $params) {
27
        public function action($actionID, $params) {
28
 
28
 
29
                if ($actionID == 'import_xml_file') {
29
                if ($actionID == 'import_xml_file') {
30
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
30
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
31
                                throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')));
31
                                throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')));
32
                        }
32
                        }
33
 
33
 
34
                        if (!isset($_FILES['userfile'])) {
34
                        if (!isset($_FILES['userfile'])) {
35
                                throw new OIDplusException(_L('Please choose a file.'));
35
                                throw new OIDplusException(_L('Please choose a file.'));
36
                        }
36
                        }
37
 
37
 
38
                        $xml_contents = file_get_contents($_FILES['userfile']['tmp_name']);
38
                        $xml_contents = file_get_contents($_FILES['userfile']['tmp_name']);
39
 
39
 
40
                        $errors = array();
40
                        $errors = array();
41
                        list($count_imported_oids, $count_already_existing, $count_errors, $count_warnings) = $this->oidinfoImportXML($xml_contents, $errors, $replaceExistingOIDs=false, $orphan_mode=self::ORPHAN_AUTO_DEORPHAN);
41
                        list($count_imported_oids, $count_already_existing, $count_errors, $count_warnings) = $this->oidinfoImportXML($xml_contents, $errors, $replaceExistingOIDs=false, $orphan_mode=self::ORPHAN_AUTO_DEORPHAN);
42
                        if (count($errors) > 0) {
42
                        if (count($errors) > 0) {
43
                                // Note: These "errors" can also be warnings (partial success)
43
                                // Note: These "errors" can also be warnings (partial success)
44
                                // TODO: since the output can be very long, should we really show it in a JavaScript alert() ?!
44
                                // TODO: since the output can be very long, should we really show it in a JavaScript alert() ?!
45
                                return array(
45
                                return array(
46
                                        "status" => -1,
46
                                        "status" => -1,
47
                                        "count_imported_oids" => $count_imported_oids,
47
                                        "count_imported_oids" => $count_imported_oids,
48
                                        "count_already_existing" => $count_already_existing,
48
                                        "count_already_existing" => $count_already_existing,
49
                                        "count_errors" => $count_errors,
49
                                        "count_errors" => $count_errors,
50
                                        "count_warnings" => $count_warnings,
50
                                        "count_warnings" => $count_warnings,
51
                                        "error" => implode("\n",$errors)
51
                                        "error" => implode("\n",$errors)
52
                                );
52
                                );
53
                        } else {
53
                        } else {
54
                                return array(
54
                                return array(
55
                                        "status" => 0,
55
                                        "status" => 0,
56
                                        "count_imported_oids" => $count_imported_oids,
56
                                        "count_imported_oids" => $count_imported_oids,
57
                                        "count_already_existing" => $count_already_existing,
57
                                        "count_already_existing" => $count_already_existing,
58
                                        "count_errors" => $count_errors,
58
                                        "count_errors" => $count_errors,
59
                                        "count_warnings" => $count_warnings
59
                                        "count_warnings" => $count_warnings
60
                                );
60
                                );
61
                        }
61
                        }
62
                } else if ($actionID == 'import_oidinfo_oid') {
62
                } else if ($actionID == 'import_oidinfo_oid') {
63
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
63
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
64
                                throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')));
64
                                throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')));
65
                        }
65
                        }
66
 
66
 
67
                        _CheckParamExists($params, 'oid');
67
                        _CheckParamExists($params, 'oid');
68
 
68
 
69
                        $oid = $params['oid'];
69
                        $oid = $params['oid'];
70
 
70
 
71
                        $query = self::QUERY_GET_OIDINFO_DATA_V1;
71
                        $query = self::QUERY_GET_OIDINFO_DATA_V1;
72
 
72
 
73
                        $payload = array(
73
                        $payload = array(
74
                                "query" => $query, // we must repeat the query because we want to sign it
74
                                "query" => $query, // we must repeat the query because we want to sign it
75
                                "system_id" => OIDplus::getSystemId(false),
75
                                "system_id" => OIDplus::getSystemId(false),
76
                                "oid" => $oid
76
                                "oid" => $oid
77
                        );
77
                        );
78
 
78
 
79
                        $signature = '';
79
                        $signature = '';
80
                        if (!OIDplus::getPkiStatus() || !@openssl_sign(json_encode($payload), $signature, OIDplus::getSystemPrivateKey())) {
80
                        if (!OIDplus::getPkiStatus() || !@openssl_sign(json_encode($payload), $signature, OIDplus::getSystemPrivateKey())) {
81
                                if (!OIDplus::getPkiStatus()) {
81
                                if (!OIDplus::getPkiStatus()) {
82
                                        throw new OIDplusException(_L('Error: Your system could not generate a private/public key pair. (OpenSSL is probably missing on your system). Therefore, you cannot register/unregister your OIDplus instance.'));
82
                                        throw new OIDplusException(_L('Error: Your system could not generate a private/public key pair. (OpenSSL is probably missing on your system). Therefore, you cannot register/unregister your OIDplus instance.'));
83
                                } else {
83
                                } else {
84
                                        throw new OIDplusException(_L('Signature failed'));
84
                                        throw new OIDplusException(_L('Signature failed'));
85
                                }
85
                                }
86
                        }
86
                        }
87
 
87
 
88
                        $data = array(
88
                        $data = array(
89
                                "payload" => $payload,
89
                                "payload" => $payload,
90
                                "signature" => base64_encode($signature)
90
                                "signature" => base64_encode($signature)
91
                        );
91
                        );
92
 
92
 
93
                        if (!function_exists('curl_init')) {
93
                        if (!function_exists('curl_init')) {
94
                                throw new OIDplusException(_L('The "%1" PHP extension is not installed at your system. Please enable the PHP extension <code>%2</code>.','CURL','php_curl'));
94
                                throw new OIDplusException(_L('The "%1" PHP extension is not installed at your system. Please enable the PHP extension <code>%2</code>.','CURL','php_curl'));
95
                        }
95
                        }
96
 
96
 
97
                        if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
97
                        if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
98
                                // The oid-info.com import functionality is a confidential API between ViaThinkSoft and oid-info.com and cannot be used in forks of OIDplus
98
                                // The oid-info.com import functionality is a confidential API between ViaThinkSoft and oid-info.com and cannot be used in forks of OIDplus
99
                                throw new OIDplusException(_L('This feature is only available in the ViaThinkSoft edition of OIDplus'));
99
                                throw new OIDplusException(_L('This feature is only available in the ViaThinkSoft edition of OIDplus'));
100
                        }
100
                        }
101
 
101
 
102
                        $ch = curl_init();
102
                        $ch = curl_init();
103
                        if (ini_get('curl.cainfo') == '') curl_setopt($ch, CURLOPT_CAINFO, OIDplus::localpath() . 'vendor/cacert.pem');
103
                        if (ini_get('curl.cainfo') == '') curl_setopt($ch, CURLOPT_CAINFO, OIDplus::localpath() . 'vendor/cacert.pem');
104
                        curl_setopt($ch, CURLOPT_URL, 'https://oidplus.viathinksoft.com/reg2/query.php');
104
                        curl_setopt($ch, CURLOPT_URL, 'https://oidplus.viathinksoft.com/reg2/query.php');
105
                        curl_setopt($ch, CURLOPT_USERAGENT, 'ViaThinkSoft-OIDplus/2.0');
105
                        curl_setopt($ch, CURLOPT_USERAGENT, 'ViaThinkSoft-OIDplus/2.0');
106
                        curl_setopt($ch, CURLOPT_POST, 1);
106
                        curl_setopt($ch, CURLOPT_POST, 1);
107
                        if (function_exists('gzdeflate')) {
107
                        if (function_exists('gzdeflate')) {
108
                                $compressed = "1";
108
                                $compressed = "1";
109
                                $data2 = gzdeflate(json_encode($data));
109
                                $data2 = gzdeflate(json_encode($data));
110
                        } else {
110
                        } else {
111
                                $compressed = "0";
111
                                $compressed = "0";
112
                                $data2 = json_encode($data);
112
                                $data2 = json_encode($data);
113
                        }
113
                        }
114
                        curl_setopt($ch, CURLOPT_POSTFIELDS, "query=".urlencode($query)."&compressed=$compressed&data=".urlencode(base64_encode($data2)));
114
                        curl_setopt($ch, CURLOPT_POSTFIELDS, "query=".urlencode($query)."&compressed=$compressed&data=".urlencode(base64_encode($data2)));
115
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
115
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
116
                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
116
                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
117
                        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
117
                        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
118
                        if (!($res_curl = @curl_exec($ch))) {
118
                        if (!($res_curl = @curl_exec($ch))) {
119
                                throw new OIDplusException(_L('Communication with ViaThinkSoft server failed: %1',curl_error($ch)));
119
                                throw new OIDplusException(_L('Communication with ViaThinkSoft server failed: %1',curl_error($ch)));
120
                        }
120
                        }
121
                        curl_close($ch);
121
                        curl_close($ch);
122
 
122
 
123
                        $json = @json_decode($res_curl, true);
123
                        $json = @json_decode($res_curl, true);
124
 
124
 
125
                        if (!$json) {
125
                        if (!$json) {
126
                                return array(
126
                                return array(
127
                                        "status" => -1,
127
                                        "status" => -1,
128
                                        "error" => _L('JSON reply from ViaThinkSoft decoding error: %1',$res_curl)
128
                                        "error" => _L('JSON reply from ViaThinkSoft decoding error: %1',$res_curl)
129
                                );
129
                                );
130
                        }
130
                        }
131
 
131
 
132
                        if (isset($json['error']) || ($json['status'] < 0)) {
132
                        if (isset($json['error']) || ($json['status'] < 0)) {
133
                                return array(
133
                                return array(
134
                                        "status" => -1,
134
                                        "status" => -1,
135
                                        "error" => isset($json['error']) ? $json['error'] : _L('Received error status code: %1',$json['status'])
135
                                        "error" => isset($json['error']) ? $json['error'] : _L('Received error status code: %1',$json['status'])
136
                                );
136
                                );
137
                        }
137
                        }
138
 
138
 
139
                        $errors = array();
139
                        $errors = array();
140
                        list($count_imported_oids, $count_already_existing, $count_errors, $count_warnings) = $this->oidinfoImportXML('<oid-database>'.$json['xml'].'</oid-database>', $errors, $replaceExistingOIDs=false, $orphan_mode=self::ORPHAN_DISALLOW_ORPHANS);
140
                        list($count_imported_oids, $count_already_existing, $count_errors, $count_warnings) = $this->oidinfoImportXML('<oid-database>'.$json['xml'].'</oid-database>', $errors, $replaceExistingOIDs=false, $orphan_mode=self::ORPHAN_DISALLOW_ORPHANS);
141
                        if (count($errors) > 0) {
141
                        if (count($errors) > 0) {
142
                                return array("status" => -1, "error" => implode("\n",$errors));
142
                                return array("status" => -1, "error" => implode("\n",$errors));
143
                        } else if ($count_imported_oids <> 1) {
143
                        } else if ($count_imported_oids <> 1) {
144
                                return array("status" => -1, "error" => _L('Imported %1, but expected to import 1',$count_imported_oids));
144
                                return array("status" => -1, "error" => _L('Imported %1, but expected to import 1',$count_imported_oids));
145
                        } else {
145
                        } else {
146
                                return array("status" => 0);
146
                                return array("status" => 0);
147
                        }
147
                        }
148
                } else {
148
                } else {
149
                        throw new OIDplusException(_L('Unknown action ID'));
149
                        throw new OIDplusException(_L('Unknown action ID'));
150
                }
150
                }
151
        }
151
        }
152
 
152
 
153
        public function init($html=true) {
153
        public function init($html=true) {
154
                // Nothing
154
                // Nothing
155
        }
155
        }
156
 
156
 
157
        public function gui($id, &$out, &$handled) {
157
        public function gui($id, &$out, &$handled) {
158
                $ary = explode('$', $id);
158
                $ary = explode('$', $id);
159
                if (isset($ary[1])) {
159
                if (isset($ary[1])) {
160
                        $id = $ary[0];
160
                        $id = $ary[0];
161
                        $tab = $ary[1];
161
                        $tab = $ary[1];
162
                } else {
162
                } else {
163
                        $tab = 'export';
163
                        $tab = 'export';
164
                }
164
                }
165
                if ($id === 'oidplus:oidinfo_compare_export') {
165
                if ($id === 'oidplus:oidinfo_compare_export') {
166
                        $handled = true;
166
                        $handled = true;
167
                        $out['title'] = _L('List OIDs in your system which are missing at oid-info.com');
167
                        $out['title'] = _L('List OIDs in your system which are missing at oid-info.com');
168
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
168
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
169
 
169
 
170
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
170
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
171
                                $out['icon'] = 'img/error.png';
171
                                $out['icon'] = 'img/error.png';
172
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
172
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
173
                                return;
173
                                return;
174
                        }
174
                        }
175
 
175
 
176
                        $query = self::QUERY_LIST_OIDINFO_OIDS_V1;
176
                        $query = self::QUERY_LIST_OIDINFO_OIDS_V1;
177
 
177
 
178
                        $payload = array(
178
                        $payload = array(
179
                                "query" => $query, // we must repeat the query because we want to sign it
179
                                "query" => $query, // we must repeat the query because we want to sign it
180
                                "system_id" => OIDplus::getSystemId(false),
180
                                "system_id" => OIDplus::getSystemId(false),
181
                                "show_all" => 1 // this is required so that the VTS OIDRA gets no false notifications for adding the systems in the directory 1.3.6.1.4.1.37476.30.9
181
                                "show_all" => 1 // this is required so that the VTS OIDRA gets no false notifications for adding the systems in the directory 1.3.6.1.4.1.37476.30.9
182
                        );
182
                        );
183
 
183
 
184
                        $signature = '';
184
                        $signature = '';
185
                        if (!OIDplus::getPkiStatus() || !@openssl_sign(json_encode($payload), $signature, OIDplus::getSystemPrivateKey())) {
185
                        if (!OIDplus::getPkiStatus() || !@openssl_sign(json_encode($payload), $signature, OIDplus::getSystemPrivateKey())) {
186
                                if (!OIDplus::getPkiStatus()) {
186
                                if (!OIDplus::getPkiStatus()) {
187
                                        throw new OIDplusException(_L('Error: Your system could not generate a private/public key pair. (OpenSSL is probably missing on your system). Therefore, you cannot register/unregister your OIDplus instance.'));
187
                                        throw new OIDplusException(_L('Error: Your system could not generate a private/public key pair. (OpenSSL is probably missing on your system). Therefore, you cannot register/unregister your OIDplus instance.'));
188
                                } else {
188
                                } else {
189
                                        throw new OIDplusException(_L('Signature failed'));
189
                                        throw new OIDplusException(_L('Signature failed'));
190
                                }
190
                                }
191
                        }
191
                        }
192
 
192
 
193
                        $data = array(
193
                        $data = array(
194
                                "payload" => $payload,
194
                                "payload" => $payload,
195
                                "signature" => base64_encode($signature)
195
                                "signature" => base64_encode($signature)
196
                        );
196
                        );
197
 
197
 
198
                        if (!function_exists('curl_init')) {
198
                        if (!function_exists('curl_init')) {
199
                                throw new OIDplusException(_L('The "%1" PHP extension is not installed at your system. Please enable the PHP extension <code>%2</code>.','CURL','php_curl'));
199
                                throw new OIDplusException(_L('The "%1" PHP extension is not installed at your system. Please enable the PHP extension <code>%2</code>.','CURL','php_curl'));
200
                        }
200
                        }
201
 
201
 
202
                        if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
202
                        if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
203
                                // The oid-info.com import functionality is a confidential API between ViaThinkSoft and oid-info.com and cannot be used in forks of OIDplus
203
                                // The oid-info.com import functionality is a confidential API between ViaThinkSoft and oid-info.com and cannot be used in forks of OIDplus
204
                                throw new OIDplusException(_L('This feature is only available in the ViaThinkSoft edition of OIDplus'));
204
                                throw new OIDplusException(_L('This feature is only available in the ViaThinkSoft edition of OIDplus'));
205
                        }
205
                        }
206
 
206
 
207
                        $ch = curl_init();
207
                        $ch = curl_init();
208
                        if (ini_get('curl.cainfo') == '') curl_setopt($ch, CURLOPT_CAINFO, OIDplus::localpath() . 'vendor/cacert.pem');
208
                        if (ini_get('curl.cainfo') == '') curl_setopt($ch, CURLOPT_CAINFO, OIDplus::localpath() . 'vendor/cacert.pem');
209
                        curl_setopt($ch, CURLOPT_URL, 'https://oidplus.viathinksoft.com/reg2/query.php');
209
                        curl_setopt($ch, CURLOPT_URL, 'https://oidplus.viathinksoft.com/reg2/query.php');
210
                        curl_setopt($ch, CURLOPT_USERAGENT, 'ViaThinkSoft-OIDplus/2.0');
210
                        curl_setopt($ch, CURLOPT_USERAGENT, 'ViaThinkSoft-OIDplus/2.0');
211
                        curl_setopt($ch, CURLOPT_POST, 1);
211
                        curl_setopt($ch, CURLOPT_POST, 1);
212
                        if (function_exists('gzdeflate')) {
212
                        if (function_exists('gzdeflate')) {
213
                                $compressed = "1";
213
                                $compressed = "1";
214
                                $data2 = gzdeflate(json_encode($data));
214
                                $data2 = gzdeflate(json_encode($data));
215
                        } else {
215
                        } else {
216
                                $compressed = "0";
216
                                $compressed = "0";
217
                                $data2 = json_encode($data);
217
                                $data2 = json_encode($data);
218
                        }
218
                        }
219
                        curl_setopt($ch, CURLOPT_POSTFIELDS, "query=".urlencode($query)."&compressed=$compressed&data=".urlencode(base64_encode($data2)));
219
                        curl_setopt($ch, CURLOPT_POSTFIELDS, "query=".urlencode($query)."&compressed=$compressed&data=".urlencode(base64_encode($data2)));
220
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
220
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
221
                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
221
                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
222
                        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
222
                        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
223
                        if (!($res_curl = @curl_exec($ch))) {
223
                        if (!($res_curl = @curl_exec($ch))) {
224
                                throw new OIDplusException(_L('Communication with ViaThinkSoft server failed: %1',curl_error($ch)));
224
                                throw new OIDplusException(_L('Communication with ViaThinkSoft server failed: %1',curl_error($ch)));
225
                        }
225
                        }
226
                        curl_close($ch);
226
                        curl_close($ch);
227
 
227
 
228
                        $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:datatransfer$export').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back to data transfer main page').'</a></p>';
228
                        $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:datatransfer$export').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back to data transfer main page').'</a></p>';
229
 
229
 
230
                        $json = @json_decode($res_curl, true);
230
                        $json = @json_decode($res_curl, true);
231
 
231
 
232
                        if (!$json) {
232
                        if (!$json) {
233
                                $out['icon'] = 'img/error.png';
233
                                $out['icon'] = 'img/error.png';
234
                                $out['text'] .= _L('JSON reply from ViaThinkSoft decoding error: %1',$res_curl);
234
                                $out['text'] .= _L('JSON reply from ViaThinkSoft decoding error: %1',$res_curl);
235
                                return;
235
                                return;
236
                        }
236
                        }
237
 
237
 
238
                        if (isset($json['error']) || ($json['status'] < 0)) {
238
                        if (isset($json['error']) || ($json['status'] < 0)) {
239
                                $out['icon'] = 'img/error.png';
239
                                $out['icon'] = 'img/error.png';
240
                                if (isset($json['error'])) {
240
                                if (isset($json['error'])) {
241
                                        $out['text'] .= _L('Received error: %1',$json['error']);
241
                                        $out['text'] .= _L('Received error: %1',$json['error']);
242
                                } else {
242
                                } else {
243
                                        $out['text'] .= _L('Received error status code: %1',$json['status']);
243
                                        $out['text'] .= _L('Received error status code: %1',$json['status']);
244
                                }
244
                                }
245
                                return;
245
                                return;
246
                        }
246
                        }
247
 
247
 
248
                        if (isset($json['error']) || ($json['status'] < 0)) {
248
                        if (isset($json['error']) || ($json['status'] < 0)) {
249
                                $out['text'] .= '<p>'._L('Error: %1',htmlentities($json['error'])).'</p>';
249
                                $out['text'] .= '<p>'._L('Error: %1',htmlentities($json['error'])).'</p>';
250
                        } else {
250
                        } else {
251
                                // TODO: If roots were created or deleted recently, we must do a re-query of the registration, so that the "roots" information at the directory service gets refreshed
251
                                // TODO: If roots were created or deleted recently, we must do a re-query of the registration, so that the "roots" information at the directory service gets refreshed
252
                                if (count($json['roots']) == 0) $out['text'] .= '<p>'._L('In order to use this feature, you need to have at least one (root) OID added in your system, and the system needs to report the newly added root to the directory service (the reporting interval is 1 hour).').'</p>';
252
                                if (count($json['roots']) == 0) $out['text'] .= '<p>'._L('In order to use this feature, you need to have at least one (root) OID added in your system, and the system needs to report the newly added root to the directory service (the reporting interval is 1 hour).').'</p>';
253
                                foreach ($json['roots'] as $root) {
253
                                foreach ($json['roots'] as $root) {
254
                                        $oid = $root['oid'];
254
                                        $oid = $root['oid'];
255
                                        $out['text'] .= '<h2>'._L('Root OID %1',$oid).'</h2>';
255
                                        $out['text'] .= '<h2>'._L('Root OID %1',$oid).'</h2>';
256
                                        if ($root['verified']) {
256
                                        if ($root['verified']) {
257
                                                $count = 0;
257
                                                $count = 0;
258
                                                $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
258
                                                $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
259
                                                $out['text'] .= '<table class="table table-bordered table-striped">';
259
                                                $out['text'] .= '<table class="table table-bordered table-striped">';
260
                                                $out['text'] .= '<tr><th colspan="3">'._L('Actions').'</th><th>'._L('OID').'</th></tr>';
260
                                                $out['text'] .= '<tr><th colspan="3">'._L('Actions').'</th><th>'._L('OID').'</th></tr>';
261
 
261
 
262
                                                $lookup_nonoid = array();
262
                                                $lookup_nonoid = array();
263
                                                $row_lookup = array();
263
                                                $row_lookup = array();
264
 
264
 
265
                                                $all_local_oids_of_root = array();
265
                                                $all_local_oids_of_root = array();
266
                                                $res = OIDplus::db()->query("select * from ###objects where confidential <> 1");
266
                                                $res = OIDplus::db()->query("select * from ###objects where confidential <> 1");
267
                                                while ($row = $res->fetch_object()) {
267
                                                while ($row = $res->fetch_object()) {
268
                                                        $obj = OIDplusObject::parse($row->id);
268
                                                        $obj = OIDplusObject::parse($row->id);
269
                                                        if (!$obj) continue; // can happen when object type is not enabled
269
                                                        if (!$obj) continue; // can happen when object type is not enabled
270
                                                        if ($obj->isConfidential()) continue; // This will also exclude OIDs which are descendants of confidential OIDs
270
                                                        if ($obj->isConfidential()) continue; // This will also exclude OIDs which are descendants of confidential OIDs
271
                                                        if (strpos($row->id, 'oid:') === 0) {
271
                                                        if (strpos($row->id, 'oid:') === 0) {
272
                                                                $oid = substr($row->id,strlen('oid:'));
272
                                                                $oid = substr($row->id,strlen('oid:'));
273
                                                                if (strpos($oid.'.', $root['oid']) === 0) {
273
                                                                if (strpos($oid.'.', $root['oid']) === 0) {
274
                                                                        $row_lookup[$oid] = $row;
274
                                                                        $row_lookup[$oid] = $row;
275
                                                                        $all_local_oids_of_root[] = $oid;
275
                                                                        $all_local_oids_of_root[] = $oid;
276
                                                                }
276
                                                                }
277
                                                        } else {
277
                                                        } else {
278
                                                                $aids = $obj->getAltIds();
278
                                                                $aids = $obj->getAltIds();
279
                                                                foreach ($aids as $aid) {
279
                                                                foreach ($aids as $aid) {
280
                                                                        if ($aid->getNamespace() == 'oid') {
280
                                                                        if ($aid->getNamespace() == 'oid') {
281
                                                                                $oid = $aid->getId();
281
                                                                                $oid = $aid->getId();
282
                                                                                if (strpos($oid.'.', $root['oid']) === 0) {
282
                                                                                if (strpos($oid.'.', $root['oid']) === 0) {
283
                                                                                        $row_lookup[$oid] = $row;
283
                                                                                        $row_lookup[$oid] = $row;
284
                                                                                        $all_local_oids_of_root[] = $oid;
284
                                                                                        $all_local_oids_of_root[] = $oid;
285
                                                                                        $lookup_nonoid[$oid] = $row->id;
285
                                                                                        $lookup_nonoid[$oid] = $row->id;
286
                                                                                }
286
                                                                                }
287
                                                                        }
287
                                                                        }
288
                                                                }
288
                                                                }
289
                                                        }
289
                                                        }
290
                                                }
290
                                                }
291
 
291
 
292
                                                natsort($all_local_oids_of_root);
292
                                                natsort($all_local_oids_of_root);
293
                                                foreach ($all_local_oids_of_root as $local_oid) {
293
                                                foreach ($all_local_oids_of_root as $local_oid) {
294
                                                        if (!in_array($local_oid, $root['children'])) {
294
                                                        if (!in_array($local_oid, $root['children'])) {
295
                                                                $count++;
295
                                                                $count++;
296
 
296
 
297
                                                                // Start: Build oid-info.com create URL
297
                                                                // Start: Build oid-info.com create URL
298
 
298
 
299
                                                                $row = $row_lookup[$local_oid];
299
                                                                $row = $row_lookup[$local_oid];
300
 
300
 
301
                                                                $url = "http://www.oid-info.com/cgi-bin/manage?f=".oid_up($local_oid)."&a=create";
301
                                                                $url = "http://www.oid-info.com/cgi-bin/manage?f=".oid_up($local_oid)."&a=create";
302
 
302
 
303
                                                                $tmp = explode('.',$local_oid);
303
                                                                $tmp = explode('.',$local_oid);
304
                                                                $url .= "&nb=".urlencode(array_pop($tmp));
304
                                                                $url .= "&nb=".urlencode(array_pop($tmp));
305
 
305
 
306
                                                                $asn1_ids = array();
306
                                                                $asn1_ids = array();
307
                                                                $res_asn = OIDplus::db()->query("select * from ###asn1id where oid = ?", array($row->id));
307
                                                                $res_asn = OIDplus::db()->query("select * from ###asn1id where oid = ?", array($row->id));
308
                                                                while ($row_asn = $res_asn->fetch_object()) {
308
                                                                while ($row_asn = $res_asn->fetch_object()) {
309
                                                                        $asn1_ids[] = $row_asn->name; // 'unicode-label' is currently not in the standard format (oid.xsd)
309
                                                                        $asn1_ids[] = $row_asn->name; // 'unicode-label' is currently not in the standard format (oid.xsd)
310
                                                                }
310
                                                                }
311
                                                                $url .= "&id=".array_shift($asn1_ids); // urlencode() is already done (see above)
311
                                                                $url .= "&id=".array_shift($asn1_ids); // urlencode() is already done (see above)
312
                                                                $url .= "&syn_id=".implode('%0A', $asn1_ids); // urlencode() is already done (see above)
312
                                                                $url .= "&syn_id=".implode('%0A', $asn1_ids); // urlencode() is already done (see above)
313
 
313
 
314
                                                                $iri_ids = array();
314
                                                                $iri_ids = array();
315
                                                                $res_iri = OIDplus::db()->query("select * from ###iri where oid = ?", array($row->id));
315
                                                                $res_iri = OIDplus::db()->query("select * from ###iri where oid = ?", array($row->id));
316
                                                                while ($row_iri = $res_iri->fetch_object()) {
316
                                                                while ($row_iri = $res_iri->fetch_object()) {
317
                                                                        $iri_ids[] = $row_iri->name;
317
                                                                        $iri_ids[] = $row_iri->name;
318
                                                                }
318
                                                                }
319
                                                                $url .= "&unicode_label_list=".implode('%0A', $iri_ids); // urlencode() is already done (see above)
319
                                                                $url .= "&unicode_label_list=".implode('%0A', $iri_ids); // urlencode() is already done (see above)
320
 
320
 
321
                                                                if (!empty($row->title)) {
321
                                                                if (!empty($row->title)) {
322
                                                                        $tmp_description = $row->title;
322
                                                                        $tmp_description = $row->title;
323
                                                                        $tmp_information = $row->description;/** @phpstan-ignore-line */
323
                                                                        $tmp_information = $row->description;/** @phpstan-ignore-line */
324
                                                                        if (trim($row->title) == trim(strip_tags($row->description))) {/** @phpstan-ignore-line */
324
                                                                        if (trim($row->title) == trim(strip_tags($row->description))) {/** @phpstan-ignore-line */
325
                                                                                $tmp_information = '';
325
                                                                                $tmp_information = '';
326
                                                                        }
326
                                                                        }
327
                                                                } else if (isset($asn1_ids[0])) {
327
                                                                } else if (isset($asn1_ids[0])) {
328
                                                                        $tmp_description = '"'.$asn1_ids[0].'"';
328
                                                                        $tmp_description = '"'.$asn1_ids[0].'"';
329
                                                                        $tmp_information = $row->description;
329
                                                                        $tmp_information = $row->description;
330
                                                                } else if (isset($iri_ids[0])) {
330
                                                                } else if (isset($iri_ids[0])) {
331
                                                                        $tmp_description = '"'.$iri_ids[0].'"';
331
                                                                        $tmp_description = '"'.$iri_ids[0].'"';
332
                                                                        $tmp_information = $row->description;
332
                                                                        $tmp_information = $row->description;
333
                                                                } else if (!empty($row->description)) {
333
                                                                } else if (!empty($row->description)) {
334
                                                                        $tmp_description = $row->description;
334
                                                                        $tmp_description = $row->description;
335
                                                                        $tmp_information = '';
335
                                                                        $tmp_information = '';
336
                                                                } else if (!empty($row->comment)) {
336
                                                                } else if (!empty($row->comment)) {
337
                                                                        $tmp_description = $row->comment;
337
                                                                        $tmp_description = $row->comment;
338
                                                                        $tmp_information = '';
338
                                                                        $tmp_information = '';
339
                                                                } else {
339
                                                                } else {
340
                                                                        $tmp_description = '<i>No description available</i>'; // do not translate
340
                                                                        $tmp_description = '<i>No description available</i>'; // do not translate
341
                                                                        $tmp_information = '';
341
                                                                        $tmp_information = '';
342
                                                                }
342
                                                                }
343
 
343
 
344
                                                                if ($tmp_information != '') {
344
                                                                if ($tmp_information != '') {
345
                                                                        $tmp_information .= '<br/><br/>';
345
                                                                        $tmp_information .= '<br/><br/>';
346
                                                                }
346
                                                                }
347
 
347
 
348
                                                                $tmp_information .= 'See <a href="'.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'?goto='.urlencode($id).'">more information</a>.'; // do not translate
348
                                                                $tmp_information .= 'See <a href="'.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'?goto='.urlencode($id).'">more information</a>.'; // do not translate
349
 
349
 
350
                                                                if (explode(':',$id,2)[0] != 'oid') {
350
                                                                if (explode(':',$id,2)[0] != 'oid') {
351
                                                                        $tmp_information = "Object: $id\n\n" . $tmp_information; // do not translate
351
                                                                        $tmp_information = "Object: $id\n\n" . $tmp_information; // do not translate
352
                                                                }
352
                                                                }
353
 
353
 
354
                                                                $url .= "&description=".urlencode(self::repair_relative_links($tmp_description));
354
                                                                $url .= "&description=".urlencode(self::repair_relative_links($tmp_description));
355
                                                                $url .= "&info=".urlencode(self::repair_relative_links($tmp_information));
355
                                                                $url .= "&info=".urlencode(self::repair_relative_links($tmp_information));
356
 
356
 
357
                                                                $url .= "&current_registrant_email=".urlencode($row->ra_email);
357
                                                                $url .= "&current_registrant_email=".urlencode($row->ra_email);
358
 
358
 
359
                                                                $res_ra = OIDplus::db()->query("select * from ###ra where email = ?", array($row->ra_email));
359
                                                                $res_ra = OIDplus::db()->query("select * from ###ra where email = ?", array($row->ra_email));
360
                                                                if ($res_ra->any()) {
360
                                                                if ($res_ra->any()) {
361
                                                                        $row_ra = $res_ra->fetch_object();
361
                                                                        $row_ra = $res_ra->fetch_object();
362
 
362
 
363
                                                                        $tmp = array();
363
                                                                        $tmp = array();
364
                                                                        if (!empty($row_ra->personal_name)) {
364
                                                                        if (!empty($row_ra->personal_name)) {
365
                                                                                $name_ary = split_firstname_lastname($row_ra->personal_name);
365
                                                                                $name_ary = split_firstname_lastname($row_ra->personal_name);
366
                                                                                $tmp_first_name = $name_ary[0];
366
                                                                                $tmp_first_name = $name_ary[0];
367
                                                                                $tmp_last_name  = $name_ary[1];
367
                                                                                $tmp_last_name  = $name_ary[1];
368
                                                                                if (!empty($row_ra->ra_name)       ) $tmp[] = $row_ra->ra_name;
368
                                                                                if (!empty($row_ra->ra_name)       ) $tmp[] = $row_ra->ra_name;
369
                                                                                if (!empty($row_ra->office)        ) $tmp[] = $row_ra->office;
369
                                                                                if (!empty($row_ra->office)        ) $tmp[] = $row_ra->office;
370
                                                                                if (!empty($row_ra->organization)  ) $tmp[] = $row_ra->organization;
370
                                                                                if (!empty($row_ra->organization)  ) $tmp[] = $row_ra->organization;
371
                                                                        } else {
371
                                                                        } else {
372
                                                                                $tmp_first_name = $row_ra->ra_name;
372
                                                                                $tmp_first_name = $row_ra->ra_name;
373
                                                                                $tmp_last_name  = '';
373
                                                                                $tmp_last_name  = '';
374
                                                                                if (!empty($row_ra->personal_name) ) $tmp[] = $row_ra->personal_name;
374
                                                                                if (!empty($row_ra->personal_name) ) $tmp[] = $row_ra->personal_name;
375
                                                                                if (!empty($row_ra->office)        ) $tmp[] = $row_ra->office;
375
                                                                                if (!empty($row_ra->office)        ) $tmp[] = $row_ra->office;
376
                                                                                if (!empty($row_ra->organization)  ) $tmp[] = $row_ra->organization;
376
                                                                                if (!empty($row_ra->organization)  ) $tmp[] = $row_ra->organization;
377
                                                                        }
377
                                                                        }
378
 
378
 
379
                                                                        if (empty($tmp_first_name) || empty($tmp_last_name)) {
379
                                                                        if (empty($tmp_first_name) || empty($tmp_last_name)) {
380
                                                                                $name = self::split_name($tmp_first_name.' '.$tmp_last_name);
380
                                                                                $name = self::split_name($tmp_first_name.' '.$tmp_last_name);
381
                                                                                $tmp_first_name = $name[0];
381
                                                                                $tmp_first_name = $name[0];
382
                                                                                $tmp_last_name = $name[1];
382
                                                                                $tmp_last_name = $name[1];
383
                                                                        }
383
                                                                        }
384
                                                                        $url .= "&current_registrant_first_name=".urlencode($tmp_first_name);
384
                                                                        $url .= "&current_registrant_first_name=".urlencode($tmp_first_name);
385
                                                                        $url .= "&current_registrant_last_name=".urlencode($tmp_last_name);
385
                                                                        $url .= "&current_registrant_last_name=".urlencode($tmp_last_name);
386
 
386
 
387
                                                                        if ((count($tmp) > 0) && ($tmp[0] == $row_ra->ra_name)) array_shift($tmp);
387
                                                                        if ((count($tmp) > 0) && ($tmp[0] == $row_ra->ra_name)) array_shift($tmp);
388
                                                                        $tmp = array_unique($tmp);
388
                                                                        $tmp = array_unique($tmp);
389
 
389
 
390
                                                                        if (!$row_ra->privacy) {
390
                                                                        if (!$row_ra->privacy) {
391
                                                                                if (!empty($row_ra->street))   $tmp[] = $row_ra->street;
391
                                                                                if (!empty($row_ra->street))   $tmp[] = $row_ra->street;
392
                                                                                if (!empty($row_ra->zip_town)) $tmp[] = $row_ra->zip_town;
392
                                                                                if (!empty($row_ra->zip_town)) $tmp[] = $row_ra->zip_town;
393
                                                                                if (!empty($row_ra->country))  $tmp[] = $row_ra->country;
393
                                                                                if (!empty($row_ra->country))  $tmp[] = $row_ra->country;
394
                                                                                $url .= "&current_registrant_tel=".urlencode(!empty($row_ra->phone) ? $row_ra->phone : $row_ra->mobile);
394
                                                                                $url .= "&current_registrant_tel=".urlencode(!empty($row_ra->phone) ? $row_ra->phone : $row_ra->mobile);
395
                                                                                $url .= "&current_registrant_fax=".urlencode($row_ra->fax);
395
                                                                                $url .= "&current_registrant_fax=".urlencode($row_ra->fax);
396
                                                                        }
396
                                                                        }
397
                                                                        if (empty($row_ra->zip_town) && empty($row_ra->country)) {
397
                                                                        if (empty($row_ra->zip_town) && empty($row_ra->country)) {
398
                                                                                // The address is useless if we do neither know city nor country
398
                                                                                // The address is useless if we do neither know city nor country
399
                                                                                // Ignore it
399
                                                                                // Ignore it
400
                                                                        } else {
400
                                                                        } else {
401
                                                                                $tmp = self::split_address_country(implode("<br/>", $tmp));
401
                                                                                $tmp = self::split_address_country(implode("<br/>", $tmp));
402
                                                                                $url .= "&current_registrant_address=".urlencode($tmp[0]);
402
                                                                                $url .= "&current_registrant_address=".urlencode($tmp[0]);
403
                                                                                $url .= "&current_registrant_country=".urlencode($tmp[1]);
403
                                                                                $url .= "&current_registrant_country=".urlencode($tmp[1]);
404
                                                                        }
404
                                                                        }
405
                                                                }
405
                                                                }
406
                                                                if (!empty($row->updated)) {
406
                                                                if (!empty($row->updated)) {
407
                                                                        $tmp = explode('-', self::_formatdate($row->updated));
407
                                                                        $tmp = explode('-', self::_formatdate($row->updated));
408
                                                                        $url .= "&modification_year=".urlencode($tmp[0]);
408
                                                                        $url .= "&modification_year=".urlencode($tmp[0]);
409
                                                                        $url .= "&modification_month=".urlencode($tmp[1]);
409
                                                                        $url .= "&modification_month=".urlencode($tmp[1]);
410
                                                                        $url .= "&modification_day=".urlencode($tmp[2]);
410
                                                                        $url .= "&modification_day=".urlencode($tmp[2]);
411
                                                                }
411
                                                                }
412
 
412
 
413
                                                                //$url .= "&submitter_last_name=".urlencode($xml->{'submitter'}->{'last-name'});
413
                                                                //$url .= "&submitter_last_name=".urlencode($xml->{'submitter'}->{'last-name'});
414
                                                                //$url .= "&submitter_first_name=".urlencode($xml->{'submitter'}->{'first-name'});
414
                                                                //$url .= "&submitter_first_name=".urlencode($xml->{'submitter'}->{'first-name'});
415
                                                                //$url .= "&submitter_email=".urlencode($xml->{'submitter'}->{'email'});
415
                                                                //$url .= "&submitter_email=".urlencode($xml->{'submitter'}->{'email'});
416
 
416
 
417
                                                                // End: Build oid-info.com create URL
417
                                                                // End: Build oid-info.com create URL
418
 
418
 
419
                                                                // Note: "Actions" is at the left, because it has a fixed width, so the user can continue clicking without the links moving if the OID length changes between lines
419
                                                                // Note: "Actions" is at the left, because it has a fixed width, so the user can continue clicking without the links moving if the OID length changes between lines
420
                                                                $out['text'] .= '<tr id="missing_oid_'.str_replace('.','_',$local_oid).'">'.
420
                                                                $out['text'] .= '<tr id="missing_oid_'.str_replace('.','_',$local_oid).'">'.
421
                                                                '<td><a '.OIDplus::gui()->link(isset($lookup_nonoid[$local_oid]) ? $lookup_nonoid[$local_oid] : 'oid:'.$local_oid, true).'>'._L('View local OID').'</a></td>'.
421
                                                                '<td><a '.OIDplus::gui()->link(isset($lookup_nonoid[$local_oid]) ? $lookup_nonoid[$local_oid] : 'oid:'.$local_oid, true).'>'._L('View local OID').'</a></td>'.
422
                                                                '<td><a href="javascript:OIDplusPageAdminOIDInfoExport.removeMissingOid(\''.$local_oid.'\');">'._L('Ignore for now').'</a></td>'.
422
                                                                '<td><a href="javascript:OIDplusPageAdminOIDInfoExport.removeMissingOid(\''.$local_oid.'\');">'._L('Ignore for now').'</a></td>'.
423
                                                                '<td><a target="_blank" href="'.$url.'">'._L('Add to oid-info.com manually').'</a></td>'.
423
                                                                '<td><a target="_blank" href="'.$url.'">'._L('Add to oid-info.com manually').'</a></td>'.
424
                                                                '<td>'.$local_oid.'</td>'.
424
                                                                '<td>'.$local_oid.'</td>'.
425
                                                                '</tr>';
425
                                                                '</tr>';
426
                                                        }
426
                                                        }
427
                                                }
427
                                                }
428
                                                if ($count == 0) {
428
                                                if ($count == 0) {
429
                                                        $out['text'] .= '<tr><td colspan="4">'._L('No missing OIDs found').'</td></tr>';
429
                                                        $out['text'] .= '<tr><td colspan="4">'._L('No missing OIDs found').'</td></tr>';
430
                                                }
430
                                                }
431
                                                $out['text'] .= '</table></div></div>';
431
                                                $out['text'] .= '</table></div></div>';
432
                                        } else {
432
                                        } else {
433
                                                $out['text'] .= '<p>'._L('This root is not validated. Please send an email to %1 in order to request ownership verification of this root OID.',$json['vts_verification_email']).'</p>';
433
                                                $out['text'] .= '<p>'._L('This root is not validated. Please send an email to %1 in order to request ownership verification of this root OID.',$json['vts_verification_email']).'</p>';
434
                                        }
434
                                        }
435
                                }
435
                                }
436
                        }
436
                        }
437
                }
437
                }
438
 
438
 
439
                if ($id === 'oidplus:oidinfo_compare_import') {
439
                if ($id === 'oidplus:oidinfo_compare_import') {
440
                        $handled = true;
440
                        $handled = true;
441
                        $out['title'] = _L('List OIDs at oid-info.com which are missing in your system');
441
                        $out['title'] = _L('List OIDs at oid-info.com which are missing in your system');
442
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
442
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
443
 
443
 
444
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
444
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
445
                                $out['icon'] = 'img/error.png';
445
                                $out['icon'] = 'img/error.png';
446
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
446
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
447
                                return;
447
                                return;
448
                        }
448
                        }
449
 
449
 
450
                        $query = self::QUERY_LIST_OIDINFO_OIDS_V1;
450
                        $query = self::QUERY_LIST_OIDINFO_OIDS_V1;
451
 
451
 
452
                        $payload = array(
452
                        $payload = array(
453
                                "query" => $query, // we must repeat the query because we want to sign it
453
                                "query" => $query, // we must repeat the query because we want to sign it
454
                                "system_id" => OIDplus::getSystemId(false),
454
                                "system_id" => OIDplus::getSystemId(false),
455
                                "show_all" => 0
455
                                "show_all" => 0
456
                        );
456
                        );
457
 
457
 
458
                        $signature = '';
458
                        $signature = '';
459
                        if (!OIDplus::getPkiStatus() || !@openssl_sign(json_encode($payload), $signature, OIDplus::getSystemPrivateKey())) {
459
                        if (!OIDplus::getPkiStatus() || !@openssl_sign(json_encode($payload), $signature, OIDplus::getSystemPrivateKey())) {
460
                                if (!OIDplus::getPkiStatus()) {
460
                                if (!OIDplus::getPkiStatus()) {
461
                                        throw new OIDplusException(_L('Error: Your system could not generate a private/public key pair. (OpenSSL is probably missing on your system). Therefore, you cannot register/unregister your OIDplus instance.'));
461
                                        throw new OIDplusException(_L('Error: Your system could not generate a private/public key pair. (OpenSSL is probably missing on your system). Therefore, you cannot register/unregister your OIDplus instance.'));
462
                                } else {
462
                                } else {
463
                                        throw new OIDplusException(_L('Signature failed'));
463
                                        throw new OIDplusException(_L('Signature failed'));
464
                                }
464
                                }
465
                        }
465
                        }
466
 
466
 
467
                        $data = array(
467
                        $data = array(
468
                                "payload" => $payload,
468
                                "payload" => $payload,
469
                                "signature" => base64_encode($signature)
469
                                "signature" => base64_encode($signature)
470
                        );
470
                        );
471
 
471
 
472
                        if (!function_exists('curl_init')) {
472
                        if (!function_exists('curl_init')) {
473
                                throw new OIDplusException(_L('The "%1" PHP extension is not installed at your system. Please enable the PHP extension <code>%2</code>.','CURL','php_curl'));
473
                                throw new OIDplusException(_L('The "%1" PHP extension is not installed at your system. Please enable the PHP extension <code>%2</code>.','CURL','php_curl'));
474
                        }
474
                        }
475
 
475
 
476
                        if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
476
                        if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
477
                                // The oid-info.com import functionality is a confidential API between ViaThinkSoft and oid-info.com and cannot be used in forks of OIDplus
477
                                // The oid-info.com import functionality is a confidential API between ViaThinkSoft and oid-info.com and cannot be used in forks of OIDplus
478
                                throw new OIDplusException(_L('This feature is only available in the ViaThinkSoft edition of OIDplus'));
478
                                throw new OIDplusException(_L('This feature is only available in the ViaThinkSoft edition of OIDplus'));
479
                        }
479
                        }
480
 
480
 
481
                        $ch = curl_init();
481
                        $ch = curl_init();
482
                        if (ini_get('curl.cainfo') == '') curl_setopt($ch, CURLOPT_CAINFO, OIDplus::localpath() . 'vendor/cacert.pem');
482
                        if (ini_get('curl.cainfo') == '') curl_setopt($ch, CURLOPT_CAINFO, OIDplus::localpath() . 'vendor/cacert.pem');
483
                        curl_setopt($ch, CURLOPT_URL, 'https://oidplus.viathinksoft.com/reg2/query.php');
483
                        curl_setopt($ch, CURLOPT_URL, 'https://oidplus.viathinksoft.com/reg2/query.php');
484
                        curl_setopt($ch, CURLOPT_USERAGENT, 'ViaThinkSoft-OIDplus/2.0');
484
                        curl_setopt($ch, CURLOPT_USERAGENT, 'ViaThinkSoft-OIDplus/2.0');
485
                        curl_setopt($ch, CURLOPT_POST, 1);
485
                        curl_setopt($ch, CURLOPT_POST, 1);
486
                        if (function_exists('gzdeflate')) {
486
                        if (function_exists('gzdeflate')) {
487
                                $compressed = "1";
487
                                $compressed = "1";
488
                                $data2 = gzdeflate(json_encode($data));
488
                                $data2 = gzdeflate(json_encode($data));
489
                        } else {
489
                        } else {
490
                                $compressed = "0";
490
                                $compressed = "0";
491
                                $data2 = json_encode($data);
491
                                $data2 = json_encode($data);
492
                        }
492
                        }
493
                        curl_setopt($ch, CURLOPT_POSTFIELDS, "query=".urlencode($query)."&compressed=$compressed&data=".urlencode(base64_encode($data2)));
493
                        curl_setopt($ch, CURLOPT_POSTFIELDS, "query=".urlencode($query)."&compressed=$compressed&data=".urlencode(base64_encode($data2)));
494
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
494
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
495
                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
495
                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
496
                        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
496
                        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
497
                        if (!($res = @curl_exec($ch))) {
497
                        if (!($res = @curl_exec($ch))) {
498
                                throw new OIDplusException(_L('Communication with ViaThinkSoft server failed: %1',curl_error($ch)));
498
                                throw new OIDplusException(_L('Communication with ViaThinkSoft server failed: %1',curl_error($ch)));
499
                        }
499
                        }
500
                        curl_close($ch);
500
                        curl_close($ch);
501
 
501
 
502
                        $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:datatransfer$import').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back to data transfer main page').'</a></p>';
502
                        $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:datatransfer$import').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back to data transfer main page').'</a></p>';
503
 
503
 
504
                        $json = @json_decode($res, true);
504
                        $json = @json_decode($res, true);
505
 
505
 
506
                        if (!$json) {
506
                        if (!$json) {
507
                                $out['icon'] = 'img/error.png';
507
                                $out['icon'] = 'img/error.png';
508
                                $out['text'] .= _L('JSON reply from ViaThinkSoft decoding error: %1',$res);
508
                                $out['text'] .= _L('JSON reply from ViaThinkSoft decoding error: %1',$res);
509
                                return;
509
                                return;
510
                        }
510
                        }
511
 
511
 
512
                        if (isset($json['error']) || ($json['status'] < 0)) {
512
                        if (isset($json['error']) || ($json['status'] < 0)) {
513
                                $out['icon'] = 'img/error.png';
513
                                $out['icon'] = 'img/error.png';
514
                                if (isset($json['error'])) {
514
                                if (isset($json['error'])) {
515
                                        $out['text'] .= _L('Received error: %1',$json['error']);
515
                                        $out['text'] .= _L('Received error: %1',$json['error']);
516
                                } else {
516
                                } else {
517
                                        $out['text'] .= _L('Received error status code: %1',$json['status']);
517
                                        $out['text'] .= _L('Received error status code: %1',$json['status']);
518
                                }
518
                                }
519
                                return;
519
                                return;
520
                        }
520
                        }
521
 
521
 
522
                        $all_local_oids = array();
522
                        $all_local_oids = array();
523
                        $res = OIDplus::db()->query("select id from ###objects");
523
                        $res = OIDplus::db()->query("select id from ###objects");
524
                        while ($row = $res->fetch_array()) {
524
                        while ($row = $res->fetch_array()) {
525
                                if (strpos($row['id'], 'oid:') === 0) {
525
                                if (strpos($row['id'], 'oid:') === 0) {
526
                                        $all_local_oids[] = substr($row['id'],strlen('oid:'));
526
                                        $all_local_oids[] = substr($row['id'],strlen('oid:'));
527
                                } else {
527
                                } else {
528
                                        $obj = OIDplusObject::parse($row['id']);
528
                                        $obj = OIDplusObject::parse($row['id']);
529
                                        if (!$obj) continue; // can happen when object type is not enabled
529
                                        if (!$obj) continue; // can happen when object type is not enabled
530
                                        $aids = $obj->getAltIds();
530
                                        $aids = $obj->getAltIds();
531
                                        foreach ($aids as $aid) {
531
                                        foreach ($aids as $aid) {
532
                                                if ($aid->getNamespace() == 'oid') {
532
                                                if ($aid->getNamespace() == 'oid') {
533
                                                        $all_local_oids[] = $aid->getId();
533
                                                        $all_local_oids[] = $aid->getId();
534
                                                }
534
                                                }
535
                                        }
535
                                        }
536
                                }
536
                                }
537
                        }
537
                        }
538
 
538
 
539
                        if (isset($json['error']) || ($json['status'] < 0)) {
539
                        if (isset($json['error']) || ($json['status'] < 0)) {
540
                                $out['text'] .= '<p>'._L('Error: %1',htmlentities($json['error'])).'</p>';
540
                                $out['text'] .= '<p>'._L('Error: %1',htmlentities($json['error'])).'</p>';
541
                        } else {
541
                        } else {
542
                                // TODO: If roots were created or deleted recently, we must do a re-query of the registration, so that the "roots" information at the directory service gets refreshed
542
                                // TODO: If roots were created or deleted recently, we must do a re-query of the registration, so that the "roots" information at the directory service gets refreshed
543
                                if (count($json['roots']) == 0) $out['text'] .= '<p>'._L('In order to use this feature, you need to have at least one (root) OID added in your system, and the system needs to report the newly added root to the directory service (the reporting interval is 1 hour).').'</p>';
543
                                if (count($json['roots']) == 0) $out['text'] .= '<p>'._L('In order to use this feature, you need to have at least one (root) OID added in your system, and the system needs to report the newly added root to the directory service (the reporting interval is 1 hour).').'</p>';
544
                                foreach ($json['roots'] as $root) {
544
                                foreach ($json['roots'] as $root) {
545
                                        $oid = $root['oid'];
545
                                        $oid = $root['oid'];
546
                                        $out['text'] .= '<h2>'._L('Root OID %1',$oid).'</h2>';
546
                                        $out['text'] .= '<h2>'._L('Root OID %1',$oid).'</h2>';
547
                                        // TODO: "Import all" button
547
                                        // TODO: "Import all" button
548
                                        if ($root['verified']) {
548
                                        if ($root['verified']) {
549
                                                $count = 0;
549
                                                $count = 0;
550
                                                $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
550
                                                $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
551
                                                $out['text'] .= '<table class="table table-bordered table-striped">';
551
                                                $out['text'] .= '<table class="table table-bordered table-striped">';
552
                                                $out['text'] .= '<tr><th colspan="4">'._L('Actions').'</th><th>'._L('OID').'</th></tr>';
552
                                                $out['text'] .= '<tr><th colspan="4">'._L('Actions').'</th><th>'._L('OID').'</th></tr>';
553
                                                natsort($root['children']);
553
                                                natsort($root['children']);
554
                                                foreach ($root['children'] as $child_oid) {
554
                                                foreach ($root['children'] as $child_oid) {
555
                                                        if (!in_array($child_oid, $all_local_oids)) {
555
                                                        if (!in_array($child_oid, $all_local_oids)) {
556
                                                                $count++;
556
                                                                $count++;
557
                                                                // Note: "Actions" is at the left, because it has a fixed width, so the user can continue clicking without the links moving if the OID length changes between lines
557
                                                                // Note: "Actions" is at the left, because it has a fixed width, so the user can continue clicking without the links moving if the OID length changes between lines
558
                                                                $out['text'] .= '<tr id="missing_oid_'.str_replace('.','_',$child_oid).'">'.
558
                                                                $out['text'] .= '<tr id="missing_oid_'.str_replace('.','_',$child_oid).'">'.
559
                                                                '<td><a target="_blank" href="http://www.oid-info.com/get/'.$child_oid.'">'._L('View OID at oid-info.com').'</a></td>'.
559
                                                                '<td><a target="_blank" href="http://www.oid-info.com/get/'.$child_oid.'">'._L('View OID at oid-info.com').'</a></td>'.
560
                                                                '<td><a href="javascript:OIDplusPageAdminOIDInfoExport.removeMissingOid(\''.$child_oid.'\');">'._L('Ignore for now').'</a></td>'.
560
                                                                '<td><a href="javascript:OIDplusPageAdminOIDInfoExport.removeMissingOid(\''.$child_oid.'\');">'._L('Ignore for now').'</a></td>'.
561
                                                                '<td><a href="mailto:admin@oid-info.com">'._L('Report illegal OID').'</a></td>'.
561
                                                                '<td><a href="mailto:admin@oid-info.com">'._L('Report illegal OID').'</a></td>'.
562
                                                                (strpos($child_oid,'1.3.6.1.4.1.37476.30.9.') === 0 ? '<td>&nbsp;</td>' : '<td><a href="javascript:OIDplusPageAdminOIDInfoExport.importMissingOid(\''.$child_oid.'\');">'._L('Import OID').'</a></td>').
562
                                                                (strpos($child_oid,'1.3.6.1.4.1.37476.30.9.') === 0 ? '<td>&nbsp;</td>' : '<td><a href="javascript:OIDplusPageAdminOIDInfoExport.importMissingOid(\''.$child_oid.'\');">'._L('Import OID').'</a></td>').
563
                                                                '<td>'.$child_oid.'</td>'.
563
                                                                '<td>'.$child_oid.'</td>'.
564
                                                                '</tr>';
564
                                                                '</tr>';
565
                                                        }
565
                                                        }
566
                                                }
566
                                                }
567
                                                if ($count == 0) {
567
                                                if ($count == 0) {
568
                                                        $out['text'] .= '<tr><td colspan="5">'._L('No extra OIDs found').'</td></tr>';
568
                                                        $out['text'] .= '<tr><td colspan="5">'._L('No extra OIDs found').'</td></tr>';
569
                                                }
569
                                                }
570
                                                $out['text'] .= '</table></div></div>';
570
                                                $out['text'] .= '</table></div></div>';
571
                                        } else {
571
                                        } else {
572
                                                $out['text'] .= '<p>'._L('This root is not validated. Please send an email to %1 in order to request ownership verification of this root OID.',$json['vts_verification_email']).'</p>';
572
                                                $out['text'] .= '<p>'._L('This root is not validated. Please send an email to %1 in order to request ownership verification of this root OID.',$json['vts_verification_email']).'</p>';
573
                                        }
573
                                        }
574
                                }
574
                                }
575
                        }
575
                        }
576
                }
576
                }
577
 
577
 
578
                if ($id === 'oidplus:datatransfer') {
578
                if ($id === 'oidplus:datatransfer') {
579
                        $handled = true;
579
                        $handled = true;
580
                        $out['title'] = _L('Data Transfer');
580
                        $out['title'] = _L('Data Transfer');
581
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
581
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
582
 
582
 
583
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
583
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
584
                                $out['icon'] = 'img/error.png';
584
                                $out['icon'] = 'img/error.png';
585
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
585
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
586
                                return;
586
                                return;
587
                        }
587
                        }
588
 
588
 
589
                        $out['text'] = '<noscript>';
589
                        $out['text'] = '<noscript>';
590
                        $out['text'] .= '<p>'._L('You need to enable JavaScript to use the login area.').'</p>';
590
                        $out['text'] .= '<p>'._L('You need to enable JavaScript to use the login area.').'</p>';
591
                        $out['text'] .= '</noscript>';
591
                        $out['text'] .= '</noscript>';
592
 
592
 
593
                        $out['text'] .= '<br><div id="dataTransferArea" style="visibility: hidden"><div id="dataTransferTab" class="container" style="width:100%;">';
593
                        $out['text'] .= '<br><div id="dataTransferArea" style="visibility: hidden"><div id="dataTransferTab" class="container" style="width:100%;">';
594
 
594
 
595
                        // ---------------- Tab control
595
                        // ---------------- Tab control
596
                        $out['text'] .= OIDplus::gui()->tabBarStart();
596
                        $out['text'] .= OIDplus::gui()->tabBarStart();
597
                        $out['text'] .= OIDplus::gui()->tabBarElement('export', _L('Export'), $tab === 'export');
597
                        $out['text'] .= OIDplus::gui()->tabBarElement('export', _L('Export'), $tab === 'export');
598
                        $out['text'] .= OIDplus::gui()->tabBarElement('import', _L('Import'), $tab === 'import');
598
                        $out['text'] .= OIDplus::gui()->tabBarElement('import', _L('Import'), $tab === 'import');
599
                        $out['text'] .= OIDplus::gui()->tabBarEnd();
599
                        $out['text'] .= OIDplus::gui()->tabBarEnd();
600
                        $out['text'] .= OIDplus::gui()->tabContentStart();
600
                        $out['text'] .= OIDplus::gui()->tabContentStart();
601
                        // ---------------- "Export" tab
601
                        // ---------------- "Export" tab
602
                        $tabcont  = '<h2>'._L('Generate XML file containing all OIDs').'</h2>';
602
                        $tabcont  = '<h2>'._L('Generate XML file containing all OIDs').'</h2>';
603
                        $tabcont .= '<p>'._L('These XML files are following the <a %1>XML schema</a> of <b>oid-info.com</b>. They can be used for various purposes though.','href="http://www.oid-info.com/oid.xsd" target="_blank"').'</p>';
603
                        $tabcont .= '<p>'._L('These XML files are following the <a %1>XML schema</a> of <b>oid-info.com</b>. They can be used for various purposes though.','href="http://www.oid-info.com/oid.xsd" target="_blank"').'</p>';
604
                        $tabcont .= '<p><input type="button" onclick="window.open(\''.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'oidinfo_export.php\',\'_blank\')" value="'._L('Generate XML (all OIDs)').'"></p>';
604
                        $tabcont .= '<p><input type="button" onclick="window.open(\''.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'oidinfo_export.php\',\'_blank\')" value="'._L('Generate XML (all OIDs)').'"></p>';
605
                        $tabcont .= '<p><input type="button" onclick="window.open(\''.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'oidinfo_export.php?online=1\',\'_blank\')" value="'._L('Generate XML (only OIDs which do not exist at oid-info.com)').'"></p>';
605
                        $tabcont .= '<p><input type="button" onclick="window.open(\''.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'oidinfo_export.php?online=1\',\'_blank\')" value="'._L('Generate XML (only OIDs which do not exist at oid-info.com)').'"></p>';
606
                        $tabcont .= '<p><a href="http://www.oid-info.com/submit.htm" target="_blank">'._L('Upload XML files manually to oid-info.com').'</a></p>';
606
                        $tabcont .= '<p><a href="http://www.oid-info.com/submit.htm" target="_blank">'._L('Upload XML files manually to oid-info.com').'</a></p>';
607
                        $tabcont .= '<br><p>'._L('Attention: Do not use this XML Export/Import to exchange, backup or restore data between OIDplus systems!<br>It will cause various loss of information, e.g. because Non-OIDs like GUIDs are converted in OIDs and can\'t be converted back.').'</p>';
607
                        $tabcont .= '<br><p>'._L('Attention: Do not use this XML Export/Import to exchange, backup or restore data between OIDplus systems!<br>It will cause various loss of information, e.g. because Non-OIDs like GUIDs are converted in OIDs and can\'t be converted back.').'</p>';
608
                        $tabcont .= '<h2>'._L('Automatic export to oid-info.com').'</h2>';
608
                        $tabcont .= '<h2>'._L('Automatic export to oid-info.com').'</h2>';
609
                        $privacy_level = OIDplus::config()->getValue('reg_privacy');
609
                        $privacy_level = OIDplus::config()->getValue('reg_privacy');
610
                        if ($privacy_level == 0) {
610
                        if ($privacy_level == 0) {
611
                                $tabcont .= '<p>'._L('All your OIDs will automatically submitted to oid-info.com through the remote directory service in regular intervals.').' (<a '.OIDplus::gui()->link('oidplus:srv_registration').'>'._L('Change preference').'</a>)</p>';
611
                                $tabcont .= '<p>'._L('All your OIDs will automatically submitted to oid-info.com through the remote directory service in regular intervals.').' (<a '.OIDplus::gui()->link('oidplus:srv_registration').'>'._L('Change preference').'</a>)</p>';
612
                        } else {
612
                        } else {
613
                                $tabcont .= '<p>'._L('If you set the privacy option to "0" (your system is registered), then all your OIDs will be automatically exported to oid-info.com.').' (<a '.OIDplus::gui()->link('oidplus:srv_registration').'>'._L('Change preference').'</a>)</p>';
613
                                $tabcont .= '<p>'._L('If you set the privacy option to "0" (your system is registered), then all your OIDs will be automatically exported to oid-info.com.').' (<a '.OIDplus::gui()->link('oidplus:srv_registration').'>'._L('Change preference').'</a>)</p>';
614
                        }
614
                        }
615
                        $tabcont .= '<h2>'._L('Comparison with oid-info.com').'</h2>';
615
                        $tabcont .= '<h2>'._L('Comparison with oid-info.com').'</h2>';
616
                        $tabcont .= '<p><a '.OIDplus::gui()->link('oidplus:oidinfo_compare_export').'>'._L('List OIDs in your system which are missing at oid-info.com').'</a></p>';
616
                        $tabcont .= '<p><a '.OIDplus::gui()->link('oidplus:oidinfo_compare_export').'>'._L('List OIDs in your system which are missing at oid-info.com').'</a></p>';
617
                        $out['text'] .= OIDplus::gui()->tabContentPage('export', $tabcont, $tab === 'export');
617
                        $out['text'] .= OIDplus::gui()->tabContentPage('export', $tabcont, $tab === 'export');
618
                        // ---------------- "Import" tab
618
                        // ---------------- "Import" tab
619
                        $tabcont  = '<h2>'._L('Import XML file').'</h2>';
619
                        $tabcont  = '<h2>'._L('Import XML file').'</h2>';
620
                        $tabcont .= '<p>'._L('These XML files are following the <a %1>XML schema</a> of <b>oid-info.com</b>.','href="http://www.oid-info.com/oid.xsd" target="_blank"').'</p>';
620
                        $tabcont .= '<p>'._L('These XML files are following the <a %1>XML schema</a> of <b>oid-info.com</b>.','href="http://www.oid-info.com/oid.xsd" target="_blank"').'</p>';
621
                        // TODO: we need a waiting animation!
621
                        // TODO: we need a waiting animation!
622
                        $tabcont .= '<form action="javascript:void(0);" onsubmit="return OIDplusPageAdminOIDInfoExport.uploadXmlFileOnSubmit(this);" enctype="multipart/form-data" id="uploadXmlFileForm">';
622
                        $tabcont .= '<form action="javascript:void(0);" onsubmit="return OIDplusPageAdminOIDInfoExport.uploadXmlFileOnSubmit(this);" enctype="multipart/form-data" id="uploadXmlFileForm">';
623
                        $tabcont .= '<div>'._L('Choose XML file here').':<input type="file" name="userfile" value="" id="userfile">';
623
                        $tabcont .= '<div>'._L('Choose XML file here').':<input type="file" name="userfile" value="" id="userfile">';
624
                        $tabcont .= '<br><input type="submit" value="'._L('Import XML').'"></div>';
624
                        $tabcont .= '<br><input type="submit" value="'._L('Import XML').'"></div>';
625
                        $tabcont .= '</form>';
625
                        $tabcont .= '</form>';
626
                        $tabcont .= '<br><p>'._L('Attention: Do not use this XML Export/Import to exchange, backup or restore data between OIDplus systems!<br>It will cause various loss of information, e.g. because Non-OIDs like GUIDs are converted in OIDs and can\'t be converted back.').'</p>';
626
                        $tabcont .= '<br><p>'._L('Attention: Do not use this XML Export/Import to exchange, backup or restore data between OIDplus systems!<br>It will cause various loss of information, e.g. because Non-OIDs like GUIDs are converted in OIDs and can\'t be converted back.').'</p>';
627
                        $tabcont .= '<h2>'._L('Comparison with oid-info.com').'</h2>';
627
                        $tabcont .= '<h2>'._L('Comparison with oid-info.com').'</h2>';
628
                        $tabcont .= '<p><a '.OIDplus::gui()->link('oidplus:oidinfo_compare_import').'>'._L('List OIDs at oid-info.com which are missing in your system').'</a></p>';
628
                        $tabcont .= '<p><a '.OIDplus::gui()->link('oidplus:oidinfo_compare_import').'>'._L('List OIDs at oid-info.com which are missing in your system').'</a></p>';
629
                        $out['text'] .= OIDplus::gui()->tabContentPage('import', $tabcont, $tab === 'import');
629
                        $out['text'] .= OIDplus::gui()->tabContentPage('import', $tabcont, $tab === 'import');
630
                        $out['text'] .= OIDplus::gui()->tabContentEnd();
630
                        $out['text'] .= OIDplus::gui()->tabContentEnd();
631
                        // ---------------- Tab control END
631
                        // ---------------- Tab control END
632
 
632
 
633
                        $out['text'] .= '</div></div><script>$("#dataTransferArea")[0].style.visibility = "visible";</script>';
633
                        $out['text'] .= '</div></div><script>$("#dataTransferArea")[0].style.visibility = "visible";</script>';
634
                }
634
                }
635
        }
635
        }
636
 
636
 
637
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
637
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
638
                if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
638
                if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
639
 
639
 
640
                if (file_exists(__DIR__.'/img/main_icon16.png')) {
640
                if (file_exists(__DIR__.'/img/main_icon16.png')) {
641
                        $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
641
                        $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
642
                } else {
642
                } else {
643
                        $tree_icon = null; // default icon (folder)
643
                        $tree_icon = null; // default icon (folder)
644
                }
644
                }
645
 
645
 
646
                $json[] = array(
646
                $json[] = array(
647
                        'id' => 'oidplus:datatransfer',
647
                        'id' => 'oidplus:datatransfer',
648
                        'icon' => $tree_icon,
648
                        'icon' => $tree_icon,
649
                        'text' => _L('Data Transfer')
649
                        'text' => _L('Data Transfer')
650
                );
650
                );
651
 
651
 
652
                return true;
652
                return true;
653
        }
653
        }
654
 
654
 
655
        public function tree_search($request) {
655
        public function tree_search($request) {
656
                return false;
656
                return false;
657
        }
657
        }
658
 
658
 
659
        public static function outputXML($only_non_existing) {
659
        public static function outputXML($only_non_existing) {
660
                $out_type = null;
660
                $out_type = null;
661
                $out_content = '';
661
                $out_content = '';
662
 
662
 
663
                // This file contains class OIDInfoAPI.
663
                // This file contains class \OIDInfoAPI.
664
                // We cannot include this in init(), because the init
664
                // We cannot include this in init(), because the init
665
                // of the registration plugin (OIDplusPageAdminRegistration) uses
665
                // of the registration plugin (OIDplusPageAdminRegistration) uses
666
                // OIDplusPageAdminOIDInfoExport::outputXML() before
666
                // OIDplusPageAdminOIDInfoExport::outputXML() before
667
                // OIDplusPageAdminOIDInfoExport::init() ,
667
                // OIDplusPageAdminOIDInfoExport::init() ,
668
                // because OIDplusPageAdminRegistration::init() comes first sometimes.
668
                // because OIDplusPageAdminRegistration::init() comes first sometimes.
669
                require_once __DIR__ . '/oidinfo_api.inc.php';
669
                require_once __DIR__ . '/oidinfo_api.inc.php';
670
 
670
 
671
                $oa = new OIDInfoAPI();
671
                $oa = new \OIDInfoAPI();
672
                if ($only_non_existing) {
672
                if ($only_non_existing) {
673
                        if (!function_exists('socket_create')) {
673
                        if (!function_exists('socket_create')) {
674
                                throw new OIDplusException(_L('You must install the PHP "sockets" in order to check for non-existing OIDs.'));
674
                                throw new OIDplusException(_L('You must install the PHP "sockets" in order to check for non-existing OIDs.'));
675
                        }
675
                        }
676
                        $oa->addSimplePingProvider('viathinksoft.de:49500');
676
                        $oa->addSimplePingProvider('viathinksoft.de:49500');
677
                }
677
                }
678
 
678
 
679
                $email = OIDplus::config()->getValue('admin_email');
679
                $email = OIDplus::config()->getValue('admin_email');
680
                if (empty($email)) $email = 'unknown@example.com';
680
                if (empty($email)) $email = 'unknown@example.com';
681
 
681
 
682
                $sys_title = OIDplus::config()->getValue('system_title');
682
                $sys_title = OIDplus::config()->getValue('system_title');
683
                $name1 = !empty($sys_title) ? $sys_title : 'OIDplus 2.0';
683
                $name1 = !empty($sys_title) ? $sys_title : 'OIDplus 2.0';
684
                $name2 = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'Export interface';
684
                $name2 = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'Export interface';
685
                $out_content .= $oa->xmlAddHeader($name1, $name2, $email); // do not translate
685
                $out_content .= $oa->xmlAddHeader($name1, $name2, $email); // do not translate
686
 
686
 
687
                $params['allow_html'] = true;
687
                $params['allow_html'] = true;
688
                $params['allow_illegal_email'] = true; // It should be enabled, because the creator could have used some kind of human-readable anti-spam technique
688
                $params['allow_illegal_email'] = true; // It should be enabled, because the creator could have used some kind of human-readable anti-spam technique
689
                $params['soft_correct_behavior'] = OIDInfoAPI::SOFT_CORRECT_BEHAVIOR_NONE;
689
                $params['soft_correct_behavior'] = \OIDInfoAPI::SOFT_CORRECT_BEHAVIOR_NONE;
690
                $params['do_online_check'] = false; // Flag to disable this online check, because it generates a lot of traffic and runtime.
690
                $params['do_online_check'] = false; // Flag to disable this online check, because it generates a lot of traffic and runtime.
691
                $params['do_illegality_check'] = true;
691
                $params['do_illegality_check'] = true;
692
                $params['do_simpleping_check'] = $only_non_existing;
692
                $params['do_simpleping_check'] = $only_non_existing;
693
                $params['auto_extract_name'] = '';
693
                $params['auto_extract_name'] = '';
694
                $params['auto_extract_url'] = '';
694
                $params['auto_extract_url'] = '';
695
                $params['always_output_comment'] = false;
695
                $params['always_output_comment'] = false;
696
                $params['creation_allowed_check'] = $only_non_existing;
696
                $params['creation_allowed_check'] = $only_non_existing;
697
                $params['tolerant_htmlentities'] = true;
697
                $params['tolerant_htmlentities'] = true;
698
                $params['ignore_xhtml_light'] = false;
698
                $params['ignore_xhtml_light'] = false;
699
 
699
 
700
                $nonConfidential = OIDplusObject::getAllNonConfidential();
700
                $nonConfidential = OIDplusObject::getAllNonConfidential();
701
                natsort($nonConfidential);
701
                natsort($nonConfidential);
702
 
702
 
703
                foreach ($nonConfidential as $id) {
703
                foreach ($nonConfidential as $id) {
704
                        $obj = OIDplusObject::parse($id);
704
                        $obj = OIDplusObject::parse($id);
705
                        if ($obj) {
705
                        if ($obj) {
706
                                $elements['identifier'] = array();
706
                                $elements['identifier'] = array();
707
                                $res_asn = OIDplus::db()->query("select * from ###asn1id where oid = ?", array($id));
707
                                $res_asn = OIDplus::db()->query("select * from ###asn1id where oid = ?", array($id));
708
                                while ($row_asn = $res_asn->fetch_object()) {
708
                                while ($row_asn = $res_asn->fetch_object()) {
709
                                        $elements['identifier'][] = $row_asn->name; // 'unicode-label' is currently not in the standard format (oid.xsd)
709
                                        $elements['identifier'][] = $row_asn->name; // 'unicode-label' is currently not in the standard format (oid.xsd)
710
                                }
710
                                }
711
 
711
 
712
                                $elements['unicode-label'] = array();
712
                                $elements['unicode-label'] = array();
713
                                $res_iri = OIDplus::db()->query("select * from ###iri where oid = ?", array($id));
713
                                $res_iri = OIDplus::db()->query("select * from ###iri where oid = ?", array($id));
714
                                while ($row_iri = $res_iri->fetch_object()) {
714
                                while ($row_iri = $res_iri->fetch_object()) {
715
                                        $elements['unicode-label'][] = $row_iri->name;
715
                                        $elements['unicode-label'][] = $row_iri->name;
716
                                }
716
                                }
717
 
717
 
718
                                $title = $obj->getTitle();
718
                                $title = $obj->getTitle();
719
                                $description = $obj->getDescription();
719
                                $description = $obj->getDescription();
720
                                $comment = $obj->getComment();
720
                                $comment = $obj->getComment();
721
                                if (!empty($title)) {
721
                                if (!empty($title)) {
722
                                        $elements['description'] = $title;
722
                                        $elements['description'] = $title;
723
                                        $elements['information'] = $description;
723
                                        $elements['information'] = $description;
724
                                        if (trim($title) == trim(strip_tags($description))) {
724
                                        if (trim($title) == trim(strip_tags($description))) {
725
                                                $elements['information'] = '';
725
                                                $elements['information'] = '';
726
                                        }
726
                                        }
727
                                } else if (isset($elements['identifier'][0])) {
727
                                } else if (isset($elements['identifier'][0])) {
728
                                        $elements['description'] = '"'.$elements['identifier'][0].'"';
728
                                        $elements['description'] = '"'.$elements['identifier'][0].'"';
729
                                        $elements['information'] = $description;
729
                                        $elements['information'] = $description;
730
                                } else if (isset($elements['unicode-label'][0])) {
730
                                } else if (isset($elements['unicode-label'][0])) {
731
                                        $elements['description'] = '"'.$elements['unicode-label'][0].'"';
731
                                        $elements['description'] = '"'.$elements['unicode-label'][0].'"';
732
                                        $elements['information'] = $description;
732
                                        $elements['information'] = $description;
733
                                } else if (!empty($description)) {
733
                                } else if (!empty($description)) {
734
                                        $elements['description'] = $description;
734
                                        $elements['description'] = $description;
735
                                        $elements['information'] = '';
735
                                        $elements['information'] = '';
736
                                } else if (!empty($comment)) {
736
                                } else if (!empty($comment)) {
737
                                        $elements['description'] = $comment;
737
                                        $elements['description'] = $comment;
738
                                        $elements['information'] = '';
738
                                        $elements['information'] = '';
739
                                } else {
739
                                } else {
740
                                        $elements['description'] = '<i>No description available</i>'; // do not translate
740
                                        $elements['description'] = '<i>No description available</i>'; // do not translate
741
                                        $elements['information'] = '';
741
                                        $elements['information'] = '';
742
                                }
742
                                }
743
 
743
 
744
                                if ($elements['information'] != '') {
744
                                if ($elements['information'] != '') {
745
                                        $elements['information'] .= '<br/><br/>';
745
                                        $elements['information'] .= '<br/><br/>';
746
                                }
746
                                }
747
 
747
 
748
                                $elements['information'] .= 'See <a href="'.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'?goto='.urlencode($id).'">more information</a>.'; // do not translate
748
                                $elements['information'] .= 'See <a href="'.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'?goto='.urlencode($id).'">more information</a>.'; // do not translate
749
 
749
 
750
                                if (explode(':',$id,2)[0] != 'oid') {
750
                                if (explode(':',$id,2)[0] != 'oid') {
751
                                        $elements['information'] = "Object: $id\n\n" . $elements['information']; // do not translate
751
                                        $elements['information'] = "Object: $id\n\n" . $elements['information']; // do not translate
752
                                }
752
                                }
753
 
753
 
754
                                $elements['description'] = self::repair_relative_links($elements['description']);
754
                                $elements['description'] = self::repair_relative_links($elements['description']);
755
                                $elements['information'] = self::repair_relative_links($elements['information']);
755
                                $elements['information'] = self::repair_relative_links($elements['information']);
756
 
756
 
757
                                $elements['first-registrant']['first-name'] = '';
757
                                $elements['first-registrant']['first-name'] = '';
758
                                $elements['first-registrant']['last-name'] = '';
758
                                $elements['first-registrant']['last-name'] = '';
759
                                $elements['first-registrant']['address'] = '';
759
                                $elements['first-registrant']['address'] = '';
760
                                $elements['first-registrant']['email'] = '';
760
                                $elements['first-registrant']['email'] = '';
761
                                $elements['first-registrant']['phone'] = '';
761
                                $elements['first-registrant']['phone'] = '';
762
                                $elements['first-registrant']['fax'] = '';
762
                                $elements['first-registrant']['fax'] = '';
763
                                $elements['first-registrant']['creation-date'] = self::_formatdate($obj->getCreatedTime());
763
                                $elements['first-registrant']['creation-date'] = self::_formatdate($obj->getCreatedTime());
764
 
764
 
765
                                $elements['current-registrant']['first-name'] = '';
765
                                $elements['current-registrant']['first-name'] = '';
766
                                $elements['current-registrant']['last-name'] = '';
766
                                $elements['current-registrant']['last-name'] = '';
767
                                $elements['current-registrant']['email'] = $obj->getRaMail();
767
                                $elements['current-registrant']['email'] = $obj->getRaMail();
768
                                $elements['current-registrant']['phone'] = '';
768
                                $elements['current-registrant']['phone'] = '';
769
                                $elements['current-registrant']['fax'] = '';
769
                                $elements['current-registrant']['fax'] = '';
770
                                $elements['current-registrant']['address'] = '';
770
                                $elements['current-registrant']['address'] = '';
771
 
771
 
772
                                $res_ra = OIDplus::db()->query("select * from ###ra where email = ?", array($obj->getRaMail()));
772
                                $res_ra = OIDplus::db()->query("select * from ###ra where email = ?", array($obj->getRaMail()));
773
                                if ($res_ra->any()) {
773
                                if ($res_ra->any()) {
774
                                        $row_ra = $res_ra->fetch_object();
774
                                        $row_ra = $res_ra->fetch_object();
775
 
775
 
776
                                        $tmp = array();
776
                                        $tmp = array();
777
                                        if (!empty($row_ra->personal_name)) {
777
                                        if (!empty($row_ra->personal_name)) {
778
                                                $name_ary = split_firstname_lastname($row_ra->personal_name);
778
                                                $name_ary = split_firstname_lastname($row_ra->personal_name);
779
                                                $elements['current-registrant']['first-name'] = $name_ary[0];
779
                                                $elements['current-registrant']['first-name'] = $name_ary[0];
780
                                                $elements['current-registrant']['last-name']  = $name_ary[1];
780
                                                $elements['current-registrant']['last-name']  = $name_ary[1];
781
                                                if (!empty($row_ra->ra_name)       ) $tmp[] = $row_ra->ra_name;
781
                                                if (!empty($row_ra->ra_name)       ) $tmp[] = $row_ra->ra_name;
782
                                                if (!empty($row_ra->office)        ) $tmp[] = $row_ra->office;
782
                                                if (!empty($row_ra->office)        ) $tmp[] = $row_ra->office;
783
                                                if (!empty($row_ra->organization)  ) $tmp[] = $row_ra->organization;
783
                                                if (!empty($row_ra->organization)  ) $tmp[] = $row_ra->organization;
784
                                        } else {
784
                                        } else {
785
                                                $elements['current-registrant']['first-name'] = $row_ra->ra_name;
785
                                                $elements['current-registrant']['first-name'] = $row_ra->ra_name;
786
                                                $elements['current-registrant']['last-name']  = '';
786
                                                $elements['current-registrant']['last-name']  = '';
787
                                                if (!empty($row_ra->personal_name) ) $tmp[] = $row_ra->personal_name;
787
                                                if (!empty($row_ra->personal_name) ) $tmp[] = $row_ra->personal_name;
788
                                                if (!empty($row_ra->office)        ) $tmp[] = $row_ra->office;
788
                                                if (!empty($row_ra->office)        ) $tmp[] = $row_ra->office;
789
                                                if (!empty($row_ra->organization)  ) $tmp[] = $row_ra->organization;
789
                                                if (!empty($row_ra->organization)  ) $tmp[] = $row_ra->organization;
790
                                        }
790
                                        }
791
 
791
 
792
                                        if ((count($tmp) > 0) && ($tmp[0] == $row_ra->ra_name)) array_shift($tmp);
792
                                        if ((count($tmp) > 0) && ($tmp[0] == $row_ra->ra_name)) array_shift($tmp);
793
                                        $tmp = array_unique($tmp);
793
                                        $tmp = array_unique($tmp);
794
 
794
 
795
                                        if (!$row_ra->privacy) {
795
                                        if (!$row_ra->privacy) {
796
                                                if (!empty($row_ra->street))   $tmp[] = $row_ra->street;
796
                                                if (!empty($row_ra->street))   $tmp[] = $row_ra->street;
797
                                                if (!empty($row_ra->zip_town)) $tmp[] = $row_ra->zip_town;
797
                                                if (!empty($row_ra->zip_town)) $tmp[] = $row_ra->zip_town;
798
                                                if (!empty($row_ra->country))  $tmp[] = $row_ra->country;
798
                                                if (!empty($row_ra->country))  $tmp[] = $row_ra->country;
799
                                                $elements['current-registrant']['phone'] = !empty($row_ra->phone) ? $row_ra->phone : $row_ra->mobile;
799
                                                $elements['current-registrant']['phone'] = !empty($row_ra->phone) ? $row_ra->phone : $row_ra->mobile;
800
                                                $elements['current-registrant']['fax'] = $row_ra->fax;
800
                                                $elements['current-registrant']['fax'] = $row_ra->fax;
801
                                        }
801
                                        }
802
                                        if (empty($row_ra->zip_town) && empty($row_ra->country)) {
802
                                        if (empty($row_ra->zip_town) && empty($row_ra->country)) {
803
                                                // The address is useless if we do neither know city nor country
803
                                                // The address is useless if we do neither know city nor country
804
                                                // Ignore it
804
                                                // Ignore it
805
                                                $elements['current-registrant']['address'] = '';
805
                                                $elements['current-registrant']['address'] = '';
806
                                        } else {
806
                                        } else {
807
                                                $elements['current-registrant']['address'] = implode("<br/>", $tmp);
807
                                                $elements['current-registrant']['address'] = implode("<br/>", $tmp);
808
                                        }
808
                                        }
809
                                }
809
                                }
810
                                $elements['current-registrant']['modification-date'] = self::_formatdate($obj->getUpdatedTime());
810
                                $elements['current-registrant']['modification-date'] = self::_formatdate($obj->getUpdatedTime());
811
 
811
 
812
                                // Request from O.D. 20 May 2019: First registrant should not be empty (especially for cases where Creation and Modify Dates are the same)
812
                                // Request from O.D. 20 May 2019: First registrant should not be empty (especially for cases where Creation and Modify Dates are the same)
813
                                // Actually, this is a problem because we don't know the first registrant.
813
                                // Actually, this is a problem because we don't know the first registrant.
814
                                // However, since oidinfo gets their XML very fast (if using registration), it is likely that the reported RA is still the same...
814
                                // However, since oidinfo gets their XML very fast (if using registration), it is likely that the reported RA is still the same...
815
                                // ... and changes at the RA are not reported to oid-info.com anyways - the XML is only for creation
815
                                // ... and changes at the RA are not reported to oid-info.com anyways - the XML is only for creation
816
 
816
 
817
                                $elements['first-registrant']['first-name'] = $elements['current-registrant']['first-name'];
817
                                $elements['first-registrant']['first-name'] = $elements['current-registrant']['first-name'];
818
                                $elements['first-registrant']['last-name']  = $elements['current-registrant']['last-name'];
818
                                $elements['first-registrant']['last-name']  = $elements['current-registrant']['last-name'];
819
                                $elements['first-registrant']['address']    = $elements['current-registrant']['address'];
819
                                $elements['first-registrant']['address']    = $elements['current-registrant']['address'];
820
                                $elements['first-registrant']['email']      = $elements['current-registrant']['email'];
820
                                $elements['first-registrant']['email']      = $elements['current-registrant']['email'];
821
                                $elements['first-registrant']['phone']      = $elements['current-registrant']['phone'];
821
                                $elements['first-registrant']['phone']      = $elements['current-registrant']['phone'];
822
                                $elements['first-registrant']['fax']        = $elements['current-registrant']['fax'];
822
                                $elements['first-registrant']['fax']        = $elements['current-registrant']['fax'];
823
 
823
 
824
                                $elements['current-registrant']['first-name'] = '';
824
                                $elements['current-registrant']['first-name'] = '';
825
                                $elements['current-registrant']['last-name'] = '';
825
                                $elements['current-registrant']['last-name'] = '';
826
                                $elements['current-registrant']['address'] = '';
826
                                $elements['current-registrant']['address'] = '';
827
                                $elements['current-registrant']['email'] = '';
827
                                $elements['current-registrant']['email'] = '';
828
                                $elements['current-registrant']['phone'] = '';
828
                                $elements['current-registrant']['phone'] = '';
829
                                $elements['current-registrant']['fax'] = '';
829
                                $elements['current-registrant']['fax'] = '';
830
                                $elements['current-registrant']['modification-date'] = '';
830
                                $elements['current-registrant']['modification-date'] = '';
831
 
831
 
832
                                // End request O.D. 20 May 2019
832
                                // End request O.D. 20 May 2019
833
 
833
 
834
                                list($ns,$id) = explode(':',$obj->nodeId());
834
                                list($ns,$id) = explode(':',$obj->nodeId());
835
                                if ($ns == 'oid') {
835
                                if ($ns == 'oid') {
836
                                        $out_content .= $oa->createXMLEntry($id, $elements, $params, $comment=$obj->nodeId());
836
                                        $out_content .= $oa->createXMLEntry($id, $elements, $params, $comment=$obj->nodeId());
837
                                } else {
837
                                } else {
838
                                        $alt_ids = $obj->getAltIds(); // TODO: slow!
838
                                        $alt_ids = $obj->getAltIds(); // TODO: slow!
839
                                        foreach ($alt_ids as $alt_id) {
839
                                        foreach ($alt_ids as $alt_id) {
840
                                                $ns = $alt_id->getNamespace();
840
                                                $ns = $alt_id->getNamespace();
841
                                                $id = $alt_id->getId();
841
                                                $id = $alt_id->getId();
842
                                                $desc = $alt_id->getDescription();
842
                                                $desc = $alt_id->getDescription();
843
                                                if ($ns == 'oid') {
843
                                                if ($ns == 'oid') {
844
                                                        if (strpos($id, '2.25.') === 0) continue; // don't spam the uuid arc with GUID objects
844
                                                        if (strpos($id, '2.25.') === 0) continue; // don't spam the uuid arc with GUID objects
845
                                                        $out_content .= $oa->createXMLEntry($id, $elements, $params, $comment=$obj->nodeId());
845
                                                        $out_content .= $oa->createXMLEntry($id, $elements, $params, $comment=$obj->nodeId());
846
                                                }
846
                                                }
847
                                        }
847
                                        }
848
                                }
848
                                }
849
                        }
849
                        }
850
                }
850
                }
851
 
851
 
852
                $out_content .= $oa->xmlAddFooter();
852
                $out_content .= $oa->xmlAddFooter();
853
 
853
 
854
                $out_type = 'text/xml';
854
                $out_type = 'text/xml';
855
                return array($out_content, $out_type);
855
                return array($out_content, $out_type);
856
        }
856
        }
857
 
857
 
858
        private static function _formatdate($str) {
858
        private static function _formatdate($str) {
859
                $str = explode(' ',$str)[0];
859
                $str = explode(' ',$str)[0];
860
                if ($str == '0000-00-00') $str = '';
860
                if ($str == '0000-00-00') $str = '';
861
                return $str;
861
                return $str;
862
        }
862
        }
863
 
863
 
864
        private static function repair_relative_links($str) {
864
        private static function repair_relative_links($str) {
865
                $str = preg_replace_callback('@(href\s*=\s*([\'"]))(.+)(\\2)@ismU', function($treffer) {
865
                $str = preg_replace_callback('@(href\s*=\s*([\'"]))(.+)(\\2)@ismU', function($treffer) {
866
                        $url = $treffer[3];
866
                        $url = $treffer[3];
867
                        if ((stripos($url,'http:') !== 0) && (stripos($url,'https:') !== 0) && (stripos($url,'ftp:') !== 0)) {
867
                        if ((stripos($url,'http:') !== 0) && (stripos($url,'https:') !== 0) && (stripos($url,'ftp:') !== 0)) {
868
                                if (stripos($url,'www.') === 0) {
868
                                if (stripos($url,'www.') === 0) {
869
                                        $url .= 'http://' . $url;
869
                                        $url .= 'http://' . $url;
870
                                } else {
870
                                } else {
871
                                        $url = OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL) . $url; // TODO: Canonical or not?
871
                                        $url = OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL) . $url; // TODO: Canonical or not?
872
                                }
872
                                }
873
                        }
873
                        }
874
                        return $treffer[1].$url.$treffer[4];
874
                        return $treffer[1].$url.$treffer[4];
875
                }, $str);
875
                }, $str);
876
                return $str;
876
                return $str;
877
        }
877
        }
878
 
878
 
879
        private static function split_address_country($address) {
879
        private static function split_address_country($address) {
880
                global $oidinfo_countries;
880
                global $oidinfo_countries;
881
                $ary = explode("\n", $address);
881
                $ary = explode("\n", $address);
882
                $last_line = array_pop($ary);
882
                $last_line = array_pop($ary);
883
                $rest = implode("\n", $ary);
883
                $rest = implode("\n", $ary);
884
                if (isset($oidinfo_countries[$last_line])) {
884
                if (isset($oidinfo_countries[$last_line])) {
885
                        return array($rest, $oidinfo_countries[$last_line]);
885
                        return array($rest, $oidinfo_countries[$last_line]);
886
                } else {
886
                } else {
887
                        return array($rest."\n".$last_line, '');
887
                        return array($rest."\n".$last_line, '');
888
                }
888
                }
889
        }
889
        }
890
 
890
 
891
        private static function split_name($name) {
891
        private static function split_name($name) {
892
                // uses regex that accepts any word character or hyphen in last name
892
                // uses regex that accepts any word character or hyphen in last name
893
                // https://stackoverflow.com/questions/13637145/split-text-string-into-first-and-last-name-in-php
893
                // https://stackoverflow.com/questions/13637145/split-text-string-into-first-and-last-name-in-php
894
                $name = trim($name);
894
                $name = trim($name);
895
                $last_name = (strpos($name, ' ') === false) ? '' : preg_replace('#.*\s([\w-]*)$#', '$1', $name);
895
                $last_name = (strpos($name, ' ') === false) ? '' : preg_replace('#.*\s([\w-]*)$#', '$1', $name);
896
                $first_name = trim( preg_replace('#'.preg_quote($last_name,'#').'#', '', $name ) );
896
                $first_name = trim( preg_replace('#'.preg_quote($last_name,'#').'#', '', $name ) );
897
                return array($first_name, $last_name);
897
                return array($first_name, $last_name);
898
        }
898
        }
899
 
899
 
900
        /*protected*/ const ORPHAN_IGNORE = 0;
900
        /*protected*/ const ORPHAN_IGNORE = 0;
901
        /*protected*/ const ORPHAN_AUTO_DEORPHAN = 1;
901
        /*protected*/ const ORPHAN_AUTO_DEORPHAN = 1;
902
        /*protected*/ const ORPHAN_DISALLOW_ORPHANS = 2;
902
        /*protected*/ const ORPHAN_DISALLOW_ORPHANS = 2;
903
 
903
 
904
        protected function oidinfoImportXML($xml_contents, &$errors, $replaceExistingOIDs=false, $orphan_mode=self::ORPHAN_AUTO_DEORPHAN) {
904
        protected function oidinfoImportXML($xml_contents, &$errors, $replaceExistingOIDs=false, $orphan_mode=self::ORPHAN_AUTO_DEORPHAN) {
905
                // TODO: Implement RA import (let the user decide)
905
                // TODO: Implement RA import (let the user decide)
906
                // TODO: Let the user decide about $replaceExistingOIDs
906
                // TODO: Let the user decide about $replaceExistingOIDs
907
                // TODO: Let the user decide if "created=now" should be set (this is good when the XML files is created by the user itself to do bulk-inserts)
907
                // TODO: Let the user decide if "created=now" should be set (this is good when the XML files is created by the user itself to do bulk-inserts)
908
 
908
 
909
                $xml_contents = str_replace('<description>', '<description><![CDATA[', $xml_contents);
909
                $xml_contents = str_replace('<description>', '<description><![CDATA[', $xml_contents);
910
                $xml_contents = str_replace('</description>', ']]></description>', $xml_contents);
910
                $xml_contents = str_replace('</description>', ']]></description>', $xml_contents);
911
 
911
 
912
                $xml_contents = str_replace('<information>', '<information><![CDATA[', $xml_contents);
912
                $xml_contents = str_replace('<information>', '<information><![CDATA[', $xml_contents);
913
                $xml_contents = str_replace('</information>', ']]></information>', $xml_contents);
913
                $xml_contents = str_replace('</information>', ']]></information>', $xml_contents);
914
 
914
 
915
                $xml = @simplexml_load_string($xml_contents);
915
                $xml = @simplexml_load_string($xml_contents);
916
 
916
 
917
                $count_already_existing = 0;
917
                $count_already_existing = 0;
918
                $count_errors = 0;
918
                $count_errors = 0;
919
                $count_warnings = 0;
919
                $count_warnings = 0;
920
 
920
 
921
                if (!$xml) {
921
                if (!$xml) {
922
                        $errors[] = _L('Cannot read XML data. The XML file is probably invalid.');
922
                        $errors[] = _L('Cannot read XML data. The XML file is probably invalid.');
923
                        $count_errors++;
923
                        $count_errors++;
924
                        return array(0, 0, 1, 0);
924
                        return array(0, 0, 1, 0);
925
                }
925
                }
926
 
926
 
927
                $ok_oids = array();
927
                $ok_oids = array();
928
 
928
 
929
                foreach ($xml->oid as $xoid) {
929
                foreach ($xml->oid as $xoid) {
930
 
930
 
931
                        if (isset($xoid->{'dot-notation'})) {
931
                        if (isset($xoid->{'dot-notation'})) {
932
                                $dot_notation = $xoid->{'dot-notation'}->__toString();
932
                                $dot_notation = $xoid->{'dot-notation'}->__toString();
933
                        } else if (isset($xoid->{'asn1-notation'})) {
933
                        } else if (isset($xoid->{'asn1-notation'})) {
934
                                $dot_notation = asn1_to_dot($xoid->{'asn1-notation'}->__toString());
934
                                $dot_notation = asn1_to_dot($xoid->{'asn1-notation'}->__toString());
935
                        } else {
935
                        } else {
936
                                $errors[] = _L('Cannot find dot notation because fields asn1-notation and dot-notation are both not existing');
936
                                $errors[] = _L('Cannot find dot notation because fields asn1-notation and dot-notation are both not existing');
937
                                $count_errors++;
937
                                $count_errors++;
938
                                continue;
938
                                continue;
939
                        }
939
                        }
940
 
940
 
941
                        $id = "oid:$dot_notation";
941
                        $id = "oid:$dot_notation";
942
                        $title = isset($xoid->{'description'}) ? $xoid->{'description'}->__toString() : '';
942
                        $title = isset($xoid->{'description'}) ? $xoid->{'description'}->__toString() : '';
943
                        $info = isset($xoid->{'description'}) ? $xoid->{'information'}->__toString() : '';
943
                        $info = isset($xoid->{'description'}) ? $xoid->{'information'}->__toString() : '';
944
 
944
 
945
                        // For ASN.1 definitions, "Description" is filled with the definition and "Information" is usually empty
945
                        // For ASN.1 definitions, "Description" is filled with the definition and "Information" is usually empty
946
                        if (strpos($title,'<br') !== false) {
946
                        if (strpos($title,'<br') !== false) {
947
                                $info = $title . $info;
947
                                $info = $title . $info;
948
                                $title = explode(' ',$title)[0];
948
                                $title = explode(' ',$title)[0];
949
                        }
949
                        }
950
 
950
 
951
                        if (isset($xoid->{'current-registrant'}->email)) {
951
                        if (isset($xoid->{'current-registrant'}->email)) {
952
                                $ra = $xoid->{'current-registrant'}->email->__toString();
952
                                $ra = $xoid->{'current-registrant'}->email->__toString();
953
                        } else if (isset($xoid->{'first-registrant'}->email)) {
953
                        } else if (isset($xoid->{'first-registrant'}->email)) {
954
                                $ra = $xoid->{'first-registrant'}->email->__toString();
954
                                $ra = $xoid->{'first-registrant'}->email->__toString();
955
                        } else {
955
                        } else {
956
                                $ra = '';
956
                                $ra = '';
957
                        }
957
                        }
958
 
958
 
959
                        if (!oid_valid_dotnotation($dot_notation, false, false)) {
959
                        if (!oid_valid_dotnotation($dot_notation, false, false)) {
960
                                $errors[] = _L('Ignored OID %1 because its dot notation is illegal or was not found',$dot_notation);
960
                                $errors[] = _L('Ignored OID %1 because its dot notation is illegal or was not found',$dot_notation);
961
                                $count_errors++;
961
                                $count_errors++;
962
                                continue;
962
                                continue;
963
                        }
963
                        }
964
 
964
 
965
                        $parent = 'oid:'.oid_up($dot_notation);
965
                        $parent = 'oid:'.oid_up($dot_notation);
966
 
966
 
967
                        if ($orphan_mode === self::ORPHAN_DISALLOW_ORPHANS) {
967
                        if ($orphan_mode === self::ORPHAN_DISALLOW_ORPHANS) {
968
                                if (!OIDplusObject::exists($parent)) {
968
                                if (!OIDplusObject::exists($parent)) {
969
                                        $errors[] = _L('Cannot import %1, because its parent is not in the database.',$dot_notation);
969
                                        $errors[] = _L('Cannot import %1, because its parent is not in the database.',$dot_notation);
970
                                        $count_errors++;
970
                                        $count_errors++;
971
                                        continue;
971
                                        continue;
972
                                }
972
                                }
973
                        }
973
                        }
974
 
974
 
975
                        OIDplus::db()->transaction_begin();
975
                        OIDplus::db()->transaction_begin();
976
 
976
 
977
                        $obj_test = OIDplusObject::findFitting($id);
977
                        $obj_test = OIDplusObject::findFitting($id);
978
                        if ($obj_test) {
978
                        if ($obj_test) {
979
                                if ($replaceExistingOIDs) {
979
                                if ($replaceExistingOIDs) {
980
                                        OIDplus::db()->query("delete from ###objects where id = ?", array($id));
980
                                        OIDplus::db()->query("delete from ###objects where id = ?", array($id));
981
                                        OIDplus::db()->query("delete from ###asn1id where oid = ?", array($id));
981
                                        OIDplus::db()->query("delete from ###asn1id where oid = ?", array($id));
982
                                        OIDplus::db()->query("delete from ###iri where oid = ?", array($id));
982
                                        OIDplus::db()->query("delete from ###iri where oid = ?", array($id));
983
                                } else {
983
                                } else {
984
                                        //$errors[] = "Ignore OID '$dot_notation' because it already exists";
984
                                        //$errors[] = "Ignore OID '$dot_notation' because it already exists";
985
                                        //$count_errors++;
985
                                        //$count_errors++;
986
                                        $count_already_existing++;
986
                                        $count_already_existing++;
987
                                        continue;
987
                                        continue;
988
                                }
988
                                }
989
                        }
989
                        }
990
 
990
 
991
                        // TODO: we can probably get the created and modified timestamp from oid-info.com XML
991
                        // TODO: we can probably get the created and modified timestamp from oid-info.com XML
992
                        OIDplus::db()->query("insert into ###objects (id, parent, title, description, confidential, ra_email) values (?, ?, ?, ?, ?, ?)", array($id, $parent, $title, $info, 0, $ra));
992
                        OIDplus::db()->query("insert into ###objects (id, parent, title, description, confidential, ra_email) values (?, ?, ?, ?, ?, ?)", array($id, $parent, $title, $info, 0, $ra));
993
 
993
 
994
                        OIDplus::db()->transaction_commit();
994
                        OIDplus::db()->transaction_commit();
995
                        OIDplusObject::resetObjectInformationCache();
995
                        OIDplusObject::resetObjectInformationCache();
996
 
996
 
997
                        $this_oid_has_warnings = false;
997
                        $this_oid_has_warnings = false;
998
 
998
 
999
                        // ---------------------------------------------------------------------
999
                        // ---------------------------------------------------------------------
1000
 
1000
 
1001
                        $asn1ids = array();
1001
                        $asn1ids = array();
1002
                        if (isset($xoid->{'identifier'})) {
1002
                        if (isset($xoid->{'identifier'})) {
1003
                                $asn1ids[] = $xoid->{'identifier'}->__toString();
1003
                                $asn1ids[] = $xoid->{'identifier'}->__toString();
1004
                        }
1004
                        }
1005
                        if (isset($xoid->{'asn1-notation'})) {
1005
                        if (isset($xoid->{'asn1-notation'})) {
1006
                                $last_id = asn1_last_identifier($xoid->{'asn1-notation'}->__toString());
1006
                                $last_id = asn1_last_identifier($xoid->{'asn1-notation'}->__toString());
1007
                                if ($last_id) {
1007
                                if ($last_id) {
1008
                                        $asn1ids[] = $last_id;
1008
                                        $asn1ids[] = $last_id;
1009
                                }
1009
                                }
1010
                        }
1010
                        }
1011
                        if (isset($xoid->{'synonymous-identifier'})) {
1011
                        if (isset($xoid->{'synonymous-identifier'})) {
1012
                                foreach ($xoid->{'synonymous-identifier'} as $synid) {
1012
                                foreach ($xoid->{'synonymous-identifier'} as $synid) {
1013
                                        $asn1ids[] = $synid->__toString();
1013
                                        $asn1ids[] = $synid->__toString();
1014
                                }
1014
                                }
1015
                        }
1015
                        }
1016
                        $asn1ids = array_unique($asn1ids);
1016
                        $asn1ids = array_unique($asn1ids);
1017
                        foreach ($asn1ids as $asn1id) {
1017
                        foreach ($asn1ids as $asn1id) {
1018
                                if (!oid_id_is_valid($asn1id)) {
1018
                                if (!oid_id_is_valid($asn1id)) {
1019
                                        $errors[] = _L('Warning').' ['._L('OID %1',$dot_notation).']: '._L('Ignored alphanumeric identifier %1, because it is invalid',$asn1id);
1019
                                        $errors[] = _L('Warning').' ['._L('OID %1',$dot_notation).']: '._L('Ignored alphanumeric identifier %1, because it is invalid',$asn1id);
1020
                                        $this_oid_has_warnings = true;
1020
                                        $this_oid_has_warnings = true;
1021
                                } else {
1021
                                } else {
1022
                                        OIDplus::db()->query("delete from ###asn1id where oid = ? and name = ?", array($id, $asn1id));
1022
                                        OIDplus::db()->query("delete from ###asn1id where oid = ? and name = ?", array($id, $asn1id));
1023
                                        OIDplus::db()->query("insert into ###asn1id (oid, name) values (?, ?)", array($id, $asn1id));
1023
                                        OIDplus::db()->query("insert into ###asn1id (oid, name) values (?, ?)", array($id, $asn1id));
1024
                                }
1024
                                }
1025
                        }
1025
                        }
1026
 
1026
 
1027
                        // ---------------------------------------------------------------------
1027
                        // ---------------------------------------------------------------------
1028
 
1028
 
1029
                        if (isset($xoid->{'unicode-label'})) {
1029
                        if (isset($xoid->{'unicode-label'})) {
1030
                                $iris = array();
1030
                                $iris = array();
1031
                                foreach ($xoid->{'unicode-label'} as $iri) {
1031
                                foreach ($xoid->{'unicode-label'} as $iri) {
1032
                                        $iris[] = $iri->__toString();
1032
                                        $iris[] = $iri->__toString();
1033
                                }
1033
                                }
1034
                                $iris = array_unique($iris);
1034
                                $iris = array_unique($iris);
1035
                                foreach ($iris as $iri) {
1035
                                foreach ($iris as $iri) {
1036
                                        if (!iri_arc_valid($iri, false)) {
1036
                                        if (!iri_arc_valid($iri, false)) {
1037
                                                $errors[] = _L('Warning').' ['._L('OID %1',$dot_notation).']: '._L('Ignored Unicode label %1, because it is invalid',$iri);
1037
                                                $errors[] = _L('Warning').' ['._L('OID %1',$dot_notation).']: '._L('Ignored Unicode label %1, because it is invalid',$iri);
1038
                                                $this_oid_has_warnings = true;
1038
                                                $this_oid_has_warnings = true;
1039
                                        } else {
1039
                                        } else {
1040
                                                OIDplus::db()->query("delete from ###iri where oid = ? and name = ?", array($id, $iri));
1040
                                                OIDplus::db()->query("delete from ###iri where oid = ? and name = ?", array($id, $iri));
1041
                                                OIDplus::db()->query("insert into ###iri (oid, name) values (?, ?)", array($id, $iri));
1041
                                                OIDplus::db()->query("insert into ###iri (oid, name) values (?, ?)", array($id, $iri));
1042
                                        }
1042
                                        }
1043
                                }
1043
                                }
1044
                        }
1044
                        }
1045
 
1045
 
1046
                        if ($this_oid_has_warnings) $count_warnings++;
1046
                        if ($this_oid_has_warnings) $count_warnings++;
1047
                        $ok_oids[] = $id;
1047
                        $ok_oids[] = $id;
1048
                }
1048
                }
1049
 
1049
 
1050
                // De-orphanize
1050
                // De-orphanize
1051
                //if ($orphan_mode === self::ORPHAN_AUTO_DEORPHAN) {
1051
                //if ($orphan_mode === self::ORPHAN_AUTO_DEORPHAN) {
1052
                //      OIDplus::db()->query("update ###objects set parent = 'oid:' where parent like 'oid:%' and parent not in (select id from ###objects)");
1052
                //      OIDplus::db()->query("update ###objects set parent = 'oid:' where parent like 'oid:%' and parent not in (select id from ###objects)");
1053
                //      OIDplusObject::resetObjectInformationCache();
1053
                //      OIDplusObject::resetObjectInformationCache();
1054
                //}
1054
                //}
1055
                foreach ($ok_oids as $id) {
1055
                foreach ($ok_oids as $id) {
1056
                        // De-orphanize if neccessary
1056
                        // De-orphanize if neccessary
1057
                        if ($orphan_mode === self::ORPHAN_AUTO_DEORPHAN) {
1057
                        if ($orphan_mode === self::ORPHAN_AUTO_DEORPHAN) {
1058
                                $res = OIDplus::db()->query("select * from ###objects where id = ? and parent not in (select id from ###objects)", array($id));
1058
                                $res = OIDplus::db()->query("select * from ###objects where id = ? and parent not in (select id from ###objects)", array($id));
1059
                                if ($res->any()) {
1059
                                if ($res->any()) {
1060
                                        $errors[] = _L("%1 was de-orphaned (placed as root OID) because its parent is not existing.",$id);
1060
                                        $errors[] = _L("%1 was de-orphaned (placed as root OID) because its parent is not existing.",$id);
1061
                                        $count_warnings++;
1061
                                        $count_warnings++;
1062
                                        OIDplus::db()->query("update ###objects set parent = 'oid:' where id = ? and parent not in (select id from ###objects)", array($id));
1062
                                        OIDplus::db()->query("update ###objects set parent = 'oid:' where id = ? and parent not in (select id from ###objects)", array($id));
1063
                                        OIDplusObject::resetObjectInformationCache();
1063
                                        OIDplusObject::resetObjectInformationCache();
1064
                                }
1064
                                }
1065
                        }
1065
                        }
1066
 
1066
 
1067
                        // We do the logging at the end, otherwise SUPOIDRA() might not work correctly if the OIDs were not imported in order or if there were orphans
1067
                        // We do the logging at the end, otherwise SUPOIDRA() might not work correctly if the OIDs were not imported in order or if there were orphans
1068
                        OIDplus::logger()->log("[INFO]OID($id)+[INFO]SUPOID($id)+[INFO]SUPOIDRA($id)!/[INFO]A!", "Object '$id' was automatically created by the XML import tool");
1068
                        OIDplus::logger()->log("[INFO]OID($id)+[INFO]SUPOID($id)+[INFO]SUPOIDRA($id)!/[INFO]A!", "Object '$id' was automatically created by the XML import tool");
1069
                }
1069
                }
1070
 
1070
 
1071
                $count_imported_oids = count($ok_oids);
1071
                $count_imported_oids = count($ok_oids);
1072
 
1072
 
1073
                return array($count_imported_oids, $count_already_existing, $count_errors, $count_warnings);
1073
                return array($count_imported_oids, $count_already_existing, $count_errors, $count_warnings);
1074
 
1074
 
1075
        }
1075
        }
1076
 
1076
 
1077
        public function implementsFeature($id) {
1077
        public function implementsFeature($id) {
1078
                if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
1078
                if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
1079
                return false;
1079
                return false;
1080
        }
1080
        }
1081
 
1081
 
1082
        public function getNotifications($user=null): array {
1082
        public function getNotifications($user=null): array {
1083
                // Interface 1.3.6.1.4.1.37476.2.5.2.3.8
1083
                // Interface 1.3.6.1.4.1.37476.2.5.2.3.8
1084
                $notifications = array();
1084
                $notifications = array();
1085
                if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
1085
                if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
1086
                        if (!function_exists('curl_init')) {
1086
                        if (!function_exists('curl_init')) {
1087
                                $title = _L('OID-Info.com import/export');
1087
                                $title = _L('OID-Info.com import/export');
1088
                                $notifications[] = array('ERR', _L('OIDplus plugin "%1" is enabled, but the required PHP extension "%2" is not installed.', '<a '.OIDplus::gui()->link('oidplus:datatransfer').'>'.htmlentities($title).'</a>', 'php_curl'));
1088
                                $notifications[] = array('ERR', _L('OIDplus plugin "%1" is enabled, but the required PHP extension "%2" is not installed.', '<a '.OIDplus::gui()->link('oidplus:datatransfer').'>'.htmlentities($title).'</a>', 'php_curl'));
1089
                        }
1089
                        }
1090
                }
1090
                }
1091
                return $notifications;
1091
                return $notifications;
1092
        }
1092
        }
1093
 
1093
 
1094
}
1094
}
1095
 
1095