Fixed problems with not using the correct value for target in some places.
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 2 Nov 2018 19:37:24 +0000 (15:37 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 2 Nov 2018 19:37:24 +0000 (15:37 -0400)
classes/serverBandwidthSupport.php
models/adminServerStats.php
models/ajaxServerBandwidthGraphs.php
views/adminServerStats.html

index 53012f7..2b84049 100755 (executable)
@@ -104,9 +104,11 @@ class glmServerStatsBandwidthSupport
      * Gets host, user, password, and database name from a WP option
      * that was saved by the configure page.
      *
+     * @param string website Specified Website name - Optional
+     *
      * @return string Error message. If blank, then no error.
      */
-    public function bandwidthDataConnect()
+    public function bandwidthDataConnect($website = false)
     {
 
         $this->connected = false;
@@ -133,6 +135,9 @@ class glmServerStatsBandwidthSupport
             $config['db_name']
         );
 
+        if (!$website) {
+            $website = $config['website'];
+        }
         // If there was an error connecting
         if (!$res) {
             $this->connectError = mysqli_connect_error();
@@ -140,7 +145,7 @@ class glmServerStatsBandwidthSupport
             $this->connected = true;
 
             // Get Website Settings
-            $settings = $this->bandwidthGetWebsiteSettingsFromName($config['website']);
+            $settings = $this->bandwidthGetWebsiteSettingsFromName($website);
 
             // Save them in class parameters
             $this->website      = $config['website'];
index e3855c9..3aa2b6f 100755 (executable)
@@ -37,17 +37,14 @@ class adminServerStats extends glmServerStatsBandwidthSupport
     */
     public function __construct()
     {
+        $websiteSelected = false;
 
-        // Connect to Bandwidth Database selected in the Configure page
-        $this->bandwidthDataConnect();
-
-        // Use default website unless another is specified by an admin user.
-        $websiteIn = filter_input( INPUT_GET, 'website', FILTER_SANITIZE_STRING);
-        if (current_user_can('administrator') && $websiteIn) {
-            $this->website = trim($websiteIn);
-            $this->siteId = $this->bandwidthGetWebsiteID($this->website);
+        if (current_user_can('administrator')) {
+            $websiteSelected = filter_input( INPUT_GET, 'selected_site', FILTER_SANITIZE_STRING);
         }
 
+        // Connect to Bandwidth Database selected in the Configure page
+        $this->bandwidthDataConnect($websiteSelected);
 
     }
 
index 43f1caa..7b90c79 100755 (executable)
@@ -48,16 +48,6 @@ class ajaxServerBandwidthGraphs  extends glmServerStatsBandwidthSupport
     public function __construct()
     {
 
-        // Connect to Bandwidth Database selected in the Configure page
-        $this->bandwidthDataConnect();
-
-        // Use default website unless another is specified by an admin user.
-        $websiteIn = filter_input( INPUT_GET, 'website', FILTER_SANITIZE_STRING);
-        if (current_user_can('administrator') && $websiteIn) {
-            $this->website = trim($websiteIn);
-            $this->siteId = $this->bandwidthGetWebsiteID($this->website);
-        }
-
     }
 
     /*
@@ -75,6 +65,11 @@ class ajaxServerBandwidthGraphs  extends glmServerStatsBandwidthSupport
     public function model()
     {
 
+            $websiteSelected = filter_input( INPUT_GET, 'selected_site', FILTER_SANITIZE_STRING);
+
+        // Connect to Bandwidth Database selected in the Configure page
+        $this->bandwidthDataConnect($websiteSelected);
+
         $graphType = $_REQUEST['graphType'];
 
         // Set reference Date
index dabe3c3..7c917a6 100755 (executable)
@@ -59,9 +59,9 @@
         <h3>Select a site to display</h3>    
         <p>
         Sort by:&nbsp;&nbsp;
-        <input type="radio" name="site_sort" {if $site_sort == 'target_percent'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=target_percent&selected_site={$selectedSite}';">Percent of Target&nbsp;&nbsp;
-        <input type="radio" name="site_sort" {if $site_sort == 'data_total'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=data_total&selected_site={$selectedSite}';">Total Traffic&nbsp;&nbsp;
-        <input type="radio" name="site_sort" {if $site_sort == 'site_name'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=site_name&selected_site={$selectedSite}';">Site Name
+        <input type="radio" name="site_sort" value="target_percent" {if $site_sort == 'target_percent'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=target_percent&selected_site={$selectedSite}';">Percent of Target&nbsp;&nbsp;
+        <input type="radio" name="site_sort" value="data_total" {if $site_sort == 'data_total'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=data_total&selected_site={$selectedSite}';">Total Traffic&nbsp;&nbsp;
+        <input type="radio" name="site_sort" value="site_name" {if $site_sort == 'site_name'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=site_name&selected_site={$selectedSite}';">Site Name
         </p>
         <div class="pickContainer">
             <pre class="pseudoPickTitles">Website                                                Last Month             Target       % of Target   </pre>
                 $('#twoDayImg').attr('src', '{$assetsUrl}/graph.png');
                 $('#twoMonthImg').attr('src', '{$assetsUrl}/graph.png');
                 $('#twoYearImg').attr('src', '{$assetsUrl}/graph.png');
-                $('#twoDayImg').attr('src', '{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxServerBandwidthGraphs&website={$selectedSite}&graphType=oneDay&refDate=' + d);
-                $('#twoMonthImg').attr('src', '{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxServerBandwidthGraphs&website={$selectedSite}&graphType=twoMonth&refDate=' + d);
-                $('#twoYearImg').attr('src', '{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxServerBandwidthGraphs&website={$selectedSite}&graphType=twoYear&refDate=' + d);
-                $('#twoYearStorageImg').attr('src', '{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxServerBandwidthGraphs&website={$selectedSite}&graphType=twoYearStorage&refDate=' + d);
+                $('#twoDayImg').attr('src', '{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxServerBandwidthGraphs&selected_site={$selectedSite}&graphType=oneDay&refDate=' + d);
+                $('#twoMonthImg').attr('src', '{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxServerBandwidthGraphs&selected_site={$selectedSite}&graphType=twoMonth&refDate=' + d);
+                $('#twoYearImg').attr('src', '{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxServerBandwidthGraphs&selected_site={$selectedSite}&graphType=twoYear&refDate=' + d);
+                $('#twoYearStorageImg').attr('src', '{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxServerBandwidthGraphs&selected_site={$selectedSite}&graphType=twoYearStorage&refDate=' + d);
             }
             
             $(".graph-print").click(function(){
                     popX:       200,            // popup window screen X position
                     popY:       200,            //popup window screen Y position
                     popTitle:   'Server Usage',   // popup window title element
-                    popClose:   false,           // popup window close after printing
+                    popClose:   true,           // popup window close after printing
                     extraCss:   '',             // Comma separated list of extra css to include
                     extraHead:  '',             // Comma separated list of extra elements to be appended to head tag
                     strict:     false           // strict or loose Transitional html 4.01 document standard or undefined to not include at all only for popup option