Просмотр файла admin_list/mysql_si.php

Размер файла: 2.93Kb
  1. <?
  2. /*
  3. =============================================
  4. Движок: SHCMS Engine
  5. =============================================
  6. Название файла: Вес сайта и база данных
  7. =============================================
  8. Official website: http://shcms.ru
  9. =============================================
  10. */
  11. define('SHCMS', true);
  12. include_once'../system/inc/basic_settings.php';
  13. $shcmsengine['title'] = 'SHCMS Engine Вес сайта и Базы данных';
  14. include_once'../template/head.php';
  15. registrat();
  16.  
  17. include_once H.'system/inc/config.php';
  18.  
  19. $user4 = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE id= $user_id"));
  20. if($user4['team'] < 6)
  21. {
  22. echo 'Ошибка';
  23. header('Refresh: 1; url=/index.php?'.$conservation.'&');
  24. include_once'../template/foot.php';
  25. exit();
  26. }
  27. include_once'secu.php';
  28. function size_file($dir) {
  29. global $f_size;
  30. $dh = opendir ($dir);
  31. while ($file = readdir($dh)) {
  32. if($file!="." && $file!="..") {
  33. $fullpath = $dir."/".$file;
  34. if(!is_dir ($fullpath))
  35. {
  36. $f_size = $f_size + filesize ($fullpath);
  37. } else {
  38. size_file($fullpath);
  39. }
  40. }
  41. }
  42. closedir ($dh);
  43. return ($f_size);
  44. }
  45. function size_mysql($bd_host, $bd_login, $bd_parol, $bd_name) {
  46. $connect = @mysql_connect($bd_host, $bd_login, $bd_parol);
  47. if ($connect) {
  48. if (@mysql_select_db ( $bd_name, $connect ) ) {
  49. mysql_select_db( $dbname );
  50. $result = mysql_query( "SHOW TABLE STATUS" );
  51. while( $row = mysql_fetch_array( $result ) ) {
  52. $dbsize += $row[ "Data_length" ] + $row[ "Index_length" ];
  53. }
  54. return $dbsize;
  55. } else { die("База данных недоступна."); }
  56. } else { die("Немогу подключиться."); }
  57. }
  58. function formatfilesize($data) {
  59. if($data) {
  60. if( $data < 1024 ) {
  61. return $data . " байт";
  62. } else if( $data < 1048576 ) {
  63. return round( ( $data / 1024 ), 2 ) . " килобайт";
  64. } else if( $data < 1073741824 ) {
  65. return round( ( $data / 1048576 ), 2 ) . " мегабайт";
  66. } else {
  67. return round( ( $data / 1073741824 ), 2 ) . " гигабайт";
  68. }
  69. }
  70. }
  71. $files = size_file(".");
  72. $mysql = size_mysql(DBHOST,DBUSER,DBPASS,DBNAME);
  73. $all = $files+$mysql;
  74. echo "<hr/>Файлы весят: " . formatfilesize($files)."";
  75. echo "<hr/>База данных весит: " . formatfilesize($mysql)."";
  76. echo "<hr/>Общий вес сайта: " . formatfilesize($all)."<hr/>";
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83. include_once'../template/foot.php';
  84.  
  85. ?>