| 1 |
<?php |
| 2 |
/* |
| 3 |
+----------------------------------------------------------------+ |
| 4 |
| | |
| 5 |
| WordPress 2.0 Plugin: WP-DBManager 2.04 | |
| 6 |
| Copyright (c) 2005 Lester "GaMerZ" Chan | |
| 7 |
| | |
| 8 |
| File Written By: | |
| 9 |
| - Lester "GaMerZ" Chan | |
| 10 |
| - http://www.lesterchan.net | |
| 11 |
| | |
| 12 |
| File Information: | |
| 13 |
| - Database Manager | |
| 14 |
| - wp-content/plugins/dbmanager/database-manager.php | |
| 15 |
| | |
| 16 |
+----------------------------------------------------------------+ |
| 17 |
*/ |
| 18 |
|
| 19 |
|
| 20 |
### Require Database Config |
| 21 |
require('database-config.php'); |
| 22 |
|
| 23 |
|
| 24 |
### Get MYSQL Version |
| 25 |
$sqlversion = $wpdb->get_var("SELECT VERSION() AS version"); |
| 26 |
?> |
| 27 |
<?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?> |
| 28 |
<!-- Database Information --> |
| 29 |
<div class="wrap"> |
| 30 |
<h2>Database Information</h2> |
| 31 |
<table width="100%" cellspacing="3" cellpadding="3" border="0"> |
| 32 |
<tr> |
| 33 |
<th align="left" scope="col">Setting</th> |
| 34 |
<th align="left" scope="col">Value</th> |
| 35 |
</tr> |
| 36 |
<tr> |
| 37 |
<td>Database Host</td> |
| 38 |
<td><?php echo DB_HOST; ?></td> |
| 39 |
</tr> |
| 40 |
<tr> |
| 41 |
<td>Database Name</td> |
| 42 |
<td><?php echo DB_NAME; ?></td> |
| 43 |
</tr> |
| 44 |
<tr> |
| 45 |
<td>Database User</td> |
| 46 |
<td><?php echo DB_USER; ?></td> |
| 47 |
</tr> |
| 48 |
<tr> |
| 49 |
<td>Database Type</td> |
| 50 |
<td>MYSQL</td> |
| 51 |
</tr> |
| 52 |
<tr> |
| 53 |
<td>Database Version</td> |
| 54 |
<td>v<?php echo $sqlversion; ?></td> |
| 55 |
</tr> |
| 56 |
</table> |
| 57 |
</div> |
| 58 |
<div class="wrap"> |
| 59 |
<h2>Tables Information</h2> |
| 60 |
<table width="100%" cellspacing="3" cellpadding="3" border="0"> |
| 61 |
<tr> |
| 62 |
<th align="left" scope="col">No.</th> |
| 63 |
<th align="left" scope="col">Tables</th> |
| 64 |
<th align="left" scope="col">Records</th> |
| 65 |
<th align="left" scope="col">Data Usage</th> |
| 66 |
<th align="left" scope="col">Index Usage</th> |
| 67 |
<th align="left" scope="col">Overhead</th> |
| 68 |
</tr> |
| 69 |
<?php |
| 70 |
// If MYSQL Version More Than 3.23, Get More Info |
| 71 |
if($sqlversion >= '3.23') { |
| 72 |
$tablesstatus = $wpdb->get_results("SHOW TABLE STATUS"); |
| 73 |
foreach($tablesstatus as $tablestatus) { |
| 74 |
if($no%2 == 0) { |
| 75 |
$style = 'style=\'background-color: #eee\''; |
| 76 |
} else { |
| 77 |
$style = 'style=\'background-color: none\''; |
| 78 |
} |
| 79 |
$no++; |
| 80 |
echo "<tr $style>\n<td>$no</td>\n"; |
| 81 |
echo "<td>$tablestatus->Name</td>\n"; |
| 82 |
echo "<td>".number_format($tablestatus->Rows)."</td>\n"; |
| 83 |
echo "<td>".format_size($tablestatus->Data_length)."</td>\n"; |
| 84 |
echo "<td>".format_size($tablestatus->Index_length)."</td>\n"; |
| 85 |
echo "<td>".format_size($tablestatus->Data_free)."</td>\n"; |
| 86 |
$row_usage += $tablestatus->Rows; |
| 87 |
$data_usage += $tablestatus->Data_length; |
| 88 |
$index_usage += $tablestatus->Index_length; |
| 89 |
$overhead_usage += $tablestatus->Data_free; |
| 90 |
} |
| 91 |
echo "<tr><th align=\"left\" scope=\"row\">Total:</th>\n"; |
| 92 |
echo "<th align=\"left\" scope=\"row\">$no Tables</th>\n"; |
| 93 |
echo "<th align=\"left\" scope=\"row\">".number_format($row_usage)."</th>\n"; |
| 94 |
echo "<th align=\"left\" scope=\"row\">".format_size($data_usage)."</th>\n"; |
| 95 |
echo "<th align=\"left\" scope=\"row\">".format_size($index_usage)."</th>"; |
| 96 |
echo "<th align=\"left\" scope=\"row\">".format_size($overhead_usage)."</th></tr>"; |
| 97 |
} else { |
| 98 |
echo '<tr><td colspan="6" align="center"><b>Could Not Show Table Status Due To Your MYSQL Version Is Lower Than 3.23.</b></td></tr>'; |
| 99 |
} |
| 100 |
?> |
| 101 |
</table> |
| 102 |
</div> |