Subversion Repositories oidplus

Rev

Rev 685 | Rev 697 | Go to most recent revision | Details | Compare with Previous | 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>';
688 daniel-mar 53
 
54
                        $sys_title = OIDplus::config()->getValue('system_title');
635 daniel-mar 55
                        $out['text'] .= '       <tr>';
688 daniel-mar 56
                        $out['text'] .= '               <td>'._L('System title').'</td>';
57
                        $out['text'] .= '               <td>'.htmlentities($sys_title).'</td>';
58
                        $out['text'] .= '       </tr>';
635 daniel-mar 59
 
688 daniel-mar 60
                        $out['text'] .= '       <tr>';
61
                        $out['text'] .= '               <td>'._L('System directory').'</td>';
62
                        $out['text'] .= '               <td>'.(isset($_SERVER['SCRIPT_FILENAME']) ? htmlentities(dirname($_SERVER['SCRIPT_FILENAME'])) : '<i>'._L('unknown').'</i>').'</td>';
63
                        $out['text'] .= '       </tr>';
64
 
635 daniel-mar 65
                        $sysid_oid = OIDplus::getSystemId(true);
688 daniel-mar 66
                        $out['text'] .= '       <tr>';
635 daniel-mar 67
                        $out['text'] .= '               <td>'._L('System OID').'</td>';
68
                        $out['text'] .= '               <td>'.(!$sysid_oid ? '<i>'._L('unknown').'</i>' : htmlentities($sysid_oid)).'</td>';
69
                        $out['text'] .= '       </tr>';
70
 
71
                        $sys_url = OIDplus::webpath();
72
                        $out['text'] .= '       <tr>';
73
                        $out['text'] .= '               <td>'._L('System URL').'</td>';
74
                        $out['text'] .= '               <td>'.htmlentities($sys_url).'</td>';
75
                        $out['text'] .= '       </tr>';
76
 
77
                        $sys_ver = OIDplus::getVersion();
78
                        $out['text'] .= '       <tr>';
79
                        $out['text'] .= '               <td>'._L('System version').'</td>';
80
                        $out['text'] .= '               <td>'.(!$sys_ver ? '<i>'._L('unknown').'</i>' : htmlentities($sys_ver)).'</td>';
81
                        $out['text'] .= '       </tr>';
82
 
83
                        $sys_install_type = OIDplus::getInstallType();
84
                        $out['text'] .= '       <tr>';
85
                        $out['text'] .= '               <td>'._L('Installation type').'</td>';
86
                        $out['text'] .= '               <td>'.htmlentities($sys_install_type).'</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>';
662 daniel-mar 121
                        $out['text'] .= '       <tr>';
122
                        $out['text'] .= '               <td>'._L('User account').'</td>';
688 daniel-mar 123
                        $current_user = exec('whoami');
124
                        if ($current_user == '') {
125
                                if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
126
                                        // Windows on an IIS server:
127
                                        //     getenv('USERNAME')     MARSCHALL$                (That is the "machine account", see https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities#accessing-the-network )
128
                                        //     get_current_user()     DefaultAppPool
129
                                        //     exec('whoami')         iis apppool\defaultapppool
130
                                        // Windows with XAMPP:
131
                                        //     getenv('USERNAME')     dmarschall
132
                                        //     get_current_user()     dmarschall               (even if script has a different NTFS owner!)
133
                                        //     exec('whoami')         hickelsoft\dmarschall
134
                                        $current_user = get_current_user();
135
                                        if ($current_user == '') $current_user = getenv('USERNAME');
136
                                } else {
137
                                        // On Linux:
138
                                        // get_current_user() will get the owner of the PHP script, not the process owner!
139
                                        // We want the process owner, so we use posix_geteuid().
140
                                        $uid = posix_geteuid();
141
                                        $current_user = posix_getpwuid($uid); // receive username (required read access to /etc/passwd )
142
                                        if ($current_user == '') $current_user = get_current_user();
143
                                        if ($current_user == '') $current_user = '#'.$uid;
144
                                }
685 daniel-mar 145
                        }
688 daniel-mar 146
                        $out['text'] .= '               <td>'.($current_user == '' ? '<i>'._L('unknown').'</i>' : htmlentities($current_user)).'</td>';
662 daniel-mar 147
                        $out['text'] .= '       </tr>';
635 daniel-mar 148
                        $out['text'] .= '</table>';
149
                        $out['text'] .= '</div></div>';
150
 
151
                        # ---
152
 
153
                        $out['text'] .= '<h2>'._L('Operating System').'</h2>';
154
                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
155
                        $out['text'] .= '<table class="table table-bordered table-striped">';
156
                        $out['text'] .= '       <tr>';
157
                        $out['text'] .= '               <th width="50%">'._L('Attribute').'</th>';
158
                        $out['text'] .= '               <th width="50%">'._L('Value').'</th>';
159
                        $out['text'] .= '       </tr>';
160
                        if (php_uname("m") == php_uname("n")) {
161
                                // At some hosts like Strato, php_uname() always returns the same string
162
                                // "Linux localhost 3.10.0-1127.10.1.el7.x86_64 #1 SMP"
163
                                $out['text'] .= '       <tr>';
164
                                $out['text'] .= '               <td>'._L('Operating System').'</td>';
165
                                $out['text'] .= '               <td>'.htmlentities(PHP_OS).'</td>';
166
                                $out['text'] .= '       </tr>';
167
                                $out['text'] .= '       <tr>';
168
                                $out['text'] .= '               <td>'._L('Hostname').'</td>';
169
                                $out['text'] .= '               <td>'.htmlentities(gethostname()).'</td>';
170
                                $out['text'] .= '       </tr>';
171
                        } else {
172
                                $out['text'] .= '       <tr>';
173
                                $out['text'] .= '               <td>'._L('Operating System').'</td>';
174
                                $out['text'] .= '               <td>'.htmlentities(php_uname("s").' '.php_uname("r").' '.php_uname("v")).'</td>';
175
                                $out['text'] .= '       </tr>';
176
                                $out['text'] .= '       <tr>';
177
                                $out['text'] .= '               <td>'._L('Machine type').'</td>';
178
                                $out['text'] .= '               <td>'.htmlentities(php_uname("m")).'</td>';
179
                                $out['text'] .= '       </tr>';
180
                                $out['text'] .= '       <tr>';
181
                                $out['text'] .= '               <td>'._L('Hostname').'</td>';
182
                                $out['text'] .= '               <td>'.htmlentities(php_uname("n")).'</td>';
183
                                $out['text'] .= '       </tr>';
184
                        }
185
                        $out['text'] .= '</table>';
186
                        $out['text'] .= '</div></div>';
187
 
188
                        # ---
189
 
190
                        $out['text'] .= '<h2>'._L('Database').'</h2>';
191
                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
192
                        $out['text'] .= '<table class="table table-bordered table-striped">';
193
                        $out['text'] .= '       <tr>';
194
                        $out['text'] .= '               <th width="50%">'._L('Attribute').'</th>';
195
                        $out['text'] .= '               <th width="50%">'._L('Value').'</th>';
196
                        $out['text'] .= '       </tr>';
197
 
198
                        $out['text'] .= '       <tr>';
199
                        $out['text'] .= '               <td>'._L('Database provider').'</td>';
200
                        $out['text'] .= '               <td>'.OIDplus::db()->getPlugin()->getManifest()->getName().'</td>';
201
                        $out['text'] .= '       </tr>';
202
 
203
                        $out['text'] .= '       <tr>';
204
                        $out['text'] .= '               <td>'._L('SQL slang').'</td>';
205
                        $out['text'] .= '               <td>'.OIDplus::db()->getSlang()->getManifest()->getName().'</td>';
206
                        $out['text'] .= '       </tr>';
207
 
208
                        $table_prefix = OIDplus::baseConfig()->getValue('TABLENAME_PREFIX');
209
                        $out['text'] .= '       <tr>';
210
                        $out['text'] .= '               <td>'._L('Table name prefix').'</td>';
211
                        $out['text'] .= '               <td>'.(!empty($table_prefix) ? htmlentities($table_prefix) : '<i>'._L('none').'</i>').'</td>';
212
                        $out['text'] .= '       </tr>';
213
                        $out['text'] .= '</table>';
214
                        $out['text'] .= '</div></div>';
215
 
216
                        // TODO: can we somehow get the DBMS version, connection string etc?
217
 
218
                        # ---
219
 
220
                }
221
        }
222
 
223
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
224
                if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
225
 
226
                if (file_exists(__DIR__.'/treeicon.png')) {
227
                        $tree_icon = OIDplus::webpath(__DIR__).'treeicon.png';
228
                } else {
229
                        $tree_icon = null; // default icon (folder)
230
                }
231
 
232
                $json[] = array(
233
                        'id' => 'oidplus:systeminfo',
234
                        'icon' => $tree_icon,
235
                        'text' => _L('System information')
236
                );
237
 
238
                return true;
239
        }
240
 
241
        public function tree_search($request) {
242
                return false;
243
        }
244
 
245
        public function implementsFeature($id) {
246
                return false;
247
        }
662 daniel-mar 248
}