Rev 350 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 350 | Rev 360 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | 24 | ||
25 | public function action($actionID, $params) { |
25 | public function action($actionID, $params) { |
26 | 26 | ||
27 | if ($actionID == 'import_xml_file') { |
27 | if ($actionID == 'import_xml_file') { |
28 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
28 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
29 | throw new OIDplusException('You need to log in as administrator.'); |
29 | throw new OIDplusException(_L('You need to log in as administrator.')); |
30 | } |
30 | } |
31 | 31 | ||
32 | if (!isset($_FILES['userfile'])) { |
32 | if (!isset($_FILES['userfile'])) { |
33 | throw new OIDplusException('Please choose a file'); |
33 | throw new OIDplusException(_L('Please choose a file.')); |
34 | } |
34 | } |
35 | 35 | ||
36 | $xml_contents = file_get_contents($_FILES['userfile']['tmp_name']); |
36 | $xml_contents = file_get_contents($_FILES['userfile']['tmp_name']); |
37 | 37 | ||
38 | $errors = array(); |
38 | $errors = array(); |
Line 57... | Line 57... | ||
57 | "count_warnings" => $count_warnings |
57 | "count_warnings" => $count_warnings |
58 | ); |
58 | ); |
59 | } |
59 | } |
60 | } else if ($actionID == 'import_oidinfo_oid') { |
60 | } else if ($actionID == 'import_oidinfo_oid') { |
61 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
61 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
62 | throw new OIDplusException('You need to log in as administrator.'); |
62 | throw new OIDplusException(_L('You need to log in as administrator.')); |
63 | } |
63 | } |
64 | 64 | ||
65 | $oid = $params['oid']; |
65 | $oid = $params['oid']; |
66 | 66 | ||
67 | $query = self::QUERY_GET_OIDINFO_DATA_V1; |
67 | $query = self::QUERY_GET_OIDINFO_DATA_V1; |
Line 73... | Line 73... | ||
73 | ); |
73 | ); |
74 | 74 | ||
75 | $signature = ''; |
75 | $signature = ''; |
76 | if (!@openssl_sign(json_encode($payload), $signature, OIDplus::config()->getValue('oidplus_private_key'))) { |
76 | if (!@openssl_sign(json_encode($payload), $signature, OIDplus::config()->getValue('oidplus_private_key'))) { |
77 | if (!OIDplus::getPkiStatus()) { |
77 | if (!OIDplus::getPkiStatus()) { |
78 | throw new OIDplusException('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.'); |
78 | 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.')); |
79 | } else { |
79 | } else { |
80 | throw new OIDplusException("Signature failed"); |
80 | throw new OIDplusException(_L('Signature failed')); |
81 | } |
81 | } |
82 | } |
82 | } |
83 | 83 | ||
84 | $data = array( |
84 | $data = array( |
85 | "payload" => $payload, |
85 | "payload" => $payload, |
Line 92... | Line 92... | ||
92 | curl_setopt($ch, CURLOPT_POSTFIELDS, "query=$query&data=".base64_encode(json_encode($data))); |
92 | curl_setopt($ch, CURLOPT_POSTFIELDS, "query=$query&data=".base64_encode(json_encode($data))); |
93 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
93 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
94 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
94 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
95 | curl_setopt($ch, CURLOPT_AUTOREFERER, true); |
95 | curl_setopt($ch, CURLOPT_AUTOREFERER, true); |
96 | if (!($res = @curl_exec($ch))) { |
96 | if (!($res = @curl_exec($ch))) { |
97 | throw new OIDplusException("Communication with ViaThinkSoft server failed: " . curl_error($ch)); |
97 | throw new OIDplusException(_L('Communication with ViaThinkSoft server failed: %1',curl_error($ch))); |
98 | } |
98 | } |
99 | curl_close($ch); |
99 | curl_close($ch); |
100 | 100 | ||
101 | $json = json_decode($res, true); |
101 | $json = json_decode($res, true); |
102 | 102 | ||
103 | if (!$json) { |
103 | if (!$json) { |
104 | return array("status" => 1, "error" => 'JSON reply from ViaThinkSoft decoding error: ' . $res); |
104 | return array("status" => 1, "error" => _L('JSON reply from ViaThinkSoft decoding error: %1',$res)); |
105 | } |
105 | } |
106 | 106 | ||
107 | if (isset($json['error']) || ($json['status'] != 0)) { |
107 | if (isset($json['error']) || ($json['status'] != 0)) { |
108 | return array("status" => 1, "error" => $json['error']); |
108 | return array("status" => 1, "error" => $json['error']); |
109 | } else { |
109 | } else { |
110 | $errors = array(); |
110 | $errors = array(); |
111 | 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); |
111 | 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); |
112 | if (count($errors) > 0) { |
112 | if (count($errors) > 0) { |
113 | return array("status" => 1, "error" => implode("\n",$errors)); |
113 | return array("status" => 1, "error" => implode("\n",$errors)); |
114 | } else if ($count_imported_oids <> 1) { |
114 | } else if ($count_imported_oids <> 1) { |
115 | return array("status" => 1, "error" => "Imported $count_imported_oids, but expected to import 1"); |
115 | return array("status" => 1, "error" => _L('Imported %1, but expected to import 1',$count_imported_oids)); |
116 | } else { |
116 | } else { |
117 | return array("status" => 0); |
117 | return array("status" => 0); |
118 | } |
118 | } |
119 | 119 | ||
120 | } |
120 | } |
121 | } else { |
121 | } else { |
122 | throw new OIDplusException("Unknown action ID"); |
122 | throw new OIDplusException(_L('Unknown action ID')); |
123 | } |
123 | } |
124 | } |
124 | } |
125 | 125 | ||
126 | public function init($html=true) { |
126 | public function init($html=true) { |
127 | // Nothing |
127 | // Nothing |
128 | } |
128 | } |
129 | 129 | ||
130 | public function gui($id, &$out, &$handled) { |
130 | public function gui($id, &$out, &$handled) { |
131 | if ($id === 'oidplus:oidinfo_compare_export') { |
131 | if ($id === 'oidplus:oidinfo_compare_export') { |
132 | $handled = true; |
132 | $handled = true; |
133 | $out['title'] = 'List OIDs in your system which are missing at oid-info.com'; |
133 | $out['title'] = _L('List OIDs in your system which are missing at oid-info.com'); |
134 | $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : ''; |
134 | $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : ''; |
135 | 135 | ||
136 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
136 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
137 | $out['icon'] = 'img/error_big.png'; |
137 | $out['icon'] = 'img/error_big.png'; |
138 | $out['text'] = '<p>You need to <a '.OIDplus::gui()->link('oidplus:login').'>log in</a> as administrator.</p>'; |
138 | $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login')).'</p>'; |
139 | return; |
139 | return; |
140 | } |
140 | } |
141 | 141 | ||
142 | $query = self::QUERY_LIST_OIDINFO_OIDS_V1; |
142 | $query = self::QUERY_LIST_OIDINFO_OIDS_V1; |
143 | 143 | ||
Line 148... | Line 148... | ||
148 | ); |
148 | ); |
149 | 149 | ||
150 | $signature = ''; |
150 | $signature = ''; |
151 | if (!@openssl_sign(json_encode($payload), $signature, OIDplus::config()->getValue('oidplus_private_key'))) { |
151 | if (!@openssl_sign(json_encode($payload), $signature, OIDplus::config()->getValue('oidplus_private_key'))) { |
152 | if (!OIDplus::getPkiStatus()) { |
152 | if (!OIDplus::getPkiStatus()) { |
153 | throw new OIDplusException('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.'); |
153 | 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.')); |
154 | } else { |
154 | } else { |
155 | throw new OIDplusException("Signature failed"); |
155 | throw new OIDplusException(_L('Signature failed')); |
156 | } |
156 | } |
157 | } |
157 | } |
158 | 158 | ||
159 | $data = array( |
159 | $data = array( |
160 | "payload" => $payload, |
160 | "payload" => $payload, |
Line 167... | Line 167... | ||
167 | curl_setopt($ch, CURLOPT_POSTFIELDS, "query=$query&data=".base64_encode(json_encode($data))); |
167 | curl_setopt($ch, CURLOPT_POSTFIELDS, "query=$query&data=".base64_encode(json_encode($data))); |
168 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
168 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
169 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
169 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
170 | curl_setopt($ch, CURLOPT_AUTOREFERER, true); |
170 | curl_setopt($ch, CURLOPT_AUTOREFERER, true); |
171 | if (!($res = @curl_exec($ch))) { |
171 | if (!($res = @curl_exec($ch))) { |
172 | throw new OIDplusException("Communication with ViaThinkSoft server failed: " . curl_error($ch)); |
172 | throw new OIDplusException(_L('Communication with ViaThinkSoft server failed: %1',curl_error($ch))); |
173 | } |
173 | } |
174 | curl_close($ch); |
174 | curl_close($ch); |
175 | 175 | ||
176 | $json = json_decode($res, true); |
176 | $json = json_decode($res, true); |
177 | 177 | ||
178 | if (!$json) { |
178 | if (!$json) { |
179 | $out['icon'] = 'img/error_big.png'; |
179 | $out['icon'] = 'img/error_big.png'; |
180 | $out['text'] = 'JSON reply from ViaThinkSoft decoding error: ' . $res; |
180 | $out['text'] = _L('JSON reply from ViaThinkSoft decoding error: %1',$res); |
181 | return; |
181 | return; |
182 | } |
182 | } |
183 | 183 | ||
184 | $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:datatransfer').'><img src="img/arrow_back.png" width="16"> Go back to data transfer main page</a>'; // TODO: How to automatically jump to the "Export" tab? |
184 | $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:datatransfer').'><img src="img/arrow_back.png" width="16"> '._L('Go back to data transfer main page').'</a>'; // TODO: How to automatically jump to the "Export" tab? |
185 | 185 | ||
186 | if (isset($json['error']) || ($json['status'] != 0)) { |
186 | if (isset($json['error']) || ($json['status'] != 0)) { |
187 | $out['text'] .= '<p>Error: ' . htmlentities($json['error']) . '</p>'; |
187 | $out['text'] .= '<p>'._L('Error: %1',htmlentities($json['error'])).'</p>'; |
188 | } else { |
188 | } else { |
189 | // 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 |
189 | // 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 |
190 | if (count($json['roots']) == 0) $out['text'] .= '<p>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>'; |
190 | 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>'; |
191 | foreach ($json['roots'] as $root) { |
191 | foreach ($json['roots'] as $root) { |
192 | $oid = $root['oid']; |
192 | $oid = $root['oid']; |
193 | $out['text'] .= '<h2>Root OID '.$oid.'</h2>'; |
193 | $out['text'] .= '<h2>'._L('Root OID %1',$oid).'</h2>'; |
194 | if ($root['verified']) { |
194 | if ($root['verified']) { |
195 | $count = 0; |
195 | $count = 0; |
196 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
196 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
197 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
197 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
198 | $out['text'] .= '<tr><th colspan="3">Actions</th><th>OID</th></tr>'; |
198 | $out['text'] .= '<tr><th colspan="3">'._L('Actions').'</th><th>'._L('OID').'</th></tr>'; |
199 | 199 | ||
200 | $lookup_nonoid = array(); |
200 | $lookup_nonoid = array(); |
201 | $row_lookup = array(); |
201 | $row_lookup = array(); |
202 | 202 | ||
203 | $all_local_oids_of_root = array(); |
203 | $all_local_oids_of_root = array(); |
Line 273... | Line 273... | ||
273 | $tmp_information = ''; |
273 | $tmp_information = ''; |
274 | } else if (!empty($row->comment)) { |
274 | } else if (!empty($row->comment)) { |
275 | $tmp_description = $row->comment; |
275 | $tmp_description = $row->comment; |
276 | $tmp_information = ''; |
276 | $tmp_information = ''; |
277 | } else { |
277 | } else { |
278 | $tmp_description = '<i>No description available</i>'; |
278 | $tmp_description = '<i>No description available</i>'; // do not translate |
279 | $tmp_information = ''; |
279 | $tmp_information = ''; |
280 | } |
280 | } |
281 | 281 | ||
282 | if ($tmp_information != '') { |
282 | if ($tmp_information != '') { |
283 | $tmp_information .= '<br/><br/>'; |
283 | $tmp_information .= '<br/><br/>'; |
284 | } |
284 | } |
285 | 285 | ||
286 | $tmp_information .= 'See <a href="'.OIDplus::getSystemUrl(false).'?goto='.urlencode($id).'">more information</a>.'; |
286 | $tmp_information .= 'See <a href="'.OIDplus::getSystemUrl(false).'?goto='.urlencode($id).'">more information</a>.'; // do not translate |
287 | 287 | ||
288 | if (explode(':',$id,2)[0] != 'oid') { |
288 | if (explode(':',$id,2)[0] != 'oid') { |
289 | $tmp_information = "Object: $id\n\n" . $tmp_information; |
289 | $tmp_information = "Object: $id\n\n" . $tmp_information; // do not translate |
290 | } |
290 | } |
291 | 291 | ||
292 | $url .= "&description=".urlencode(self::repair_relative_links($tmp_description)); |
292 | $url .= "&description=".urlencode(self::repair_relative_links($tmp_description)); |
293 | $url .= "&info=".urlencode(self::repair_relative_links($tmp_information)); |
293 | $url .= "&info=".urlencode(self::repair_relative_links($tmp_information)); |
294 | 294 | ||
Line 354... | Line 354... | ||
354 | 354 | ||
355 | // End: Build oid-info.com create URL |
355 | // End: Build oid-info.com create URL |
356 | 356 | ||
357 | // 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 |
357 | // 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 |
358 | $out['text'] .= '<tr id="missing_oid_'.str_replace('.','_',$local_oid).'">'. |
358 | $out['text'] .= '<tr id="missing_oid_'.str_replace('.','_',$local_oid).'">'. |
359 | '<td><a '.OIDplus::gui()->link(isset($lookup_nonoid[$local_oid]) ? $lookup_nonoid[$local_oid] : 'oid:'.$local_oid, true).'>View local OID</a></td>'. |
359 | '<td><a '.OIDplus::gui()->link(isset($lookup_nonoid[$local_oid]) ? $lookup_nonoid[$local_oid] : 'oid:'.$local_oid, true).'>'._L('View local OID').'</a></td>'. |
360 | '<td><a href="javascript:removeMissingOid(\''.$local_oid.'\');">Ignore for now</a></td>'. |
360 | '<td><a href="javascript:removeMissingOid(\''.$local_oid.'\');">'._L('Ignore for now').'</a></td>'. |
361 | '<td><a target="_blank" href="'.$url.'">Add to oid-info.com manually</a></td>'. |
361 | '<td><a target="_blank" href="'.$url.'">'._L('Add to oid-info.com manually').'</a></td>'. |
362 | '<td>'.$local_oid.'</td>'. |
362 | '<td>'.$local_oid.'</td>'. |
363 | '</tr>'; |
363 | '</tr>'; |
364 | } |
364 | } |
365 | } |
365 | } |
366 | if ($count == 0) { |
366 | if ($count == 0) { |
367 | $out['text'] .= '<tr><td colspan="4">No missing OIDs found</td></tr>'; |
367 | $out['text'] .= '<tr><td colspan="4">'._L('No missing OIDs found').'</td></tr>'; |
368 | } |
368 | } |
369 | $out['text'] .= '</table></div></div>'; |
369 | $out['text'] .= '</table></div></div>'; |
370 | } else { |
370 | } else { |
371 | $out['text'] .= '<p>This root is not validated. Please send an email to '.$json['vts_verification_email'].' in order to request ownership verification of this root OID.</p>'; |
371 | $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>'; |
372 | } |
372 | } |
373 | } |
373 | } |
374 | } |
374 | } |
375 | } |
375 | } |
376 | 376 | ||
377 | if ($id === 'oidplus:oidinfo_compare_import') { |
377 | if ($id === 'oidplus:oidinfo_compare_import') { |
378 | $handled = true; |
378 | $handled = true; |
379 | $out['title'] = 'List OIDs at oid-info.com which are missing in your system'; |
379 | $out['title'] = _L('List OIDs at oid-info.com which are missing in your system'); |
380 | $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : ''; |
380 | $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : ''; |
381 | 381 | ||
382 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
382 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
383 | $out['icon'] = 'img/error_big.png'; |
383 | $out['icon'] = 'img/error_big.png'; |
384 | $out['text'] = '<p>You need to <a '.OIDplus::gui()->link('oidplus:login').'>log in</a> as administrator.</p>'; |
384 | $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login')).'</p>'; |
385 | return; |
385 | return; |
386 | } |
386 | } |
387 | 387 | ||
388 | $query = self::QUERY_LIST_OIDINFO_OIDS_V1; |
388 | $query = self::QUERY_LIST_OIDINFO_OIDS_V1; |
389 | 389 | ||
Line 394... | Line 394... | ||
394 | ); |
394 | ); |
395 | 395 | ||
396 | $signature = ''; |
396 | $signature = ''; |
397 | if (!@openssl_sign(json_encode($payload), $signature, OIDplus::config()->getValue('oidplus_private_key'))) { |
397 | if (!@openssl_sign(json_encode($payload), $signature, OIDplus::config()->getValue('oidplus_private_key'))) { |
398 | if (!OIDplus::getPkiStatus()) { |
398 | if (!OIDplus::getPkiStatus()) { |
399 | throw new OIDplusException('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.'); |
399 | 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.')); |
400 | } else { |
400 | } else { |
401 | throw new OIDplusException("Signature failed"); |
401 | throw new OIDplusException(_L('Signature failed')); |
402 | } |
402 | } |
403 | } |
403 | } |
404 | 404 | ||
405 | $data = array( |
405 | $data = array( |
406 | "payload" => $payload, |
406 | "payload" => $payload, |
Line 413... | Line 413... | ||
413 | curl_setopt($ch, CURLOPT_POSTFIELDS, "query=$query&data=".base64_encode(json_encode($data))); |
413 | curl_setopt($ch, CURLOPT_POSTFIELDS, "query=$query&data=".base64_encode(json_encode($data))); |
414 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
414 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
415 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
415 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
416 | curl_setopt($ch, CURLOPT_AUTOREFERER, true); |
416 | curl_setopt($ch, CURLOPT_AUTOREFERER, true); |
417 | if (!($res = @curl_exec($ch))) { |
417 | if (!($res = @curl_exec($ch))) { |
418 | throw new OIDplusException("Communication with ViaThinkSoft server failed: " . curl_error($ch)); |
418 | throw new OIDplusException(_L('Communication with ViaThinkSoft server failed: %1',curl_error($ch))); |
419 | } |
419 | } |
420 | curl_close($ch); |
420 | curl_close($ch); |
421 | 421 | ||
422 | $json = json_decode($res, true); |
422 | $json = json_decode($res, true); |
423 | 423 | ||
424 | if (!$json) { |
424 | if (!$json) { |
425 | $out['icon'] = 'img/error_big.png'; |
425 | $out['icon'] = 'img/error_big.png'; |
426 | $out['text'] = 'JSON reply from ViaThinkSoft decoding error: ' . $res; |
426 | $out['text'] = _L('JSON reply from ViaThinkSoft decoding error: %1',$res); |
427 | return; |
427 | return; |
428 | } |
428 | } |
429 | 429 | ||
430 | $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:datatransfer').'><img src="img/arrow_back.png" width="16"> Go back to data transfer main page</a>'; // TODO: How to automatically jump to the "Import" tab? |
430 | $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:datatransfer').'><img src="img/arrow_back.png" width="16"> '._L('Go back to data transfer main page').'</a>'; // TODO: How to automatically jump to the "Import" tab? |
431 | 431 | ||
432 | $all_local_oids = array(); |
432 | $all_local_oids = array(); |
433 | $res = OIDplus::db()->query("select id from ###objects"); |
433 | $res = OIDplus::db()->query("select id from ###objects"); |
434 | while ($row = $res->fetch_array()) { |
434 | while ($row = $res->fetch_array()) { |
435 | if (strpos($row['id'], 'oid:') === 0) { |
435 | if (strpos($row['id'], 'oid:') === 0) { |
Line 445... | Line 445... | ||
445 | } |
445 | } |
446 | } |
446 | } |
447 | } |
447 | } |
448 | 448 | ||
449 | if (isset($json['error']) || ($json['status'] != 0)) { |
449 | if (isset($json['error']) || ($json['status'] != 0)) { |
450 | $out['text'] .= '<p>Error: ' . htmlentities($json['error']) . '</p>'; |
450 | $out['text'] .= '<p>'._L('Error: %1',htmlentities($json['error'])).'</p>'; |
451 | } else { |
451 | } else { |
452 | // 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 |
452 | // 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 |
453 | if (count($json['roots']) == 0) $out['text'] .= '<p>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>'; |
453 | 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>'; |
454 | foreach ($json['roots'] as $root) { |
454 | foreach ($json['roots'] as $root) { |
455 | $oid = $root['oid']; |
455 | $oid = $root['oid']; |
456 | $out['text'] .= '<h2>Root OID '.$oid.'</h2>'; |
456 | $out['text'] .= '<h2>'._L('Root OID %1',$oid).'</h2>'; |
457 | // TODO: "Import all" button |
457 | // TODO: "Import all" button |
458 | if ($root['verified']) { |
458 | if ($root['verified']) { |
459 | $count = 0; |
459 | $count = 0; |
460 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
460 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
461 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
461 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
462 | $out['text'] .= '<tr><th colspan="4">Actions</th><th>OID</th></tr>'; |
462 | $out['text'] .= '<tr><th colspan="4">'._L('Actions').'</th><th>'._L('OID').'</th></tr>'; |
463 | natsort($root['children']); |
463 | natsort($root['children']); |
464 | foreach ($root['children'] as $child_oid) { |
464 | foreach ($root['children'] as $child_oid) { |
465 | if (!in_array($child_oid, $all_local_oids)) { |
465 | if (!in_array($child_oid, $all_local_oids)) { |
466 | $count++; |
466 | $count++; |
467 | // 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 |
467 | // 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 |
468 | $out['text'] .= '<tr id="missing_oid_'.str_replace('.','_',$child_oid).'">'. |
468 | $out['text'] .= '<tr id="missing_oid_'.str_replace('.','_',$child_oid).'">'. |
469 | '<td><a target="_blank" href="http://www.oid-info.com/get/'.$child_oid.'">View OID at oid-info.com</a></td>'. |
469 | '<td><a target="_blank" href="http://www.oid-info.com/get/'.$child_oid.'">'._L('View OID at oid-info.com').'</a></td>'. |
470 | '<td><a href="javascript:removeMissingOid(\''.$child_oid.'\');">Ignore for now</a></td>'. |
470 | '<td><a href="javascript:removeMissingOid(\''.$child_oid.'\');">'._L('Ignore for now').'</a></td>'. |
471 | '<td><a href="mailto:admin@oid-info.com">Report illegal OID</a></td>'. |
471 | '<td><a href="mailto:admin@oid-info.com">'._L('Report illegal OID').'</a></td>'. |
472 | (strpos($child_oid,'1.3.6.1.4.1.37476.30.9.') === 0 ? '<td> </td>' : '<td><a href="javascript:importMissingOid(\''.$child_oid.'\');">Import OID</a></td>'). |
472 | (strpos($child_oid,'1.3.6.1.4.1.37476.30.9.') === 0 ? '<td> </td>' : '<td><a href="javascript:importMissingOid(\''.$child_oid.'\');">'._L('Import OID').'</a></td>'). |
473 | '<td>'.$child_oid.'</td>'. |
473 | '<td>'.$child_oid.'</td>'. |
474 | '</tr>'; |
474 | '</tr>'; |
475 | } |
475 | } |
476 | } |
476 | } |
477 | if ($count == 0) { |
477 | if ($count == 0) { |
478 | $out['text'] .= '<tr><td colspan="5">No extra OIDs found</td></tr>'; |
478 | $out['text'] .= '<tr><td colspan="5">'._L('No extra OIDs found').'</td></tr>'; |
479 | } |
479 | } |
480 | $out['text'] .= '</table></div></div>'; |
480 | $out['text'] .= '</table></div></div>'; |
481 | } else { |
481 | } else { |
482 | $out['text'] .= '<p>This root is not validated. Please send an email to '.$json['vts_verification_email'].' in order to request ownership verification of this root OID.</p>'; |
482 | $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>'; |
483 | } |
483 | } |
484 | } |
484 | } |
485 | } |
485 | } |
486 | } |
486 | } |
487 | 487 | ||
488 | if ($id === 'oidplus:datatransfer') { |
488 | if ($id === 'oidplus:datatransfer') { |
489 | $handled = true; |
489 | $handled = true; |
490 | $out['title'] = 'Data Transfer'; |
490 | $out['title'] = _L('Data Transfer'); |
491 | $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : ''; |
491 | $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : ''; |
492 | 492 | ||
493 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
493 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
494 | $out['icon'] = 'img/error_big.png'; |
494 | $out['icon'] = 'img/error_big.png'; |
495 | $out['text'] = '<p>You need to <a '.OIDplus::gui()->link('oidplus:login').'>log in</a> as administrator.</p>'; |
495 | $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login')).'</p>'; |
496 | return; |
496 | return; |
497 | } |
497 | } |
498 | 498 | ||
499 | $out['text'] = ''; |
499 | $out['text'] = ''; |
500 | 500 | ||
501 | $out['text'] .= '<div id="oidinfoMainArea" style="visibility: hidden"><div id="oidinfoMainTab" class="container" style="width:100%;">'; |
501 | $out['text'] .= '<div id="oidinfoMainArea" style="visibility: hidden"><div id="oidinfoMainTab" class="container" style="width:100%;">'; |
502 | $out['text'] .= '<br>'; |
502 | $out['text'] .= '<br>'; |
503 | $out['text'] .= '<ul class="nav nav-pills">'; |
503 | $out['text'] .= '<ul class="nav nav-pills">'; |
504 | $out['text'] .= ' <li class="active">'; |
504 | $out['text'] .= ' <li class="active">'; |
505 | $out['text'] .= ' <a href="#1a" data-toggle="tab">Export</a>'; |
505 | $out['text'] .= ' <a href="#1a" data-toggle="tab">'._L('Export').'</a>'; |
506 | $out['text'] .= ' </li>'; |
506 | $out['text'] .= ' </li>'; |
507 | $out['text'] .= ' <li><a href="#2a" data-toggle="tab">Import</a>'; |
507 | $out['text'] .= ' <li><a href="#2a" data-toggle="tab">'._L('Import').'</a>'; |
508 | $out['text'] .= ' </li>'; |
508 | $out['text'] .= ' </li>'; |
509 | $out['text'] .= ' </ul>'; |
509 | $out['text'] .= ' </ul>'; |
510 | $out['text'] .= ' <div class="tab-content clearfix">'; |
510 | $out['text'] .= ' <div class="tab-content clearfix">'; |
511 | $out['text'] .= ' <div class="tab-pane active" id="1a">'; |
511 | $out['text'] .= ' <div class="tab-pane active" id="1a">'; |
512 | // ---------------- Start "Export" tab |
512 | // ---------------- Start "Export" tab |
513 | $out['text'] .= '<h2>Generate XML file containing all OIDs</h2>'; |
513 | $out['text'] .= '<h2>'._L('Generate XML file containing all OIDs').'</h2>'; |
514 | $out['text'] .= '<p>These XML files are following the <a href="http://www.oid-info.com/oid.xsd" target="_blank">XML schema</a> of <b>oid-info.com</b>. They can be used for various purposes though.</p>'; |
514 | $out['text'] .= '<p>'._L('These XML files are following the <a %1>XML schema</a> of <b>oid-info.com</b>. They can be used for various purposes though.','href="http://www.oid-info.com/oid.xsd" target="_blank"').'</p>'; |
515 | $out['text'] .= '<p><input type="button" onclick="window.open(\''.OIDplus::webpath(__DIR__).'oidinfo_export.php\',\'_blank\')" value="Generate XML (all)"></p>'; |
515 | $out['text'] .= '<p><input type="button" onclick="window.open(\''.OIDplus::webpath(__DIR__).'oidinfo_export.php\',\'_blank\')" value="'._L('Generate XML (all OIDs)').'"></p>'; |
516 | $out['text'] .= '<p><input type="button" onclick="window.open(\''.OIDplus::webpath(__DIR__).'oidinfo_export.php?online=1\',\'_blank\')" value="Generate XML (only OIDs which do not exist at oid-info.com)"></p>'; |
516 | $out['text'] .= '<p><input type="button" onclick="window.open(\''.OIDplus::webpath(__DIR__).'oidinfo_export.php?online=1\',\'_blank\')" value="'._L('Generate XML (only OIDs which do not exist at oid-info.com)').'"></p>'; |
517 | $out['text'] .= '<p><a href="http://www.oid-info.com/submit.htm" target="_blank">Upload XML files manually to oid-info.com</a></p>'; |
517 | $out['text'] .= '<p><a href="http://www.oid-info.com/submit.htm" target="_blank">'._L('Upload XML files manually to oid-info.com').'</a></p>'; |
518 | $out['text'] .= '<br><p>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>'; |
518 | $out['text'] .= '<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>'; |
519 | $out['text'] .= '<h2>Automatic export to oid-info.com</h2>'; |
519 | $out['text'] .= '<h2>'._L('Automatic export to oid-info.com').'</h2>'; |
520 | $privacy_level = OIDplus::config()->getValue('reg_privacy'); |
520 | $privacy_level = OIDplus::config()->getValue('reg_privacy'); |
521 | if ($privacy_level == 0) { |
521 | if ($privacy_level == 0) { |
522 | $out['text'] .= '<p>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').'>Change preference</a>)</p>'; |
522 | $out['text'] .= '<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>'; |
523 | } else { |
523 | } else { |
524 | $out['text'] .= '<p>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').'>Change preference</a>)</p>'; |
524 | $out['text'] .= '<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>'; |
525 | } |
525 | } |
526 | $out['text'] .= '<h2>Comparison with oid-info.com</h2>'; |
526 | $out['text'] .= '<h2>'._L('Comparison with oid-info.com').'</h2>'; |
527 | $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:oidinfo_compare_export').'>List OIDs in your system which are missing at oid-info.com</a></p>'; |
527 | $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:oidinfo_compare_export').'>'._L('List OIDs in your system which are missing at oid-info.com').'</a></p>'; |
528 | // ---------------- End "Export" tab |
528 | // ---------------- End "Export" tab |
529 | $out['text'] .= ' </div>'; |
529 | $out['text'] .= ' </div>'; |
530 | $out['text'] .= ' <div class="tab-pane" id="2a">'; |
530 | $out['text'] .= ' <div class="tab-pane" id="2a">'; |
531 | // ---------------- Start "Import" tab |
531 | // ---------------- Start "Import" tab |
532 | $out['text'] .= '<h2>Import XML file</h2>'; |
532 | $out['text'] .= '<h2>'._L('Import XML file').'</h2>'; |
533 | $out['text'] .= '<p>These XML files are following the <a href="http://www.oid-info.com/oid.xsd" target="_blank">XML schema</a> of <b>oid-info.com</b>.</p>'; |
533 | $out['text'] .= '<p>'._L('These XML files are following the <a %1>XML schema</a> of <b>oid-info.com</b>.','href="http://www.oid-info.com/oid.xsd" target="_blank"').'</p>'; |
534 | // TODO XXX: we need a waiting animation! |
534 | // TODO XXX: we need a waiting animation! |
535 | $out['text'] .= '<form onsubmit="return uploadXmlFileOnSubmit(this);" enctype="multipart/form-data" id="uploadXmlFileForm">'; |
535 | $out['text'] .= '<form onsubmit="return uploadXmlFileOnSubmit(this);" enctype="multipart/form-data" id="uploadXmlFileForm">'; |
536 | $out['text'] .= '<div>Choose XML file here:<input type="file" name="userfile" value="" id="userfile">'; |
536 | $out['text'] .= '<div>'._L('Choose XML file here').':<input type="file" name="userfile" value="" id="userfile">'; |
537 | $out['text'] .= '<br><input type="submit" value="Import XML"></div>'; |
537 | $out['text'] .= '<br><input type="submit" value="'._L('Import XML').'"></div>'; |
538 | $out['text'] .= '</form>'; |
538 | $out['text'] .= '</form>'; |
539 | $out['text'] .= '<br><p>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>'; |
539 | $out['text'] .= '<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>'; |
540 | $out['text'] .= '<h2>Comparison with oid-info.com</h2>'; |
540 | $out['text'] .= '<h2>'._L('Comparison with oid-info.com').'</h2>'; |
541 | $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:oidinfo_compare_import').'>List OIDs at oid-info.com which are missing in your system</a></p>'; |
541 | $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:oidinfo_compare_import').'>'._L('List OIDs at oid-info.com which are missing in your system').'</a></p>'; |
542 | // ---------------- End "Import" tab |
542 | // ---------------- End "Import" tab |
543 | $out['text'] .= ' </div>'; |
543 | $out['text'] .= ' </div>'; |
544 | $out['text'] .= ' </div>'; |
544 | $out['text'] .= ' </div>'; |
545 | $out['text'] .= ' </div></div>'; |
545 | $out['text'] .= ' </div></div>'; |
546 | 546 | ||
Line 558... | Line 558... | ||
558 | } |
558 | } |
559 | 559 | ||
560 | $json[] = array( |
560 | $json[] = array( |
561 | 'id' => 'oidplus:datatransfer', |
561 | 'id' => 'oidplus:datatransfer', |
562 | 'icon' => $tree_icon, |
562 | 'icon' => $tree_icon, |
563 | 'text' => 'Data Transfer' |
563 | 'text' => _L('Data Transfer') |
564 | ); |
564 | ); |
565 | 565 | ||
566 | return true; |
566 | return true; |
567 | } |
567 | } |
568 | 568 | ||
Line 583... | Line 583... | ||
583 | $oa->addSimplePingProvider('viathinksoft.de:49500'); |
583 | $oa->addSimplePingProvider('viathinksoft.de:49500'); |
584 | 584 | ||
585 | $email = OIDplus::config()->getValue('admin_email'); |
585 | $email = OIDplus::config()->getValue('admin_email'); |
586 | if (empty($email)) $email = 'unknown@example.com'; |
586 | if (empty($email)) $email = 'unknown@example.com'; |
587 | 587 | ||
588 | echo $oa->xmlAddHeader(OIDplus::config()->getValue('system_title'), isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'Export interface', $email); |
588 | echo $oa->xmlAddHeader(OIDplus::config()->getValue('system_title'), isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'Export interface', $email); // do not translate |
589 | 589 | ||
590 | $params['allow_html'] = true; |
590 | $params['allow_html'] = true; |
591 | $params['allow_illegal_email'] = true; // It should be enabled, because the creator could have used some kind of human-readable anti-spam technique |
591 | $params['allow_illegal_email'] = true; // It should be enabled, because the creator could have used some kind of human-readable anti-spam technique |
592 | $params['soft_correct_behavior'] = OIDInfoAPI::SOFT_CORRECT_BEHAVIOR_NONE; |
592 | $params['soft_correct_behavior'] = OIDInfoAPI::SOFT_CORRECT_BEHAVIOR_NONE; |
593 | $params['do_online_check'] = false; // Flag to disable this online check, because it generates a lot of traffic and runtime. |
593 | $params['do_online_check'] = false; // Flag to disable this online check, because it generates a lot of traffic and runtime. |
Line 635... | Line 635... | ||
635 | $elements['information'] = ''; |
635 | $elements['information'] = ''; |
636 | } else if (!empty($row->comment)) { |
636 | } else if (!empty($row->comment)) { |
637 | $elements['description'] = $row->comment; |
637 | $elements['description'] = $row->comment; |
638 | $elements['information'] = ''; |
638 | $elements['information'] = ''; |
639 | } else { |
639 | } else { |
640 | $elements['description'] = '<i>No description available</i>'; |
640 | $elements['description'] = '<i>No description available</i>'; // do not translate |
641 | $elements['information'] = ''; |
641 | $elements['information'] = ''; |
642 | } |
642 | } |
643 | 643 | ||
644 | if ($elements['information'] != '') { |
644 | if ($elements['information'] != '') { |
645 | $elements['information'] .= '<br/><br/>'; |
645 | $elements['information'] .= '<br/><br/>'; |
646 | } |
646 | } |
647 | 647 | ||
648 | $elements['information'] .= 'See <a href="'.OIDplus::getSystemUrl(false).'?goto='.urlencode($id).'">more information</a>.'; |
648 | $elements['information'] .= 'See <a href="'.OIDplus::getSystemUrl(false).'?goto='.urlencode($id).'">more information</a>.'; // do not translate |
649 | 649 | ||
650 | if (explode(':',$id,2)[0] != 'oid') { |
650 | if (explode(':',$id,2)[0] != 'oid') { |
651 | $elements['information'] = "Object: $id\n\n" . $elements['information']; |
651 | $elements['information'] = "Object: $id\n\n" . $elements['information']; // do not translate |
652 | } |
652 | } |
653 | 653 | ||
654 | $elements['description'] = self::repair_relative_links($elements['description']); |
654 | $elements['description'] = self::repair_relative_links($elements['description']); |
655 | $elements['information'] = self::repair_relative_links($elements['information']); |
655 | $elements['information'] = self::repair_relative_links($elements['information']); |
656 | 656 | ||
Line 816... | Line 816... | ||
816 | $count_already_existing = 0; |
816 | $count_already_existing = 0; |
817 | $count_errors = 0; |
817 | $count_errors = 0; |
818 | $count_warnings = 0; |
818 | $count_warnings = 0; |
819 | 819 | ||
820 | if (!$xml) { |
820 | if (!$xml) { |
821 | $errors[] = "Cannot read XML data. The XML file is probably invalid."; |
821 | $errors[] = _L('Cannot read XML data. The XML file is probably invalid.'); |
822 | $count_errors++; |
822 | $count_errors++; |
823 | return array(0, 0, 1, 0); |
823 | return array(0, 0, 1, 0); |
824 | } |
824 | } |
825 | 825 | ||
826 | $ok_oids = array(); |
826 | $ok_oids = array(); |
Line 830... | Line 830... | ||
830 | if (isset($xoid->{'dot-notation'})) { |
830 | if (isset($xoid->{'dot-notation'})) { |
831 | $dot_notation = $xoid->{'dot-notation'}->__toString(); |
831 | $dot_notation = $xoid->{'dot-notation'}->__toString(); |
832 | } else if (isset($xoid->{'asn1-notation'})) { |
832 | } else if (isset($xoid->{'asn1-notation'})) { |
833 | $dot_notation = asn1_to_dot($xoid->{'asn1-notation'}->__toString()); |
833 | $dot_notation = asn1_to_dot($xoid->{'asn1-notation'}->__toString()); |
834 | } else { |
834 | } else { |
835 | $errors[] = "Cannot find dot notation because fields asn1-notation and dot-notation are both not existing"; |
835 | $errors[] = _L('Cannot find dot notation because fields asn1-notation and dot-notation are both not existing'); |
836 | $count_errors++; |
836 | $count_errors++; |
837 | continue; |
837 | continue; |
838 | } |
838 | } |
839 | 839 | ||
840 | $id = "oid:$dot_notation"; |
840 | $id = "oid:$dot_notation"; |
Line 848... | Line 848... | ||
848 | } else { |
848 | } else { |
849 | $ra = ''; |
849 | $ra = ''; |
850 | } |
850 | } |
851 | 851 | ||
852 | if (!oid_valid_dotnotation($dot_notation, false, false)) { |
852 | if (!oid_valid_dotnotation($dot_notation, false, false)) { |
853 | $errors[] = "Ignored OID '$dot_notation' because its dot notation is illegal or was not found"; |
853 | $errors[] = _L('Ignored OID %1 because its dot notation is illegal or was not found',$dot_notation); |
854 | $count_errors++; |
854 | $count_errors++; |
855 | continue; |
855 | continue; |
856 | } |
856 | } |
857 | 857 | ||
858 | $parent = 'oid:'.oid_up($dot_notation); |
858 | $parent = 'oid:'.oid_up($dot_notation); |
859 | 859 | ||
860 | if ($orphan_mode === self::ORPHAN_DISALLOW_ORPHANS) { |
860 | if ($orphan_mode === self::ORPHAN_DISALLOW_ORPHANS) { |
861 | $res = OIDplus::db()->query("select * from ###objects where id = ?", array($parent)); |
861 | $res = OIDplus::db()->query("select * from ###objects where id = ?", array($parent)); |
862 | if ($res->num_rows() === 0) { |
862 | if ($res->num_rows() === 0) { |
863 | $errors[] = "Cannot import $dot_notation, because its parent is not in the database."; |
863 | $errors[] = _L('Cannot import %1, because its parent is not in the database.',$dot_notation); |
864 | $count_errors++; |
864 | $count_errors++; |
865 | continue; |
865 | continue; |
866 | } |
866 | } |
867 | } |
867 | } |
868 | 868 | ||
Line 903... | Line 903... | ||
903 | } |
903 | } |
904 | } |
904 | } |
905 | $asn1ids = array_unique($asn1ids); |
905 | $asn1ids = array_unique($asn1ids); |
906 | foreach ($asn1ids as $asn1id) { |
906 | foreach ($asn1ids as $asn1id) { |
907 | if (!oid_id_is_valid($asn1id)) { |
907 | if (!oid_id_is_valid($asn1id)) { |
908 | $errors[] = "Warning: OID '$dot_notation': Ignored alphanumeric identifier '$asn1id' because it is invalid"; |
908 | $errors[] = _L('Warning').' ['._L('OID %1',$dot_notation).']: '._L('Ignored alphanumeric identifier %1, because it is invalid',$asn1id); |
909 | $this_oid_has_warnings = true; |
909 | $this_oid_has_warnings = true; |
910 | } else { |
910 | } else { |
911 | OIDplus::db()->query("delete from ###asn1id where oid = ? and name = ?", array($id, $asn1id)); |
911 | OIDplus::db()->query("delete from ###asn1id where oid = ? and name = ?", array($id, $asn1id)); |
912 | OIDplus::db()->query("insert into ###asn1id (oid, name) values (?, ?)", array($id, $asn1id)); |
912 | OIDplus::db()->query("insert into ###asn1id (oid, name) values (?, ?)", array($id, $asn1id)); |
913 | } |
913 | } |
Line 921... | Line 921... | ||
921 | $iris[] = $iri->__toString(); |
921 | $iris[] = $iri->__toString(); |
922 | } |
922 | } |
923 | $iris = array_unique($iris); |
923 | $iris = array_unique($iris); |
924 | foreach ($iris as $iri) { |
924 | foreach ($iris as $iri) { |
925 | if (!iri_arc_valid($iri, false)) { |
925 | if (!iri_arc_valid($iri, false)) { |
926 | $errors[] = "Warning: OID '$dot_notation': Ignored Unicode label '$iri' because it is invalid"; |
926 | $errors[] = _L('Warning').' ['._L('OID %1',$dot_notation).']: '._L('Ignored Unicode label %1, because it is invalid',$iri); |
927 | $this_oid_has_warnings = true; |
927 | $this_oid_has_warnings = true; |
928 | } else { |
928 | } else { |
929 | OIDplus::db()->query("delete from ###iri where oid = ? and name = ?", array($id, $iri)); |
929 | OIDplus::db()->query("delete from ###iri where oid = ? and name = ?", array($id, $iri)); |
930 | OIDplus::db()->query("insert into ###iri (oid, name) values (?, ?)", array($id, $iri)); |
930 | OIDplus::db()->query("insert into ###iri (oid, name) values (?, ?)", array($id, $iri)); |
931 | } |
931 | } |
Line 941... | Line 941... | ||
941 | foreach ($ok_oids as $id) { |
941 | foreach ($ok_oids as $id) { |
942 | // De-orphanize if neccessary |
942 | // De-orphanize if neccessary |
943 | if ($orphan_mode === self::ORPHAN_AUTO_DEORPHAN) { |
943 | if ($orphan_mode === self::ORPHAN_AUTO_DEORPHAN) { |
944 | $res = OIDplus::db()->query("select * from ###objects where id = ? and parent not in (select id from ###objects)", array($id)); |
944 | $res = OIDplus::db()->query("select * from ###objects where id = ? and parent not in (select id from ###objects)", array($id)); |
945 | if ($res->num_rows() > 0) { |
945 | if ($res->num_rows() > 0) { |
946 | $errors[] = "'$id' was de-orphanized (placed as root OID) because its parent is not existing."; |
946 | $errors[] = _L("%1 was de-orphaned (placed as root OID) because its parent is not existing.",$id); |
947 | $count_warnings++; |
947 | $count_warnings++; |
948 | OIDplus::db()->query("update ###objects set parent = 'oid:' where id = ? and parent not in (select id from ###objects)", array($id)); |
948 | OIDplus::db()->query("update ###objects set parent = 'oid:' where id = ? and parent not in (select id from ###objects)", array($id)); |
949 | } |
949 | } |
950 | } |
950 | } |
951 | 951 |