Subversion Repositories oidplus

Rev

Rev 1116 | Rev 1147 | 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
 
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()) {
800 daniel-mar 50
                                $out['icon'] = 'img/error.png';
635 daniel-mar 51
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
52
                                return;
53
                        }
54
 
1116 daniel-mar 55
                        $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 56
                        $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>';
57
                        $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>';
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
 
61
                        $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>';
62
 
63
                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
64
                        $out['text'] .= '<table class="table table-bordered table-striped">';
1138 daniel-mar 65
                        $out['text'] .= '<thead>';
635 daniel-mar 66
                        $out['text'] .= '       <tr>';
67
                        $out['text'] .= '            <th>'._L('OID').'</th>';
68
                        $out['text'] .= '            <th>'._L('ASN.1 identifiers (comma sep.)').'</th>';
69
                        $out['text'] .= '            <th>'._L('IRI identifiers (comma sep.)').'</th>';
70
                        $out['text'] .= '       </tr>';
1138 daniel-mar 71
                        $out['text'] .= '</thead>';
72
                        $out['text'] .= '<tbody>';
635 daniel-mar 73
 
74
                        /*
75
                        $res = OIDplus::db()->query("select a.oid from (".
76
                                                    "select oid from ###asn1id where well_known = ? union ".
77
                                                    "select oid from ###iri where well_known = ?) a ".
78
                                                    "order by ".OIDplus::db()->natOrder('oid'), array(true, true)); // <-- This prepared statement does not work in SQL-Server!
79
                        */
80
                        $res = OIDplus::db()->query("select a.oid from (".
81
                                                    "select oid, well_known from ###asn1id union ".
82
                                                    "select oid, well_known from ###iri) a ".
83
                                                    "where a.well_known = ? ".
84
                                                    "order by ".OIDplus::db()->natOrder('oid'), array(true)); // <-- This works
85
                        while ($row = $res->fetch_array()) {
86
                                $asn1ids = array();
87
                                $res2 = OIDplus::db()->query("select name, standardized from ###asn1id where oid = ?", array($row['oid']));
88
                                while ($row2 = $res2->fetch_array()) {
89
                                        $asn1ids[] = $row2['name'].($row2['standardized'] ? ' ('._L('standardized').')' : '');
90
                                }
91
 
92
                                $iris = array();
93
                                $res2 = OIDplus::db()->query("select name, longarc from ###iri where oid = ?", array($row['oid']));
94
                                while ($row2 = $res2->fetch_array()) {
95
                                        $iris[] = $row2['name'].($row2['longarc'] ? ' ('._L('long arc').')' : '');
96
                                }
97
 
98
                                $out['text'] .= '<tr>';
99
                                $out['text'] .= '     <td>'.htmlentities(explode(':',$row['oid'])[1]).'</td>';
100
                                $out['text'] .= '     <td>'.htmlentities(implode(', ', $asn1ids)).'</td>';
101
                                $out['text'] .= '     <td>'.htmlentities(implode(', ', $iris)).'</td>';
102
                                $out['text'] .= '</tr>';
103
                        }
104
 
1138 daniel-mar 105
                        $out['text'] .= '</tbody>';
635 daniel-mar 106
                        $out['text'] .= '</table>';
107
                        $out['text'] .= '</div></div>';
108
                }
109
        }
110
 
1116 daniel-mar 111
        /**
112
         * @param array $json
113
         * @param string|null $ra_email
114
         * @param bool $nonjs
115
         * @param string $req_goto
116
         * @return bool
117
         * @throws OIDplusException
118
         */
119
        public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
635 daniel-mar 120
                if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
121
 
800 daniel-mar 122
                if (file_exists(__DIR__.'/img/main_icon16.png')) {
801 daniel-mar 123
                        $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
635 daniel-mar 124
                } else {
125
                        $tree_icon = null; // default icon (folder)
126
                }
127
 
128
                $json[] = array(
129
                        'id' => 'oidplus:well_known_oids',
130
                        'icon' => $tree_icon,
131
                        'text' => _L('Well known OIDs')
132
                );
133
 
134
                return true;
135
        }
136
 
1116 daniel-mar 137
        /**
138
         * @param string $request
139
         * @return array|false
140
         */
141
        public function tree_search(string $request) {
635 daniel-mar 142
                return false;
143
        }
144
}