Subversion Repositories oidplus

Rev

Rev 101 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

  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) {
  34.                 OIDplus::config()->prepareConfigKey('whois_auth_token', 'OID-over-WHOIS authentication token to display confidential data', '', 0, 1);
  35.         }
  36.  
  37.         public function cfgSetValue($name, $value) {
  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.                 }
  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.  
  53.                         $out['text']  = '';
  54.                         $out['text'] .= '<p>With the web based whois service, you can query object information in a machine readable format.</p>';
  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>';
  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">';
  58.                         $out['text'] .= '       <input type="submit" value="Query">';
  59.                         $out['text'] .= '</form>';
  60.                 }
  61.         }
  62.  
  63.         public function tree(&$json, $ra_email=null, $nonjs=false) {
  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.                 );
  75.  
  76.                 return true;
  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());
  85.