Subversion Repositories oidplus

Rev

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

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