Subversion Repositories oidplus

Rev

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

Rev Author Line No. Line
61 daniel-mar 1
<?php
2
 
3
/*
4
 * OIDplus 2.0
5
 * Copyright 2019 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
 
112 daniel-mar 20
if (!defined('IN_OIDPLUS')) die();
21
 
61 daniel-mar 22
class OIDplusPageAdminWellKnownOIDs extends OIDplusPagePlugin {
222 daniel-mar 23
        public static function getPluginInformation() {
24
                $out = array();
25
                $out['name'] = 'Well known OIDs';
26
                $out['author'] = 'ViaThinkSoft';
27
                $out['version'] = null;
28
                $out['descriptionHTML'] = null;
29
                return $out;
30
        }
31
 
61 daniel-mar 32
        public function type() {
33
                return 'admin';
34
        }
35
 
36
        public function priority() {
37
                return 100;
38
        }
39
 
40
        public function action(&$handled) {
41
                // Nothing
42
        }
43
 
75 daniel-mar 44
        public function init($html=true) {
61 daniel-mar 45
                // Nothing
46
        }
47
 
48
        public function cfgSetValue($name, $value) {
49
                // Nothing
50
        }
51
 
52
        public function gui($id, &$out, &$handled) {
53
                if ($id === 'oidplus:well_known_oids') {
54
                        $handled = true;
55
                        $out['title'] = 'Well known OIDs';
241 daniel-mar 56
                        $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
61 daniel-mar 57
 
58
                        if (!OIDplus::authUtils()::isAdminLoggedIn()) {
59
                                $out['icon'] = 'img/error_big.png';
153 daniel-mar 60
                                $out['text'] = '<p>You need to <a '.oidplus_link('oidplus:login').'>log in</a> as administrator.</p>';
61 daniel-mar 61
                        } else {
62
                                $out['text'] = '<p><abbr title="These ID names can only be edited in the database directly (Tables '.OIDPLUS_TABLENAME_PREFIX.'asn1id and '.OIDPLUS_TABLENAME_PREFIX.'iri). Usually, there is no need to do this, though.">How to edit these IDs?</abbr></p>';
63
 
64
                                $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
65
                                $out['text'] .= '<table class="table table-bordered table-striped">';
66
                                $out['text'] .= '       <tr>';
67
                                $out['text'] .= '            <th>OID</th>';
68
                                $out['text'] .= '            <th>ASN.1 identifiers (comma sep.)</th>';
69
                                $out['text'] .= '            <th>IRI identifiers (comma sep.)</th>';
70
                                $out['text'] .= '       </tr>';
71
 
239 daniel-mar 72
                                $res = OIDplus::db()->query("select a.oid from (select oid from ".OIDPLUS_TABLENAME_PREFIX."asn1id where well_known = '1' union select oid from ".OIDPLUS_TABLENAME_PREFIX."iri where well_known = '1') a order by ".OIDplus::db()->natOrder('oid'));
236 daniel-mar 73
                                while ($row = $res->fetch_array()) {
61 daniel-mar 74
                                        $asn1ids = array();
150 daniel-mar 75
                                        $res2 = OIDplus::db()->query("select name, standardized from ".OIDPLUS_TABLENAME_PREFIX."asn1id where oid = ?", array($row['oid']));
236 daniel-mar 76
                                        while ($row2 = $res2->fetch_array()) {
61 daniel-mar 77
                                                $asn1ids[] = $row2['name'].($row2['standardized'] ? ' (standardized)' : '');
78
                                        }
79
 
80
                                        $iris = array();
150 daniel-mar 81
                                        $res2 = OIDplus::db()->query("select name, longarc from ".OIDPLUS_TABLENAME_PREFIX."iri where oid = ?", array($row['oid']));
236 daniel-mar 82
                                        while ($row2 = $res2->fetch_array()) {
61 daniel-mar 83
                                                $iris[] = $row2['name'].($row2['longarc'] ? ' (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
 
106 daniel-mar 99
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
61 daniel-mar 100
                if (file_exists(__DIR__.'/treeicon.png')) {
241 daniel-mar 101
                        $tree_icon = OIDplus::webpath(__DIR__).'treeicon.png';
61 daniel-mar 102
                } else {
103
                        $tree_icon = null; // default icon (folder)
104
                }
105
 
106
                $json[] = array(
107
                        'id' => 'oidplus:well_known_oids',
108
                        'icon' => $tree_icon,
109
                        'text' => 'Well known OIDs'
110
                );
104 daniel-mar 111
 
112
                return true;
61 daniel-mar 113
        }
108 daniel-mar 114
 
115
        public function tree_search($request) {
116
                return false;
117
        }
61 daniel-mar 118
}