phpBB

Code Changes

File: includes/functions_admin.php

  Unmodified   Added   Modified   Removed
Line 2832Line 2832

/**
* Get database size


/**
* Get database size

* Currently only mysql and mssql are supported

 
*/
function get_database_size()
{

*/
function get_database_size()
{

	global $db, $user, $table_prefix;

	global $db, $user;


$database_size = false;



$database_size = false;


	// This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0

 
	switch ($db->get_sql_layer())
{
case 'mysqli':

	switch ($db->get_sql_layer())
{
case 'mysqli':

			$sql = 'SELECT VERSION() AS mysql_version';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

if ($row)
{
$version = $row['mysql_version'];

if (preg_match('#(3\.23|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria)#', $version))
{
$db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name();

			$mysql_engine	= ['MyISAM', 'InnoDB', 'Aria'];
$db_name = $db->get_db_name();
$database_size = 0;











$sql = 'SHOW TABLE STATUS
FROM ' . $db_name;
$result = $db->sql_query($sql, 7200);



$sql = 'SHOW TABLE STATUS
FROM ' . $db_name;
$result = $db->sql_query($sql, 7200);


					$database_size = 0;

 
					while ($row = $db->sql_fetchrow($result))
{

					while ($row = $db->sql_fetchrow($result))
{

						if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB' || $row['Engine'] == 'Aria')))
{
if ($table_prefix != '')
{
if (strpos($row['Name'], $table_prefix) !== false)

				if (isset($row['Engine']) && in_array($row['Engine'], $mysql_engine))





								{
$database_size += $row['Data_length'] + $row['Index_length'];
}
}

								{
$database_size += $row['Data_length'] + $row['Index_length'];
}
}

							else
{
$database_size += $row['Data_length'] + $row['Index_length'];
}
}
}








					$db->sql_freeresult($result);

					$db->sql_freeresult($result);

				}
}



$database_size = $database_size ? $database_size : false;


		break;

case 'sqlite3':

		break;

case 'sqlite3':