Subversion Repositories oidplus

Rev

Rev 510 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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