diff --git a/settings_debug.php b/settings_debug.php index 65f2495c..07dbf687 100644 --- a/settings_debug.php +++ b/settings_debug.php @@ -3,6 +3,36 @@ require_once("inc_all_settings.php"); require_once("database_version.php"); require_once("config.php"); +$folderPath = 'uploads'; + +function countFilesInDirectory($dir) { + $count = 0; + $size = 0; + $files = scandir($dir); + + foreach ($files as $file) { + if ($file === '.' || $file === '..') { + continue; + } + + $filePath = $dir . '/' . $file; + + if (is_file($filePath)) { + $count++; + $size += filesize($filePath); + } elseif (is_dir($filePath)) { + $result = countFilesInDirectory($filePath); + $count += $result['count']; + $size += $result['size']; + } + } + + return [ + 'count' => $count, + 'size' => $size + ]; +} + // Function to compare two arrays recursively and return the differences function arrayDiffRecursive($array1, $array2) { $diff = array(); @@ -81,7 +111,7 @@ function fetchDatabaseStructureFromServer() { } } - $mysqli->close(); + //$mysqli->close(); return $tables; } @@ -115,6 +145,7 @@ $differences = arrayDiffRecursive($desiredStructure, $currentStructure);

Database Structure Check

+ +
+ +

Database stats

+ query($tablesQuery); + + // Check if the query was successful + if ($tablesResult) { + $numTables = $tablesResult->num_rows; + $numFields = 0; + $numRows = 0; + + // Loop through each table + while ($row = $tablesResult->fetch_row()) { + $tableName = $row[0]; + + // Query to fetch the number of fields + $fieldsQuery = "DESCRIBE `$tableName`"; + $fieldsResult = $mysqli->query($fieldsQuery); + + // Check if the query was successful + if ($fieldsResult) { + $numFields += $fieldsResult->num_rows; + + // Query to fetch the number of rows + $rowsQuery = "SELECT COUNT(*) FROM `$tableName`"; + $rowsResult = $mysqli->query($rowsQuery); + + // Check if the query was successful + if ($rowsResult) { + $numRows += $rowsResult->fetch_row()[0]; + } else { + echo "Error executing query: " . $mysqli->error; + } + } else { + echo "Error executing query: " . $mysqli->error; + } + } + + echo "Number of tables: " . $numTables . "
"; + echo "Total number of fields: " . $numFields . "
"; + echo "Total number of rows: " . $numRows . "
"; + } else { + echo "Error executing query: " . $mysqli->error; + } + // Query to fetch the database size + $query = "SELECT table_schema AS 'Database', SUM(data_length + index_length) / (1024 * 1024) AS 'Size (MB)' + FROM information_schema.TABLES WHERE table_schema = '$database' + GROUP BY table_schema"; + $result = $mysqli->query($query); + + // Check if the query was successful + if ($result) { + $row = $result->fetch_assoc(); + $dbSize = $row['Size (MB)']; + echo "Database Size: " . $dbSize . " MB"; + } else { + echo "Error executing query: " . $conn->error; + } + + ?> + +
+ +

Installed PHP Modules

+ + "; + } + ?> + +
+ +

Versions

+ + "; + + $mysqlVersion = $mysqli->server_version; + echo "MySQL Version: " . $mysqlVersion; + echo "
"; + + $operatingSystem = shell_exec('uname -a'); + echo "Operating System: " . $operatingSystem; + + ?> + +
+ +

File System

+ "; + echo "Total size of files in $folderPath and its subdirectories: " . $totalSizeMB . " MB"; + ?> + +
+