Rev 662 | Rev 688 | 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>'; |
||
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>'; |
||
662 | daniel-mar | 121 | $out['text'] .= ' <tr>'; |
122 | $out['text'] .= ' <td>'._L('User account').'</td>'; |
||
685 | daniel-mar | 123 | // Note: get_current_user() will get the owner of the PHP script, not the process owner! |
124 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
||
125 | $current_user = getenv('USERNAME'); |
||
126 | } else { |
||
127 | $uid = posix_geteuid(); |
||
128 | $current_user = posix_getpwuid($uid); |
||
129 | if ($current_user === false) $current_user = '#'.$uid; |
||
130 | } |
||
131 | $out['text'] .= ' <td>'.($current_user === false ? '<i>'._L('unknown').'</i>' : htmlentities($current_user)).'</td>'; |
||
662 | daniel-mar | 132 | $out['text'] .= ' </tr>'; |
635 | daniel-mar | 133 | $out['text'] .= '</table>'; |
134 | $out['text'] .= '</div></div>'; |
||
135 | |||
136 | # --- |
||
137 | |||
138 | $out['text'] .= '<h2>'._L('Operating System').'</h2>'; |
||
139 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
||
140 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
||
141 | $out['text'] .= ' <tr>'; |
||
142 | $out['text'] .= ' <th width="50%">'._L('Attribute').'</th>'; |
||
143 | $out['text'] .= ' <th width="50%">'._L('Value').'</th>'; |
||
144 | $out['text'] .= ' </tr>'; |
||
145 | if (php_uname("m") == php_uname("n")) { |
||
146 | // At some hosts like Strato, php_uname() always returns the same string |
||
147 | // "Linux localhost 3.10.0-1127.10.1.el7.x86_64 #1 SMP" |
||
148 | $out['text'] .= ' <tr>'; |
||
149 | $out['text'] .= ' <td>'._L('Operating System').'</td>'; |
||
150 | $out['text'] .= ' <td>'.htmlentities(PHP_OS).'</td>'; |
||
151 | $out['text'] .= ' </tr>'; |
||
152 | $out['text'] .= ' <tr>'; |
||
153 | $out['text'] .= ' <td>'._L('Hostname').'</td>'; |
||
154 | $out['text'] .= ' <td>'.htmlentities(gethostname()).'</td>'; |
||
155 | $out['text'] .= ' </tr>'; |
||
156 | } else { |
||
157 | $out['text'] .= ' <tr>'; |
||
158 | $out['text'] .= ' <td>'._L('Operating System').'</td>'; |
||
159 | $out['text'] .= ' <td>'.htmlentities(php_uname("s").' '.php_uname("r").' '.php_uname("v")).'</td>'; |
||
160 | $out['text'] .= ' </tr>'; |
||
161 | $out['text'] .= ' <tr>'; |
||
162 | $out['text'] .= ' <td>'._L('Machine type').'</td>'; |
||
163 | $out['text'] .= ' <td>'.htmlentities(php_uname("m")).'</td>'; |
||
164 | $out['text'] .= ' </tr>'; |
||
165 | $out['text'] .= ' <tr>'; |
||
166 | $out['text'] .= ' <td>'._L('Hostname').'</td>'; |
||
167 | $out['text'] .= ' <td>'.htmlentities(php_uname("n")).'</td>'; |
||
168 | $out['text'] .= ' </tr>'; |
||
169 | } |
||
170 | $out['text'] .= '</table>'; |
||
171 | $out['text'] .= '</div></div>'; |
||
172 | |||
173 | # --- |
||
174 | |||
175 | $out['text'] .= '<h2>'._L('Database').'</h2>'; |
||
176 | $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
||
177 | $out['text'] .= '<table class="table table-bordered table-striped">'; |
||
178 | $out['text'] .= ' <tr>'; |
||
179 | $out['text'] .= ' <th width="50%">'._L('Attribute').'</th>'; |
||
180 | $out['text'] .= ' <th width="50%">'._L('Value').'</th>'; |
||
181 | $out['text'] .= ' </tr>'; |
||
182 | |||
183 | $out['text'] .= ' <tr>'; |
||
184 | $out['text'] .= ' <td>'._L('Database provider').'</td>'; |
||
185 | $out['text'] .= ' <td>'.OIDplus::db()->getPlugin()->getManifest()->getName().'</td>'; |
||
186 | $out['text'] .= ' </tr>'; |
||
187 | |||
188 | $out['text'] .= ' <tr>'; |
||
189 | $out['text'] .= ' <td>'._L('SQL slang').'</td>'; |
||
190 | $out['text'] .= ' <td>'.OIDplus::db()->getSlang()->getManifest()->getName().'</td>'; |
||
191 | $out['text'] .= ' </tr>'; |
||
192 | |||
193 | $table_prefix = OIDplus::baseConfig()->getValue('TABLENAME_PREFIX'); |
||
194 | $out['text'] .= ' <tr>'; |
||
195 | $out['text'] .= ' <td>'._L('Table name prefix').'</td>'; |
||
196 | $out['text'] .= ' <td>'.(!empty($table_prefix) ? htmlentities($table_prefix) : '<i>'._L('none').'</i>').'</td>'; |
||
197 | $out['text'] .= ' </tr>'; |
||
198 | $out['text'] .= '</table>'; |
||
199 | $out['text'] .= '</div></div>'; |
||
200 | |||
201 | // TODO: can we somehow get the DBMS version, connection string etc? |
||
202 | |||
203 | # --- |
||
204 | |||
205 | } |
||
206 | } |
||
207 | |||
208 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
||
209 | if (!OIDplus::authUtils()->isAdminLoggedIn()) return false; |
||
210 | |||
211 | if (file_exists(__DIR__.'/treeicon.png')) { |
||
212 | $tree_icon = OIDplus::webpath(__DIR__).'treeicon.png'; |
||
213 | } else { |
||
214 | $tree_icon = null; // default icon (folder) |
||
215 | } |
||
216 | |||
217 | $json[] = array( |
||
218 | 'id' => 'oidplus:systeminfo', |
||
219 | 'icon' => $tree_icon, |
||
220 | 'text' => _L('System information') |
||
221 | ); |
||
222 | |||
223 | return true; |
||
224 | } |
||
225 | |||
226 | public function tree_search($request) { |
||
227 | return false; |
||
228 | } |
||
229 | |||
230 | public function implementsFeature($id) { |
||
231 | return false; |
||
232 | } |
||
662 | daniel-mar | 233 | } |