Subversion Repositories oidplus

Rev

Rev 444 | 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 OIDplusPageAdminSysteminfo extends OIDplusPagePluginAdmin {
  21.  
  22.         public function action($actionID, $params) {
  23.         }
  24.  
  25.         public function init($html=true) {
  26.         }
  27.  
  28.         public function gui($id, &$out, &$handled) {
  29.                 if ($id === 'oidplus:systeminfo') {
  30.                         $handled = true;
  31.                         $out['title'] = _L('System information');
  32.                         $out['icon']  = OIDplus::webpath(__DIR__).'icon_big.png';
  33.  
  34.                         if (!OIDplus::authUtils()::isAdminLoggedIn()) {
  35.                                 $out['icon'] = 'img/error_big.png';
  36.                                 $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login')).'</p>';
  37.                                 return;
  38.                         }
  39.  
  40.                         $out['text']  = '';
  41.  
  42.                         # ---
  43.  
  44.                         $out['text'] .= '<h2>'._L('OIDplus').'</h2>';
  45.                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  46.                         $out['text'] .= '<table class="table table-bordered table-striped">';
  47.                         $out['text'] .= '       <tr>';
  48.                         $out['text'] .= '               <th width="50%">'._L('Attribute').'</th>';
  49.                         $out['text'] .= '               <th width="50%">'._L('Value').'</th>';
  50.                         $out['text'] .= '       </tr>';
  51.                         $out['text'] .= '       <tr>';
  52.  
  53.                         $sysid_oid = OIDplus::getSystemId(true);
  54.                         $out['text'] .= '               <td>'._L('System OID').'</td>';
  55.                         $out['text'] .= '               <td>'.(!$sysid_oid ? '<i>'._L('unknown').'</i>' : htmlentities($sysid_oid)).'</td>';
  56.                         $out['text'] .= '       </tr>';
  57.  
  58.                         $sys_url = OIDplus::webpath();
  59.                         $out['text'] .= '       <tr>';
  60.                         $out['text'] .= '               <td>'._L('System URL').'</td>';
  61.                         $out['text'] .= '               <td>'.htmlentities($sys_url).'</td>';
  62.                         $out['text'] .= '       </tr>';
  63.  
  64.                         $sys_ver = OIDplus::getVersion();
  65.                         $out['text'] .= '       <tr>';
  66.                         $out['text'] .= '               <td>'._L('System version').'</td>';
  67.                         $out['text'] .= '               <td>'.(!$sys_ver ? '<i>'._L('unknown').'</i>' : htmlentities($sys_ver)).'</td>';
  68.                         $out['text'] .= '       </tr>';
  69.  
  70.                         $sys_install_type = OIDplus::getInstallType();
  71.                         $out['text'] .= '       <tr>';
  72.                         $out['text'] .= '               <td>'._L('Installation type').'</td>';
  73.                         $out['text'] .= '               <td>'.htmlentities($sys_install_type).'</td>';
  74.                         $out['text'] .= '       </tr>';
  75.  
  76.                         $sys_title = OIDplus::config()->getValue('system_title');
  77.                         $out['text'] .= '       <tr>';
  78.                         $out['text'] .= '               <td>'._L('System title').'</td>';
  79.                         $out['text'] .= '               <td>'.htmlentities($sys_title).'</td>';
  80.                         $out['text'] .= '       </tr>';
  81.  
  82.                         $out['text'] .= '       <tr>';
  83.                         $out['text'] .= '               <td>'._L('System directory').'</td>';
  84.                         $out['text'] .= '               <td>'.(isset($_SERVER['SCRIPT_FILENAME']) ? htmlentities(dirname($_SERVER['SCRIPT_FILENAME'])) : '<i>'._L('unknown').'</i>').'</td>';
  85.                         $out['text'] .= '       </tr>';
  86.  
  87.                         $out['text'] .= '</table>';
  88.                         $out['text'] .= '</div></div>';
  89.  
  90.                         # ---
  91.  
  92.                         $out['text'] .= '<h2>'._L('PHP').'</h2>';
  93.                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  94.                         $out['text'] .= '<table class="table table-bordered table-striped">';
  95.                         $out['text'] .= '       <tr>';
  96.                         $out['text'] .= '               <th width="50%">'._L('Attribute').'</th>';
  97.                         $out['text'] .= '               <th width="50%">'._L('Value').'</th>';
  98.                         $out['text'] .= '       </tr>';
  99.                         $out['text'] .= '       <tr>';
  100.                         $out['text'] .= '               <td>'._L('PHP version').'</td>';
  101.                         $out['text'] .= '               <td>'.PHP_VERSION.'</td>';
  102.                         $out['text'] .= '       </tr>';
  103.                         $out['text'] .= '</table>';
  104.                         $out['text'] .= '</div></div>';
  105.  
  106.                         # ---
  107.  
  108.                         $out['text'] .= '<h2>'._L('Webserver').'</h2>';
  109.                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  110.                         $out['text'] .= '<table class="table table-bordered table-striped">';
  111.                         $out['text'] .= '       <tr>';
  112.                         $out['text'] .= '               <th width="50%">'._L('Attribute').'</th>';
  113.                         $out['text'] .= '               <th width="50%">'._L('Value').'</th>';
  114.                         $out['text'] .= '       </tr>';
  115.                         $out['text'] .= '       <tr>';
  116.                         $out['text'] .= '               <td>'._L('Server software').'</td>';
  117.                         $out['text'] .= '               <td>'.(isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '<i>'._L('unknown').'</i>').'</td>';
  118.                         $out['text'] .= '       </tr>';
  119.                         $out['text'] .= '</table>';
  120.                         $out['text'] .= '</div></div>';
  121.  
  122.                         # ---
  123.  
  124.                         $out['text'] .= '<h2>'._L('Operating System').'</h2>';
  125.                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  126.                         $out['text'] .= '<table class="table table-bordered table-striped">';
  127.                         $out['text'] .= '       <tr>';
  128.                         $out['text'] .= '               <th width="50%">'._L('Attribute').'</th>';
  129.                         $out['text'] .= '               <th width="50%">'._L('Value').'</th>';
  130.                         $out['text'] .= '       </tr>';
  131.                         $out['text'] .= '       <tr>';
  132.                         $out['text'] .= '               <td>'._L('Operating System').'</td>';
  133.                         $out['text'] .= '               <td>'.htmlentities(php_uname("s").' '.php_uname("r").' '.php_uname("v")).'</td>';
  134.                         $out['text'] .= '       </tr>';
  135.                         $out['text'] .= '       <tr>';
  136.                         $out['text'] .= '               <td>'._L('Machine type').'</td>';
  137.                         $out['text'] .= '               <td>'.htmlentities(php_uname("m")).'</td>';
  138.                         $out['text'] .= '       </tr>';
  139.                         $out['text'] .= '       <tr>';
  140.                         $out['text'] .= '               <td>'._L('Hostname').'</td>';
  141.                         $out['text'] .= '               <td>'.htmlentities(php_uname("n")).'</td>';
  142.                         $out['text'] .= '       </tr>';
  143.                         $out['text'] .= '</table>';
  144.                         $out['text'] .= '</div></div>';
  145.  
  146.                         # ---
  147.  
  148.                         $out['text'] .= '<h2>'._L('Database').'</h2>';
  149.                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  150.                         $out['text'] .= '<table class="table table-bordered table-striped">';
  151.                         $out['text'] .= '       <tr>';
  152.                         $out['text'] .= '               <th width="50%">'._L('Attribute').'</th>';
  153.                         $out['text'] .= '               <th width="50%">'._L('Value').'</th>';
  154.                         $out['text'] .= '       </tr>';
  155.  
  156.                         $out['text'] .= '       <tr>';
  157.                         $out['text'] .= '               <td>'._L('Database provider').'</td>';
  158.                         $out['text'] .= '               <td>'.OIDplus::db()->getPlugin()->getManifest()->getName().'</td>';
  159.                         $out['text'] .= '       </tr>';
  160.  
  161.                         $out['text'] .= '       <tr>';
  162.                         $out['text'] .= '               <td>'._L('SQL slang').'</td>';
  163.                         $out['text'] .= '               <td>'.OIDplus::db()->getSlang()->getManifest()->getName().'</td>';
  164.                         $out['text'] .= '       </tr>';
  165.  
  166.                         $table_prefix = OIDplus::baseConfig()->getValue('TABLENAME_PREFIX');
  167.                         $out['text'] .= '       <tr>';
  168.                         $out['text'] .= '               <td>'._L('Table name prefix').'</td>';
  169.                         $out['text'] .= '               <td>'.(!empty($table_prefix) ? htmlentities($table_prefix) : '<i>'._L('none').'</i>').'</td>';
  170.                         $out['text'] .= '       </tr>';
  171.                         $out['text'] .= '</table>';
  172.                         $out['text'] .= '</div></div>';
  173.  
  174.                         // TODO: can we somehow get the DBMS version, connection string etc?
  175.  
  176.                         # ---
  177.  
  178.                 }
  179.         }
  180.  
  181.         public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
  182.                 if (!OIDplus::authUtils()::isAdminLoggedIn()) return false;
  183.  
  184.                 if (file_exists(__DIR__.'/treeicon.png')) {
  185.                         $tree_icon = OIDplus::webpath(__DIR__).'treeicon.png';
  186.                 } else {
  187.                         $tree_icon = null; // default icon (folder)
  188.                 }
  189.  
  190.                 $json[] = array(
  191.                         'id' => 'oidplus:systeminfo',
  192.                         'icon' => $tree_icon,
  193.                         'text' => _L('System information')
  194.                 );
  195.  
  196.                 return true;
  197.         }
  198.  
  199.         public function tree_search($request) {
  200.                 return false;
  201.         }
  202.  
  203.         public function implementsFeature($id) {
  204.                 return false;
  205.         }
  206. }