Subversion Repositories oidplus

Rev

Rev 1266 | 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
 
1116 daniel-mar 28
        /**
29
         * @param bool $html
30
         * @return void
31
         */
32
        public function init(bool $html=true) {
635 daniel-mar 33
                // Nothing
34
        }
35
 
1116 daniel-mar 36
        /**
37
         * @param string $id
38
         * @param array $out
39
         * @param bool $handled
40
         * @return void
41
         * @throws OIDplusException
42
         */
43
        public function gui(string $id, array &$out, bool &$handled) {
635 daniel-mar 44
                if ($id === 'oidplus:well_known_oids') {
45
                        $handled = true;
46
                        $out['title'] = _L('Well known OIDs');
801 daniel-mar 47
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
635 daniel-mar 48
 
49
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
1266 daniel-mar 50
                                throw new OIDplusHtmlException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')), $out['title'], 401);
635 daniel-mar 51
                        }
52
 
1116 daniel-mar 53
                        $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>';
635 daniel-mar 54
                        $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>';
1436 daniel-mar 55
                        if (OIDplus::getEditionInfo()['vendor'] == 'ViaThinkSoft') {
56
                                $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>';
57
                        }
635 daniel-mar 58
                        // $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>';
59
                        $out['text'] .= '</ol></p>';
60
 
1153 daniel-mar 61
                        $out['text'] .= '<p><b>'._L('How to edit these IDs?').'</b> '._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.').'</p>';
635 daniel-mar 62
                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
63
                        $out['text'] .= '<table class="table table-bordered table-striped">';
1138 daniel-mar 64
                        $out['text'] .= '<thead>';
635 daniel-mar 65
                        $out['text'] .= '       <tr>';
66
                        $out['text'] .= '            <th>'._L('OID').'</th>';
67
                        $out['text'] .= '            <th>'._L('ASN.1 identifiers (comma sep.)').'</th>';
68
                        $out['text'] .= '            <th>'._L('IRI identifiers (comma sep.)').'</th>';
69
                        $out['text'] .= '       </tr>';
1138 daniel-mar 70
                        $out['text'] .= '</thead>';
71
                        $out['text'] .= '<tbody>';
635 daniel-mar 72
 
1147 daniel-mar 73
                        $asn1ids = array();
74
                        $res = OIDplus::db()->query("select oid, name, standardized from ###asn1id where well_known = ?", array(true));
635 daniel-mar 75
                        while ($row = $res->fetch_array()) {
1147 daniel-mar 76
                                $oid = $row['oid'];
77
                                if (!isset($asn1ids[$oid])) $asn1ids[$oid] = array();
78
                                $asn1ids[$oid][] = $row['name'].($row['standardized'] ? ' ('._L('standardized').')' : '');
79
                        }
635 daniel-mar 80
 
1147 daniel-mar 81
                        $iris = array();
82
                        $res = OIDplus::db()->query("select oid, name, longarc from ###iri where well_known = ?", array(true));
83
                        while ($row = $res->fetch_array()) {
84
                                $oid = $row['oid'];
85
                                if (!isset($iris[$oid])) $iris[$oid] = array();
1149 daniel-mar 86
                                $iris[$oid][] = $row['name'].($row['longarc'] ? ' ('._L('long arc').')' : '');
1147 daniel-mar 87
                        }
635 daniel-mar 88
 
1147 daniel-mar 89
                        $oids = array_merge(array_keys($asn1ids), array_keys($iris));
90
                        $oids = array_unique($oids);
91
                        natsort($oids);
92
 
93
                        foreach ($oids as $oid) {
94
                                $local_asn1ids = $asn1ids[$oid] ?? array();
95
                                $local_iris = $iris[$oid] ?? array();
635 daniel-mar 96
                                $out['text'] .= '<tr>';
1147 daniel-mar 97
                                $out['text'] .= '     <td>'.htmlentities(explode(':', $oid)[1]).'</td>';
98
                                $out['text'] .= '     <td>'.htmlentities(implode(', ', $local_asn1ids)).'</td>';
99
                                $out['text'] .= '     <td>'.htmlentities(implode(', ', $local_iris)).'</td>';
635 daniel-mar 100
                                $out['text'] .= '</tr>';
101
                        }
102
 
1138 daniel-mar 103
                        $out['text'] .= '</tbody>';
635 daniel-mar 104
                        $out['text'] .= '</table>';
105
                        $out['text'] .= '</div></div>';
106
                }
107
        }
108
 
1116 daniel-mar 109
        /**
110
         * @param array $json
111
         * @param string|null $ra_email
112
         * @param bool $nonjs
113
         * @param string $req_goto
114
         * @return bool
115
         * @throws OIDplusException
116
         */
117
        public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
635 daniel-mar 118
                if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
119
 
800 daniel-mar 120
                if (file_exists(__DIR__.'/img/main_icon16.png')) {
801 daniel-mar 121
                        $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
635 daniel-mar 122
                } else {
123
                        $tree_icon = null; // default icon (folder)
124
                }
125
 
126
                $json[] = array(
127
                        'id' => 'oidplus:well_known_oids',
128
                        'icon' => $tree_icon,
129
                        'text' => _L('Well known OIDs')
130
                );
131
 
132
                return true;
133
        }
134
 
1116 daniel-mar 135
        /**
136
         * @param string $request
137
         * @return array|false
138
         */
139
        public function tree_search(string $request) {
635 daniel-mar 140
                return false;
141
        }
142
}