From f2bfda7a6f0594b1b3ece8ae1d043144c7a3674e Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Fri, 13 Jan 2017 15:40:58 -0500 Subject: [PATCH] Now checking for this plugin not being configured. --- index.php | 6 ++--- models/adminServerStats.php | 51 ++++++++++++++++++++++++------------- views/adminServerStats.html | 5 +++- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/index.php b/index.php index 31848fb..3d301db 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM ServerStats - Stand Alone * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Server Stats Display. - * Version: 1.0.8 + * Version: 1.0.9 * Author: Gaslight Media * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -19,10 +19,10 @@ * @package glmServerStats * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.0.8 + * @version 1.0.9 */ -define('GLM_SERVERSTATS_PLUGIN_VERSION', '1.0.8'); +define('GLM_SERVERSTATS_PLUGIN_VERSION', '1.0.9'); // Check that we're being called by WordPress. if (!defined('ABSPATH')) { diff --git a/models/adminServerStats.php b/models/adminServerStats.php index 8824511..4aa71e4 100644 --- a/models/adminServerStats.php +++ b/models/adminServerStats.php @@ -49,31 +49,48 @@ class adminServerStats extends glmServerStatsBandwidthSupport public function model() { + $haveStats = false; + $thisDate = false; + $thisDateTime = false; + $thisMonth = false; + $thisMonthTime = false; + $websiteId = false; + // Get current bandwidth configuration $config = get_option('glmServerStatsConfigData'); - // Connect to the bandwidth database - $this->bandwidthDataConnect( - $config['db_host'], - $config['db_user'], - $config['db_pass'], - $config['db_name'], - $config['website'] - ); + if ($config != false) { + + // Connect to the bandwidth database + $this->bandwidthDataConnect( + $config['db_host'], + $config['db_user'], + $config['db_pass'], + $config['db_name'], + $config['website'] + ); + + // Get the current bandwidth stats + $stats = $this->bandwidthGetStats(); - // Get the current bandwidth stats - $stats = $this->bandwidthGetStats(); + if ($stats != false) { - // Build summary info - $thisDate = date('m/d/Y'); - $thisDateTime = strtotime($thisDate); - $thisMonth = date('m/Y'); - $thisMonthTime = strtotime(date('m/01/Y')); - $websiteId = $this->siteId; + // Build summary info + $thisDate = date('m/d/Y'); + $thisDateTime = strtotime($thisDate); + $thisMonth = date('m/Y'); + $thisMonthTime = strtotime(date('m/01/Y')); + $websiteId = $this->siteId; + + $haveStats = true; + + } + + } // Compile template data $templateData = array( - 'serverStats' => $stats, + 'haveStats' => $haveStats, 'serverStats' => $stats, 'thisDate' => $thisDate, 'thisDateTime' => $thisDateTime, diff --git a/views/adminServerStats.html b/views/adminServerStats.html index fb91934..5c31a0a 100644 --- a/views/adminServerStats.html +++ b/views/adminServerStats.html @@ -3,6 +3,7 @@

Server Bandwidth

+{if $haveStats}

Server Bandwidth is the amount of data sent and received by this Web site. @@ -112,6 +113,8 @@ }); - +{else} +

Server Bandwidth has not been configured. Please ask system administrator to configure this plugin.

+{/if} {include file='footer.html'} -- 2.17.1