Subversion Repositories oidplus

Rev

Rev 1050 | Rev 1086 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1050 Rev 1052
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * OIDplus 2.0
4
 * OIDplus 2.0
5
 * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2019 - 2022 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
 *
Line 275... Line 275...
275
                                                                        $all_local_oids_of_root[] = $oid;
275
                                                                        $all_local_oids_of_root[] = $oid;
276
                                                                }
276
                                                                }
277
                                                        } else {
277
                                                        } else {
278
                                                                $aids = $obj->getAltIds();
278
                                                                $aids = $obj->getAltIds();
279
                                                                foreach ($aids as $aid) {
279
                                                                foreach ($aids as $aid) {
-
 
280
                                                                        // TODO: Let Object Type plugins decide if they want that their OID representations get published or not (via a Feature OID implementation)
280
                                                                        if ($aid->getNamespace() == 'oid') {
281
                                                                        if ($aid->getNamespace() == 'oid') {
281
                                                                                $oid = $aid->getId();
282
                                                                                $oid = $aid->getId();
282
                                                                                if (strpos($oid.'.', $root['oid']) === 0) {
283
                                                                                if (strpos($oid.'.', $root['oid']) === 0) {
283
                                                                                        $row_lookup[$oid] = $row;
284
                                                                                        $row_lookup[$oid] = $row;
284
                                                                                        $all_local_oids_of_root[] = $oid;
285
                                                                                        $all_local_oids_of_root[] = $oid;
Line 296... Line 297...
296
 
297
 
297
                                                                // Start: Build oid-info.com create URL
298
                                                                // Start: Build oid-info.com create URL
298
 
299
 
299
                                                                $row = $row_lookup[$local_oid];
300
                                                                $row = $row_lookup[$local_oid];
300
 
301
 
301
                                                                $url = "http://www.oid-info.com/cgi-bin/manage?f=".oid_up($local_oid)."&a=create";
302
                                                                $url = "https://oid-rep.orange-labs.fr/cgi-bin/manage?f=".oid_up($local_oid)."&a=create";
302
 
303
 
303
                                                                $tmp = explode('.',$local_oid);
304
                                                                $tmp = explode('.',$local_oid);
304
                                                                $url .= "&nb=".urlencode(array_pop($tmp));
305
                                                                $url .= "&nb=".urlencode(array_pop($tmp));
305
 
306
 
306
                                                                $asn1_ids = array();
307
                                                                $asn1_ids = array();
Line 527... Line 528...
527
                                } else {
528
                                } else {
528
                                        $obj = OIDplusObject::parse($row['id']);
529
                                        $obj = OIDplusObject::parse($row['id']);
529
                                        if (!$obj) continue; // can happen when object type is not enabled
530
                                        if (!$obj) continue; // can happen when object type is not enabled
530
                                        $aids = $obj->getAltIds();
531
                                        $aids = $obj->getAltIds();
531
                                        foreach ($aids as $aid) {
532
                                        foreach ($aids as $aid) {
-
 
533
                                                // TODO: Let Object Type plugins decide if they want that their OID representations get published or not (via a Feature OID implementation)
532
                                                if ($aid->getNamespace() == 'oid') {
534
                                                if ($aid->getNamespace() == 'oid') {
533
                                                        $all_local_oids[] = $aid->getId();
535
                                                        $all_local_oids[] = $aid->getId();
534
                                                }
536
                                                }
535
                                        }
537
                                        }
536
                                }
538
                                }
Line 554... Line 556...
554
                                                foreach ($root['children'] as $child_oid) {
556
                                                foreach ($root['children'] as $child_oid) {
555
                                                        if (!in_array($child_oid, $all_local_oids)) {
557
                                                        if (!in_array($child_oid, $all_local_oids)) {
556
                                                                $count++;
558
                                                                $count++;
557
                                                                // Note: "Actions" is at the left, because it has a fixed width, so the user can continue clicking without the links moving if the OID length changes between lines
559
                                                                // Note: "Actions" is at the left, because it has a fixed width, so the user can continue clicking without the links moving if the OID length changes between lines
558
                                                                $out['text'] .= '<tr id="missing_oid_'.str_replace('.','_',$child_oid).'">'.
560
                                                                $out['text'] .= '<tr id="missing_oid_'.str_replace('.','_',$child_oid).'">'.
559
                                                                '<td><a target="_blank" href="http://www.oid-info.com/get/'.$child_oid.'">'._L('View OID at oid-info.com').'</a></td>'.
561
                                                                '<td><a target="_blank" href="https://oid-rep.orange-labs.fr/get/'.$child_oid.'">'._L('View OID at oid-info.com').'</a></td>'.
560
                                                                '<td><a href="javascript:OIDplusPageAdminOIDInfoExport.removeMissingOid(\''.$child_oid.'\');">'._L('Ignore for now').'</a></td>'.
562
                                                                '<td><a href="javascript:OIDplusPageAdminOIDInfoExport.removeMissingOid(\''.$child_oid.'\');">'._L('Ignore for now').'</a></td>'.
561
                                                                '<td><a href="mailto:admin@oid-info.com">'._L('Report illegal OID').'</a></td>'.
563
                                                                '<td><a href="mailto:admin@oid-info.com">'._L('Report illegal OID').'</a></td>'.
562
                                                                (strpos($child_oid,'1.3.6.1.4.1.37476.30.9.') === 0 ? '<td>&nbsp;</td>' : '<td><a href="javascript:OIDplusPageAdminOIDInfoExport.importMissingOid(\''.$child_oid.'\');">'._L('Import OID').'</a></td>').
564
                                                                (strpos($child_oid,'1.3.6.1.4.1.37476.30.9.') === 0 ? '<td>&nbsp;</td>' : '<td><a href="javascript:OIDplusPageAdminOIDInfoExport.importMissingOid(\''.$child_oid.'\');">'._L('Import OID').'</a></td>').
563
                                                                '<td>'.$child_oid.'</td>'.
565
                                                                '<td>'.$child_oid.'</td>'.
564
                                                                '</tr>';
566
                                                                '</tr>';
Line 598... Line 600...
598
                        $out['text'] .= OIDplus::gui()->tabBarElement('import', _L('Import'), $tab === 'import');
600
                        $out['text'] .= OIDplus::gui()->tabBarElement('import', _L('Import'), $tab === 'import');
599
                        $out['text'] .= OIDplus::gui()->tabBarEnd();
601
                        $out['text'] .= OIDplus::gui()->tabBarEnd();
600
                        $out['text'] .= OIDplus::gui()->tabContentStart();
602
                        $out['text'] .= OIDplus::gui()->tabContentStart();
601
                        // ---------------- "Export" tab
603
                        // ---------------- "Export" tab
602
                        $tabcont  = '<h2>'._L('Generate XML file containing all OIDs').'</h2>';
604
                        $tabcont  = '<h2>'._L('Generate XML file containing all OIDs').'</h2>';
603
                        $tabcont .= '<p>'._L('These XML files are following the <a %1>XML schema</a> of <b>oid-info.com</b>. They can be used for various purposes though.','href="http://www.oid-info.com/oid.xsd" target="_blank"').'</p>';
605
                        $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>';
604
                        $tabcont .= '<p><input type="button" onclick="window.open(\''.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'oidinfo_export.php\',\'_blank\')" value="'._L('Generate XML (all OIDs)').'"></p>';
606
                        $tabcont .= '<p><input type="button" onclick="window.open(\''.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'oidinfo_export.php\',\'_blank\')" value="'._L('Generate XML (all OIDs)').'"></p>';
605
                        $tabcont .= '<p><input type="button" onclick="window.open(\''.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'oidinfo_export.php?online=1\',\'_blank\')" value="'._L('Generate XML (only OIDs which do not exist at oid-info.com)').'"></p>';
607
                        $tabcont .= '<p><input type="button" onclick="window.open(\''.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'oidinfo_export.php?online=1\',\'_blank\')" value="'._L('Generate XML (only OIDs which do not exist at oid-info.com)').'"></p>';
606
                        $tabcont .= '<p><a href="http://www.oid-info.com/submit.htm" target="_blank">'._L('Upload XML files manually to oid-info.com').'</a></p>';
608
                        $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>';
607
                        $tabcont .= '<br><p>'._L('Attention: Do not use this XML Export/Import to exchange, backup or restore data between OIDplus systems!<br>It will cause various loss of information, e.g. because Non-OIDs like GUIDs are converted in OIDs and can\'t be converted back.').'</p>';
609
                        $tabcont .= '<br><p>'._L('Attention: Do not use this XML Export/Import to exchange, backup or restore data between OIDplus systems!<br>It will cause various loss of information, e.g. because Non-OIDs like GUIDs are converted in OIDs and can\'t be converted back.').'</p>';
608
                        $tabcont .= '<h2>'._L('Automatic export to oid-info.com').'</h2>';
610
                        $tabcont .= '<h2>'._L('Automatic export to oid-info.com').'</h2>';
609
                        $privacy_level = OIDplus::config()->getValue('reg_privacy');
611
                        $privacy_level = OIDplus::config()->getValue('reg_privacy');
610
                        if ($privacy_level == 0) {
612
                        if ($privacy_level == 0) {
611
                                $tabcont .= '<p>'._L('All your OIDs will automatically submitted to oid-info.com through the remote directory service in regular intervals.').' (<a '.OIDplus::gui()->link('oidplus:srv_registration').'>'._L('Change preference').'</a>)</p>';
613
                                $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>';
Line 615... Line 617...
615
                        $tabcont .= '<h2>'._L('Comparison with oid-info.com').'</h2>';
617
                        $tabcont .= '<h2>'._L('Comparison with oid-info.com').'</h2>';
616
                        $tabcont .= '<p><a '.OIDplus::gui()->link('oidplus:oidinfo_compare_export').'>'._L('List OIDs in your system which are missing at oid-info.com').'</a></p>';
618
                        $tabcont .= '<p><a '.OIDplus::gui()->link('oidplus:oidinfo_compare_export').'>'._L('List OIDs in your system which are missing at oid-info.com').'</a></p>';
617
                        $out['text'] .= OIDplus::gui()->tabContentPage('export', $tabcont, $tab === 'export');
619
                        $out['text'] .= OIDplus::gui()->tabContentPage('export', $tabcont, $tab === 'export');
618
                        // ---------------- "Import" tab
620
                        // ---------------- "Import" tab
619
                        $tabcont  = '<h2>'._L('Import XML file').'</h2>';
621
                        $tabcont  = '<h2>'._L('Import XML file').'</h2>';
620
                        $tabcont .= '<p>'._L('These XML files are following the <a %1>XML schema</a> of <b>oid-info.com</b>.','href="http://www.oid-info.com/oid.xsd" target="_blank"').'</p>';
622
                        $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>';
621
                        // TODO: we need a waiting animation!
623
                        // TODO: we need a waiting animation!
622
                        $tabcont .= '<form action="javascript:void(0);" onsubmit="return OIDplusPageAdminOIDInfoExport.uploadXmlFileOnSubmit(this);" enctype="multipart/form-data" id="uploadXmlFileForm">';
624
                        $tabcont .= '<form action="javascript:void(0);" onsubmit="return OIDplusPageAdminOIDInfoExport.uploadXmlFileOnSubmit(this);" enctype="multipart/form-data" id="uploadXmlFileForm">';
623
                        $tabcont .= '<div>'._L('Choose XML file here').':<input type="file" name="userfile" value="" id="userfile">';
625
                        $tabcont .= '<div>'._L('Choose XML file here').':<input type="file" name="userfile" value="" id="userfile">';
624
                        $tabcont .= '<br><input type="submit" value="'._L('Import XML').'"></div>';
626
                        $tabcont .= '<br><input type="submit" value="'._L('Import XML').'"></div>';
625
                        $tabcont .= '</form>';
627
                        $tabcont .= '</form>';
Line 839... Line 841...
839
                                        foreach ($alt_ids as $alt_id) {
841
                                        foreach ($alt_ids as $alt_id) {
840
                                                $ns = $alt_id->getNamespace();
842
                                                $ns = $alt_id->getNamespace();
841
                                                $id = $alt_id->getId();
843
                                                $id = $alt_id->getId();
842
                                                $desc = $alt_id->getDescription();
844
                                                $desc = $alt_id->getDescription();
843
                                                if ($ns == 'oid') {
845
                                                if ($ns == 'oid') {
-
 
846
                                                        // TODO: Let Object Type plugins decide if they want that their OID representations get published or not (via a Feature OID implementation)
844
                                                        if (strpos($id, '2.25.') === 0) continue; // don't spam the uuid arc with GUID objects
847
                                                        if (strpos($id, '2.25.') === 0) continue; // don't spam the uuid arc with GUID objects
845
                                                        $out_content .= $oa->createXMLEntry($id, $elements, $params, $comment=$obj->nodeId());
848
                                                        $out_content .= $oa->createXMLEntry($id, $elements, $params, $comment=$obj->nodeId());
846
                                                }
849
                                                }
847
                                        }
850
                                        }
848
                                }
851
                                }