OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
oxdiagnostics.php
Go to the documentation of this file.
1 <?php
2 
10 {
16  protected $_sEdition = "";
17 
23  protected $_sVersion = "";
24 
30  protected $_sRevision = "";
31 
37  protected $_sShopLink = "";
38 
44  protected $_aFileCheckerPathList = array(
45  'bootstrap.php',
46  'index.php',
47  'oxid.php',
48  'oxseo.php',
49  'admin/',
50  'application/',
51  'bin/',
52  'core/',
53  'modules/',
54  );
55 
61  protected $_aFileCheckerExtensionList = array( 'php', 'tpl' );
62 
68  public function setFileCheckerPathList( $aPathList )
69  {
70  $this->_aFileCheckerPathList = $aPathList;
71  }
72 
78  public function getFileCheckerPathList()
79  {
81  }
82 
88  public function setFileCheckerExtensionList( $aExtList )
89  {
90  $this->_aFileCheckerExtensionList = $aExtList;
91  }
92 
98  public function getFileCheckerExtensionList()
99  {
101  }
102 
103 
109  public function setVersion( $sVersion )
110  {
111  if ( !empty( $sVersion ) ) {
112  $this->_sVersion = $sVersion;
113  }
114  }
115 
121  public function getVersion()
122  {
123  return $this->_sVersion;
124  }
125 
131  public function setEdition( $sEdition )
132  {
133  if ( !empty( $sEdition ) ) {
134  $this->_sEdition = $sEdition;
135  }
136  }
137 
143  public function getEdition()
144  {
145  return $this->_sEdition;
146  }
147 
153  public function setRevision( $sRevision )
154  {
155  if ( !empty( $sRevision ) ) {
156  $this->_sRevision = $sRevision;
157  }
158  }
159 
165  public function getRevision()
166  {
167  return $this->_sRevision;
168  }
169 
170 
176  public function setShopLink( $sShopLink )
177  {
178  if ( !empty( $sShopLink ) ) {
179  $this->_sShopLink = $sShopLink;
180  }
181  }
182 
188  public function getShopLink()
189  {
190  return $this->_sShopLink;
191  }
192 
198  public function getShopDetails()
199  {
200  $aShopDetails = array(
201  'Date' => date( oxRegistry::getLang()->translateString( 'fullDateFormat' ), time() ),
202  'URL' => $this->getShopLink(),
203  'Edition' => $this->getEdition(),
204  'Version' => $this->getVersion(),
205  'Revision' => $this->getRevision(),
206  'Subshops (Total)' => $this->_countRows( 'oxshops', true ),
207  'Subshops (Active)' => $this->_countRows( 'oxshops', false ),
208  'Categories (Total)' => $this->_countRows( 'oxcategories', true ),
209  'Categories (Active)' => $this->_countRows( 'oxcategories', false ),
210  'Articles (Total)' => $this->_countRows( 'oxarticles', true ),
211  'Articles (Active)' => $this->_countRows( 'oxarticles', false ),
212  'Users (Total)' => $this->_countRows( 'oxuser', true ),
213  );
214 
215  return $aShopDetails;
216  }
217 
225  protected function _countRows( $sTable, $blMode )
226  {
227  $oDb = oxDb::getDb();
228  $sRequest = 'SELECT COUNT(*) FROM '.$sTable;
229 
230  if ( $blMode == false){
231  $sRequest .= ' WHERE oxactive = 1';
232  }
233 
234  $aRes = $oDb->execute( $sRequest)->fields(0);
235  return $aRes[0];
236  }
237 
238 
239 
245  public function getPhpSelection()
246  {
247  $aPhpIniParams = array(
248  'allow_url_fopen',
249  'display_errors',
250  'file_uploads',
251  'max_execution_time',
252  'memory_limit',
253  'post_max_size',
254  'register_globals',
255  'upload_max_filesize',
256  );
257 
258  $aPhpIniConf = array();
259 
260  foreach ( $aPhpIniParams as $sParam ){
261  $sValue = ini_get( $sParam );
262  $aPhpIniConf[$sParam] = $sValue;
263  }
264 
265  return $aPhpIniConf;
266  }
267 
268 
269 
275  public function getPhpDecoder()
276  {
277  $sReturn = 'Zend ';
278 
279  if ( function_exists( 'zend_optimizer_version' ) )
280  {
281  $sReturn .= 'Optimizer';
282  }
283 
284  if ( function_exists( 'zend_loader_enabled' ) )
285  {
286  $sReturn .= 'Guard Loader';
287  }
288 
289  return $sReturn;
290  }
291 
292 
293 
300  public function getServerInfo()
301  {
302  // init empty variables (can be filled if exec is allowed)
303  $iCpuAmnt = $iCpuMhz = $iBogo = $iMemTotal = $iMemFree = $sCpuModelName = $sCpuModel = $sCpuFreq = $iCpuCores = null;
304 
305  // fill, if exec is allowed
306  if ( $this->isExecAllowed())
307  {
308  $iCpuAmnt = $this->_getCpuAmount();
309  $iCpuMhz = $this->_getCpuMhz();
310  $iBogo = $this->_getBogoMips();
311  $iMemTotal = $this->_getMemoryTotal();
312  $iMemFree = $this->_getMemoryFree();
313  $sCpuModelName = $this->_getCpuModel();
314  $sCpuModel = $iCpuAmnt.'x '.$sCpuModelName;
315  $sCpuFreq = $iCpuMhz.' MHz';
316 
317  // prevent "division by zero" error
318  if ( $iBogo && $iCpuMhz ){
319  $iCpuCores = $iBogo / $iCpuMhz;
320  }
321  }
322 
323  $aServerInfo = array(
324  'Server OS' => @php_uname('s'),
325  'VM' => $this->_getVirtualizationSystem(),
326  'PHP' => $this->_getPhpVersion(),
327  'MySQL' => $this->_getMySqlServerInfo(),
328  'Apache' => $this->_getApacheVersion(),
329  'Disk total' => $this->_getDiskTotalSpace(),
330  'Disk free' => $this->_getDiskFreeSpace(),
331  'Memory total' => $iMemTotal,
332  'Memory free' => $iMemFree,
333  'CPU Model' => $sCpuModel,
334  'CPU frequency' => $sCpuFreq,
335  'CPU cores' => round( $iCpuCores,0),
336  );
337 
338  return $aServerInfo;
339  }
340 
346  protected function _getApacheVersion()
347  {
348  if ( function_exists( 'apache_get_version' ) ){
349  $sReturn = apache_get_version();
350  } else {
351  $sReturn = $_SERVER['SERVER_SOFTWARE'];
352  }
353 
354  return $sReturn;
355  }
356 
362  protected function _getVirtualizationSystem()
363  {
364  $sSystemType = '';
365 
366  if ( $this->isExecAllowed() ){
367  //VMWare
368  @$sDeviceList = $this->_getDeviceList( 'vmware' );
369  if ( $sDeviceList ){
370  $sSystemType = 'VMWare';
371  unset( $sDeviceList );
372  }
373 
374  //VirtualBox
375  @$sDeviceList = $this->_getDeviceList( 'VirtualBox' );
376  if( $sDeviceList ){
377  $sSystemType = 'VirtualBox';
378  unset( $sDeviceList );
379  }
380  }
381 
382  return $sSystemType;
383  }
384 
390  public function isExecAllowed()
391  {
392  return function_exists( 'exec' );
393  }
394 
401  protected function _getDeviceList( $sSystemType )
402  {
403  return exec( 'lspci | grep -i '. $sSystemType );
404  }
405 
411  protected function _getCpuAmount()
412  {
413  // cat /proc/cpuinfo | grep "processor" | sort -u | cut -d: -f2');
414  return exec('cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l');
415  }
416 
422  protected function _getCpuMhz()
423  {
424  return round(exec('cat /proc/cpuinfo | grep "MHz" | sort -u | cut -d: -f2'),0);
425  }
426 
432  protected function _getBogoMips()
433  {
434  return exec('cat /proc/cpuinfo | grep "bogomips" | sort -u | cut -d: -f2');
435  }
436 
442  protected function _getMemoryTotal()
443  {
444  return exec('cat /proc/meminfo | grep "MemTotal" | sort -u | cut -d: -f2');
445  }
446 
452  protected function _getMemoryFree()
453  {
454  return exec('cat /proc/meminfo | grep "MemFree" | sort -u | cut -d: -f2');
455  }
456 
462  protected function _getCpuModel()
463  {
464  return exec('cat /proc/cpuinfo | grep "model name" | sort -u | cut -d: -f2');
465  }
466 
472  protected function _getDiskTotalSpace()
473  {
474  return round( disk_total_space('/') / 1024 / 1024 , 0 ) .' GiB';
475  }
476 
482  protected function _getDiskFreeSpace()
483  {
484  return round(disk_free_space('/') / 1024 / 1024, 0) . ' GiB';
485  }
486 
492  protected function _getPhpVersion()
493  {
494  return phpversion();
495  }
496 
502  protected function _getMySqlServerInfo()
503  {
504  $aResult = oxDb::getDb(oxDb::FETCH_MODE_ASSOC)->getRow("SHOW VARIABLES LIKE 'version'");
505  return $aResult['Value'];
506  }
507 
508 
509 }