Размер файла: 2.93Kb
- <?
- /*
- =============================================
- Движок: SHCMS Engine
- =============================================
- Название файла: Вес сайта и база данных
- =============================================
- Official website: http://shcms.ru
- =============================================
- */
- define('SHCMS', true);
- include_once'../system/inc/basic_settings.php';
- $shcmsengine['title'] = 'SHCMS Engine Вес сайта и Базы данных';
- include_once'../template/head.php';
- registrat();
-
- include_once H.'system/inc/config.php';
-
- $user4 = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE id= $user_id"));
- if($user4['team'] < 6)
- {
- echo 'Ошибка';
- header('Refresh: 1; url=/index.php?'.$conservation.'&');
- include_once'../template/foot.php';
- exit();
- }
- include_once'secu.php';
- function size_file($dir) {
- global $f_size;
- $dh = opendir ($dir);
- while ($file = readdir($dh)) {
- if($file!="." && $file!="..") {
- $fullpath = $dir."/".$file;
- if(!is_dir ($fullpath))
- {
- $f_size = $f_size + filesize ($fullpath);
- } else {
- size_file($fullpath);
- }
- }
- }
- closedir ($dh);
- return ($f_size);
- }
- function size_mysql($bd_host, $bd_login, $bd_parol, $bd_name) {
- $connect = @mysql_connect($bd_host, $bd_login, $bd_parol);
- if ($connect) {
- if (@mysql_select_db ( $bd_name, $connect ) ) {
- mysql_select_db( $dbname );
- $result = mysql_query( "SHOW TABLE STATUS" );
- while( $row = mysql_fetch_array( $result ) ) {
- $dbsize += $row[ "Data_length" ] + $row[ "Index_length" ];
- }
- return $dbsize;
- } else { die("База данных недоступна."); }
- } else { die("Немогу подключиться."); }
- }
- function formatfilesize($data) {
- if($data) {
- if( $data < 1024 ) {
- return $data . " байт";
- } else if( $data < 1048576 ) {
- return round( ( $data / 1024 ), 2 ) . " килобайт";
- } else if( $data < 1073741824 ) {
- return round( ( $data / 1048576 ), 2 ) . " мегабайт";
- } else {
- return round( ( $data / 1073741824 ), 2 ) . " гигабайт";
- }
- }
- }
- $files = size_file(".");
- $mysql = size_mysql(DBHOST,DBUSER,DBPASS,DBNAME);
- $all = $files+$mysql;
- echo "<hr/>Файлы весят: " . formatfilesize($files)."";
- echo "<hr/>База данных весит: " . formatfilesize($mysql)."";
- echo "<hr/>Общий вес сайта: " . formatfilesize($all)."<hr/>";
-
-
-
-
-
-
- include_once'../template/foot.php';
-
- ?>