Subversion Repositories oidplus

Rev

Rev 801 | Rev 1086 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
635 daniel-mar 1
<?php
2
 
3
/*
4
 * OIDplus 2.0
5
 * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
 
1050 daniel-mar 20
namespace ViaThinkSoft\OIDplus;
635 daniel-mar 21
 
22
class OIDplusPageAdminWellKnownOIDs extends OIDplusPagePluginAdmin {
23
 
24
        public function init($html=true) {
25
                // Nothing
26
        }
27
 
28
        public function gui($id, &$out, &$handled) {
29
                if ($id === 'oidplus:well_known_oids') {
30
                        $handled = true;
31
                        $out['title'] = _L('Well known OIDs');
801 daniel-mar 32
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
635 daniel-mar 33
 
34
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
800 daniel-mar 35
                                $out['icon'] = 'img/error.png';
635 daniel-mar 36
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
37
                                return;
38
                        }
39
 
40
                        $out['text'] = '';
41
 
42
                        $out['text'] .= '<p>'._L('Well-known OIDs are OIDs of Registration Authorities which are assigning OIDs to customers, i.e. they are most likely to be used by OIDplus users as their root OID. Well-known OIDs have the following purposes:').'<ol>';
43
                        $out['text'] .= '<li>'._L('When a new OIDplus user creates his root OID into OIDplus, then the ASN.1 identifiers and Unicode labels of the superior OIDs are automatically added.').'</li>';
44
                        $out['text'] .= '<li>'._L('In the automatic oid-info.com publishing, well-known OIDs will not be transmitted (because it is unlikely that RAs of well-known OIDs will be using OIDplus in combination with automatic publishing to oid-info.com). Instead, all children inside these well-known OIDs are most likely to be yours, so these will be reported to oid-info.com instead.').'</li>';
45
                        // $out['text'] .= '<li>'._L('In OID-WHOIS, if a user requests information about an unknown OID which is inside a well-known OID, then OID-WHOIS will output information at which place more information can be retrieved from.').'</li>';
46
                        $out['text'] .= '</ol></p>';
47
 
48
                        $out['text'] .= '<p><abbr title="'._L('These ID names can only be edited in the database directly (Tables ###asn1id and ###iri). Usually, there is no need to do this, though.').'">'._L('How to edit these IDs?').'</abbr></p>';
49
 
50
                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
51
                        $out['text'] .= '<table class="table table-bordered table-striped">';
52
                        $out['text'] .= '       <tr>';
53
                        $out['text'] .= '            <th>'._L('OID').'</th>';
54
                        $out['text'] .= '            <th>'._L('ASN.1 identifiers (comma sep.)').'</th>';
55
                        $out['text'] .= '            <th>'._L('IRI identifiers (comma sep.)').'</th>';
56
                        $out['text'] .= '       </tr>';
57
 
58
                        /*
59
                        $res = OIDplus::db()->query("select a.oid from (".
60
                                                    "select oid from ###asn1id where well_known = ? union ".
61
                                                    "select oid from ###iri where well_known = ?) a ".
62
                                                    "order by ".OIDplus::db()->natOrder('oid'), array(true, true)); // <-- This prepared statement does not work in SQL-Server!
63
                        */
64
                        $res = OIDplus::db()->query("select a.oid from (".
65
                                                    "select oid, well_known from ###asn1id union ".
66
                                                    "select oid, well_known from ###iri) a ".
67
                                                    "where a.well_known = ? ".
68
                                                    "order by ".OIDplus::db()->natOrder('oid'), array(true)); // <-- This works
69
                        while ($row = $res->fetch_array()) {
70
                                $asn1ids = array();
71
                                $res2 = OIDplus::db()->query("select name, standardized from ###asn1id where oid = ?", array($row['oid']));
72
                                while ($row2 = $res2->fetch_array()) {
73
                                        $asn1ids[] = $row2['name'].($row2['standardized'] ? ' ('._L('standardized').')' : '');
74
                                }
75
 
76
                                $iris = array();
77
                                $res2 = OIDplus::db()->query("select name, longarc from ###iri where oid = ?", array($row['oid']));
78
                                while ($row2 = $res2->fetch_array()) {
79
                                        $iris[] = $row2['name'].($row2['longarc'] ? ' ('._L('long arc').')' : '');
80
                                }
81
 
82
                                $out['text'] .= '<tr>';
83
                                $out['text'] .= '     <td>'.htmlentities(explode(':',$row['oid'])[1]).'</td>';
84
                                $out['text'] .= '     <td>'.htmlentities(implode(', ', $asn1ids)).'</td>';
85
                                $out['text'] .= '     <td>'.htmlentities(implode(', ', $iris)).'</td>';
86
                                $out['text'] .= '</tr>';
87
                        }
88
 
89
                        $out['text'] .= '</table>';
90
                        $out['text'] .= '</div></div>';
91
                }
92
        }
93
 
94
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
95
                if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
96
 
800 daniel-mar 97
                if (file_exists(__DIR__.'/img/main_icon16.png')) {
801 daniel-mar 98
                        $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
635 daniel-mar 99
                } else {
100
                        $tree_icon = null; // default icon (folder)
101
                }
102
 
103
                $json[] = array(
104
                        'id' => 'oidplus:well_known_oids',
105
                        'icon' => $tree_icon,
106
                        'text' => _L('Well known OIDs')
107
                );
108
 
109
                return true;
110
        }
111
 
112
        public function tree_search($request) {
113
                return false;
114
        }
115
}