2011-05-02 09:17:45 +00:00
< ? php
2011-05-02 10:30:11 +00:00
/**
* file semmelstatzR_database . php
*
2011-11-14 14:21:22 +00:00
* @ package SemmelstatzR
* @ version $Rev $
* @ since 1.0 . 0 Beta
* @ author SEM - Team
* @ copyright ( c ) 2011 SEM - Team
* @ link http :// sourceforge . net / projects / semmelstatz /
* @ license http :// www . gnu . org / licenses / gpl - 3.0 . html
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2011-05-02 10:30:11 +00:00
*
* $Id $
2011-11-14 14:21:22 +00:00
*
2011-05-02 10:30:11 +00:00
*/
2011-11-14 14:21:22 +00:00
/**
* based upon semmelstatz
* Copyright ( c ) 2005 - 2009 Andreas 'Redunzl' Mueller ( redunzl @ gmx . de )
*
* @ license http :// www . gnu . org / licenses / gpl - 2.0 . html
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License ( version 2 ) as
* published by the Free Software Foundation .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License along
* with this program ; if not , write to the Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA
*/
2011-11-14 08:13:34 +00:00
if ( current_user_can ( 'manage_statz' )) {
global $wpdb ;
$pre = $wpdb -> prefix ; $lenpre = strlen ( $pre );
$tablesstatus = $wpdb -> get_results ( " SHOW TABLE STATUS " );
print " <div class='wrap'> " ;
print " <div><a name='top'></a></div> " ;
print " <div id='icon-semmelstatzR' class='icon32'><br /></div> " ;
print " <h2>SemmelstatzR › Datenbank</h2> " ;
print " <div class='statz'>Datenbank</div> " ;
2011-05-02 09:17:45 +00:00
print " <table class='statzelement'> " ;
2011-11-14 08:13:34 +00:00
print " <tr> " ;
print " <th style='text-align:center;width:6%'>Nr.</th> " ;
print " <th style='text-align:left;width:20%'>Tabellen</th> " ;
print " <th style='text-align:right;width:10%'>Datensätze</th> " ;
print " <th style='text-align:right;width:10%'>Daten</th> " ;
print " <th style='text-align:right;width:10%'>Index</th> " ;
print " <th style='text-align:right;width:10%'>Daten & Index</th> " ;
print " <th style='text-align:right;width:7%'>Überhang</th> " ;
2011-11-14 14:21:22 +00:00
$row_usage = 0 ;
$data_usage = 0 ;
$index_usage = 0 ;
$total_usage = 0 ;
$overhead_usage = 0 ;
2011-11-14 08:13:34 +00:00
foreach ( $tablesstatus as $key => $tablestatus ) {
2011-11-14 14:21:22 +00:00
if ( substr ( $tablestatus -> Name , 0 , $lenpre ) != $pre ) continue ;
2011-11-14 08:13:34 +00:00
2011-11-14 14:21:22 +00:00
print " <tr " ; if ( 1 & $key ) print " class='alternate' " ; print " > " ;
print " <td style='text-align:center;'> " . ( $key + 1 ) . " </td> " ;
print " <td style='text-align:left;'> " . $tablestatus -> Name . " </td> " ;
print " <td style='text-align:right;'> " . number_format ( $tablestatus -> Rows , 0 , ',' , '.' ) . " </td> " ;
print " <td style='text-align:right;'> " . number_format ( $tablestatus -> Data_length / 1024 , 0 , ',' , '.' ) . " kb</td> " ;
print " <td style='text-align:right;'> " . number_format ( $tablestatus -> Index_length / 1024 , 0 , ',' , '.' ) . " kb</td> " ;
print " <td style='text-align:right;'> " . number_format (( $tablestatus -> Data_length + $tablestatus -> Index_length ) / 1024 , 0 , ',' , '.' ) . " kb</td> " ;
2011-11-14 08:13:34 +00:00
2011-11-14 14:21:22 +00:00
if ( $tablestatus -> Data_free > 0 ) {
print " <td style='color:#ff0000;text-align:right;'> " ;
print " " . number_format ( $tablestatus -> Data_free / 1024 , 2 , ',' , '.' ) . " kb " ;
print " </td> " ;
}
else {
print " <td style='text-align:right;'>--</td> " ;
}
2011-11-14 08:13:34 +00:00
2011-11-14 14:21:22 +00:00
$row_usage += $tablestatus -> Rows ;
$data_usage += $tablestatus -> Data_length ;
$index_usage += $tablestatus -> Index_length ;
$total_usage += $tablestatus -> Data_length + $tablestatus -> Index_length ;
$overhead_usage += $tablestatus -> Data_free ;
echo '</tr>' ;
2011-11-14 08:13:34 +00:00
}
print " <tr> " ;
print " <th style='text-align:center;'>Gesamt</th> " ;
print " <th style='text-align:left;'> </th> " ;
print " <th style='text-align:right;'> " . number_format ( $row_usage , 0 , ',' , '.' ) . " </th> " ;
print " <th style='text-align:right;'> " . number_format ( $data_usage / 1024 , 0 , ',' , '.' ) . " kb</th> " ;
print " <th style='text-align:right;'> " . number_format ( $index_usage / 1024 , 0 , ',' , '.' ) . " kb</th> " ;
print " <th style='text-align:right;'> " . number_format ( $total_usage / 1024 , 0 , ',' , '.' ) . " kb</th> " ;
print " <th style='color:#ff0000;text-align:right;'> " . number_format ( $overhead_usage / 1024 , 2 , ',' , '.' ) . " kb</th> " ;
print " </tr> " ;
print " <tr><td colspan='7'><p align='right'>Es werden ausschließlich die WORDPRESS-Tabellen angezeigt, die zum Blog <b>' " . get_option ( 'blogname' ) . " '</b> gehören.</p></td></tr> " ;
print " </table> " ;
print " <hr /> " ;
sem_showCopyright ();
print " </div> " ;
} else {
echo '<p>No permission to access this area</p>' ;
}
2011-05-02 09:17:45 +00:00
?>