Subversion Repositories oidplus

Rev

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