Rev 148 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
101 | 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 | |||
101 | daniel-mar | 22 | class OIDplusPagePublicWhois extends OIDplusPagePlugin { |
23 | public function type() { |
||
24 | return 'public'; |
||
25 | } |
||
26 | |||
27 | public function priority() { |
||
28 | return 100; |
||
29 | } |
||
30 | |||
31 | public function action(&$handled) { |
||
32 | // Nothing |
||
33 | } |
||
34 | |||
35 | public function init($html=true) { |
||
104 | daniel-mar | 36 | OIDplus::config()->prepareConfigKey('whois_auth_token', 'OID-over-WHOIS authentication token to display confidential data', '', 0, 1); |
101 | daniel-mar | 37 | } |
38 | |||
39 | public function cfgSetValue($name, $value) { |
||
104 | daniel-mar | 40 | if ($name == 'whois_auth_token') { |
41 | $test_value = preg_replace('@[0-9a-zA-Z]*@', '', $value); |
||
42 | if ($test_value != '') { |
||
43 | throw new Exception("Only characters and numbers are allowed as authentication token."); |
||
44 | } |
||
45 | } |
||
101 | daniel-mar | 46 | } |
47 | |||
48 | public function gui($id, &$out, &$handled) { |
||
49 | if (explode('$',$id)[0] == 'oidplus:whois') { |
||
50 | $handled = true; |
||
51 | |||
52 | $out['title'] = 'Web WHOIS'; |
||
148 | daniel-mar | 53 | $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : ''; |
101 | daniel-mar | 54 | |
104 | daniel-mar | 55 | $out['text'] = ''; |
101 | daniel-mar | 56 | $out['text'] .= '<p>With the web based whois service, you can query object information in a machine readable format.</p>'; |
201 | daniel-mar | 57 | $out['text'] .= '<p>RFC draft (for Text format): <a href="plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/whois/rfc/draft-viathinksoft-oidwhois-00.txt">TXT</a> | <a href="plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/whois/rfc/draft-viathinksoft-oidwhois-00.nroff">NROFF</a></p>'; |
148 | daniel-mar | 58 | $out['text'] .= '<form action="plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/whois/webwhois.php" method="GET">'; |
201 | daniel-mar | 59 | $out['text'] .= ' <label class="padding_label">Format:</label><select name="format">'; |
60 | $out['text'] .= ' <option value="txt">Text (RFC pending)</option>'; |
||
61 | $out['text'] .= ' <option value="json">JSON</option>'; |
||
62 | $out['text'] .= ' <option value="xml">XML</option>'; |
||
63 | $out['text'] .= ' </select><br>'; |
||
64 | $out['text'] .= ' <label class="padding_label">Query:</label><input type="text" name="query" value="oid:2.999" style="width:250px">'; |
||
104 | daniel-mar | 65 | $out['text'] .= ' <input type="submit" value="Query">'; |
101 | daniel-mar | 66 | $out['text'] .= '</form>'; |
67 | } |
||
68 | } |
||
69 | |||
106 | daniel-mar | 70 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
101 | daniel-mar | 71 | if (file_exists(__DIR__.'/treeicon.png')) { |
148 | daniel-mar | 72 | $tree_icon = 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/treeicon.png'; |
101 | daniel-mar | 73 | } else { |
74 | $tree_icon = null; // default icon (folder) |
||
75 | } |
||
76 | |||
77 | $json[] = array( |
||
78 | 'id' => 'oidplus:whois', |
||
79 | 'icon' => $tree_icon, |
||
80 | 'text' => 'Web WHOIS' |
||
81 | ); |
||
104 | daniel-mar | 82 | |
83 | return true; |
||
101 | daniel-mar | 84 | } |
85 | |||
86 | public function modifyContent($id, &$title, &$icon, &$text) { |
||
148 | daniel-mar | 87 | $text .= '<br><img src="plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/page_pictogram.png" height="15" alt=""> <a href="plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/whois/webwhois.php?query='.urlencode($id).'" class="gray_footer_font">Whois</a>'; |
101 | daniel-mar | 88 | } |
108 | daniel-mar | 89 | |
90 | public function tree_search($request) { |
||
91 | return false; |
||
92 | } |
||
101 | daniel-mar | 93 | } |
94 | |||
95 | OIDplus::registerPagePlugin(new OIDplusPagePublicWhois()); |