From: Chuck Scott Date: Fri, 2 Nov 2018 19:37:24 +0000 (-0400) Subject: Fixed problems with not using the correct value for target in some places. X-Git-Tag: v2.0.0~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=b8e1446e330b5577196f01bc5649b483731f9894;p=WP-Plugins%2Fglm-serverstats.git Fixed problems with not using the correct value for target in some places. --- diff --git a/classes/serverBandwidthSupport.php b/classes/serverBandwidthSupport.php index 53012f7..2b84049 100755 --- a/classes/serverBandwidthSupport.php +++ b/classes/serverBandwidthSupport.php @@ -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']; diff --git a/models/adminServerStats.php b/models/adminServerStats.php index e3855c9..3aa2b6f 100755 --- a/models/adminServerStats.php +++ b/models/adminServerStats.php @@ -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); } diff --git a/models/ajaxServerBandwidthGraphs.php b/models/ajaxServerBandwidthGraphs.php index 43f1caa..7b90c79 100755 --- a/models/ajaxServerBandwidthGraphs.php +++ b/models/ajaxServerBandwidthGraphs.php @@ -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 diff --git a/views/adminServerStats.html b/views/adminServerStats.html index dabe3c3..7c917a6 100755 --- a/views/adminServerStats.html +++ b/views/adminServerStats.html @@ -59,9 +59,9 @@

Select a site to display

Sort by:   - Percent of Target   - Total Traffic   - Site Name + Percent of Target   + Total Traffic   + Site Name

Website                                                Last Month             Target       % of Target   
@@ -294,10 +294,10 @@ $('#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(){ @@ -313,7 +313,7 @@ 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