Subversion Repositories oidplus

Rev

Rev 662 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
635 daniel-mar 1
<?php
2
 
3
/*
4
 * OIDplus 2.0
5
 * Copyright 2019 - 2021 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
if (!defined('INSIDE_OIDPLUS')) die();
21
 
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;
33
                        $out['title'] = _L('System information');
34
                        $out['icon']  = OIDplus::webpath(__DIR__).'icon_big.png';
35
 
36
                        if (!OIDplus::authUtils()->isAdminLoggedIn()) {
37
                                $out['icon'] = 'img/error_big.png';
38
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
39
                                return;
40
                        }
41
 
42
                        $out['text']  = '';
43
 
44
                        # ---
45
 
46
                        $out['text'] .= '<h2>'._L('OIDplus').'</h2>';
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>';
50
                        $out['text'] .= '               <th width="50%">'._L('Attribute').'</th>';
51
                        $out['text'] .= '               <th width="50%">'._L('Value').'</th>';
52
                        $out['text'] .= '       </tr>';
53
                        $out['text'] .= '       <tr>';
54
 
55
                        $sysid_oid = OIDplus::getSystemId(true);
56
                        $out['text'] .= '               <td>'._L('System OID').'</td>';
57
                        $out['text'] .= '               <td>'.(!$sysid_oid ? '<i>'._L('unknown').'</i>' : htmlentities($sysid_oid)).'</td>';
58
                        $out['text'] .= '       </tr>';
59
 
60
                        $sys_url = OIDplus::webpath();
61
                        $out['text'] .= '       <tr>';
62
                        $out['text'] .= '               <td>'._L('System URL').'</td>';
63
                        $out['text'] .= '               <td>'.htmlentities($sys_url).'</td>';
64
                        $out['text'] .= '       </tr>';
65
 
66
                        $sys_ver = OIDplus::getVersion();
67
                        $out['text'] .= '       <tr>';
68
                        $out['text'] .= '               <td>'._L('System version').'</td>';
69
                        $out['text'] .= '               <td>'.(!$sys_ver ? '<i>'._L('unknown').'</i>' : htmlentities($sys_ver)).'</td>';
70
                        $out['text'] .= '       </tr>';
71
 
72
                        $sys_install_type = OIDplus::getInstallType();
73
                        $out['text'] .= '       <tr>';
74
                        $out['text'] .= '               <td>'._L('Installation type').'</td>';
75
                        $out['text'] .= '               <td>'.htmlentities($sys_install_type).'</td>';
76
                        $out['text'] .= '       </tr>';
77
 
78
                        $sys_title = OIDplus::config()->getValue('system_title');
79
                        $out['text'] .= '       <tr>';
80
                        $out['text'] .= '               <td>'._L('System title').'</td>';
81
                        $out['text'] .= '               <td>'.htmlentities($sys_title).'</td>';
82
                        $out['text'] .= '       </tr>';
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
 
89
                        $out['text'] .= '</table>';
90
                        $out['text'] .= '</div></div>';
91
 
92
                        # ---
93
 
94
                        $out['text'] .= '<h2>'._L('PHP').'</h2>';
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>';
98
                        $out['text'] .= '               <th width="50%">'._L('Attribute').'</th>';
99
                        $out['text'] .= '               <th width="50%">'._L('Value').'</th>';
100
                        $out['text'] .= '       </tr>';
101
                        $out['text'] .= '       <tr>';
102
                        $out['text'] .= '               <td>'._L('PHP version').'</td>';
103
                        $out['text'] .= '               <td>'.PHP_VERSION.'</td>';
104
                        $out['text'] .= '       </tr>';
105
                        $out['text'] .= '</table>';
106
                        $out['text'] .= '</div></div>';
107
 
108
                        # ---
109
 
110
                        $out['text'] .= '<h2>'._L('Webserver').'</h2>';
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>';
114
                        $out['text'] .= '               <th width="50%">'._L('Attribute').'</th>';
115
                        $out['text'] .= '               <th width="50%">'._L('Value').'</th>';
116
                        $out['text'] .= '       </tr>';
117
                        $out['text'] .= '       <tr>';
118
                        $out['text'] .= '               <td>'._L('Server software').'</td>';
119
                        $out['text'] .= '               <td>'.(isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '<i>'._L('unknown').'</i>').'</td>';
120
                        $out['text'] .= '       </tr>';
121
                        $out['text'] .= '</table>';
122
                        $out['text'] .= '</div></div>';
123
 
124
                        # ---
125
 
126
                        $out['text'] .= '<h2>'._L('Operating System').'</h2>';
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>';
130
                        $out['text'] .= '               <th width="50%">'._L('Attribute').'</th>';
131
                        $out['text'] .= '               <th width="50%">'._L('Value').'</th>';
132
                        $out['text'] .= '       </tr>';
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
                        }
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>';
173
                        $out['text'] .= '               <td>'.OIDplus::db()->getPlugin()->getManifest()->getName().'</td>';
174
                        $out['text'] .= '       </tr>';
175
 
176
                        $out['text'] .= '       <tr>';
177
                        $out['text'] .= '               <td>'._L('SQL slang').'</td>';
178
                        $out['text'] .= '               <td>'.OIDplus::db()->getSlang()->getManifest()->getName().'</td>';
179
                        $out['text'] .= '       </tr>';
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>';
186
                        $out['text'] .= '</table>';
187
                        $out['text'] .= '</div></div>';
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,
208
                        'text' => _L('System information')
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
        }
221
}