Subversion Repositories oidplus

Rev

Rev 1050 | Rev 1116 | 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
1086 daniel-mar 5
 * Copyright 2019 - 2023 Daniel Marschall, ViaThinkSoft
635 daniel-mar 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
 
1086 daniel-mar 22
// phpcs:disable PSR1.Files.SideEffects
23
\defined('INSIDE_OIDPLUS') or die;
24
// phpcs:enable PSR1.Files.SideEffects
25
 
635 daniel-mar 26
class OIDplusPageAdminWellKnownOIDs extends OIDplusPagePluginAdmin {
27
 
28
        public function init($html=true) {
29
                // Nothing
30
        }
31
 
32
        public function gui($id, &$out, &$handled) {
33
                if ($id === 'oidplus:well_known_oids') {
34
                        $handled = true;
35
                        $out['title'] = _L('Well known OIDs');
801 daniel-mar 36
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
635 daniel-mar 37
 
38
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
800 daniel-mar 39
                                $out['icon'] = 'img/error.png';
635 daniel-mar 40
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
41
                                return;
42
                        }
43
 
44
                        $out['text'] = '';
45
 
46
                        $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>';
47
                        $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>';
48
                        $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>';
49
                        // $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>';
50
                        $out['text'] .= '</ol></p>';
51
 
52
                        $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>';
53
 
54
                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
55
                        $out['text'] .= '<table class="table table-bordered table-striped">';
56
                        $out['text'] .= '       <tr>';
57
                        $out['text'] .= '            <th>'._L('OID').'</th>';
58
                        $out['text'] .= '            <th>'._L('ASN.1 identifiers (comma sep.)').'</th>';
59
                        $out['text'] .= '            <th>'._L('IRI identifiers (comma sep.)').'</th>';
60
                        $out['text'] .= '       </tr>';
61
 
62
                        /*
63
                        $res = OIDplus::db()->query("select a.oid from (".
64
                                                    "select oid from ###asn1id where well_known = ? union ".
65
                                                    "select oid from ###iri where well_known = ?) a ".
66
                                                    "order by ".OIDplus::db()->natOrder('oid'), array(true, true)); // <-- This prepared statement does not work in SQL-Server!
67
                        */
68
                        $res = OIDplus::db()->query("select a.oid from (".
69
                                                    "select oid, well_known from ###asn1id union ".
70
                                                    "select oid, well_known from ###iri) a ".
71
                                                    "where a.well_known = ? ".
72
                                                    "order by ".OIDplus::db()->natOrder('oid'), array(true)); // <-- This works
73
                        while ($row = $res->fetch_array()) {
74
                                $asn1ids = array();
75
                                $res2 = OIDplus::db()->query("select name, standardized from ###asn1id where oid = ?", array($row['oid']));
76
                                while ($row2 = $res2->fetch_array()) {
77
                                        $asn1ids[] = $row2['name'].($row2['standardized'] ? ' ('._L('standardized').')' : '');
78
                                }
79
 
80
                                $iris = array();
81
                                $res2 = OIDplus::db()->query("select name, longarc from ###iri where oid = ?", array($row['oid']));
82
                                while ($row2 = $res2->fetch_array()) {
83
                                        $iris[] = $row2['name'].($row2['longarc'] ? ' ('._L('long arc').')' : '');
84
                                }
85
 
86
                                $out['text'] .= '<tr>';
87
                                $out['text'] .= '     <td>'.htmlentities(explode(':',$row['oid'])[1]).'</td>';
88
                                $out['text'] .= '     <td>'.htmlentities(implode(', ', $asn1ids)).'</td>';
89
                                $out['text'] .= '     <td>'.htmlentities(implode(', ', $iris)).'</td>';
90
                                $out['text'] .= '</tr>';
91
                        }
92
 
93
                        $out['text'] .= '</table>';
94
                        $out['text'] .= '</div></div>';
95
                }
96
        }
97
 
98
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
99
                if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
100
 
800 daniel-mar 101
                if (file_exists(__DIR__.'/img/main_icon16.png')) {
801 daniel-mar 102
                        $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
635 daniel-mar 103
                } else {
104
                        $tree_icon = null; // default icon (folder)
105
                }
106
 
107
                $json[] = array(
108
                        'id' => 'oidplus:well_known_oids',
109
                        'icon' => $tree_icon,
110
                        'text' => _L('Well known OIDs')
111
                );
112
 
113
                return true;
114
        }
115
 
116
        public function tree_search($request) {
117
                return false;
118
        }
119
}