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 "
"; + print "
"; + print "

"; + print "

SemmelstatzR › Datenbank

"; + + print "
Datenbank
"; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + + foreach($tablesstatus as $key=>$tablestatus) { + + if(substr($tablestatus->Name,0,$lenpre) != $pre) continue; + + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + + if($tablestatus->Data_free > 0) { + 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 ''; + } + + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + + print ""; + + print "
Nr.TabellenDatensätzeDatenIndexDaten & IndexÜberhang".($key+1)."".$tablestatus->Name."".number_format($tablestatus->Rows,0,',','.')."".number_format($tablestatus->Data_length/1024,0,',','.')." kb".number_format($tablestatus->Index_length/1024,0,',','.')." kb".number_format(($tablestatus->Data_length + $tablestatus->Index_length)/1024,0,',','.')." kb"; + print " ".number_format($tablestatus->Data_free/1024,2,',','.')." kb"; + print "--
Gesamt ".number_format($row_usage,0,',','.')."".number_format($data_usage/1024,0,',','.')." kb".number_format($index_usage/1024,0,',','.')." kb".number_format($total_usage/1024,0,',','.')." kb".number_format($overhead_usage/1024,2,',','.')." kb

Es werden ausschließlich die WORDPRESS-Tabellen angezeigt, die zum Blog '".get_option('blogname')."' gehören.

"; + print "
"; + + sem_showCopyright(); + + print "
"; + +} else { + echo '

No permission to access this area

'; } - global $wpdb; - $pre = $wpdb->prefix; $lenpre = strlen($pre); - $tablesstatus = $wpdb->get_results("SHOW TABLE STATUS"); - - print "
"; - print "
"; - print "

"; - print "

SemmelstatzR › Datenbank

"; - - print "
Datenbank
"; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - - foreach($tablesstatus as $key=>$tablestatus) { - - if(substr($tablestatus->Name,0,$lenpre) != $pre) continue; - - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - - if($tablestatus->Data_free > 0) { - 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 ''; - } - - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - - print ""; - - print "
Nr.TabellenDatensätzeDatenIndexDaten & IndexÜberhang".($key+1)."".$tablestatus->Name."".number_format($tablestatus->Rows,0,',','.')."".number_format($tablestatus->Data_length/1024,0,',','.')." kb".number_format($tablestatus->Index_length/1024,0,',','.')." kb".number_format(($tablestatus->Data_length + $tablestatus->Index_length)/1024,0,',','.')." kb"; - print " ".number_format($tablestatus->Data_free/1024,2,',','.')." kb"; - print "--
Gesamt ".number_format($row_usage,0,',','.')."".number_format($data_usage/1024,0,',','.')." kb".number_format($index_usage/1024,0,',','.')." kb".number_format($total_usage/1024,0,',','.')." kb".number_format($overhead_usage/1024,2,',','.')." kb

Es werden ausschließlich die WORDPRESS-Tabellen angezeigt, die zum Blog '".get_option('blogname')."' gehören.

"; - print "
"; - - sem_showCopyright(); - - print "
"; - ?> \ No newline at end of file diff --git a/trunk/semmelstatzR.php b/trunk/semmelstatzR.php index 67c0fd0..875f6ef 100644 --- a/trunk/semmelstatzR.php +++ b/trunk/semmelstatzR.php @@ -1,31 +1,47 @@ + * @author Ortwin Pinke * @author Andreas 'Redunzl' Mueller - * @copyright (c)2011 PHP-Backoffice + * @copyright (c)2011 SEM-Team * @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 + * @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 . * * $Id$ - * + * + */ +/** + * based upon semmelstatz * Copyright (c) 2005-2009 Andreas 'Redunzl' Mueller (redunzl@gmx.de) - * Copyright (c) 2011- Ortwin Pinke (info@php-backoffice.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. @@ -40,32 +56,7 @@ Author URI: http://www.ortwinpinke.de * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -### constants -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__))); - -### Deklaration der Tabellennamen -global $wpdb; -$wpdb->statz = $wpdb->prefix . 'statz'; -$wpdb->statzhist = $wpdb->prefix . 'statzhist'; - -### Auslesen des Domainnamens -global $homehost; -if(substr($_SERVER['SERVER_NAME'],0,4) == 'www.') { - $homehost = '%' . substr($_SERVER['SERVER_NAME'],4) . '%'; -} else { - $homehost = '%' . $_SERVER['SERVER_NAME'] . '%'; -} - -### localization -//if(!load_plugin_textdomain('semmelstatzR','/wp-content/languages/')) { - $plugin_dir = basename(dirname(__FILE__)); - load_plugin_textdomain('semmelstatzR',null,$plugin_dir.'/locale/'); -//} - -include_once SEMMELSTATZR_SRVPATH.'/includes/functions.semr.php'; -include_once SEMMELSTATZR_SRVPATH.'/includes/functions.semr_template.php'; +require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'semmelstatzR_startup.php'; if(is_admin() == true) { @@ -340,4 +331,4 @@ add_action('wp_dashboard_setup', 'sem_dashboardStatz_setup'); .sprintf(semr_i18np("%d Hit","%d Hits",$hits),$hits)." - " .sprintf(semr_i18np("%d Referer","%d Referers",$referers),$referers); } -?> \ No newline at end of file +?> diff --git a/trunk/semmelstatzR_startup.php b/trunk/semmelstatzR_startup.php new file mode 100644 index 0000000..734e67b --- /dev/null +++ b/trunk/semmelstatzR_startup.php @@ -0,0 +1,42 @@ + + * @author Andreas 'Redunzl' Mueller + * @copyright (c)2011 PHP-Backoffice + * @copyright (c)2005-2009 kopfhoch-studio + * @link http://sourceforge.net/projects/semmelstatz/ + * @license http://www.gnu.org/licenses/gpl-2.0.html + * + * $Id$ + */ +### constants +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__))); + +### Deklaration der Tabellennamen +global $wpdb; +$wpdb->statz = $wpdb->prefix . 'statz'; +$wpdb->statzhist = $wpdb->prefix . 'statzhist'; + +### Auslesen des Domainnamens +global $homehost; +if(substr($_SERVER['SERVER_NAME'],0,4) == 'www.') { + $homehost = '%' . substr($_SERVER['SERVER_NAME'],4) . '%'; +} else { + $homehost = '%' . $_SERVER['SERVER_NAME'] . '%'; +} + +### localization +if(!load_plugin_textdomain('semmelstatzR')) { + $plugin_dir = basename(dirname(__FILE__)); + load_plugin_textdomain('semmelstatzR',null,$plugin_dir.'/locale/'); +} + +include_once SEMMELSTATZR_SRVPATH.'/includes/functions.semr.php'; +include_once SEMMELSTATZR_SRVPATH.'/includes/functions.semr_template.php'; +?> \ No newline at end of file