Subversion Repositories oidplus

Rev

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