人人商城

sysinfo.ctrl.php 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. $_W['page']['title'] = '系统信息 - 系统管理';
  8. $info = array();
  9. $info['uid'] = $_W['uid'];
  10. $info['account'] = $_W['account'] ? $_W['account']['name'] : '';
  11. $info['os'] = php_uname();
  12. $info['php'] = phpversion();
  13. $info['sapi'] = $_SERVER['SERVER_SOFTWARE'];
  14. $info['sapi'] = $info['sapi'] ? $info['sapi'] : php_sapi_name();
  15. $size = 0;
  16. $size = @ini_get('upload_max_filesize');
  17. if($size) {
  18. $size = parse_size($size);
  19. }
  20. if($size > 0) {
  21. $ts = @ini_get('post_max_size');
  22. if($ts) {
  23. $ts = parse_size($size);
  24. }
  25. if($ts > 0) {
  26. $size = min($size, $ts);
  27. }
  28. $ts = @ini_get('memory_limit');
  29. if($ts) {
  30. $ts = parse_size($size);
  31. }
  32. if($ts > 0) {
  33. $size = min($size, $ts);
  34. }
  35. }
  36. if(empty($size)) {
  37. $size = '';
  38. } else {
  39. $size = sizecount($size);
  40. }
  41. $info['limit'] = $size;
  42. $sql = 'SELECT VERSION();';
  43. $info['mysql']['version'] = pdo_fetchcolumn($sql);
  44. $tables = pdo_fetchall("SHOW TABLE STATUS LIKE '".$_W['config']['db']['tablepre']."%'");
  45. $size = 0;
  46. foreach ($tables as &$table) {
  47. $size += $table['Data_length'] + $table['Index_length'];
  48. }
  49. if(empty($size)) {
  50. $size = '';
  51. } else {
  52. $size = sizecount($size);
  53. }
  54. $info['mysql']['size'] = $size;
  55. $info['attach']['url'] = $_W['attachurl'];
  56. $path = IA_ROOT . '/' . $_W['config']['upload']['attachdir'];
  57. $size = dir_size($path);
  58. if(empty($size)) {
  59. $size = '';
  60. } else {
  61. $size = sizecount($size);
  62. }
  63. $info['attach']['size'] = $size;
  64. template('system/sysinfo');
  65. function dir_size($dir) {
  66. $size = 0;
  67. if(is_dir($dir)) {
  68. $handle = opendir($dir);
  69. while (false !== ($entry = readdir($handle))) {
  70. if($entry != '.' && $entry != '..') {
  71. if(is_dir("{$dir}/{$entry}")) {
  72. $size += dir_size("{$dir}/{$entry}");
  73. } else {
  74. $size += filesize("{$dir}/{$entry}");
  75. }
  76. }
  77. }
  78. closedir($handle);
  79. }
  80. return $size;
  81. }
  82. function parse_size($str) {
  83. if(strtolower($str[strlen($str) -1]) == 'k') {
  84. return floatval($str) * 1024;
  85. }
  86. if(strtolower($str[strlen($str) -1]) == 'm') {
  87. return floatval($str) * 1048576;
  88. }
  89. if(strtolower($str[strlen($str) -1]) == 'g') {
  90. return floatval($str) * 1073741824;
  91. }
  92. }