Fixed incorrect site name being used by ajax E-Mail process.
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 6 Nov 2018 21:15:32 +0000 (16:15 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 6 Nov 2018 21:15:32 +0000 (16:15 -0500)
classes/serverBandwidthSupport.php
models/adminServerStats.php
models/ajaxServerUsageTargetCheck.php

index 02abd78..9dde346 100755 (executable)
@@ -138,6 +138,7 @@ class glmServerStatsBandwidthSupport
         if (!$website) {
             $website = $config['website'];
         }
+
         // If there was an error connecting
         if (!$res) {
             $this->connectError = mysqli_connect_error();
@@ -148,7 +149,7 @@ class glmServerStatsBandwidthSupport
             $settings = $this->bandwidthGetWebsiteSettingsFromName($website);
 
             // Save them in class parameters
-            $this->website      = $config['website'];
+            $this->website      = $website;
             $this->siteId       = $settings['websitepk'];
             $this->target       = $settings['target'];
             $this->disk_target  = $settings['disk_target'];
@@ -456,6 +457,7 @@ class glmServerStatsBandwidthSupport
                    COALESCE ( SUM(B.total)/1000000, 0 ) as data_total,
                    COALESCE ( MAX(R.diskusage)/1000000, 0 ) as storage
               FROM bytes B, rollup R
+
              WHERE B.websitefk = ".$this->siteId."
                AND R.websitefk = ".$this->siteId."
                AND B.time BETWEEN '$yesterday' AND '$today'
@@ -775,6 +777,7 @@ class glmServerStatsBandwidthSupport
     {
 
         return ($this->connected && (strpos(GLM_SERVERSTATS_SITE_BASE_URL, '192.168.44.80') !== false || strpos(GLM_SERVERSTATS_SITE_BASE_URL, 'www.gaslightmedia.com') !== false));
+        return;
 
     }
 
@@ -953,10 +956,8 @@ class glmServerStatsBandwidthSupport
             "Reply-To: $from"
         ];
         wp_mail( $to, $subject, $msg, $header );
+        echo "Sent";
 
     }
 
-
-
-
 }
index 1ab3f10..2315704 100755 (executable)
@@ -111,8 +111,8 @@ class adminServerStats extends glmServerStatsBandwidthSupport
                         array(
                             'target'        => FILTER_VALIDATE_FLOAT,
                             'disk_target'   => FILTER_VALIDATE_FLOAT,
-                            'glm_contact'   => FILTER_VALIDATE_EMAIL,
-                            'cust_contact'  => FILTER_VALIDATE_EMAIL
+                            'glm_contact'   => FILTER_SANITIZE_STRING,
+                            'cust_contact'  => FILTER_SANITIZE_STRING
                         )
                     );
                     $sql = "
index df0c115..db637d4 100755 (executable)
@@ -41,16 +41,15 @@ class ajaxServerUsageTargetCheck  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);
+            $this->website = $websiteIn;
         }
 
+        // Connect to Bandwidth Database selected in the Configure page
+        $this->bandwidthDataConnect($this->website);
+
     }
 
     /*