Now checking for this plugin not being configured. release/1.0.9
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 13 Jan 2017 20:40:58 +0000 (15:40 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 13 Jan 2017 20:40:58 +0000 (15:40 -0500)
index.php
models/adminServerStats.php
views/adminServerStats.html

index 31848fb..3d301db 100644 (file)
--- 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
  * @package glmServerStats
  * @author Chuck Scott <cscott@gaslightmedia.com>
  * @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')) {
index 8824511..4aa71e4 100644 (file)
@@ -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,
index fb91934..5c31a0a 100644 (file)
@@ -3,6 +3,7 @@
 <h2>
     Server Bandwidth
 </h2>   
+{if $haveStats}
 <div style="width: 800px;">
     <p>
         <b>Server Bandwidth</b> is the amount of data sent and received by this Web site.  
 
     });
 </script>
-
+{else}
+    <h3 class="glm-error">Server Bandwidth has not been configured. Please ask system administrator to configure this plugin.</h3>
+{/if}
 
 {include file='footer.html'}