Rev 104 | 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 | |||
20 | class OIDplusPageAdminWellKnownOIDs extends OIDplusPagePlugin { |
||
21 | public function type() { |
||
22 | return 'admin'; |
||
23 | } |
||
24 | |||
25 | public function priority() { |
||
26 | return 100; |
||
27 | } |
||
28 | |||
29 | public function action(&$handled) { |
||
30 | // Nothing |
||
31 | } |
||
32 | |||
75 | daniel-mar | 33 | public function init($html=true) { |
61 | daniel-mar | 34 | // Nothing |
35 | } |
||
36 | |||
37 | public function cfgSetValue($name, $value) { |
||
38 | // Nothing |
||
39 | } |
||
40 | |||
41 | public function gui($id, &$out, &$handled) { |
||
42 | if ($id === 'oidplus:well_known_oids') { |
||
43 | $handled = true; |
||
44 | $out['title'] = 'Well known OIDs'; |
||
45 | $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/adminPages/'.basename(__DIR__).'/icon_big.png' : ''; |
||
46 | |||
47 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
||
48 | $out['icon'] = 'img/error_big.png'; |
||
49 | $out['text'] .= '<p>You need to <a href="?goto=oidplus:login">log in</a> as administrator.</p>'; |
||
50 | } else { |
||
51 | $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>'; |
||
52 | |||
53 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
||
54 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
||
55 | $out['text'] .= ' <tr>'; |
||
56 | $out['text'] .= ' <th>OID</th>'; |
||
57 | $out['text'] .= ' <th>ASN.1 identifiers (comma sep.)</th>'; |
||
58 | $out['text'] .= ' <th>IRI identifiers (comma sep.)</th>'; |
||
59 | $out['text'] .= ' </tr>'; |
||
60 | |||
61 | $res = OIDplus::db()->query("select oid from ".OIDPLUS_TABLENAME_PREFIX."asn1id where well_known = 1 union select oid from ".OIDPLUS_TABLENAME_PREFIX."iri where well_known = 1 order by ".OIDplus::db()->natOrder('oid')); |
||
62 | while ($row = OIDplus::db()->fetch_array($res)) { |
||
63 | $asn1ids = array(); |
||
88 | daniel-mar | 64 | $res2 = OIDplus::db()->query("select name, standardized from ".OIDPLUS_TABLENAME_PREFIX."asn1id where oid = '".OIDplus::db()->real_escape_string($row['oid'])."'"); |
61 | daniel-mar | 65 | while ($row2 = OIDplus::db()->fetch_array($res2)) { |
66 | $asn1ids[] = $row2['name'].($row2['standardized'] ? ' (standardized)' : ''); |
||
67 | } |
||
68 | |||
69 | $iris = array(); |
||
88 | daniel-mar | 70 | $res2 = OIDplus::db()->query("select name, longarc from ".OIDPLUS_TABLENAME_PREFIX."iri where oid = '".OIDplus::db()->real_escape_string($row['oid'])."'"); |
61 | daniel-mar | 71 | while ($row2 = OIDplus::db()->fetch_array($res2)) { |
72 | $iris[] = $row2['name'].($row2['longarc'] ? ' (long arc)' : ''); |
||
73 | } |
||
74 | |||
75 | $out['text'] .= '<tr>'; |
||
76 | $out['text'] .= ' <td>'.htmlentities(explode(':',$row['oid'])[1]).'</td>'; |
||
77 | $out['text'] .= ' <td>'.htmlentities(implode(', ', $asn1ids)).'</td>'; |
||
78 | $out['text'] .= ' <td>'.htmlentities(implode(', ', $iris)).'</td>'; |
||
79 | $out['text'] .= '</tr>'; |
||
80 | } |
||
81 | |||
82 | $out['text'] .= '</table>'; |
||
83 | $out['text'] .= '</div></div>'; |
||
84 | } |
||
85 | } |
||
86 | } |
||
87 | |||
106 | daniel-mar | 88 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
61 | daniel-mar | 89 | if (file_exists(__DIR__.'/treeicon.png')) { |
90 | $tree_icon = 'plugins/adminPages/'.basename(__DIR__).'/treeicon.png'; |
||
91 | } else { |
||
92 | $tree_icon = null; // default icon (folder) |
||
93 | } |
||
94 | |||
95 | $json[] = array( |
||
96 | 'id' => 'oidplus:well_known_oids', |
||
97 | 'icon' => $tree_icon, |
||
98 | 'text' => 'Well known OIDs' |
||
99 | ); |
||
104 | daniel-mar | 100 | |
101 | return true; |
||
61 | daniel-mar | 102 | } |
103 | } |
||
104 | |||
105 | OIDplus::registerPagePlugin(new OIDplusPageAdminWellKnownOIDs()); |