Your settings have been saved.

', 'hostm_plugin' ); // Success } // Display the settings edit screen echo '
'; // Settings screen title echo "

" . __( 'Hosting Monitor', 'hostm_plugin' ) . "

"; // Render Settings form, START ?>

     Leave at “0” if you have unlimited space.

 




1024; $i++ ) $filesize /= 1024; $file_size_info['size'] = round( $filesize, 3 ); $file_size_info['type'] = $bytes[$i]; return $file_size_info; } /* * Calculate actual DB size * Echoes DB size to screen, positioned using CSS * * Default values translate to: 10 MB * */ function db_size( $opt_val_db = 10, $spacecalc_db = 1024 ) { $rows = mysql_query( "SHOW table STATUS" ); $dbsize = 0; while ( $row = mysql_fetch_array( $rows ) ) { $dbsize += $row['Data_length'] + $row['Index_length']; } if ( $opt_val_db ) if ( $dbsize > $opt_val_db * $spacecalc_db ) { $color = "red"; } else { $color = "green"; } $dbsize = file_size_info( $dbsize ); return "{$dbsize ['size']} {$dbsize['type']}"; } // Get local working directory (PWD) // ### TODO msb 10-22-2011: Bad for Windows (use WP built-in folder vars) $output = substr( shell_exec( 'pwd' ), 0, -9 ); // Calculate actual disk space usage $usedspace = substr( shell_exec( 'du -s ' . $output ), 0, -( strlen( $output ) + 1 ) ); // Get storage space set by user $totalspace = ( $opt_val * $spacecalc ); $freespace = ( $totalspace ) - $usedspace; $usedspace_percent = ( $totalspace != 0 ? round( ($usedspace / ( $totalspace / 100 ) ), 1 ) : 0 ); // Calculate used space in chosen units $usedspace_units = ( $usedspace / $spacecalc ); if ( $usedspace_units < 1 ) $usedspace_units = round( $usedspace_units, 3 ); else $usedspace_units = round( $usedspace_units, 2 ); ?>
Disk Space Used
Disk Space Free

Database Size




 

 

memory = array(); } function wp_memory_usage() { return $this->__construct(); } function check_limit() { $this->memory['limit'] = (int) ini_get( 'memory_limit' ) ; } /* * * %%Entire method from Disk Space Pie Chart (DSPC) * */ function check_memory_usage() { $this->memory['usage'] = function_exists( 'memory_get_usage' ) ? round( ( memory_get_usage() / pow( 1024, 2 ) ), 2 ) : 0; if ( ! empty( $this->memory['usage'] ) && ! empty( $this->memory['limit'] ) ) { $this->memory['percent'] = round ( $this->memory['usage'] / $this->memory['limit'] * 100, 0 ); $this->memory['color'] = '#21759B'; if ( $this->memory['percent'] > 80 ) $this->memory['color'] = '#E66F00'; if ( $this->memory['percent'] > 95 ) $this->memory['color'] = 'red'; } } /* * Calculate DB size units * * ###TODO msb 10-24-2011 - De-duplicate!!! Copied from main plugin method hosting_monitor() * */ function get_file_size_info( $filesize ) { $bytes = array( 'KB', 'KB', 'MB', 'GB', 'TB' ); # values are always displayed if ( $filesize < 1024 ) $filesize = 1; # in at least kilobytes for ( $i = 0; $filesize > 1024; $i++ ) $filesize /= 1024; $file_size_info['size'] = round( $filesize, 3 ); $file_size_info['type'] = $bytes[$i]; return $file_size_info; } /* * Calculate actual DB size * Echoes DB size to screen, positioned using CSS * * Default values translate to: 10 MB * * * ###TODO msb 10-24-2011 - De-duplicate!!! Copied from main plugin method hosting_monitor() * */ function check_db_size( $opt_val_db = 10, $spacecalc_db = 1024 ) { $rows = mysql_query( "SHOW table STATUS" ); $dbsize = 0; while ( $row = mysql_fetch_array( $rows ) ) { $dbsize += $row['Data_length'] + $row['Index_length']; } if ( $dbsize > $opt_val_db * $spacecalc_db ) { $color = "red"; } else { $color = "green"; } $dbsize = $this->get_file_size_info( $dbsize ); return "{$dbsize ['size']} {$dbsize['type']}"; } /* * Build & output the Dashboard metabox * */ function dashboard_output() { $this->check_memory_usage(); $this->memory['limit'] = empty( $this->memory['limit'] ) ? __('N/A') : $this->memory['limit'] . __(' MByte'); $this->memory['usage'] = empty( $this->memory['usage'] ) ? __('N/A') : $this->memory['usage'] . __(' MByte'); // check disk usage and pop into a variable $output = substr( shell_exec( 'pwd' ), 0, -9 ); $usedspace = substr( shell_exec( 'du -s ' . $output ), 0, -( strlen( $output ) + 1 ) ); // Get user settings $opt_val = get_option( 'guru_space', false ); // Explicitly set false $opt_val_db = get_option( 'hm_db_space', false ); // Explicitly set false $opt_val2 = get_option( 'guru_unit' ); $opt_val_db2 = get_option( 'hm_db_unit' ); // Decide which units to use for graph switch ( $opt_val2 ) { // DISK case 'TB': $spacecalc = pow( 1024, 3 ); break; case 'GB': $spacecalc = pow( 1024, 2 ); break; default: $spacecalc = 1024; } switch ( $opt_val_db2 ) { // DB case 'TB': $spacecalc_db = pow( 1024, 3 ); break; case 'GB': $spacecalc_db = pow( 1024, 2 ); break; default: $spacecalc_db = 1024; } // Calculate used space in chosen units $usedspace_units = ( $usedspace / $spacecalc ); if ( $usedspace_units < 1 ) $usedspace_units = round( $usedspace_units, 3 ); else $usedspace_units = round( $usedspace_units, 2 ); // Get storage space set by user $totalspace = ( $opt_val * $spacecalc ); $freespace = ( $opt_val * $spacecalc ) - $usedspace; if ( current_user_can( 'manage_options' ) ) { $hm_user_admin = true; $config_link = '   (Hosting Monitor config)'; } if ( $opt_val === false ) { // Means user has not saved a config, prompt them if admin if ( $hm_user_admin === true ) { $free_space_message = 'Setup not completed. Please Configure Hosting Monitor now'; } } elseif ( $opt_val == 0 ) { // Zero is our save-default, assume unlimited space $free_space_message = "UNLIMITED"; if ( $hm_user_admin === true ) $free_space_message .= $config_link; } else { $free_space_message = round( ( $freespace / $spacecalc ), 2 ) . " " . $opt_val2; if ( $hm_user_admin === true ) $free_space_message .= $config_link; } // Display storage-use text ?> memory['percent'] ) ) : ?>
%
check_memory_usage(); // hook for Footer Display // ###TODO // let's do this another time,... // return $content; } } /* * Add contextual help menu * * Using WP v3.3 menus * */ function hostm_add_help_menu() { global $hostm_admin_page; $screen = get_current_screen(); // Do not add help menu if not on our own admin page if ( $screen -> id != $hostm_admin_page ) return; $help_content_faq = __("

Frequently Asked Questions

Does this Plugin run on Windows web servers?

Not entirely. It works on Windows Apache, but has errors on Windows IIS.

I've noticed my Dashboard is slow. What gives?

The used disk space is calculated when the Dashboard is loaded. It can be slow because the server counts every file, every time. On slow servers this can take some time. We agree that it's annoying and plan to fix it.

To prevent this, close the dahsboard window using the little arrow in the top-right corner. Alternatively, click on Screen Options and disable the widget.

Are you going to fix {bug X}?

Yes, as quickly as we can. The problems in version 0.5 and some we inherited from a previous plugin should be fixable. We can probably make this work correctly on Windows servers. And, we should be able to cache the disk space stats so the dashboard is not so slow.

= Where did this come from, and will you keep updating it?

Hosting Monitor is produced by: Alive Media Web Development, and developed by: Mike Bijon.

This plugin is installed on many of our customer sites. We plan to keep it updated _and_ to add new features as often as time allows. It is more than just a hobby, since it must be updated for new versions of WordPress.

", 'hostm_plugin'); $help_content_setup = __("

Setup Instructions

  1. Go to Tools > Hosting Monitor in WordPress Admin
  2. Set the maximum disk space allowed by your hosting company & press “Save Changes”

Why? Every host is different, so Hosting Monitor can't automatically tell how much space you're *allowed* to use by your host.

", 'hostm_plugin'); if ( method_exists( $screen, 'add_help_tab' ) ) { // Check if this is WP 3.3 // Do this if we are on own admin page $screen->add_help_tab( array( 'id' => 'hostm_help_faq', 'title' => __( 'Help & FAQ', 'hostm_plugin' ), 'content' => $help_content_faq, )); $screen->add_help_tab( array( 'id' => 'hostm_help_setup', 'title' => __( 'Setup Help', 'hostm_plugin' ), 'content' => $help_content_setup, )); } else { // Earlier than 3.3, use old add_contextual_help add_contextual_help( $hostm_admin_page, $help_content_faq . $help_content_setup ); } } /* * Start the plugin * * Loaded after all other plugins, so memory-use accurate * */ add_action( 'plugins_loaded', create_function( '', '$memory = new wp_memory_usage();' ) ); }