diff --git a/trunk/includes/class.semmelstatzR.php b/trunk/includes/class.semmelstatzR.php new file mode 100644 index 0000000..e25eda0 --- /dev/null +++ b/trunk/includes/class.semmelstatzR.php @@ -0,0 +1,72 @@ +. + * + * $Id$ + * + */ + +/** + * + */ +class semmelstatzR { + + protected $_oDb; + + + /** + * + * @global type $wpdb + */ + public function __construct() { + $this->_initDb(); + } + + /* public */ + + + /* protected */ + + + /* private */ + + /** + * + * @global wpdb $wpdb + * @return boolean + */ + private function _initDb() { + global $wpdb; + + if($this->_oDb instanceof $wpdb) { + return true; + } else if($wpdb instanceof wpdb) { + $this->_oDb = $wpdb; + return true; + } else { + return false; + } + } +} +?> \ No newline at end of file diff --git a/trunk/semmelstatzR-database.php b/trunk/semmelstatzR-database.php index fdb61b3..5606278 100644 --- a/trunk/semmelstatzR-database.php +++ b/trunk/semmelstatzR-database.php @@ -8,83 +8,88 @@ * @author Andreas 'Redunzl' Mueller * @copyright (c)2011 PHP-Backoffice * @copyright (c)2005-2009 kopfhoch-studio - * @link http://www.php-backoffice.de/projects/semmelstatzR * @link http://sourceforge.net/projects/semmelstatz/ * @license http://www.gnu.org/licenses/gpl-2.0.html * * $Id$ */ + +define('SEMMELSTATZR_VERSION', '1.0.0 Beta'); +define('SEMMELSTATZR_SRVPATH', dirname(__FILE__)); +define('SEMMELSTATZR_HTML_RELPATH', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__))); -if(!current_user_can('manage_statz')) { - die('Zugriff verweigert'); +if(current_user_can('manage_statz')) { + + global $wpdb; + $pre = $wpdb->prefix; $lenpre = strlen($pre); + $tablesstatus = $wpdb->get_results("SHOW TABLE STATUS"); + + print "
Nr. | "; + print "Tabellen | "; + print "Datensätze | "; + print "Daten | "; + print "Index | "; + print "Daten & Index | "; + print "Überhang | "; + + foreach($tablesstatus as $key=>$tablestatus) { + + if(substr($tablestatus->Name,0,$lenpre) != $pre) continue; + + print "|
---|---|---|---|---|---|---|---|
".($key+1)." | "; + print "".$tablestatus->Name." | "; + print "".number_format($tablestatus->Rows,0,',','.')." | "; + print "".number_format($tablestatus->Data_length/1024,0,',','.')." kb | "; + print "".number_format($tablestatus->Index_length/1024,0,',','.')." kb | "; + print "".number_format(($tablestatus->Data_length + $tablestatus->Index_length)/1024,0,',','.')." kb | "; + + if($tablestatus->Data_free > 0) { + print ""; + print " ".number_format($tablestatus->Data_free/1024,2,',','.')." kb"; + print " | "; + } + else { + print "-- | "; + } + + $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 '
Gesamt | "; + print ""; + print " | ".number_format($row_usage,0,',','.')." | "; + print "".number_format($data_usage/1024,0,',','.')." kb | "; + print "".number_format($index_usage/1024,0,',','.')." kb | "; + print "".number_format($total_usage/1024,0,',','.')." kb | "; + print "".number_format($overhead_usage/1024,2,',','.')." kb | "; + print "|
Es werden ausschließlich die WORDPRESS-Tabellen angezeigt, die zum Blog '".get_option('blogname')."' gehören. |
No permission to access this area
'; } - global $wpdb; - $pre = $wpdb->prefix; $lenpre = strlen($pre); - $tablesstatus = $wpdb->get_results("SHOW TABLE STATUS"); - - print "Nr. | "; - print "Tabellen | "; - print "Datensätze | "; - print "Daten | "; - print "Index | "; - print "Daten & Index | "; - print "Überhang | "; - - foreach($tablesstatus as $key=>$tablestatus) { - - if(substr($tablestatus->Name,0,$lenpre) != $pre) continue; - - print "|
---|---|---|---|---|---|---|---|
".($key+1)." | "; - print "".$tablestatus->Name." | "; - print "".number_format($tablestatus->Rows,0,',','.')." | "; - print "".number_format($tablestatus->Data_length/1024,0,',','.')." kb | "; - print "".number_format($tablestatus->Index_length/1024,0,',','.')." kb | "; - print "".number_format(($tablestatus->Data_length + $tablestatus->Index_length)/1024,0,',','.')." kb | "; - - if($tablestatus->Data_free > 0) { - print ""; - print " ".number_format($tablestatus->Data_free/1024,2,',','.')." kb"; - print " | "; - } - else { - print "-- | "; - } - - $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 '
Gesamt | "; - print ""; - print " | ".number_format($row_usage,0,',','.')." | "; - print "".number_format($data_usage/1024,0,',','.')." kb | "; - print "".number_format($index_usage/1024,0,',','.')." kb | "; - print "".number_format($total_usage/1024,0,',','.')." kb | "; - print "".number_format($overhead_usage/1024,2,',','.')." kb | "; - print "|
Es werden ausschließlich die WORDPRESS-Tabellen angezeigt, die zum Blog '".get_option('blogname')."' gehören. |