Completed rework of bandwidth (usage) plugin
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 9 Sep 2019 21:08:27 +0000 (17:08 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 9 Sep 2019 21:08:27 +0000 (17:08 -0400)
Need to merge in with cookie pop-up updates.
Hard Coded Database access info
Removed admin stuff fro selecting additiona info for pop-up.
Moved all admin settings to main site (GLM site)
Added fields to replace WordPress options for certain things

21 files changed:
classes/serverBandwidthSupport.php
defines.php
index.php
models/adminServerStats.php
models/adminServerStatsConfig.php [deleted file]
models/ajaxSendUsageReport.php
models/ajaxServerBandwidthGraphs.php
models/frontCookiePopUp.php
models/serverUsageTargetCheck.php
setup/adminHooks.php
setup/adminMenus.php
setup/standardTemplateParams.php
views/adminServerStats.html
views/adminServerStatsConfig.html [deleted file]
views/footer.html
views/ui/f6/form-summary-start.html
views/ui/f6/grid-start.html
views/ui/f6/section-start.html
views/ui/f6/sub-section-end.html [new file with mode: 0644]
views/ui/f6/sub-section-start.html [new file with mode: 0644]
views/ui/f6/text.html

index 9075b08..f4d0900 100755 (executable)
@@ -23,26 +23,19 @@ class glmServerStatsBandwidthSupport
 {
 
     /**
-     * Config data
+     * Selected Website
      *
-     * @var $config
-     * @access public
-     */
-    public $config = false;
-    /**
-     * Bandwidth database object
-     *
-     * @var $bwdb
+     * @var $website
      * @access public
      */
-    public $bwdb = false;
+    public $website = false;
     /**
-     * Default Website
+     * Website ID
      *
      * @var $website
      * @access public
      */
-    public $website = false;
+    public $siteId = false;
     /**
      * Reporting Threshold
      *
@@ -50,34 +43,6 @@ class glmServerStatsBandwidthSupport
      * @access public
      */
     public $threshold = -1;
-    /**
-     * Reporting Send Enabled
-     *
-     * @var $send_enabled
-     * @access public
-     */
-    public $send_enabled = false;
-    /**
-     * Default Website ID
-     *
-     * @var $siteiId
-     * @access public
-     */
-    public $siteId = false;
-    /**
-     * Target Traffic
-     *
-     * @var $target
-     * @access public
-     */
-    public $target = false;
-    /**
-     * Target Disk Use
-     *
-     * @var $disk_target
-     * @access public
-     */
-    public $disk_target = false;
     /**
      * GLM Billing E-Mail Address
      *
@@ -85,34 +50,6 @@ class glmServerStatsBandwidthSupport
      * @access public
      */
     public $glm_billing_contact = 'billing@gaslightmedia.com';
-    /**
-     * GLM Contact E-Mail
-     *
-     * @var $glm_contact
-     * @access public
-     */
-    public $glm_contact = false;
-    /**
-     * Customer Contact E-Mail
-     *
-     * @var $cust_contact
-     * @access public
-     */
-    public $cust_contact = false;
-    /**
-     * Connected to Database
-     *
-     * @var $connected
-     * @access public
-     */
-    public $connected = false;
-    /**
-     * Connect error
-     *
-     * @var $connectError
-     * @access public
-     */
-    public $connectError = false;
     /**
      * Sort full list by
      *
@@ -126,104 +63,6 @@ class glmServerStatsBandwidthSupport
 
     }
 
-    /*
-     * Connect to desired database
-     *
-     * 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($website = false)
-    {
-
-        $this->connected = false;
-
-        $this->threshold = get_option(GLM_SERVERSTATS_PLUGIN_THRESHOLD_OPTION);
-        $this->send_enabled = get_option(GLM_SERVERSTATS_PLUGIN_SEND_OPTION);
-
-
-        // Initialize MySQLi
-        $this->bwdb = mysqli_init();
-        if ($this->bwdb !== null) {
-
-            // Set a short timeout
-            $this->bwdb->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
-
-            // Get current bandwidth configuration
-            $config = get_option(GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION);
-
-            if ($config === false) {
-                $this->connectError = 'GLM Bandwidth not configured.';
-                trigger_error('GLM Usage: bandwidthDataConnect() - '.$this->connectError, E_USER_NOTICE);
-            } else {
-
-                if (!$website) {
-                    $website = $config['website'];
-                }
-
-                // Connect to MySQL
-                if ($this->bwdb->real_connect(
-                    $config['db_host'],
-                    $config['db_user'],
-                    $config['db_pass'],
-                    $config['db_name']
-                )) {
-                    $this->connected = true;
-
-                    // Get Website Settings
-                    $settings = $this->bandwidthGetWebsiteSettingsFromName($website);
-
-                    // Save them in class parameters
-                    $this->website      = $website;
-                    $this->siteId       = $settings['websitepk'];
-                    $this->target       = $settings['target'];
-                    $this->disk_target  = $settings['disk_target'];
-                    $this->glm_contact  = $settings['glm_contact'];
-                    $this->cust_contact = $settings['cust_contact'];
-
-                // Unable to connect to database
-                } else {
-                    $this->connectError = mysqli_connect_error();
-                    trigger_error('GLM Usage: bandwidthDataConnect() - SQL Connect Error = '.$this->connectError, E_USER_NOTICE);
-                    return false;
-                }
-
-            }
-        }
-
-        return $this->connected;
-
-    }
-
-    /*
-     * Get Web site ID from Web site name.
-     *
-     * The Website ID is the index used to find bandwidth data for a
-     * particular Web site
-     */
-    public function bandwidthGetWebsiteSettingsFromName($name)
-    {
-
-        $sql = "
-            SELECT *
-              FROM website
-             WHERE name = '$name'
-        ;";
-        $websiteResult = $this->bwdb->query($sql);
-        if (!$websiteResult) {
-            trigger_error("Get website settings failed: " . mysqli_error($this->bwdb) );
-        }
-        $website = mysqli_fetch_assoc($websiteResult);
-        if (!$website){
-            trigger_error("Website '$name' not found.");
-        }
-
-        return $website;
-    }
-
     /*
      * Get Web site ID from Web site name.
      *
@@ -233,23 +72,25 @@ class glmServerStatsBandwidthSupport
     public function bandwidthGetWebsiteID($website, $showUsage = false)
     {
 
+        global $bwdb;
+
         // Get Website ID
         $sql = "
             SELECT websitepk
               FROM website
              WHERE name = '$website'
         ;";
-        $websiteResult = $this->bwdb->query($sql);
+        $websiteResult = $bwdb->query($sql);
         if (!$websiteResult) {
-            trigger_error("Website ID query failed: " . mysqli_error($this->bwdb) );
+            trigger_error("Website ID query failed: " . mysqli_error($bwdb) );
         }
         $row = mysqli_fetch_assoc($websiteResult);
         if (!$row){
             trigger_error("Website '$website' not found.");
         }
-        $this->siteId = $row['websitepk'];
+        $siteId = $row['websitepk'];
 
-        return $this->siteId;
+        return $siteId;
     }
 
     /*
@@ -272,9 +113,10 @@ class glmServerStatsBandwidthSupport
      */
     public function bandwidthGetSites()
     {
+        global $bwdb;
 
         // Check for good database connection
-        if ($this->bwdb == false) {
+        if ($bwdb == false) {
             return false;
         }
 
@@ -284,7 +126,7 @@ class glmServerStatsBandwidthSupport
               FROM website
           ORDER BY (name +0) ASC ,name ASC
         ;";
-        $result = $this->bwdb->query($sql);
+        $result = $bwdb->query($sql);
 
         if (!$result) {
             return false;
@@ -306,6 +148,8 @@ class glmServerStatsBandwidthSupport
      */
     public function bandwidthLastMonthAllSites($sortBy = false, $website = false)
     {
+        global $bwdb;
+
         $stats = array();
 
         $sortByClause = 'target_percent DESC';
@@ -318,6 +162,8 @@ class glmServerStatsBandwidthSupport
             $siteWhereClause = "AND W.name = '$website'";
         }
 
+        $threshold = get_option(GLM_SERVERSTATS_PLUGIN_THRESHOLD_OPTION);
+
         // Get stats for last month in Gigabytes
         $firstDayOfMonth = date('Y-m-01', strtotime(date('Y-m-01').' -1 month'));
         $lastDayOfMonth = date('Y-m-t', strtotime($firstDayOfMonth));
@@ -341,7 +187,7 @@ class glmServerStatsBandwidthSupport
               GROUP BY R.websitefk
               ORDER BY $sortByClause
             ";
-        $lastMonthStats = $this->bwdb->query($sql);
+        $lastMonthStats = $bwdb->query($sql);
         $lastMonthStats->data_seek(0);
         while ($row = $lastMonthStats->fetch_assoc()) {
 
@@ -351,8 +197,8 @@ class glmServerStatsBandwidthSupport
             if ($row['disk_target_percent'] == '') {
                 $row['disk_target_percent'] = 0;
             }
-            $row['exceeded'] = $row['target_percent'] > $this->threshold;
-            $row['diskExceeded'] = $row['disk_target_percent'] > $this->threshold;
+            $row['exceeded'] = $row['target_percent'] > $threshold;
+            $row['diskExceeded'] = $row['disk_target_percent'] > $threshold;
 
             $stats[$row['id']] = $row;
         }
@@ -365,6 +211,8 @@ class glmServerStatsBandwidthSupport
      */
     public function bandwidthGetAllSitesStats($sortByRequest = 'name')
     {
+        global $bwdb;
+
         $stats = array();
 
         // Determine output table sort order
@@ -375,7 +223,7 @@ class glmServerStatsBandwidthSupport
         }
 
         // Check for good database connection
-        if ($this->bwdb == false) {
+        if ($bwdb == false) {
             return false;
         }
 
@@ -397,7 +245,7 @@ class glmServerStatsBandwidthSupport
           GROUP BY B.websitefk
           ORDER BY W.name
         ;";
-        $yesterdayStats = $this->bwdb->query($sql);
+        $yesterdayStats = $bwdb->query($sql);
         $yesterdayStats->data_seek(0);
         while ($row = $yesterdayStats->fetch_assoc()) {
             $stats[$row['id']]['yesterday'] = $row;
@@ -418,7 +266,7 @@ class glmServerStatsBandwidthSupport
           GROUP BY R.websitefk
           ORDER BY W.name
         ;";
-        $thisMonthStats = $this->bwdb->query($sql);
+        $thisMonthStats = $bwdb->query($sql);
         $thisMonthStats->data_seek(0);
         while ($row = $thisMonthStats->fetch_assoc()) {
             $stats[$row['id']]['thisMonth'] = $row;
@@ -439,7 +287,7 @@ class glmServerStatsBandwidthSupport
           GROUP BY R.websitefk
           ORDER BY W.name
         ;";
-        $lastMonthStats = $this->bwdb->query($sql);
+        $lastMonthStats = $bwdb->query($sql);
         $lastMonthStats->data_seek(0);
         while ($row = $lastMonthStats->fetch_assoc()) {
             $stats[$row['id']]['lastMonth'] = $row;
@@ -497,14 +345,19 @@ class glmServerStatsBandwidthSupport
 
     /*
      * Get bandwidth stats for the current day, and month
+     *
+     * @param intiger ID of site entry in website table
+     *
+     * @return array Comilied statistics
      */
-    public function bandwidthGetStats()
+    public function bandwidthGetStats($siteId)
     {
+        global $bwdb;
 
         $stats = array();
 
         // Check for good database connection
-        if ($this->bwdb == false) {
+        if ($bwdb == false) {
             return false;
         }
 
@@ -519,12 +372,12 @@ class glmServerStatsBandwidthSupport
                    COALESCE ( MAX(R.diskusage)/1000000, 0 ) as storage
               FROM bytes B, rollup R
 
-             WHERE B.websitefk = ".$this->siteId."
-               AND R.websitefk = ".$this->siteId."
+             WHERE B.websitefk = ".$siteId."
+               AND R.websitefk = ".$siteId."
                AND B.time BETWEEN '$yesterday' AND '$today'
                AND R.date = '$yesterday'
         ;";
-        $todayStats = $this->bwdb->query($sql);
+        $todayStats = $bwdb->query($sql);
         $stats['yesterday'] = $todayStats->fetch_array(MYSQLI_ASSOC);
 
         // Get stats for this month in Gigabytes
@@ -537,10 +390,10 @@ class glmServerStatsBandwidthSupport
                    COALESCE ( SUM(total)/1000000000, 0 ) as data_total,
                    COALESCE ( MAX(diskusage)/1000000, 0 ) as storage
               FROM rollup
-             WHERE websitefk = ".$this->siteId."
+             WHERE websitefk = ".$siteId."
                AND date BETWEEN '$firstDayOfMonth' AND '$lastDayOfMonth'
         ;";
-        $thisMonthStats = $this->bwdb->query($sql);
+        $thisMonthStats = $bwdb->query($sql);
         $stats['thisMonth'] = $thisMonthStats->fetch_array(MYSQLI_ASSOC);
 
         // Get stats for last month in Gigabytes
@@ -553,10 +406,10 @@ class glmServerStatsBandwidthSupport
                    COALESCE ( SUM(total)/1000000000, 0 ) as data_total,
                    COALESCE ( max(diskusage)/1000000000, 0 ) as storage
               FROM rollup
-             WHERE websitefk = ".$this->siteId."
+             WHERE websitefk = ".$siteId."
                AND date BETWEEN '$firstDayOfMonth' AND '$lastDayOfMonth'
         ;";
-        $lastMonthStats = $this->bwdb->query($sql);
+        $lastMonthStats = $bwdb->query($sql);
         $stats['lastMonth'] = $lastMonthStats->fetch_array(MYSQLI_ASSOC);
 
         return $stats;
@@ -568,9 +421,10 @@ class glmServerStatsBandwidthSupport
      */
     public function bandwidthGetGraphData($graphType = false, $siteId = false, $refDate = false)
     {
+        global $bwdb, $settings;
 
         if (!$siteId) {
-            $siteId = $this->siteId;
+            $siteId = $settings['websitepk'];
         }
 
         $bandwidth = array('data_in' => array(), 'data_out' => array(), 'data_total' => array());
@@ -601,7 +455,7 @@ class glmServerStatsBandwidthSupport
                        AND time BETWEEN '$startOfYesterday' AND '$endOfToday'
                   ORDER BY time ASC
                 ;";
-                $dayData = $this->bwdb->query($sql);
+                $dayData = $bwdb->query($sql);
                 $dayData->data_seek(0);
                 while ($row = $dayData->fetch_assoc()) {
                     $time = date('Y-m-d-H:i', strtotime($row['time']));
@@ -616,7 +470,7 @@ class glmServerStatsBandwidthSupport
                       FROM website
                      WHERE websitepk = $siteId
                 ;";
-                $targetRes = $this->bwdb->query($sql);
+                $targetRes = $bwdb->query($sql);
                 $siteName = '';
                 if ($targetRes) {
                     $targetData = mysqli_fetch_assoc($targetRes);
@@ -643,7 +497,7 @@ class glmServerStatsBandwidthSupport
                        AND date BETWEEN '$firstDayOfMonth' AND '$lastDayOfMonth'
                   ORDER BY date ASC
                 ;";
-                $monthData = $this->bwdb->query($sql);
+                $monthData = $bwdb->query($sql);
                 $monthData->data_seek(0);
                 while ($row = $monthData->fetch_assoc()) {
                     $time = date('Y-m-d', strtotime($row['time']));
@@ -658,7 +512,7 @@ class glmServerStatsBandwidthSupport
                       FROM website
                      WHERE websitepk = $siteId
                 ;";
-                $targetRes = $this->bwdb->query($sql);
+                $targetRes = $bwdb->query($sql);
                 $siteName = '';
                 if ($targetRes) {
                     $targetData = mysqli_fetch_assoc($targetRes);
@@ -686,7 +540,7 @@ class glmServerStatsBandwidthSupport
                   GROUP BY YEAR(date), MONTH(date)
                   ORDER BY date ASC
                 ;";
-                $twoYearData = $this->bwdb->query($sql);
+                $twoYearData = $bwdb->query($sql);
                 $twoYearData->data_seek(0);
                 while ($row = $twoYearData->fetch_assoc()) {
                     $time = date('Y-m', strtotime($row['time']));
@@ -701,7 +555,7 @@ class glmServerStatsBandwidthSupport
                       FROM website
                      WHERE websitepk = $siteId
                 ;";
-                $targetRes = $this->bwdb->query($sql);
+                $targetRes = $bwdb->query($sql);
                 $target = false;
                 $siteName = '';
                 if ($targetRes) {
@@ -731,7 +585,7 @@ class glmServerStatsBandwidthSupport
                   ORDER BY date ASC
                 ";
 
-                $twoYearStorageData = $this->bwdb->query($sql);
+                $twoYearStorageData = $bwdb->query($sql);
                 $twoYearStorageData->data_seek(0);
                 while ($row = $twoYearStorageData->fetch_assoc()) {
                     $time = date('Y-m', strtotime($row['time']));
@@ -744,7 +598,7 @@ class glmServerStatsBandwidthSupport
                       FROM website
                      WHERE websitepk = $siteId
                 ;";
-                $targetRes = $this->bwdb->query($sql);
+                $targetRes = $bwdb->query($sql);
                 $target = false;
                 $siteName = '';
 
@@ -770,77 +624,32 @@ class glmServerStatsBandwidthSupport
 
     }
 
-    /*
-     * Get or initialize configuration data
-     *
-     * @return array Array of configuration data for this plugin
-     */
-    public function getConfig()
-    {
-
-        // Check if configuration fields have been initialized.
-        $config = get_option(GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION);
-
-        // If we have a stored config, return that
-        if ($config) {
-            return $config;
-        }
-
-        // We don't have a config option, so create a default one.
-        $config = array(
-            'show_usage'                    => false,
-            'send_usage'                    => false,
-            'send_percent'                  => 90,
-            'show_notifications'            => false,
-            'show_cookie_popup'             => false,
-            'cookie_popup_timeout'          => 10,
-            'cookie_message'                => '',
-            'cookie_opt_gdpr'               => true,
-            'cookie_opt_access_logs'        => true,
-            'cookie_opt_permanent'          => false,
-            'cookie_opt_tracking'           => true,
-            'cookie_opt_shared_tracking'    => true,
-            'cookie_opt_https'              => true,
-            'cookie_opt_logged_in'          => true,
-            'cookie_opt_forms'              => true,
-            'cookie_opt_payment'            => false,
-            'active'                        => true,
-            'db_name'                       => 'bandwidth',
-            'db_host'                       => 'bandwidth.gaslightmedia.com',
-            'db_user'                       => 'bandwidthRO',
-            'db_pass'                       => ',Wv4W*~^bL_vF3F4PbGsS',
-            'website'                       => 'www.gaslightmedia.com'
-        );
-        add_option(GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION, $config);
-
-        return $config;
-
-    }
-
     /*
      * Get stats and check if the target traffic has been exceeded
      *
+     * @param array Settings array for desired site
+     *
      * @return array Stats array plus trafficDiff sub array
      */
-    public function getStatsAndCheckTargetExceeded()
+    public function getStatsAndCheckTargetExceeded($settings)
     {
 
-        $stats = $this->bandwidthGetStats();
+        $stats = $this->bandwidthGetStats($settings['websitepk']);
 
         // Compare the taget in Megabytes to the acutal traffic in Gigabytes
-        $diff = ($stats['lastMonth']['data_total']) - $this->target;
-        $percent = ($stats['lastMonth']['data_total'] / $this->target) * 100;
+        $diff = ($stats['lastMonth']['data_total']) - $settings['target'];
+        $percent = ($stats['lastMonth']['data_total'] / $settings['target']) * 100;
 
-        $diskDiff = ($stats['lastMonth']['storage']*1000) - $this->disk_target;
-        $diskPercent = (($stats['lastMonth']['storage']*1000) / $this->disk_target) * 100;
+        $diskDiff = ($stats['lastMonth']['storage']*1000) - $settings['disk_target'];
+        $diskPercent = (($stats['lastMonth']['storage']*1000) / $settings['disk_target']) * 100;
 
         $stats['trafficDiff'] = [
-            'target'        => $this->target,
+            'target'        => $settings['target'],
             'lastMonth'     => $stats['lastMonth']['data_total'],
             'traffic'       => $diff,
             'percent'       => $percent,
             'exceeded'      => $diff > 0,
-            'diskTarget'    => $this->disk_target,
+            'diskTarget'    => $settings['disk_target'],
             'diskLastMonth' => $stats['lastMonth']['storage']*1000,
             'disk'          => $diskDiff,
             'diskPercent'   => $diskPercent,
@@ -883,6 +692,8 @@ class glmServerStatsBandwidthSupport
     public function checkEmailNotifications($sendToGlmContact = false, $sendToCustContact = false, $sendAll = false, $site = false, $forceDisplay = false)
     {
 
+        $glmFromContact = get_option(GLM_SERVERSTATS_PLUGIN_REPORT_CONTACT);
+
         // Get info on the desired sites for processing
         $websites = $this->bandwidthLastMonthAllSites(false, $site);
 
@@ -915,13 +726,15 @@ class glmServerStatsBandwidthSupport
         $numbReporting = 0;
         $numbReportingWithContactEmail = 0;
 
+        $threshold = get_option(GLM_SERVERSTATS_PLUGIN_THRESHOLD_OPTION);
+
         // For each website retrieved
         foreach ($websites as $site) {
 
             $mesg = '';
 
             // If theshold is not -1 and at least one of usage or disk % of target equals or exceeds reporting threshold
-            if ($this->threshold != -1 && ($sendAll || $site['target_percent'] >= $this->threshold || $site['disk_target_percent'] >= $this->threshold)) {
+            if ($threshold != -1 && ($sendAll || $site['target_percent'] >= $threshold || $site['disk_target_percent'] >= $threshold)) {
 
                 $numbReporting++;
 
@@ -1026,7 +839,7 @@ class glmServerStatsBandwidthSupport
                     }
 
                     if ($sendToCustContact && $mesg != '') {
-                        $this->sendHtmlEmail($site['cust_contact'], 'info@gaslightmedia.com', 'Gaslight Media Server Usage Report', $mesg, $forceDisplay);
+                        $this->sendHtmlEmail($site['cust_contact'], $glmFromContact['name'].' <'.$glmFromContact['email'].'>', $glmFromContact['subject'], $mesg, $forceDisplay);
                     }
 
                 }
@@ -1040,7 +853,7 @@ class glmServerStatsBandwidthSupport
                 <p>Gaslight Media:</p>
                 <p>The following is a summary of usage report(s) sent for '.$month.'.</p>
                 <table>'.$glmMesg.'</table>';
-            $this->sendHtmlEmail($this->glm_billing_contact, 'info@gaslightmedia.com', 'Gaslight Media Server Usage Report', $glmMesg, $forceDisplay);
+            $this->sendHtmlEmail($this->glm_billing_contact, $glmFromContact['name'].' <'.$glmFromContact['email'].'>', $glmFromContact['subject'], $glmMesg, $forceDisplay);
         }
 
         $res = [
@@ -1049,7 +862,9 @@ class glmServerStatsBandwidthSupport
             'numbReportingWithContactEmail' => $numbReportingWithContactEmail
         ];
 
-        trigger_error("Usage E-Mail Notifications Summary - Sites: $numbSites, Sites Reporting: $numbReporting, Reporting with Contact E-Mail:  $numbReportingWithContactEmail", E_USER_NOTICE );
+        if (GLM_SERVERSTATS_PLUGIN_DEBUG) {
+            trigger_error("Usage E-Mail Notifications Summary - Sites: $numbSites, Sites Reporting: $numbReporting, Reporting with Contact E-Mail:  $numbReportingWithContactEmail", E_USER_NOTICE );
+        }
 
         return $res;
 
index bf0c2d9..6661ba5 100755 (executable)
@@ -5,15 +5,20 @@
  * Set standard defined parameters
  */
 
-// PROVIDER ENABLED ADDRESSES - If base URL matches one of these, site is considered the "Provider" site.
-define('GLM_SERVERSTATS_PROVIDER_1', '192.168.44.82');
-define('GLM_SERVERSTATS_PROVIDER_2', 'www.gaslightmedia.com');
+// Set to true to add more debug messages to the error log
+define('GLM_SERVERSTATS_PLUGIN_DEBUG', false);
 
+// Database Connection
+define('GLM_SERVERSTATS_DATABASE_NAME',     'bandwidth');
+define('GLM_SERVERSTATS_DATABASE_SERVER',   'bandwidth.gaslightmedia.com');
+define('GLM_SERVERSTATS_DATABASE_USER',     'bandwidthRO');
+define('GLM_SERVERSTATS_DATABASE_PASSWORD', ',Wv4W*~^bL_vF3F4PbGsS');
 
-define('GLM_SERVERSTATS_CONTACT_EMAIL', "plugins@gaslightmedia.com");
+// PROVIDER ENABLED ADDRESSES - If base URL matches one of these, site is considered the "Provider" site.
+define('GLM_SERVERSTATS_PROVIDER_1', '192.168.44.82');                  // Development System
+define('GLM_SERVERSTATS_PROVIDER_2', 'www.gaslightmedia.com');          // Home Site where sites are configured and reported
 
-// Set to true to add more debug messages to the error log
-define('GLM_SERVERSTATS_PLUGIN_DEBUG', true);
+// Check if debug enabled
 if (GLM_SERVERSTATS_PLUGIN_DEBUG) {
     trigger_error("GLM Data Usage Debug Enabled", E_USER_NOTICE);
 }
@@ -57,6 +62,16 @@ define('GLM_SERVERSTATS_PLUGIN_HTTP_PROTOCOL', $pageProtocol);
 
 // Get various pieces of the URL
 $urlParts = parse_url(get_bloginfo('url'));
+
+// Set Website hostname - but override if development system
+$hostname = $urlParts['host'];
+if ($hostname == GLM_SERVERSTATS_PROVIDER_1) {
+    // Must be on development system, so use data for GLM site
+    define('GLM_SERVERSTATS_PLUGIN_HOSTNAME', 'www.gaslightmedia.com');
+} else {
+    define('GLM_SERVERSTATS_PLUGIN_HOSTNAME', $urlParts['host']);
+}
+
 $pageUri = explode('?', $_SERVER['REQUEST_URI']);               // Bust this up to access URL path and script name only
 
 // Enable to display smarty template debug.
@@ -98,3 +113,4 @@ define('GLM_SERVERSTATS_PLUGIN_UPDATE_SERVER', 'http://www.gaslightmedia.com/upd
 define('GLM_SERVERSTATS_PLUGIN_THRESHOLD_OPTION', 'glmServerStatsThreshold');
 define('GLM_SERVERSTATS_PLUGIN_SEND_OPTION', 'glmServerStatsSend');
 define('GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION', 'glmServerStatsConfigData');
+define('GLM_SERVERSTATS_PLUGIN_REPORT_CONTACT', 'glmServerStatsReportContact');
index 96f5663..4dfc05b 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -40,6 +40,13 @@ require_once 'defines.php';
 
 require_once GLM_SERVERSTATS_PLUGIN_LIB_PATH.'/smartyTemplateSupport.php';
 
+// Connect to bandwidth database and get all settings for this site
+$bwdb = mysqli_init();
+$websiteSettings = bandwidthDataConnect(GLM_SERVERSTATS_PLUGIN_HOSTNAME);
+if (!$websiteSettings) {
+    wp_die('FAILURE: Unable to connect to GLM Bandwidth database. Please check connection settings in defines.php of this plugin.');
+}
+
 // If this is an admin request
 if (is_admin()) {
     add_action('admin_menu', 'configureMenus');
@@ -147,6 +154,34 @@ function glmServerStatsScripts()
 
 }
 
+
+/*
+ * Setup Cookie Notice Pop-Up
+ * Shows the pop-up. When the user clicks "Got it!" then sets a cookie to not show it again for some
+ * number of days as set in the frontCookiePopUp.php file.
+ *
+ * To test this pop-up add "cookie_notice_reset=true" to URL. This resets the browser
+ * cookie that tracks if the user clicks "Got it!".
+ */
+
+// If this is an admin request and the cookie pop-ups have been enabled - Popup test in scripting on page
+if ($websiteSettings['show_cookie_popup'] && !is_admin()) {
+
+    // Make sure that the jQuery scripts are included
+    function enqueueJquery() {
+        glmServerJqueryScipts();
+    }
+    add_action( 'wp_enqueue_scripts', 'enqueueJquery' );
+
+    // Have WordPress include the cookie pop-up code just before the footer.
+    function doCookiePopUp() {
+        include(GLM_SERVERSTATS_PLUGIN_MODEL_PATH.'/frontCookiePopUp.php');
+    }
+    add_action( 'get_footer', 'doCookiePopUp' );
+
+}
+
+
 /**
  * Admin Ajax Target
  *
@@ -366,32 +401,75 @@ if (apply_filters('glm-serverstats-is-provider', false) || true) {
 }
 
 /*
- * Cookie Notice Pop-Up
- * Shows the pop-up. When the user clicks "Got it!" then sets a cookie to not show it again for some
- * number of days as set in the frontCookiePopUp.php file.
- *
- * To test this pop-up add "cookie_notice_reset=true" to URL. This resets the browser
- * cookie that tracks if the user clicks "Got it!".
+ * Function to connect to bandwidth database and return site specific settings for this site
  */
+function bandwidthDataConnect($website = false)
+{
+    global $bwdb;
 
-// Get Configuration for Cookie info popup
-$serverstatsConfig = get_option(GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION);
+    $settings = false;
 
-// If this is an admin request and the cookie pop-ups have been enabled - Popup test in scripting on page
-if ($serverstatsConfig['show_cookie_popup'] && !is_admin()) {
+    if ($bwdb !== null) {
 
-    // Make sure that the jQuery scripts are included
-    function enqueueJquery() {
-        glmServerJqueryScipts();
+        // Set a short timeout
+        $bwdb->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
+
+        // Connect to MySQL
+        if ($bwdb->real_connect(
+                GLM_SERVERSTATS_DATABASE_SERVER,
+                GLM_SERVERSTATS_DATABASE_USER,
+                GLM_SERVERSTATS_DATABASE_PASSWORD,
+                GLM_SERVERSTATS_DATABASE_NAME
+                )) {
+
+                    // Get Website Settings
+                    $settings = bandwidthGetWebsiteSettingsFromName($website);
+
+                    if (!$settings) {
+                        trigger_error('GLM Usage: bandwidthDataConnect() - Unable to get Website Settings', E_USER_NOTICE);
+                        return false;
+                    }
+
+                    // Unable to connect to database
+                } else {
+                    $this->connectError = mysqli_connect_error();
+                    trigger_error('GLM Usage: bandwidthDataConnect() - SQL Connect Error = '.$this->connectError, E_USER_NOTICE);
+                    return false;
+                }
+
+    } else {
+        trigger_error('GLM Usage: bandwidthDataConnect() - Unable to init MySQL!', E_USER_NOTICE);
+        return false;
     }
-    add_action( 'wp_enqueue_scripts', 'enqueueJquery' );
 
-    // Have WordPress include the cookie pop-up code just before the footer.
-    function doCookiePopUp() {
-        include(GLM_SERVERSTATS_PLUGIN_MODEL_PATH.'/frontCookiePopUp.php');
+    return $settings;
+
+}
+
+/*
+ * Function to Get Web site settings from Web site name.
+ */
+function bandwidthGetWebsiteSettingsFromName($name)
+{
+    global $bwdb;
+
+    $sql = "
+        SELECT *
+          FROM website
+         WHERE name = '$name'
+    ;";
+    $websiteResult = $bwdb->query($sql);
+    if (!$websiteResult) {
+        trigger_error("Get website settings failed: " . mysqli_error($bwdb) );
+        return false;
+    }
+    $website = mysqli_fetch_assoc($websiteResult);
+    if (!$website){
+        trigger_error("Website '$name' not found.");
+        return false;
     }
-    add_action( 'get_footer', 'doCookiePopUp' );
 
+    return $website;
 }
 
 
index b340620..2cb1f47 100755 (executable)
@@ -37,12 +37,19 @@ class adminServerStats extends glmServerStatsBandwidthSupport
     */
     public function __construct()
     {
-        $this->config = $this->getConfig();
-
-        $websiteSelected = false;
 
         if (current_user_can('administrator')) {
-            $this->Website = filter_input( INPUT_GET, 'selected_site', FILTER_SANITIZE_STRING);
+
+            // Check for a selected site or use website specified in defines.php
+            $this->website = filter_input(INPUT_GET, 'selected_site', FILTER_SANITIZE_STRING);
+            if (empty($this->website)) {
+                $this->website = GLM_SERVERSTATS_PLUGIN_HOSTNAME;
+            }
+
+        }
+
+        if (GLM_SERVERSTATS_PLUGIN_DEBUG) {
+            trigger_error('GLM Usage: Selected Site = '.$this->website, E_USER_NOTICE);
         }
 
     }
@@ -50,25 +57,13 @@ class adminServerStats extends glmServerStatsBandwidthSupport
     /*
      * Model
      *
-     * Gets and displays the servers stats according to the current configuration.
+     * Gets and displays the servers stats.
      *
      * @return array Array the view to use and data for the view
      */
     public function model()
     {
-
-        // Connect to Bandwidth Database selected in the Configure page
-        $this->connected = $this->bandwidthDataConnect($this->website);
-
-        if (!$this->connected) {
-            return ['redirect' => 'adminServerStatsConfig'];
-        }
-
-/*      // Enable this code to have serverUsageTargetCheck() run each time this model runs. For Testing Only!
-        require_once GLM_SERVERSTATS_PLUGIN_MODEL_PATH.'/serverUsageTargetCheck.php';
-        $ServerUsageTargetCheck = new serverUsageTargetCheck();
-        $ServerUsageTargetCheck->model();
-*/
+        global $bwdb, $websiteSettings;
 
         $haveStats     = false;
         $stats         = false;
@@ -78,7 +73,7 @@ class adminServerStats extends glmServerStatsBandwidthSupport
         $thisMonth     = false;
         $thisMonthTime = false;
         $websites      = false;
-        $settings      = false;
+        $currentSite   = false;
 
         // If an update was submitted
         $option = 'none';
@@ -86,152 +81,176 @@ class adminServerStats extends glmServerStatsBandwidthSupport
             $option = $_REQUEST['option'];
         }
 
-        // If a threshold value is submitted, the form has been submitted
-        if (isset($_REQUEST['threshold'])) {
-
-            $this->threshold = $_REQUEST['threshold'] - 0;
-            update_option(GLM_SERVERSTATS_PLUGIN_THRESHOLD_OPTION, $this->threshold);
-
-            // If a send_enabled is submitted
-            $this->send_enabled = false;
-            if (isset($_REQUEST['send_enabled']) && $_REQUEST['send_enabled'] == 'on') {
-                $this->send_enabled = true;
-            }
-            update_option(GLM_SERVERSTATS_PLUGIN_SEND_OPTION, $this->send_enabled);
-
+        // Get selected site. If not specified use default
+        $currentSiteName = $websiteSettings['name'];
+        if (isset($_REQUEST['selected_site'])) {
+            $currentSiteName = filter_var($_REQUEST['selected_site'], FILTER_SANITIZE_STRING);
         }
 
-        // Check for a selected site or use website in config
-        $selectedSite = filter_input(INPUT_GET, 'selected_site', FILTER_SANITIZE_STRING);
-        if (!$selectedSite) {
-            $selectedSite = $this->config['website'];
-        }
+        // If user is an admin, then get a list of Websites with Bandwidth Stats
+        if (apply_filters('glm-serverstats-is-provider', false)) {
 
-        if ($this->connected) {
+            // Get submitted parameters
+            $site_sort = 'default';
+            if (isset($_REQUEST['site_sort'])) {
+                $site_sort = $_REQUEST['site_sort'];
+            }
 
-            $this->siteId = $this->bandwidthGetWebsiteID($selectedSite);
+            // Get sort order
+            switch ($site_sort) {
+                case 'storage':
+                    $sortBy = 'storage DESC';
+                    $site_sort = 'storage';
+                    break;
 
-            // If user is an admin, then get a list of Websites with Bandwidth Stats
-            if (apply_filters('glm-serverstats-is-provider', false)) {
+                case 'disk_target_percent':
+                    $sortBy = 'disk_target_percent DESC';
+                    $site_sort = 'disk_target_percent';
+                    break;
 
-                // Get submitted parameters
-                $site_sort = 'default';
-                if (isset($_REQUEST['site_sort'])) {
-                    $site_sort = $_REQUEST['site_sort'];
-                }
+                case 'data_total':
+                    $sortBy = 'data_total DESC';
+                    $site_sort = 'data_total';
+                    break;
 
-                // Get sort order
-                switch ($site_sort) {
-                    case 'storage':
-                        $sortBy = 'storage DESC';
-                        $site_sort = 'storage';
-                        break;
+                case 'target_percent':
+                    $sortBy = 'target_percent DESC';
+                    $site_sort = 'target_percent';
+                    break;
 
-                    case 'disk_target_percent':
-                        $sortBy = 'disk_target_percent DESC';
-                        $site_sort = 'disk_target_percent';
-                        break;
+                case 'site_name':
+                default:
+                    $sortBy = 'name';
+                    $site_sort = 'site_name';
+                    break;
 
-                    case 'data_total':
-                        $sortBy = 'data_total DESC';
-                        $site_sort = 'data_total';
-                        break;
 
-                    case 'target_percent':
-                        $sortBy = 'target_percent DESC';
-                        $site_sort = 'target_percent';
-                        break;
+            }
 
-                    case 'site_name':
-                    default:
-                        $sortBy = 'name';
-                        $site_sort = 'site_name';
-                        break;
+            if ($option == 'update_site') {
+
+                // Update the website table with certain values
+                $vals = filter_input_array( INPUT_POST,
+                    array(
+                        'selected_site'         => FILTER_SANITIZE_STRING,
+                        'target'                => FILTER_VALIDATE_FLOAT,
+                        'disk_target'           => FILTER_VALIDATE_FLOAT,
+                        'cust_contact'          => FILTER_SANITIZE_STRING,
+                        'cookie_popup_timeout'  => FILTER_VALIDATE_INT,
+                        'cookie_message'        => FILTER_SANITIZE_STRING,
+                        'contact_name'          => FILTER_SANITIZE_STRING,
+                        'contact_org'           => FILTER_SANITIZE_STRING,
+                        'contact_address'       => FILTER_SANITIZE_STRING,
+                        'contact_address2'      => FILTER_SANITIZE_STRING,
+                        'contact_city'          => FILTER_SANITIZE_STRING,
+                        'contact_state'         => FILTER_SANITIZE_STRING,
+                        'contact_zip'           => FILTER_SANITIZE_STRING,
+                        'contact_phone'         => FILTER_SANITIZE_STRING,
+                        'contact_email'         => FILTER_SANITIZE_STRING
+                    ),true
+                );
+
+                $sql = "
+                    UPDATE website
+                        SET target                  = ".$vals['target'].",
+                            disk_target             = ".$vals['disk_target'].",
+                            show_usage              = ".(isset($_POST['show_usage'])?1:0).",
+                            send_enabled            = ".(isset($_POST['send_enabled'])?1:0).",
+                            cust_contact            = '".$vals['cust_contact']."',
+                            show_cookie_popup       = ".(isset($_POST['show_cookie_popup'])?1:0).",
+                            cookie_popup_timeout    = ".$vals['cookie_popup_timeout'].",
+                            cookie_message          = '".$vals['cookie_message']."',
+                            contact_name            = '".$vals['contact_name']."',
+                            contact_org             = '".$vals['contact_org']."',
+                            contact_address         = '".$vals['contact_address']."',
+                            contact_address2        = '".$vals['contact_address2']."',
+                            contact_city            = '".$vals['contact_city']."',
+                            contact_state           = '".$vals['contact_state']."',
+                            contact_zip             = '".$vals['contact_zip']."',
+                            contact_phone           = '".$vals['contact_phone']."',
+                            contact_email           = '".$vals['contact_email']."'
+                     WHERE name = '".$currentSiteName."'
+                ";
+                if (!$bwdb->query($sql)) {
+                    printf("Error: %s\n", $bwdb->error);
+                }
 
+                // Update Reporting From Contact and Title (GLM)
+                $glmFromContact = [
+                    'name'          => filter_input( INPUT_POST, 'report_contact_name', FILTER_SANITIZE_STRING),
+                    'email'         => filter_input( INPUT_POST, 'report_contact_email', FILTER_SANITIZE_STRING),
+                    'subject'       => filter_input( INPUT_POST, 'report_subject', FILTER_SANITIZE_STRING)
+                ];
+                update_option(GLM_SERVERSTATS_PLUGIN_REPORT_CONTACT, $glmFromContact);
 
-                }
+                // Update Reporting Threshold
+                $threshold = $_REQUEST['threshold'] - 0;
+                update_option(GLM_SERVERSTATS_PLUGIN_THRESHOLD_OPTION, $threshold);
 
-                if ($option == 'update_site') {
-
-                    // Update the website table with certain values
-                    $settings = filter_input_array( INPUT_POST,
-                        array(
-                            'target'        => FILTER_VALIDATE_FLOAT,
-                            'disk_target'   => FILTER_VALIDATE_FLOAT,
-                            'glm_contact'   => FILTER_SANITIZE_STRING,
-                            'cust_contact'  => FILTER_SANITIZE_STRING
-                        )
-                    );
-                    $sql = "
-                        UPDATE website
-                           SET target = ".$settings['target'].",
-                               disk_target = ".$settings['disk_target'].",
-                               glm_contact = '".$settings['glm_contact']."',
-                               cust_contact = '".$settings['cust_contact']."'
-                         WHERE name = '$selectedSite'
-                    ";
-
-                    $this->bwdb->query($sql);
-
-                    // Update our class parameters
-                    $this->target = $settings['target'];
-                    $this->disk_target = $settings['disk_target'];
-                    $this->glm_contact = $settings['glm_contact'];
-                    $this->cust_contact = $settings['glm_contact'];
+                // Update Reports Enabled flag
+                $sendReportsEnabled = filter_input( INPUT_POST, 'send_reports_enabled', FILTER_VALIDATE_BOOLEAN);
+                update_option(GLM_SERVERSTATS_PLUGIN_SEND_OPTION, $sendReportsEnabled);
 
-                }
+            }
 
-                // Get the settings for the currently selected site
-                $settings = $this->bandwidthGetWebsiteSettingsFromName($selectedSite);
+            // Get the settings for the currently selected site
+            $currentSite = bandwidthGetWebsiteSettingsFromName($currentSiteName);
 
-                // Get list of sites in the bandwidth database
-                $websites = $this->bandwidthLastMonthAllSites($sortBy);
+            // Get list of sites in the bandwidth database
+            $websites = $this->bandwidthLastMonthAllSites($sortBy);
 
-            }
+        }
 
-            // Get bandwidth stats for the current site
-            $stats = $this->getStatsAndCheckTargetExceeded();
+        // Get bandwidth stats for the current site
+        $stats = $this->getStatsAndCheckTargetExceeded($currentSite);
 
-            if ($stats != false) {
+        if ($stats != false) {
 
-                // Build summary info
-                $thisDateTime = strtotime('yesterday');
-                $thisDate = date('m/d/Y', $thisDateTime);
-                $thisMonthTime = strtotime(date('m/01/Y'));
-                $thisMonth = date('m/Y');
+            // Build summary info
+            $thisDateTime = strtotime('yesterday');
+            $thisDate = date('m/d/Y', $thisDateTime);
+            $thisMonthTime = strtotime(date('m/01/Y'));
+            $thisMonth = date('m/Y');
 
-                $haveStats = true;
+            $haveStats = true;
 
-            }
+        }
 
+        $policyPageSlug = sanitize_title(GLM_SERVERSTATS_PLUGIN_POLICY_PAGE);
+        $moreInfoUrl = 'https://'.$this->website."/".$policyPageSlug;
+
+        if (trim($currentSite['cookie_message']) == '') {
+            $currentSite['cookie_message'] =
+                '<p>This site uses temporary "Cookies" to store limited information that\'s '
+                .'required to provide you with a consistent user experience. We don\'t store '
+                .'personally identifying or other sensitive information in these Cookies and '
+                .'these Cookies are erased when you close your Web Browser unless otherwise '
+                .'stated when you click "Show more".</p><p>If you\'re on a public computer, '
+                .'be sure to close all Web Browsers when you\'re done!</p>';
         }
 
-       //echo "<pre>".print_r($websites,1)."</pre>";
+       // echo "<pre>".print_r($currentSite,1)."</pre>";
        // echo "<pre>".print_r($stats,1)."</pre>";
 
         // Compile template data
         $templateData = array(
-            'baseURL'           => admin_url(),
-            'reportDate'        => date('m/d/Y'),
-            'haveStats'         => $haveStats,
-            'connected'         => $this->connected,
-            'connectError'      => $this->connectError,
-            'serverStats'       => $stats,
-            'thisDate'          => $thisDate,
-            'thisDateTime'      => $thisDateTime,
-            'thisMonth'         => $thisMonth,
-            'thisMonthTime'     => $thisMonthTime,
-            'website'           => $this->website,
-            'websiteId'         => $this->siteId,
-            'target'            => $this->target,
-            'diskTarget'        => $this->disk_target,
-            'threshold'         => $this->threshold,
-            'send_enabled'      => $this->send_enabled,
-            'websites'          => $websites,
-            'isProvider'        => apply_filters('glm-serverstats-is-provider', false),
-            'site_sort'         => $site_sort,
-            'selectedSite'      => $selectedSite,
-            'settings'          => $settings
+            'baseURL'               => admin_url(),
+            'reportDate'            => date('m/d/Y'),
+            'haveStats'             => $haveStats,
+            'serverStats'           => $stats,
+            'thisDate'              => $thisDate,
+            'thisDateTime'          => $thisDateTime,
+            'thisMonth'             => $thisMonth,
+            'thisMonthTime'         => $thisMonthTime,
+            'threshold'             => get_option(GLM_SERVERSTATS_PLUGIN_THRESHOLD_OPTION),
+            'sendReportsEnabled'    => get_option(GLM_SERVERSTATS_PLUGIN_SEND_OPTION),
+            'websites'              => $websites,
+            'isProvider'            => apply_filters('glm-serverstats-is-provider', false),
+            'site_sort'             => $site_sort,
+            'currentSite'           => $currentSite,
+            'policyPageSlug'        => $policyPageSlug,
+            'moreInfoUrl'           => $moreInfoUrl,
+            'glmFromContact'        => get_option(GLM_SERVERSTATS_PLUGIN_REPORT_CONTACT)
         );
 
         //echo "<pre>".print_r($templateData,1)."</pre>";
diff --git a/models/adminServerStatsConfig.php b/models/adminServerStatsConfig.php
deleted file mode 100755 (executable)
index 5e3749e..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-<?php
-/**
- * Gaslight Media - GLM Bandwidth
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package  glmServerStats
- * @author   Chuck Scott <cscott@gaslightmedia.com>
- * @license  http://www.gaslightmedia.com Gaslightmedia
- * @release  serverStats.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
- * @link     http://dev.gaslightmedia.com/
- */
-
-// Load Management Server Stats data abstract
-require_once GLM_SERVERSTATS_PLUGIN_CLASS_PATH.'/serverBandwidthSupport.php';
-
-/**
- * GLM Bandwidth Config Class
- *
- * PHP version 5
- *
- * @category Model
- * @package glmServerStats
- * @author  Chuck Scott <cscott@gaslightmedia.com>
- * @license http://www.gaslightmedia.com Gaslightmedia
- *          @release SVN: $Id: serverStats.php,v 1.0 2011/01/25 19:31:47 cscott
- *          Exp $
- */
-class adminServerStatsConfig extends glmServerStatsBandwidthSupport
-{
-
-    /*
-     * Constructor
-     *
-     * No work is performed by this contructor
-    */
-    public function __construct()
-    {
-    }
-
-    /*
-     * Model
-     *
-     * Gets, displays, and updates the configuration data for this plugin.
-     *
-     * @return array Array the view to use and data for the view
-     */
-    public function model()
-    {
-
-        $connectError           = false;
-        $connectionUpdated      = false;
-        $forceReload            = false;
-        $reloadUrl              = false;
-        $autoInsertDefault      = false;
-
-        // If an update was submitted
-        $option = 'none';
-        if (isset($_REQUEST['option'])) {
-            $option = $_REQUEST['option'];
-        }
-
-        $startingConfig = $this->getConfig();
-
-        // If this is a connection update, store that
-        if ($option == 'update_connection') {
-
-            // Filter the input data
-            $config = filter_input_array( INPUT_POST,
-                array(
-                    'show_usage'                    => FILTER_VALIDATE_BOOLEAN,
-                    'send_usage'                    => FILTER_VALIDATE_BOOLEAN,
-                    'send_percent'                  => FILTER_VALIDATE_INT,
-                    'show_notifications'            => FILTER_VALIDATE_BOOLEAN,
-                    'show_cookie_popup'             => FILTER_VALIDATE_BOOLEAN,
-                    'cookie_popup_timeout'          => FILTER_VALIDATE_INT,
-                    'cookie_message'                => FILTER_SANITIZE_STRING,
-                    'cookie_opt_gdpr'               => FILTER_VALIDATE_BOOLEAN,
-                    'cookie_opt_access_logs'        => FILTER_VALIDATE_BOOLEAN,
-                    'cookie_opt_permanent'          => FILTER_VALIDATE_BOOLEAN,
-                    'cookie_opt_tracking'           => FILTER_VALIDATE_BOOLEAN,
-                    'cookie_opt_shared_tracking'    => FILTER_VALIDATE_BOOLEAN,
-                    'cookie_opt_https'              => FILTER_VALIDATE_BOOLEAN,
-                    'cookie_opt_logged_in'          => FILTER_VALIDATE_BOOLEAN,
-                    'cookie_opt_forms'              => FILTER_VALIDATE_BOOLEAN,
-                    'cookie_opt_payment'            => FILTER_VALIDATE_BOOLEAN,
-                    'db_name'                       => FILTER_SANITIZE_STRING,
-                    'db_host'                       => FILTER_SANITIZE_STRING,
-                    'db_user'                       => FILTER_SANITIZE_STRING,
-                    'db_pass'                       => FILTER_SANITIZE_STRING,
-                    'website'                       => FILTER_SANITIZE_STRING
-                )
-            );
-
-
-            // Update the WordPress option where we store the configuration for this plugin
-            update_option(GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION, $config);
-
-            $connectionUpdated = true;
-
-            // If turning off show_usage, make sure we reload with a valid URL
-            if ($startingConfig['show_usage'] != $config['show_usage']) {
-                if ($config['show_usage']) {
-                    $reloadUrl = '?page=glm-server-stats-configure';
-                } else {
-                    $reloadUrl = '?page=glm-server-stats-main-menu';
-                }
-                $forceReload = true;
-            }
-
-        // Otherwise get existing connection configuration
-        } else {
-            $config = $this->getConfig();
-        }
-
-        if (trim($config['cookie_message']) == '') {
-            $config['cookie_message'] =
-                '<p>This site uses temporary "Cookies" to store limited information that\'s '
-                .'required to provide you with a consistent user experience. We don\'t store '
-                .'personally identifying or other sensitive information in these Cookies and '
-                .'these Cookies are erased when you close your Web Browser unless otherwise '
-                .'stated when you click "Show more".</p><p>If you\'re on a public computer, '
-                .'be sure to close all Web Browsers when you\'re done!</p>';
-            $autoInsertDefault = true;
-        }
-
-        // Connect to database
-        $connected = $this->bandwidthDataConnect();
-
-        // If we can connect to the database
-        if ($connected) {
-            $websiteId = $this->siteId;
-
-        // If we can't, get the reason why
-        } else {
-            $connectError = $this->connectError;
-        }
-
-        // Compile template data
-        $templateData = array_merge(
-            $config,
-            array(
-                'forceReload'           => $forceReload,
-                'reloadUrl'             => $reloadUrl,
-                'isProvider'            => apply_filters('glm-serverstats-is-provider', false),
-                'connectionUpdated'     => $connectionUpdated,
-                'connectError'          => $connectError,
-                'autoInsertDefault'     => $autoInsertDefault
-            )
-        );
-
-        // echo "<pre>".var_dump($templateData,1)."</pre>";
-
-        // Return status, suggested view, and data to controller
-        return array(
-            'view' => 'adminServerStatsConfig',
-            'data' => $templateData
-        );
-
-    }
-
-
-
-}
-
-?>
\ No newline at end of file
index 18b3297..1c01242 100755 (executable)
@@ -21,13 +21,6 @@ require_once GLM_SERVERSTATS_PLUGIN_CLASS_PATH.'/serverBandwidthSupport.php';
 class ajaxSendUsageReport  extends glmServerStatsBandwidthSupport
 {
 
-    /*
-     * Connected
-     *
-     * @var $connected
-     * @access public
-     */
-    public $connected = false;
     /*
      * Constructor
      *
@@ -57,15 +50,16 @@ class ajaxSendUsageReport  extends glmServerStatsBandwidthSupport
             // Check input
         $site = filter_input( INPUT_GET, 'selected_site', FILTER_SANITIZE_STRING);
         $display = filter_input( INPUT_GET, 'display_only', FILTER_SANITIZE_STRING);
+        $sendOverride = filter_input( INPUT_GET, 'send_override', FILTER_SANITIZE_STRING);
 
         $displayOnly = false;
         if ($display == 'true') {
            $displayOnly = true;
         }
 
-        // If Display is not requested, must be a real send so check if sending is enabled.
+        // If Display is not requested, must be a real send so check if sending is enabled and override not set.
         $send_enabled = get_option(GLM_SERVERSTATS_PLUGIN_SEND_OPTION);
-        if (!$displayOnly && !$send_enabled) {
+        if (!$displayOnly && !$send_enabled && !$sendOverride) {
             echo "<h3>Sending of notification E-Mail is dissabled!</h3>";
             wp_die();
         };
@@ -75,12 +69,6 @@ class ajaxSendUsageReport  extends glmServerStatsBandwidthSupport
 
             echo "<h2>".($displayOnly?'Displaying':'Sending')." requested usage notificaton.</h2>";
 
-            $this->connected = $this->bandwidthDataConnect($site);
-            if (!$this->connected) {
-                echo "<p>ERROR: Failed to connect to usage database.</p>";
-                wp_die();
-            }
-
             echo "<hr>";
 
             $res = $this->checkEmailNotifications(true, true, true, $site, $displayOnly);
@@ -91,13 +79,6 @@ class ajaxSendUsageReport  extends glmServerStatsBandwidthSupport
 
             echo "<h2>".($displayOnly?'Displaying':'Sending')." all usage notificatons above notification target.</h2>";
 
-            $this->connected = $this->bandwidthDataConnect();
-
-            if (!$this->connected) {
-                echo "<p>ERROR: Failed to connect to usage database.</p>";
-                wp_die();
-            }
-
             $res = $this->checkEmailNotifications(true, true, false, false, $displayOnly);
 
         }
index a888883..ae84436 100755 (executable)
@@ -65,10 +65,9 @@ class ajaxServerBandwidthGraphs  extends glmServerStatsBandwidthSupport
     public function model()
     {
 
-            $websiteSelected = filter_input( INPUT_GET, 'selected_site', FILTER_SANITIZE_STRING);
+        $websiteSelected = filter_input( INPUT_GET, 'selected_site', FILTER_SANITIZE_STRING);
 
-        // Connect to Bandwidth Database selected in the Configure page
-        $this->bandwidthDataConnect($websiteSelected);
+        $siteSettings = bandwidthGetWebsiteSettingsFromName($websiteSelected);
 
         $graphType = $_REQUEST['graphType'];
 
@@ -106,7 +105,7 @@ class ajaxServerBandwidthGraphs  extends glmServerStatsBandwidthSupport
         }
 
         // Get bandwidth data for today
-        $data = $this->bandwidthGetGraphData($graphType, $this->siteId, $refDate);
+        $data = $this->bandwidthGetGraphData($graphType, $siteSettings['websitepk'], $refDate);
 
         if (!$data || !is_array($data) || count($data) == 0) {
             die("Unable to get data. Is connection configured?");
@@ -141,13 +140,13 @@ class ajaxServerBandwidthGraphs  extends glmServerStatsBandwidthSupport
 
         // Check if we received a target value with our graph data and if so display it
         $targetValue = 0;
-        if ($useTarget && $this->target) {
-            $graph->setGoalLine(($this->target), "purple", "dashed");
-            $title .= ' - Target: '.$this->target.' Gigabytes';
+        if ($useTarget && $siteSettings['target']) {
+            $graph->setGoalLine($siteSettings['target'], "purple", "dashed");
+            $title .= ' - Target: '.$siteSettings['target'].' Gigabytes';
         }
-        if ($useDiskTarget && $this->disk_target) {
-            $graph->setGoalLine(($this->disk_target), "purple", "dashed");
-            $title .= ' - Target: '.$this->disk_target.' Gigabytes';
+        if ($useDiskTarget && $siteSettings['disk_target']) {
+            $graph->setGoalLine($siteSettings['disk_target'], "purple", "dashed");
+            $title .= ' - Target: '.$siteSettings['disk_target'].' Gigabytes';
         }
 
         $graph->setTitle($data['site_name'].'    '.$title.'    From '.substr($data['start'],0,10).' Through '.substr($data['end'],0,10));
index 0d0f250..3d28d84 100755 (executable)
@@ -1,8 +1,9 @@
 <?php
 // Get Configuration for Cookie info popup
-$serverstatsConfig = get_option(GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION);
+
 $policyPageSlug = sanitize_title(GLM_SERVERSTATS_PLUGIN_POLICY_PAGE);
 $moreInfoURL = GLM_SERVERSTATS_SITE_BASE_URL."/".$policyPageSlug;
+
 ?>
 <style>
     #cookieNoticeBox {
index 8bfabb8..f7b784f 100755 (executable)
@@ -61,9 +61,6 @@ class serverUsageTargetCheck  extends glmServerStatsBandwidthSupport
             $this->website = $websiteIn;
         }
 
-        // Connect to Bandwidth Database selected in the Configure page
-        $connected = $this->bandwidthDataConnect($this->website);
-
         if (GLM_SERVERSTATS_PLUGIN_DEBUG) {
             $debugTimeUsed = microtime(true) - $debugStartTime;
             trigger_error("GLM Usage - serverUsageTargetCheck::__construct() called: Time = $debugTimeUsed", E_USER_NOTICE );
index 01a291a..903a407 100644 (file)
@@ -60,11 +60,8 @@ add_filter('glm_associate_cron_request', function($request) {
 $user_is_admin  = current_user_can( 'administrator' );
 $user_is_editor = current_user_can( 'editor' );
 
-// Get Configuration
-$serverstatsConfig = get_option( GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION );
-
 // If this site should show notifications and is a high-level user - Check for notifications
-if ( $serverstatsConfig['show_notifications'] && ( $user_is_admin || $user_is_editor ) ) {
+if ( $user_is_admin || $user_is_editor ) {
     add_action(
         'admin_init',
         function(){
index 04911bb..72b2e38 100755 (executable)
  * @link     http://dev.gaslightmedia.com/
  */
 
-$serverstatsConfig = get_option(GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION);
-$mainServerStatsMenuSlug = 'glm-server-stats-main-menu';
-
 // Have to be either an Editor or Administration to see usage
 if (current_user_can('editor') || current_user_can('administrator')) {
 
-    // If we're showing usage - Make that the menu item
-    if ($serverstatsConfig['show_usage']) {
-
-        add_menu_page(
-            "GLM Data Usage",
-            'GLM Data Usage',
-            'edit_pages',
-            $mainServerStatsMenuSlug,
-            function() {
-                serverStatsController('adminServerStats');
-            },
-            GLM_SERVERSTATS_PLUGIN_ASSETS_URL.'/flame.png',
-            '3.100'
-        );
-
-        // If the user is an administrator they can also do config
-        if (current_user_can('administrator')) {
-            add_submenu_page(
-                $mainServerStatsMenuSlug,
-                'Configure',
-                'Configure',
-                'manage_options',
-                'glm-server-stats-configure',
-                function() {
-                    serverStatsController('adminServerStatsConfig');
-                }
-            );
-        }
-
-    // Otherwise, if we're an administrator, then just show configuration
-    } elseif (current_user_can('administrator')) {
-
-        add_menu_page(
-            "GLM Data Usage",
-            'GLM Data Usage',
-            'edit_pages',
-            $mainServerStatsMenuSlug,
-            function() {
-                serverStatsController('adminServerStatsConfig');
-            },
-            GLM_SERVERSTATS_PLUGIN_ASSETS_URL.'/flame.png',
-            '3.100'
-        );
-
-    }
-
-    if ($serverstatsConfig['show_notifications']) {
-        add_menu_page(
-            'GLM Notifications',
-            'GLM Notifications',
-            'edit_pages',
-            'glm-info-main-menu',
-            function(){
-                serverStatsController('glmInfoNotifications');
-            },
-            GLM_SERVERSTATS_PLUGIN_ASSETS_URL.'/flame.png',
-            '3.200'
-        );
-    }
+    global $websiteSettings;
+
+    // If show usage is enabled from main site or if administrator, show usage menu
+    if( $websiteSettings['show_usage'] || current_user_can('administrator') )
+    add_menu_page(
+        "GLM Data Usage",
+        'GLM Data Usage',
+        'edit_pages',
+        'glm-server-stats-main-menu',
+        function() {
+            serverStatsController('adminServerStats');
+        },
+        GLM_SERVERSTATS_PLUGIN_ASSETS_URL.'/flame.png',
+        '3.100'
+    );
+
+    add_menu_page(
+        'GLM Notifications',
+        'GLM Notifications',
+        'edit_pages',
+        'glm-info-main-menu',
+        function(){
+            serverStatsController('glmInfoNotifications');
+        },
+        GLM_SERVERSTATS_PLUGIN_ASSETS_URL.'/flame.png',
+        '3.200'
+    );
 
 }
index cb45622..5544f37 100644 (file)
@@ -14,7 +14,6 @@
  */
 
 // Common to both admin and front-end
-$smarty->templateAssign('glmPluginsContactEmail', GLM_SERVERSTATS_CONTACT_EMAIL);
 $smarty->templateAssign('glmSiteTitle', GLM_SERVERSTATS_SITE_TITLE);
 $smarty->templateAssign('glmPluginName', GLM_SERVERSTATS_PLUGIN_NAME );
 $smarty->templateAssign('siteBaseUrl', GLM_SERVERSTATS_SITE_BASE_URL);
index cea305a..a1868f9 100755 (executable)
         font-weight: bold;
     }
 </style>
-{if !$connected}
 
-    <h1>Server Data Usage Unavailable</h1>
-    <h4>{$connectError}</h4>
+{if !$haveStats}
+    <h3 class="glm-error">This application has not been configured. Please ask Gaslight Media this for your Website.</h3>
+    <p><b>Error:</b> {$connectError}</p>
+{else}
 
     {if apply_filters('glm-serverstats-is-provider', false)}
-        <p>Please check GLM Server Usage configuration menu!</p>
-    {else}
-        <p>Please contact your system administrator for assistance.</p>
-    {/if}
+        <div class="usage-section">Service Provider Section</div>
 
-{else}
+            {* Grid Start *}
+            {$ui = [
+                'sectionColor'      => '#ffE',
+                'nowrap'            => true
+            ]}
+            {include file="ui/f6/grid-start.html"}
 
-    {if !$haveStats}
-        <h3 class="glm-error">This application has not been configured. Please ask Gaslight Media this for your Website.</h3>
-        <p><b>Error:</b> {$connectError}</p>
-    {else}
+                {* Section Start *}
+                {$ui = [
+                    'title'     => 'Site Selection'
+                ]}
+                {include file="ui/f6/section-start.html"}
+
+                    {* Misc Container Start *}
+                    {include file="ui/f6/miscContainer-start.html"}
+
+                        {* Form Start *}
+                        {$ui = [
+                            'action'    => "{$thisUrl}?page={$thisPage}&selected_site={$currentSite.name}",
+                            'method'    => 'POST'
+                        ]}
+                        {include file="ui/f6/form-start.html"}
+
+                            <div class="grid-x grid-margin-x">
+                                <div style="whitespace: nowrap;">
+                                    <span class="sortBy">Sort By: </span>
+                                    <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={$currentSite.name}';">Site Name
+                                </div>
+                                <div style="whitespace: nowrap;">
+                                    <span class="sortBy">Traffic: </span>
+                                    <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={$currentSite.name}';">Total
+                                    <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={$currentSite.name}';">Percent
+                                </div>
+                                <div style="whitespace: nowrap;">
+                                    <span class="sortBy">Storage: </span>
+                                    <input type="radio" name="site_sort" value="storage" {if $site_sort == 'storage'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=storage&selected_site={$currentSite.name}';">Maximum
+                                    <input type="radio" name="site_sort" value="disk_target_percent" {if $site_sort == 'disk_target_percent'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=disk_target_percent&selected_site={$currentSite.name}';">Percent
+                                </div>
+                            </div>
+                            <div style="overflow-x: auto;">
+                                <div class="pickContainer">
+                                    <pre class="">                                                   ----------------- Traffic -------------   --------------- Storage --------------</pre>
+                                    <pre class="pseudoPickTitles">Website                                            Last Month       Target     % of Target   Last Month      Target     % of Target</pre>
+                                    <div class="pseudoPick">
+                                        {foreach $websites as $site}
+                                            <pre class="pseudoPickOption"></span>{if $site.name == $currentSite.name}<a name="selectedSite"></a>{/if}<a href="{$thisUrl}?page={$thisPage}&selected_site={$site.name}&site_id={$site.id}&site_sort={$site_sort}" class="pseudoPickOption" {if $site.name == $currentSite.name}onClick="return false;"{/if}><span{if $site.name == $currentSite.name} style="background-color: LightGray;"{/if}>{$site.name|string_format:"%-50s"} {$site.data_total|string_format:"%6.1f"} GB   {$site.target|string_format:"%8.1f"} GB     <span {if $site.target_percent > $threshold}style="color: red;"{/if}>{$site.target_percent|string_format:"%6.0f"}%</span>      {$site.storage|string_format:"%6.1f"} GB   {$site.disk_target|string_format:"%8.1f"} GB      <span {if $site.disk_target_percent > $threshold}style="color: red;"{/if}>{$site.disk_target_percent|string_format:"%6.0f"}%</span></span></a></pre>
+                                        {/foreach}
+                                    </div>
+                                  </div>
+                            </div>
+                            <p>Click on a site above to display settings and charts.</p>
+                            <div class="grid-x grid-margin-x">
+                                <div class="cell small-12 large-5 glm-f6-ui-nowrap">
+                                    <b>Send Usage Report for Selected Site:</b>
+                                    <a href="{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxSendUsageReport&selected_site={$currentSite.name}&send_override=1" target="usageEmail" class="button button-secondary button-small button-wrappable">Send for selected site</a>
+                                </div>
+                                <div class="cell small-12 large-7 glm-f6-ui-nowrap">
+                                    <b>Preview Usage Report:</b>
+                                    <a href="{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxSendUsageReport&selected_site={$currentSite.name}&display_only=true" target="usageEmail" class="button button-secondary button-small button-wrappable">Display for site selected site</a>
+                                    <a href="{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxSendUsageReport&display_only=true" target="usageEmail" class="button button-secondary button-small button-wrappable">Display for all sites above threashold</a>
+                                </div>
+                                <div class="cell small-12 large-12 glm-f6-ui-nowrap">
+                                    <br>Note that the "Send E-Mail" button above will send the E-Mail even if the global "Enable Sending Usage Reports" setting below is set to off.
+                                </div>
+                            </div>
+
+                        {include file="ui/f6/form-end.html"}
+
+                    {include file="ui/f6/miscContainer-end.html"}
 
-        {if apply_filters('glm-serverstats-is-provider', false)}
-            <div class="usage-section">Service Provider Section</div>
+                {include file="ui/f6/section-end.html"}
 
+            {* Grid End *}
+            {$ui = [
+                'noFoundationInit'     => true
+            ]}
+            {include file="ui/f6/grid-end.html"}
+
+            {* Form Start *}
+            {$ui = [
+                'action'    => "{$thisUrl}?page={$thisPage}&selected_site={$currentSite.name}",
+                'method'    => 'POST',
+                'validate'  => true,
+                'validateFocusMsg' => true,
+                'leaveModifiedFormCheck' => true
+            ]}
+            {include file="ui/f6/form-start.html"}
+
+                <input type="hidden" name="option" value="update_site">
+                <input type="hidden" name="site_sort" value="$site_sort">
+                <input type="hidden" name="selected_site" value="{$currentSite.name}">
 
                 {* Grid Start *}
                 {$ui = [
                 ]}
                 {include file="ui/f6/grid-start.html"}
 
-                    {* Section Start *}
+                    {* Form Summary Start *}
                     {$ui = [
-                        'title'     => 'Site Selection'
+                        'id'                => 'usageSettings',
+                        'title'             => 'Usage Report Settings'
                     ]}
-                    {include file="ui/f6/section-start.html"}
+                    {include file="ui/f6/form-summary-start.html"}
 
-                        {* Misc Container Start *}
-                        {include file="ui/f6/miscContainer-start.html"}
+                        <div class="cell small-12 callout glm-f6-ui-section-start">
+                            <div class="grid-x grid-margin-x">
 
-                            {* Form Start *}
-                            {$ui = [
-                                'action'    => "{$thisUrl}?page={$thisPage}&selected_site={$selectedSite}",
-                                'method'    => 'POST'
-                            ]}
-                            {include file="ui/f6/form-start.html"}
-
-                                <div class="grid-x grid-margin-x">
-                                    <div style="whitespace: nowrap;">
-                                        <span class="sortBy">Sort By: </span>
-                                        <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
-                                    </div>
-                                    <div style="whitespace: nowrap;">
-                                        <span class="sortBy">Traffic: </span>
-                                        <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
-                                        <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
-                                    </div>
-                                    <div style="whitespace: nowrap;">
-                                        <span class="sortBy">Storage: </span>
-                                        <input type="radio" name="site_sort" value="storage" {if $site_sort == 'storage'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=storage&selected_site={$selectedSite}';">Maximum
-                                        <input type="radio" name="site_sort" value="disk_target_percent" {if $site_sort == 'disk_target_percent'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=disk_target_percent&selected_site={$selectedSite}';">Percent
-                                    </div>
-                                </div>
-                                <div style="overflow-x: auto;">
-                                    <div class="pickContainer">
-                                        <pre class="">                                                   ----------------- Traffic -------------   --------------- Storage --------------</pre>
-                                        <pre class="pseudoPickTitles">Website                                            Last Month       Target     % of Target   Last Month      Target     % of Target</pre>
-                                        <div class="pseudoPick">
-                                            {foreach $websites as $site}
-                                                <pre class="pseudoPickOption"></span>{if $site.name == $selectedSite}<a name="selectedSite"></a>{/if}<a href="{$thisUrl}?page={$thisPage}&selected_site={$site.name}&site_id={$site.id}&site_sort={$site_sort}" class="pseudoPickOption" {if $site.name == $selectedSite}onClick="return false;"{/if}><span{if $site.name == $selectedSite} style="background-color: LightGray;"{/if}>{$site.name|string_format:"%-50s"} {$site.data_total|string_format:"%6.1f"} GB   {$site.target|string_format:"%8.1f"} GB     <span {if $site.target_percent > $threshold}style="color: red;"{/if}>{$site.target_percent|string_format:"%6.0f"}%</span>      {$site.storage|string_format:"%6.1f"} GB   {$site.disk_target|string_format:"%8.1f"} GB      <span {if $site.disk_target_percent > $threshold}style="color: red;"{/if}>{$site.disk_target_percent|string_format:"%6.0f"}%</span></span></a></pre>
-                                            {/foreach}
-                                        </div>
-                                      </div>
-                                </div>
-                                <p>Click on a site above to display settings and charts.</p>
-                                {if $selectedSite}
-                                    <div class="grid-x grid-margin-x">
-                                        <div class="cell small-12 large-4 glm-f6-ui-nowrap">
-                                            <b>Send E-Mail:</b>
-                                            <a href="{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxSendUsageReport&selected_site={$selectedSite}" target="usageEmail" class="button button-secondary button-small button-wrappable">Send for selected site</a>
-                                        </div>
-                                        <div class="cell small-12 large-8 glm-f6-ui-nowrap">
-                                            <b>Preview E-Mail:</b>
-                                            <a href="{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxSendUsageReport&selected_site={$selectedSite}&display_only=true" target="usageEmail" class="button button-secondary button-small button-wrappable">Display for site selected site</a>
-                                            <a href="{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxSendUsageReport&display_only=true" target="usageEmail" class="button button-secondary button-small button-wrappable">Display for all sites above threashold</a>
-                                        </div>
+                                {* Sub-Section Start *}
+                                    {$ui = [
+                                    'title'     => {'Settings For: '|cat:$currentSite.name},
+                                    'wrapSize'  => 6
+                                ]}
+                                {include file="ui/f6/sub-section-start.html"}
+
+                                    <div class="cell small-12 large-12 glm-f6-ui-nowrap"><u>Usage Reporting</u></div>
+
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Monthly Traffic Target:</b></div>
+                                    <div class="cell small-12 large-7">{$currentSite.target|string_format:"%.1f"} GB</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Disk Space Usage Target:</b></div>
+                                    <div class="cell small-12 large-7">{$currentSite.disk_target|string_format:"%.1f"} GB</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Show Usage Graphs:</b></div>
+                                    <div class="cell small-12 large-7">{if $currentSite.show_usage}Yes{else}No{/if}</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Send Usage Reports:</b></div>
+                                    <div class="cell small-12 large-7">{if $currentSite.send_enabled}Yes{else}No{/if}</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Customer Usage/Notify Address:</b></div>
+                                    <div class="cell small-12 large-7">{if !empty($currentSite.cust_contact)}{$currentSite.cust_contact}{else}(Not supplied){/if}</div>
+
+                                    <div class="cell small-12 large-12 glm-f6-ui-nowrap"><br><u>Cookie Pop-Up</u></div>
+
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Show Cookie Pop-Up:</b></div>
+                                    <div class="cell small-12 large-7">{if $currentSite.show_cookie_popup}Yes{else}No{/if}</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Cookie Pop-Up Timeout:</b></div>
+                                    <div class="cell small-12 large-7">{$currentSite.cookie_popup_timeout} Days</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Cookie Message:</b></div>
+                                    <div class="cell small-12 large-7">{$currentSite.cookie_message|nl2br}</div>
+
+                                    <div class="cell small-12 large-12 glm-f6-ui-nowrap"><br><u>Privacy/Policy Page</u></div>
+
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Privacy and Policy Contact:</b></div>
+                                    <div class="cell small-12 large-7">{if !empty($currentSite.contact_name)}{$currentSite.contact_name}{else}(Name not set){/if}</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap">&nbsp;</div>
+                                    <div class="cell small-12 large-7">{if !empty($currentSite.contact_org)}{$currentSite.contact_org}{else}(Organization not set){/if}</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap">&nbsp;</div>
+                                    <div class="cell small-12 large-7">{if !empty($currentSite.contact_address)}{$currentSite.contact_address}{else}(Address line 1 not set){/if}</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap">&nbsp;</div>
+                                    <div class="cell small-12 large-7">{if !empty($currentSite.contact_address2)}{$currentSite.contact_address2}{else}(Address line 2 not set){/if}</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap">&nbsp;</div>
+                                    <div class="cell small-12 large-7">
+                                        {if !empty($currentSite.contact_city)}{$currentSite.contact_city}{else}(City not set){/if},
+                                        {if !empty($currentSite.contact_state)}{$currentSite.contact_state}{else}(State not set){/if}
+                                        {if !empty($currentSite.contact_zip)}{$currentSite.contact_zip}{else}(Zip not set){/if},
                                     </div>
-                                {/if}
-
-                            {include file="ui/f6/form-end.html"}
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Contact Phone:</b></div>
+                                    <div class="cell small-12 large-7">{if !empty($currentSite.contact_phone)}{$currentSite.contact_phone}{else}(Phone not set){/if}</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Contact E-Mail Address:</b></div>
+                                    <div class="cell small-12 large-7">{if !empty($currentSite.contact_email)}{$currentSite.contact_email}{else}(Email not set){/if}</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Privacy/Policy Page:</b></div>
+                                    <div class="cell small-12 large-7"><a href="{$moreInfoUrl}" target="policyPage">{$policyPageSlug}</a></div>
+
+                                {include file="ui/f6/sub-section-end.html"}
+
+                                {* Sub-Section Start *}
+                                    {$ui = [
+                                    'title'     => 'Global Settings',
+                                    'wrapSize'  => 6
+                                ]}
+                                {include file="ui/f6/sub-section-start.html"}
 
-                        {include file="ui/f6/miscContainer-end.html"}
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Monthly Reporting Threshold:</b></div>
+                                    <div class="cell small-12 large-7">At or above {$threshold|string_format:"%.0f"}% of site's target levels</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Enable Sending Usage Reports:</b></div>
+                                    <div class="cell small-12 large-7">{if $sendReportsEnabled}YES{else}NO{/if}</div>
 
-                    {include file="ui/f6/section-end.html"}
+                                    <div class="cell small-12 large-12 glm-f6-ui-nowrap"><br><u>Usage Report E-Mail "From:" Settings</u></div>
 
-                {* Grid End *}
-                {$ui = [
-                    'noFoundationInit'     => true
-                ]}
-                {include file="ui/f6/grid-end.html"}
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Name:</b></div>
+                                    <div class="cell small-12 large-7">{if !empty($glmFromContact.name)}{$glmFromContact.name}{else}(Name not set){/if}</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>E-Mail Address:</b></div>
+                                    <div class="cell small-12 large-7">{if !empty($glmFromContact.name)}{$glmFromContact.email}{else}(Email not set){/if}</div>
+                                    <div class="cell small-12 large-5 glm-f6-ui-nowrap"><b>Subject:</b></div>
+                                    <div class="cell small-12 large-7">{if !empty($glmFromContact.subject)}{$glmFromContact.subject}{else}(Subject not set){/if}</div>
 
-                {* Form Start *}
-                {$ui = [
-                    'action'    => "{$thisUrl}?page={$thisPage}&selected_site={$selectedSite}",
-                    'method'    => 'POST',
-                    'validate'  => true,
-                    'validateFocusMsg' => true,
-                    'leaveModifiedFormCheck' => true
-                ]}
-                {include file="ui/f6/form-start.html"}
+                                {include file="ui/f6/sub-section-end.html"}
+                            </div>
+                        </div>
 
-                    <input type="hidden" name="option" value="update_site">
-                    <input type="hidden" name="site_sort" value="$site_sort">
-                    <input type="hidden" name="selected_site" value="{$selectedSite}">
+                    {include file="ui/f6/form-summary-end.html"}
 
-                    {* Grid Start *}
+                    {* Form Edit Start *}
                     {$ui = [
-                        'sectionColor'      => '#ffE',
-                        'nowrap'            => true
+                        'id'                => 'usageSettings',
+                        'title'             => 'Edit Settings'
                     ]}
-                    {include file="ui/f6/grid-start.html"}
-
-                        {* Form Summary Start *}
-                        {$ui = [
-                            'id'                => 'usageSettings',
-                            'title'             => 'Usage Report Settings'
-                        ]}
-                        {include file="ui/f6/form-summary-start.html"}
-
-                            <div class="cell small-12 callout glm-f6-ui-section-start">
-                                <div class="grid-x grid-margin-x">
-                                    <div class="cell small-12"><h4>For Selected Site</h4></div>
-                                    <div class="cell small-12 large-3 glm-f6-ui-nowrap"><b>Selected Site:</b></div>
-                                    <div class="cell small-12 large-9">{$selectedSite}</div>
-                                    <div class="cell small-12 large-3 glm-f6-ui-nowrap"><b>Monthly Traffic Target:</b></div>
-                                    <div class="cell small-12 large-9">{$settings.target|string_format:"%.1f"}</div>
-                                    <div class="cell small-12 large-3 glm-f6-ui-nowrap"><b>Disk Space Usage Target:</b></div>
-                                    <div class="cell small-12 large-9">{$settings.disk_target|string_format:"%.1f"}</div>
-                                    <div class="cell small-12 large-3 glm-f6-ui-nowrap"><b>Customer Contact:</b></div>
-                                    <div class="cell small-12 large-9">{if !empty($settings.cust_contact)}{$settings.cust_contact}{else}(not supplied){/if}</div>
-                                    <div class="cell small-12"><br><h4>Global Settings</h4></div>
-                                    <div class="cell small-12 large-3 glm-f6-ui-nowrap"><b>Monthly Reporting Threshold:</b></div>
-                                    <div class="cell small-12 large-9">At or above {$threshold|string_format:"%.0f"}% of site's target levels</div>
-                                    <div class="cell small-12 large-3 glm-f6-ui-nowrap"><b>Send Notices Enabled:</b></div>
-                                    <div class="cell small-12 large-9">{if !empty($send_enabled)}YES{else}NO{/if}</div>
-                                </div>
-                            </div>
+                    {include file="ui/f6/form-edit-start.html"}
 
-                        {include file="ui/f6/form-summary-end.html"}
-
-                        {* Form Edit Start *}
+                        {* Section Start *}
                         {$ui = [
-                            'id'                => 'usageSettings',
-                            'title'             => 'Edit Settings'
+                            'title'     => {'Settings For: '|cat:$currentSite.name}
                         ]}
-                        {include file="ui/f6/form-edit-start.html"}
+                        {include file="ui/f6/section-start.html"}
 
+                            {* Note about site-specific settings *}
+                            {$ui = [
+                                'text'         => '<b>NOTE: </b>The settings below affect only the currently selected site!'
+                            ]}
+                            {include file="ui/f6/text-line.html"}
 
-                            {* Section Start *}
+                            {* Sub-Section Start *}
                             {$ui = [
-                                'title'     => 'Settings for Selected Site'
+                                'title'     => 'Usage Reporting'
                             ]}
-                            {include file="ui/f6/section-start.html"}
+                            {include file="ui/f6/sub-section-start.html"}
 
                                 {* target *}
                                 {$ui = [
                                     'field'         => 'target',
-                                    'value'         => {$settings.target|string_format:"%.1f"},
-                                    'label'         => 'Monthly Traffic Target',
+                                    'value'         => {$currentSite.target|string_format:"%.1f"},
+                                    'label'         => 'Monthly Traffic Target in Gigabytes',
                                     'required'      => true,
                                     'placeholder'   => 'i.e. 2.000 for 2 Gigabytes'
                                 ]}
                                 {* disk_target *}
                                 {$ui = [
                                     'field'         => 'disk_target',
-                                    'value'         => {$settings.disk_target|string_format:"%.1f"},
-                                    'label'         => 'Disk Space Used Target',
+                                    'value'         => {$currentSite.disk_target|string_format:"%.1f"},
+                                    'label'         => 'Disk Space Used Target in Gigabytes',
                                     'required'      => true,
                                     'placeholder'   => 'i.e. 2.000 for 2 Gigabytes'
                                 ]}
                                 {include file="ui/f6/text.html"}
 
+                                {* show_usage *}
+                                {$ui = [
+                                    'field'         => 'show_usage',
+                                    'value'         => {!empty($currentSite.show_usage)},
+                                    'label'         => 'Show Traffic and Disk Usage Information & Graphs',
+                                    'helpText'      => 'Turn this on to show traffic and disk ussage information on this site.'
+
+                                ]}
+                                {include file="ui/f6/checkbox.html"}
+
+                                {* Send Enabled *}
+                                {$ui = [
+                                    'field'         => 'send_enabled',
+                                    'value'         => {$currentSite.send_enabled},
+                                    'label'         => 'Send Usage Reports',
+                                    'helpText'      => '
+                                                        Turn this on to have monthly notices sent to site contacts (below) when
+                                                        close to or above the reporting threashold.
+                                                       '
+                                ]}
+                                {include file="ui/f6/checkbox.html"}
+
                                 {* cust_contact *}
                                 {$ui = [
                                     'field'         => 'cust_contact',
-                                    'value'         => {$settings.cust_contact},
+                                    'value'         => {$currentSite.cust_contact},
                                     'label'         => 'Customer Contact E-Mail',
                                     'required'      => false,
                                     'helpText'      => 'Leave empty to prevent any E-mail from being sent for this site.'
                                 ]}
                                 {include file="ui/f6/text.html"}
 
-                            {include file="ui/f6/section-end.html"}
+                           {include file="ui/f6/sub-section-end.html"}
+
+                           {* Sub-Section Start *}
+                                {$ui = [
+                                'title'     => 'Cookie Pop-Ups for This Site',
+                                'tip'       => '
+                                                This section enables and sets parameters for the &quot;Cookie Popup&quot; that
+                                                will be displayed to a front-end user until they click to confirm that they
+                                                have read this popup. The popup will redisplay after the sent number of days
+                                                selected below.
+                                                See &quot;Additional Notices&quot; to select other standard
+                                                notices to display based on what is included in Web site.
+                                                '
+                            ]}
+                            {include file="ui/f6/sub-section-start.html"}
+
+                                {* show_cookie_popup *}
+                                {$ui = [
+                                    'field'         => 'show_cookie_popup',
+                                    'value'         => {!empty($currentSite.show_cookie_popup)},
+                                    'label'         => 'Show Cookie Pop-Up'
+                                ]}
+                                {include file="ui/f6/checkbox.html"}
+
+                                {* cookie_popup_timeout *}
+                                {$ui = [
+                                    'field'         => 'cookie_popup_timeout',
+                                    'value'         => {$currentSite.cookie_popup_timeout},
+                                    'label'         => 'Cookie Pop-Up Re-Display Days',
+                                    'required'      => true,
+                                    'min'           => 0,
+                                    'max'           => 365,
+                                    'width'         => 5,
+                                    'helpText'      => 'Number of days after user accepts the cookie pop-up that it will display again.
+                                                        <b>Do not set to a real high number. Consider 10-30 days. Set to 0 to test Cookie Popups.</b>',
+                                    'errorText'     => 'Must be between 0 and 365 days!'
+                                ]}
+                                {include file="ui/f6/number.html"}
+
+                                {* cookie_message *}
+                                {$ui = [
+                                    'field'         => 'cookie_message',
+                                    'value'         => {$currentSite.cookie_message},
+                                    'label'         => 'Cookies Pop-Up Text',
+                                    'required'      => true,
+                                    'teeny'         => true,
+                                    'rows'          => 10,
+                                    'helpText'      => '
+                                                        This is the text for the Cookie Pop-Up.
+                                                        Additional privacy and policity text is displayed on the Privacy/Policy page that is
+                                                        created automatically when this plugin is activated on a Website. That policy page
+                                                        contains standard text and may be editied using the WordPress page editor on
+                                                        the selected site.
+                                                       '
+                                ]}
+                                {include file="ui/f6/editor.html"}
+
+                            {include file="ui/f6/sub-section-end.html"}
+
+                            {* Sub-Section Start *}
+                            {$ui = [
+                                'title'     => 'Privacy/Policy Page Contact Information'
+                            ]}
+                            {include file="ui/f6/sub-section-start.html"}
+
+                                {* contact_name *}
+                                {$ui = [
+                                    'field'         => 'contact_name',
+                                    'value'         => {$currentSite.contact_name},
+                                    'label'         => 'Contact Name',
+                                    'placeholder'   => 'Name of contact person/role for Pivacy/Policy questions'
+                                ]}
+                                {include file="ui/f6/text.html"}
+
+                                {* contact_org *}
+                                {$ui = [
+                                    'field'         => 'contact_org',
+                                    'value'         => {$currentSite.contact_org},
+                                    'label'         => 'Organization',
+                                    'placeholder'   => 'Name of contact organization for Pivacy/Policy questions'
+                                ]}
+                                {include file="ui/f6/text.html"}
+
+                                {* contact_address *}
+                                {$ui = [
+                                    'field'         => 'contact_address',
+                                    'value'         => {$currentSite.contact_address},
+                                    'label'         => 'Address'
+                                ]}
+                                {include file="ui/f6/text.html"}
+
+                                {* contact_address2 *}
+                                {$ui = [
+                                    'field'         => 'contact_address2',
+                                    'value'         => {$currentSite.contact_address2},
+                                    'label'         => ''
+                                ]}
+                                {include file="ui/f6/text.html"}
+
+                                {* contact_city *}
+                                {$ui = [
+                                    'field'         => 'contact_city',
+                                    'value'         => {$currentSite.contact_city},
+                                    'label'         => 'City'
+                                ]}
+                                {include file="ui/f6/text.html"}
+
+                                {* contact_state *}
+                                {$ui = [
+                                    'field'         => 'contact_state',
+                                    'value'         => {$currentSite.contact_state},
+                                    'label'         => 'State'
+                                ]}
+                                {include file="ui/f6/text.html"}
+
+                                {* contact_zip *}
+                                {$ui = [
+                                    'field'         => 'contact_zip',
+                                    'value'         => {$currentSite.contact_zip},
+                                    'label'         => 'ZIP/Postal Code'
+                                ]}
+                                {include file="ui/f6/text.html"}
+
+                                {* contact_phone *}
+                                {$ui = [
+                                    'field'         => 'contact_phone',
+                                    'value'         => {$currentSite.contact_phone},
+                                    'label'         => 'Phone Number'
+                                ]}
+                                {include file="ui/f6/text.html"}
+
+                                {* contact_email *}
+                                {$ui = [
+                                    'field'         => 'contact_email',
+                                    'value'         => {$currentSite.contact_email},
+                                    'label'         => 'E-Mail Address'
+                                ]}
+                                {include file="ui/f6/text.html"}
+
+                                {* Policy Page Reference *}
+                                {$ui = [
+                                    'text'         => {'<a href="'|cat:{$moreInfoUrl}|cat:'" target="policyPage">Link to display Privacy/Policy Page</a>'}
+                                ]}
+                                {include file="ui/f6/text-line.html"}
+
+                            {include file="ui/f6/sub-section-end.html"}
 
-                            {* Section Start *}
+                        {include file="ui/f6/section-end.html"}
+
+                        {* Section Start *}
+                        {$ui = [
+                            'title'     => 'Global Settings'
+                        ]}
+                        {include file="ui/f6/section-start.html"}
+
+                            {* Sub-Section Start *}
                             {$ui = [
-                                'title'     => 'Global Settings'
+                                'title'         => '<b>NOTE: </b>The settings below affect all sites!'
                             ]}
-                            {include file="ui/f6/section-start.html"}
+                            {include file="ui/f6/sub-section-start.html"}
 
                                 {* Reporting Threshold *}
                                 {$ui = [
                                 ]}
                                 {include file="ui/f6/number.html"}
 
-                                {* Send Enabled *}
+                                {* sent_report_enabled *}
                                 {$ui = [
-                                    'field'         => 'send_enabled',
-                                    'value'         => {$send_enabled},
-                                    'label'         => 'Send Notices',
-                                    'helpText'      => '
-                                                        Turn this on to have monthly notices set to site contacts for sites
-                                                        above the reporting threashold.
-                                                       '
+                                    'field'         => 'send_reports_enabled',
+                                    'value'         => {!empty($sendReportsEnabled)},
+                                    'label'         => 'Enable Sending Usage Reports'
                                 ]}
                                 {include file="ui/f6/checkbox.html"}
 
-                            {include file="ui/f6/section-end.html"}
+                            {include file="ui/f6/sub-section-end.html"}
 
-                            {* Submit Button *}
+                            {* Sub-Section Start *}
                             {$ui = [
-                                'class'     => 'primary',
-                                'label'     => 'Update Site Settings',
-                                'submit'    => true
+                                'title'         => 'Usage Report E-mail "From" Information'
                             ]}
-                            {include file="ui/f6/submit.html"}
+                            {include file="ui/f6/sub-section-start.html"}
 
-                        {include file="ui/f6/form-edit-end.html"}
+                                {* Report From Name *}
+                                {$ui = [
+                                    'field'         => 'report_contact_name',
+                                    'value'         => {$glmFromContact.name},
+                                    'label'         => 'Name or Role of contact',
+                                    'required'      => true
+                                ]}
+                                {include file="ui/f6/text.html"}
 
-                    {include file="ui/f6/grid-end.html"}
+                                {* Report From E-Mail Address *}
+                                {$ui = [
+                                    'field'         => 'report_contact_email',
+                                    'value'         => {$glmFromContact.email},
+                                    'label'         => 'E-Mail Address',
+                                    'required'      => true
+                                ]}
+                                {include file="ui/f6/text.html"}
+
+                                {* Report E-mail Subject *}
+                                {$ui = [
+                                    'field'         => 'report_subject',
+                                    'value'         => {$glmFromContact.subject},
+                                    'label'         => 'Subject',
+                                    'required'      => true
+                                ]}
+                                {include file="ui/f6/text.html"}
+
+                            {include file="ui/f6/sub-section-end.html"}
 
-                {include file="ui/f6/form-end.html"}
+                        {include file="ui/f6/section-end.html"}
 
-            <div class="usage-section">Customer Section</div>
+                        {* Submit Button *}
+                        {$ui = [
+                            'class'     => 'primary',
+                            'label'     => 'Update All Settings',
+                            'submit'    => true
+                        ]}
+                        {include file="ui/f6/submit.html"}
+
+                    {include file="ui/f6/form-edit-end.html"}
 
-        {else}
+                {include file="ui/f6/grid-end.html"}
 
-            <div class="usage-section">Website Data Usage</div>
+            {include file="ui/f6/form-end.html"}
 
-        {/if} {* /is provider *}
+        <div class="usage-section">Customer Section</div>
 
-        <!-- Server Data Usage Stats -->
-        <div style="max-width: 1200px;" class="callout">
-            <center style="margin-bottom: 1rem;">
-                <span class="button button-secondary" id="guideButton">Explanation of Usage and Graphs</span>
-                &nbsp;&nbsp;<span class="button button-secondary graph-print" data-areaToPrint="StatsPrintArea">Print Page</span>
-            </center>
-            <div id="usageGuide">
-                <div class="usage-item grid-x grid-margin-x">
-                    <div class="cell small-12 medium-2 color-key-traffic">Traffic</div>
-                    <div class="cell small-12 medium-10">
-                        The data sent and received by this Web site.
-                        Traffic is displayed below in <b>Megabytes</b> or <b>Gigabytes</b>.
-                        A byte is roughly equivalent to one character, a Megabyte is roughly one Million characters,
-                        and a Gigabyte is roughtly one Trillion characters.
-                    </div>
+    {else}
+
+        <div class="usage-section">Website Data Usage</div>
+
+    {/if} {* /is provider *}
+
+    <!-- Server Data Usage Stats -->
+    <div style="max-width: 1200px;" class="callout">
+        <center style="margin-bottom: 1rem;">
+            <span class="button button-secondary" id="guideButton">Explanation of Usage and Graphs</span>
+            &nbsp;&nbsp;<span class="button button-secondary graph-print" data-areaToPrint="StatsPrintArea">Print Page</span>
+        </center>
+        <div id="usageGuide">
+            <div class="usage-item grid-x grid-margin-x">
+                <div class="cell small-12 medium-2 color-key-traffic">Traffic</div>
+                <div class="cell small-12 medium-10">
+                    The data sent and received by this Web site.
+                    Traffic is displayed below in <b>Megabytes</b> or <b>Gigabytes</b>.
+                    A byte is roughly equivalent to one character, a Megabyte is roughly one Million characters,
+                    and a Gigabyte is roughtly one Trillion characters.
                 </div>
-                <div class="usage-item grid-x grid-margin-x">
-                    <div class="cell small-12 medium-2 color-key-incoming">Incoming</div>
-                    <div class="cell small-12 medium-10">
-                        The data sent and received by this Web site.
-                        Traffic is displayed below in <b>Megabytes</b> or <b>Gigabytes</b>.
-                        A byte is roughly equivalent to one character, a Megabyte is roughly one Million characters,
-                        and a Gigabyte is roughtly one Trillion characters.
-                    </div>
+            </div>
+            <div class="usage-item grid-x grid-margin-x">
+                <div class="cell small-12 medium-2 color-key-incoming">Incoming</div>
+                <div class="cell small-12 medium-10">
+                    The data sent and received by this Web site.
+                    Traffic is displayed below in <b>Megabytes</b> or <b>Gigabytes</b>.
+                    A byte is roughly equivalent to one character, a Megabyte is roughly one Million characters,
+                    and a Gigabyte is roughtly one Trillion characters.
                 </div>
-                <div class="usage-item grid-x grid-margin-x">
-                    <div class="cell small-12 medium-2 color-key-outgoing">Outgoing</div>
-                    <div class="cell small-12 medium-10">
-                        Data sent to users of your site including all Web pages, images, and files requested
-                        by the user. Note that this line may be covered by the Total (blue) line where they are the same.
-                    </div>
+            </div>
+            <div class="usage-item grid-x grid-margin-x">
+                <div class="cell small-12 medium-2 color-key-outgoing">Outgoing</div>
+                <div class="cell small-12 medium-10">
+                    Data sent to users of your site including all Web pages, images, and files requested
+                    by the user. Note that this line may be covered by the Total (blue) line where they are the same.
                 </div>
-                <div class="usage-item grid-x grid-margin-x">
-                    <div class="cell small-12 medium-2 color-key-total">Total</div>
-                    <div class="cell small-12 medium-10">
-                        Total of all incoming and outgoing data. This is the value that is compared to the
-                        the <b>Target</b> data traffic for billing purposes.
-                    </div>
+            </div>
+            <div class="usage-item grid-x grid-margin-x">
+                <div class="cell small-12 medium-2 color-key-total">Total</div>
+                <div class="cell small-12 medium-10">
+                    Total of all incoming and outgoing data. This is the value that is compared to the
+                    the <b>Target</b> data traffic for billing purposes.
                 </div>
-                <div class="usage-item grid-x grid-margin-x">
-                    <div class="cell small-12 medium-2 color-key-target">Traffic Target</div>
-                    <div class="cell small-12 medium-10">
-                        The maximum total monthly traffic expected for your Website.
-                        You are billed based on this target. If your "Total" traffic regularly exceeds this, you will be contacted
-                        to discuss increasing this target. This value is represented by the dotted line on the
-                        "Monthly Traffic" graph.
-                    </div>
+            </div>
+            <div class="usage-item grid-x grid-margin-x">
+                <div class="cell small-12 medium-2 color-key-target">Traffic Target</div>
+                <div class="cell small-12 medium-10">
+                    The maximum total monthly traffic expected for your Website.
+                    You are billed based on this target. If your "Total" traffic regularly exceeds this, you will be contacted
+                    to discuss increasing this target. This value is represented by the dotted line on the
+                    "Monthly Traffic" graph.
                 </div>
-                <div class="usage-item grid-x grid-margin-x">
-                    <div class="cell small-12 medium-2 color-key-storage">Disk Space Used</div>
-                    <div class="cell small-12 medium-10">
-                        The greatest amount of server disk space consumed by this Web site and all associated data during the measurement period.
-                        Disk Space Used is displayed in <b>Gigabytes</b>.
-                    </div>
+            </div>
+            <div class="usage-item grid-x grid-margin-x">
+                <div class="cell small-12 medium-2 color-key-storage">Disk Space Used</div>
+                <div class="cell small-12 medium-10">
+                    The greatest amount of server disk space consumed by this Web site and all associated data during the measurement period.
+                    Disk Space Used is displayed in <b>Gigabytes</b>.
                 </div>
-                <div class="usage-item grid-x grid-margin-x">
-                    <div class="cell small-12 medium-2 color-key-target">Disk Space Target</div>
-                    <div class="cell small-12 medium-10">
-                        The maximum disk storage space your Website is expected to use.
-                        You are billed for data storage based on this target. If the "Disk Space Used" regularly exceeds this, you will be contacted
-                        to discuss increasing this target. This value is represented by the dotted line on the
-                        "Monthly Disk Space Used" graph.
-                    </div>
+            </div>
+            <div class="usage-item grid-x grid-margin-x">
+                <div class="cell small-12 medium-2 color-key-target">Disk Space Target</div>
+                <div class="cell small-12 medium-10">
+                    The maximum disk storage space your Website is expected to use.
+                    You are billed for data storage based on this target. If the "Disk Space Used" regularly exceeds this, you will be contacted
+                    to discuss increasing this target. This value is represented by the dotted line on the
+                    "Monthly Disk Space Used" graph.
                 </div>
             </div>
-            <center>
-                <div id="StatsPrintArea" class="PrintArea" style="padding: 10px;">
-                    <style>
-                        @media print {
-                            body * {
-                                font-size: 8pt;
-                            }
-                        }
-                        .glmbw-table{
-                            font-size: 1em;
-                        }
-                        .glmbw-table .glmbw-th-light {
-                            font-weight: bold;
-                            text-align: left;
-                            vertical-align: top;
-                            white-space: nowrap;
-                        }
-                        .glmbw-table th {
-                            font-weight: bold;
-                            text-align: left;
-                            vertical-align: top;
-                            white-space: nowrap;
-                            padding: 0px;
-                        }
-                        .glmbw-table td {
-                            font-weight: normal;
-                            font-size: .9em;
-                            text-align: left;
-                            vertical-align: top;
-                            padding: 0px;
-                            margin: 0px;
-                        }
-                        .glmbw-table tr {
-                            margin-bottom: 0px;
-                            padding-bottom: 0px;
-                        }
-                        .glmbw-image {
-                            max-width: 90%;
-                            height: auto;
-                            width: auto\9; /* IE8 */
-                        }
-                        .print-title {
-                            font-weight: bold;
-                            font-size: 1em;
-                            text-align: center;
-                        }
-                        #print-date {
-                            font-size: 1em;
-                            padding: 0px;
-                            margin: 0px;
-                        }
-                        .graphContainer {
-                        }
-                        .graphContainer .graphTitle {
-                            font-weight: bold;
-                            margin-bottom: 5px;
-                        }
-                        .graph {
-                        }
-                        .color-key-traffic {
-                            color: black !important;
-                            font-weight: bold;
-                        }
-                        .color-key-target {
-                            color: maroon !important;
-                            font-weight: bold;
-                        }
-                        .color-key-storage {
-                            color: gray !important;
-                            font-weight: bold;
-                        }
-                        .color-key-incoming {
-                            color: red !important;
-                            font-weight: bold;
-                        }
-                        .color-key-outgoing {
-                            color: green !important;
-                            font-weight: bold;
-                        }
-                        .color-key-total {
-                            color: blue !important;
-                            font-weight: bold;
+        </div>
+        <center>
+            <div id="StatsPrintArea" class="PrintArea" style="padding: 10px;">
+                <style>
+                    @media print {
+                        body * {
+                            font-size: 8pt;
                         }
-                    </style>
-                    <div class="print-title" style="text-align: center;">
-                        <span style="padding-right: 2rem;">SITE:&nbsp;&nbsp;{$selectedSite|upper}</span>
-                        DATE:&nbsp;<input id="print-date" style="width: 7rem;" data-id="graphDate" type="text" name="graph_date" value="{$thisDate}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time" tabindex="2">
-                    </div>
-                    <center>
-                        <table class="responsive-card-table unstriped hover glmbw-table">
-                            <thead>
-                                <tr>
-                                    <th>Time frame</th><th>Traffic</th><th>Target</th><th>% of Target</th><th>Storage</th><th>target</th><th>% of Target</th>
-                                </tr>
-                            </thead>
-                            <tbody>
-                                <tr>
-                                    <td data-label=" ">Yesterday: </td>
-                                    <td data-label="Traffic">
-                                        {$serverStats.yesterday.data_total|string_format:"%.3f"} Megabytes<br>
-                                    </td>
-                                    <td data-label="Target">&nbsp;</td>
-                                    <td data-label="% of Target">&nbsp;</td>
-                                    <td data-label="Storage">
-                                        {$serverStats.yesterday.storage|string_format:"%.3f"} Gigabytes
-                                    </td>
-                                    <td data-label="Target">&nbsp;</td>
-                                    <td data-label="% of Target">&nbsp;</td>
-                                </tr>
-                                <tr>
-                                    <td data-label=" ">This Month: </td>
-                                    <td data-label="Traffic">
-                                        {$serverStats.thisMonth.data_total|string_format:"%.3f"} Gigabytes<br>
-                                    </td>
-                                    <td data-label="Target">&nbsp;</td>
-                                    <td data-label="% of Target">&nbsp;</td>
-                                    <td data-label="Storage">
-                                        {$serverStats.thisMonth.storage|string_format:"%.3f"} Gigabytes
-                                    </td>
-                                    <td data-label="Target">&nbsp;</td>
-                                    <td data-label="% of Target">&nbsp;</td>
-                                </tr>
-                                <tr>
-                                    <td data-label=" ">Last Month: </td>
-                                    <td data-label="Traffic"{if $serverStats.trafficDiff.exceeded} style="color: red;"{/if}>
-                                        {$serverStats.lastMonth.data_total|string_format:"%.3f"} Gigabytes
-                                    </td>
-                                    <td data-label="Target">{$target|string_format:"%.1f"} Gigabytes</td>
-                                    <td data-label="% of Target"{if $serverStats.trafficDiff.exceeded} style="color: red;"{/if}>{$serverStats.trafficDiff.percent|string_format:"%.0f"}%</td>
-                                    <td data-label="Storage">
-                                        {$serverStats.lastMonth.storage*1000|string_format:"%.1f"} Gigabytes
-                                    </td>
-                                    <td data-label="Target">{$diskTarget|string_format:"%.3f"} Gigabytes</td>
-                                    <td data-label="% of Target"{if $serverStats.trafficDiff.diskExceeded} style="color: red;"{/if}>{$serverStats.trafficDiff.diskPercent|string_format:"%.0f"}%</td>
-                                </tr>
-                            </tbody>
-                        </table>
-                        <p id="key-line">
-                            Color Key: <span class="color-key-target">Target</span>, <span class="color-key-storage">Storage</span>, <span class="color-key-incoming">Incoming</span>, <span class="color-key-outgoing">Outgoing</span>, <span class="color-key-total">Total</span><br>
-                        </p>
-                        <div class="graphContainer">
-                            <div class="graph"><img id="twoYearImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
-                            <div class="graphTitle">
-                                Monthly traffic totals for the past year. The dotted line is our current/planned billing level.
-                            </div>
+                    }
+                    .glmbw-table{
+                        font-size: 1em;
+                    }
+                    .glmbw-table .glmbw-th-light {
+                        font-weight: bold;
+                        text-align: left;
+                        vertical-align: top;
+                        white-space: nowrap;
+                    }
+                    .glmbw-table th {
+                        font-weight: bold;
+                        text-align: left;
+                        vertical-align: top;
+                        white-space: nowrap;
+                        padding: 0px;
+                        padding-left: .2rem;
+                    }
+                    .glmbw-table td {
+                        font-weight: normal;
+                        font-size: .9em;
+                        text-align: left;
+                        vertical-align: top;
+                        padding: 0px;
+                        padding-left: .2rem;
+                        margin: 0px;
+                    }
+                    .glmbw-table tr {
+                        margin-bottom: 0px;
+                        padding-bottom: 0px;
+                    }
+                    .glmbw-image {
+                        max-width: 90%;
+                        height: auto;
+                        width: auto\9; /* IE8 */
+                    }
+                    .print-title {
+                        font-weight: bold;
+                        font-size: 1em;
+                        text-align: center;
+                    }
+                    #print-date {
+                        font-size: 1em;
+                        padding: 0px;
+                        margin: 0px;
+                    }
+                    .graphContainer {
+                    }
+                    .graphContainer .graphTitle {
+                        font-weight: bold;
+                        margin-bottom: 5px;
+                    }
+                    .graph {
+                    }
+                    .color-key-traffic {
+                        color: black !important;
+                        font-weight: bold;
+                    }
+                    .color-key-target {
+                        color: maroon !important;
+                        font-weight: bold;
+                    }
+                    .color-key-storage {
+                        color: gray !important;
+                        font-weight: bold;
+                    }
+                    .color-key-incoming {
+                        color: red !important;
+                        font-weight: bold;
+                    }
+                    .color-key-outgoing {
+                        color: green !important;
+                        font-weight: bold;
+                    }
+                    .color-key-total {
+                        color: blue !important;
+                        font-weight: bold;
+                    }
+                </style>
+                <div class="print-title" style="text-align: center;">
+                    <span style="padding-right: 2rem;">SITE:&nbsp;&nbsp;{$currentSite.name|upper}</span>
+                    DATE:&nbsp;<input id="print-date" style="width: 7rem;" data-id="graphDate" type="text" name="graph_date" value="{$thisDate}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time" tabindex="2">
+                </div>
+                <center>
+                    <table class="responsive-card-table unstriped hover glmbw-table">
+                        <thead>
+                            <tr>
+                                <th>Time frame</th><th>Traffic</th><th>Target</th><th>% of Target</th><th>Storage</th><th>target</th><th>% of Target</th>
+                            </tr>
+                        </thead>
+                        <tbody>
+                            <tr>
+                                <td data-label=" ">Yesterday: </td>
+                                <td data-label="Traffic">
+                                    {$serverStats.yesterday.data_total|string_format:"%.3f"} Megabytes<br>
+                                </td>
+                                <td data-label="Target">&nbsp;</td>
+                                <td data-label="% of Target">&nbsp;</td>
+                                <td data-label="Storage">
+                                    {$serverStats.yesterday.storage|string_format:"%.3f"} Gigabytes
+                                </td>
+                                <td data-label="Target">&nbsp;</td>
+                                <td data-label="% of Target">&nbsp;</td>
+                            </tr>
+                            <tr>
+                                <td data-label=" ">This Month: </td>
+                                <td data-label="Traffic">
+                                    {$serverStats.thisMonth.data_total|string_format:"%.3f"} Gigabytes<br>
+                                </td>
+                                <td data-label="Target">&nbsp;</td>
+                                <td data-label="% of Target">&nbsp;</td>
+                                <td data-label="Storage">
+                                    {$serverStats.thisMonth.storage|string_format:"%.3f"} Gigabytes
+                                </td>
+                                <td data-label="Target">&nbsp;</td>
+                                <td data-label="% of Target">&nbsp;</td>
+                            </tr>
+                            <tr>
+                                <td data-label=" ">Last Month: </td>
+                                <td data-label="Traffic"{if $serverStats.trafficDiff.exceeded} style="color: red;"{/if}>
+                                    {$serverStats.lastMonth.data_total|string_format:"%.3f"} Gigabytes
+                                </td>
+                                <td data-label="Target">{$currentSite.target|string_format:"%.1f"} Gigabytes</td>
+                                <td data-label="% of Target"{if $serverStats.trafficDiff.exceeded} style="color: red;"{/if}>{$serverStats.trafficDiff.percent|string_format:"%.0f"}%</td>
+                                <td data-label="Storage">
+                                    {$serverStats.lastMonth.storage*1000|string_format:"%.1f"} Gigabytes
+                                </td>
+                                <td data-label="Target">{$currentSite.disk_target|string_format:"%.3f"} Gigabytes</td>
+                                <td data-label="% of Target"{if $serverStats.trafficDiff.diskExceeded} style="color: red;"{/if}>{$serverStats.trafficDiff.diskPercent|string_format:"%.0f"}%</td>
+                            </tr>
+                        </tbody>
+                    </table>
+                    <p id="key-line">
+                        Color Key: <span class="color-key-target">Target</span>, <span class="color-key-storage">Storage</span>, <span class="color-key-incoming">Incoming</span>, <span class="color-key-outgoing">Outgoing</span>, <span class="color-key-total">Total</span><br>
+                    </p>
+                    <div class="graphContainer">
+                        <div class="graph"><img id="twoYearImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
+                        <div class="graphTitle">
+                            Monthly traffic totals for the past year. The dotted line is our current/planned billing level.
                         </div>
-                        <div class="graphContainer">
-                            <div class="graph"><img id="twoYearStorageImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
-                            <div class="graphTitle">
-                                Monthly maximum disk space used for past year. The dotted line is our current/planned billing level.
-                            </div>
+                    </div>
+                    <div class="graphContainer">
+                        <div class="graph"><img id="twoYearStorageImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
+                        <div class="graphTitle">
+                            Monthly maximum disk space used for past year. The dotted line is our current/planned billing level.
                         </div>
-                        <div class="graphContainer">
-                            <div class="graph"><img id="twoDayImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
-                            <div class="graphTitle">
-                                Detail traffic for past 24 hours.
-                            </div>
+                    </div>
+                    <div class="graphContainer">
+                        <div class="graph"><img id="twoDayImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
+                        <div class="graphTitle">
+                            Detail traffic for past 24 hours.
                         </div>
-                        <div class="graphContainer">
-                            <div class="graph""><img id="twoMonthImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
-                            <div class="graphTitle">
-                                Daily traffic for past two months.
-                            </div>
+                    </div>
+                    <div class="graphContainer">
+                        <div class="graph""><img id="twoMonthImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
+                        <div class="graphTitle">
+                            Daily traffic for past two months.
                         </div>
-                    </center>
-                </div>
-            </center>
-        </div>
-
-    {/if} {* /!$haveStats *}
-
-    <script src="{$jsUrl}/PrintArea/jquery.PrintArea.js" type="text/JavaScript" language="javascript"></script>
-
-    <script type="text/javascript">
-        jQuery(document).ready(function($) {
-
-            // Toggle guide contents
-            $('#guideButton').on('click', function() {
-                $('#usageGuide').toggle();
-            })
-            $('#usageGuide').hide();
-
-            // Date Only Pickers
-            $('.glm-date-input').datetimepicker({
-                format: 'm/d/Y',
-                lang: 'en',
-                step: 15,
-                opened: false,
-                closeOnWithoutClick: true,
-                timepicker: false,
-                onChangeDateTime:function(dp,$input){
-                    updateGraphs($input.val())
-                    $('#displayThisDate').html($input.val());
-                }
-            });
-
-            function updateGraphs(d) {
-                $('#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&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);
+                    </div>
+                </center>
+            </div>
+        </center>
+    </div>
+
+{/if} {* /!$haveStats *}
+
+<script src="{$jsUrl}/PrintArea/jquery.PrintArea.js" type="text/JavaScript" language="javascript"></script>
+
+<script type="text/javascript">
+    jQuery(document).ready(function($) {
+
+        // Toggle guide contents
+        $('#guideButton').on('click', function() {
+            $('#usageGuide').toggle();
+        })
+        $('#usageGuide').hide();
+
+        // Date Only Pickers
+        $('.glm-date-input').datetimepicker({
+            format: 'm/d/Y',
+            lang: 'en',
+            step: 15,
+            opened: false,
+            closeOnWithoutClick: true,
+            timepicker: false,
+            onChangeDateTime:function(dp,$input){
+                updateGraphs($input.val())
+                $('#displayThisDate').html($input.val());
             }
+        });
 
-            $(".graph-print").click(function(){
-                $('.datePrintExclude').hide();
-                $('.datePrintInclude').show();
-
-                var areaToPrint = $(this).attr('data-areaToPrint');
-                var position = $(this).offset();
-                $('#' + areaToPrint).printArea({
-                    mode:       'popup',        //printable window is either iframe or browser popup
-                    popHt:      1400,            // popup window height
-                    popWd:      1100,            // popup window width
-                    popX:       200,            // popup window screen X position
-                    popY:       200,            //popup window screen Y position
-                    popTitle:   'Server Usage',   // popup window title element
-                    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
-                });
-                $('.datePrintExclude').show();
-                $('.datePrintInclude').hide();
-           });
-
-           // Do an initial load of usage graphs
-           updateGraphs('{$thisDate}');
-           $('.datePrintInclude').hide();
-
-           location.href='#selectedSite';
-           location.href='#glmPageTop';
+        function updateGraphs(d) {
+            $('#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&selected_site={$currentSite.name}&graphType=oneDay&refDate=' + d);
+            $('#twoMonthImg').attr('src', '{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxServerBandwidthGraphs&selected_site={$currentSite.name}&graphType=twoMonth&refDate=' + d);
+            $('#twoYearImg').attr('src', '{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxServerBandwidthGraphs&selected_site={$currentSite.name}&graphType=twoYear&refDate=' + d);
+            $('#twoYearStorageImg').attr('src', '{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxServerBandwidthGraphs&selected_site={$currentSite.name}&graphType=twoYearStorage&refDate=' + d);
+        }
+
+        $(".graph-print").click(function(){
+            $('.datePrintExclude').hide();
+            $('.datePrintInclude').show();
+
+            var areaToPrint = $(this).attr('data-areaToPrint');
+            var position = $(this).offset();
+            $('#' + areaToPrint).printArea({
+                mode:       'popup',        //printable window is either iframe or browser popup
+                popHt:      1400,            // popup window height
+                popWd:      1100,            // popup window width
+                popX:       200,            // popup window screen X position
+                popY:       200,            //popup window screen Y position
+                popTitle:   'Server Usage',   // popup window title element
+                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
+            });
+            $('.datePrintExclude').show();
+            $('.datePrintInclude').hide();
+       });
 
-        });
-    </script>
+       // Do an initial load of usage graphs
+       updateGraphs('{$thisDate}');
+       $('.datePrintInclude').hide();
 
-{/if} {* /!$connected *}
+       location.href='#selectedSite';
+       location.href='#glmPageTop';
 
+    });
+</script>
 
 {include file='footer.html'}
diff --git a/views/adminServerStatsConfig.html b/views/adminServerStatsConfig.html
deleted file mode 100755 (executable)
index c22e1aa..0000000
+++ /dev/null
@@ -1,380 +0,0 @@
-{include file='header.html'}
-<a name="glmPageTop"></a>
-
-        {if $connectionUpdated} {* Place Settings Updatd after first title line *}
-            <span class="glm-notice-right glm-flash-updated glm-usage-update-notice">Settings Updated</span>
-        {/if}
-        <h2>Server Usage Statistics Configuration</h2>
-
-        {* Beginning of user interface using view UI elements *}
-
-
-            {* Form Start *}
-            {$ui = [
-                'action'            => "{$thisUrl}?page={$thisPage}",
-                'method'            => 'post',
-                'validate'          => true,
-                'validateID'        => '1234',
-                'validateFocusMsg'  => true,
-                'validateMessage'   => 'There are some errors in your form. Please check the highlighted fields below.',
-                'leaveModifiedFormCheck' => true
-            ]}
-            {include file="ui/f6/form-start.html"}
-
-                <input type="hidden" name="option" value="update_connection">
-
-                {* Grid Start *}
-                {$ui = [
-                    'sectionColor'      => '#ffE'
-                ]}
-                {include file="ui/f6/grid-start.html"}
-
-                    {* Section Start *}
-                        {$ui = [
-                        'title'     => 'Cookie Pop-Ups for This Site',
-                        'tip'       => '
-                                        This section enables and sets parameters for the &quot;Cookie Popup&quot; that
-                                        will be displayed to a front-end user until they click to confirm that they
-                                        have read this popup. The popup will redisplay after the sent number of days
-                                        selected below.
-                                        See &quot;Additional Notices&quot; to select other standard
-                                        notices to display based on what is included in Web site.
-                                        '
-                    ]}
-                    {include file="ui/f6/section-start.html"}
-
-                        {* show_cookie_popup *}
-                        {$ui = [
-                            'field'         => 'show_cookie_popup',
-                            'value'         => {!empty($show_cookie_popup)},
-                            'label'         => 'Show Cookie Pop-Up'
-                        ]}
-                        {include file="ui/f6/checkbox.html"}
-
-                        {* cookie_popup_timeout *}
-                        {$ui = [
-                            'field'         => 'cookie_popup_timeout',
-                            'value'         => {$cookie_popup_timeout},
-                            'label'         => 'Cookie Pop-Up Re-Display Days',
-                            'required'      => true,
-                            'min'           => 0,
-                            'max'           => 365,
-                            'width'         => 5,
-                            'helpText'      => 'Number of days after user accepts the cookie pop-up that it will display again.
-                                                <b>Do not set to a real high number. Consider 10-30 days. Set to 0 to test Cookie Popups.</b>',
-                            'errorText'     => 'Must be between 0 and 365 days!'
-                        ]}
-                        {include file="ui/f6/number.html"}
-
-                        {* cookie_message *}
-                        {$ui = [
-                            'field'         => 'cookie_message',
-                            'value'         => {$cookie_message},
-                            'label'         => 'Cookies Notice Text',
-                            'required'      => true,
-                            'teeny'         => true,
-                            'rows'          => 10,
-                            'helpText'      => '
-                                                This is the main text of the Cookie Pop-Up.
-                                                The selected "Additional Notices" texts will show below this text in the Cookie Popup window on the
-                                                front-end of this site when the "Show more" button is clicked. To reset this field to the original
-                                                text, remove all content in the editor below and submit this page.
-                                               ',
-                            'tip'           => '
-                                                This text is always displayed at the top of the Cookie Popup and is the only text displayed in the
-                                                Cookie Popup until the user views other notices by clicking the &quot;Show more&quot; button. This
-                                                is important text and should always be included.
-                                               '
-                        ]}
-                        {include file="ui/f6/editor.html"}
-
-                    {include file="ui/f6/section-end.html"}
-
-                    {* Section Start *}
-                    {$ui = [
-                        'title'     => 'Addional Notices',
-                        'tip'       => '
-                                        Below are various special notices that you may want to include for display in the Cookie Popup.
-                                        The content of these messages will display when the user clicks to see more information in the
-                                        cookie popup. What you select here should be related to what is included in the Web site. For
-                                        example, if the site includes a secure payment form, you would want to include the notice related
-                                        to Payment Forms.
-                                        '
-                    ]}
-                    {include file="ui/f6/section-start.html"}
-
-                        {* Text Line *}
-                        {$ui = [
-                            'text'         => 'These notices are displayed when the user clicks the "Show more" button.'
-                        ]}
-                        {include file="ui/f6/text-line.html"}
-
-                        {* cookie_opt_gdpr *}
-                        {$ui = [
-                            'field'         => 'cookie_opt_gdpr',
-                            'value'         => {$cookie_opt_gdpr},
-                            'label'         => 'GDPR',
-                            'tip'           => '
-                                                GDPR stands for General Data Protection Regulation, which is a European Union Regulation
-                                                that controls matters of personal privacy and data protection. If this site is likely to be
-                                                accessed by persons in the EU or otherwise covered by EU regulations, you will probably
-                                                want this on.
-                                               '
-                        ]}
-                        {include file="ui/f6/checkbox.html"}
-
-                        {* cookie_opt_access_logs *}
-                        {$ui = [
-                            'field'         => 'cookie_opt_access_logs',
-                            'value'         => {$cookie_opt_access_logs},
-                            'label'         => 'Access Logs',
-                            'tip'           => '
-                                                If this site maintains access logs primarily for reasons of security and compliance with
-                                                policies, but not for sharing user access information with others, you should enable this notice.
-                                               '
-                        ]}
-                        {include file="ui/f6/checkbox.html"}
-
-                        {* cookie_opt_permanent *}
-                        {$ui = [
-                            'field'         => 'cookie_opt_permanent',
-                            'value'         => {$cookie_opt_permanent},
-                            'label'         => 'Permanent Cookies',
-                            'tip'           => '
-                                                If this site issues permanent cookies to user browsers that maintain information the user will
-                                                need when they return to the site, you should enable this notice.
-                                               '
-                        ]}
-                        {include file="ui/f6/checkbox.html"}
-
-                        {* cookie_opt_tracking *}
-                        {$ui = [
-                            'field'         => 'cookie_opt_tracking',
-                            'value'         => {$cookie_opt_tracking},
-                            'label'         => 'Tracking Cookies',
-                            'tip'           => '
-                                                If this site issues cookies to user browsers for the purpose of tracking user usage primarily
-                                                to evaluate and improve the site but not for distribution to other organizations, they you should
-                                                enable this notice.
-                                               '
-                        ]}
-                        {include file="ui/f6/checkbox.html"}
-
-                        {* cookie_opt_shared_tracking *}
-                        {$ui = [
-                            'field'         => 'cookie_opt_shared_tracking',
-                            'value'         => {$cookie_opt_shared_tracking},
-                            'label'         => 'Shared Tracking Cookies',
-                            'tip'           => '
-                                                If this site issues cookies to the user browsers for the purpoose of collecting tracking information
-                                                that may be distributed to other organizations, you should enable this notice.
-                                               '
-                        ]}
-                        {include file="ui/f6/checkbox.html"}
-
-                        {* cookie_opt_https *}
-                        {$ui = [
-                            'field'         => 'cookie_opt_https',
-                            'value'         => {$cookie_opt_https},
-                            'label'         => 'HTTPS',
-                            'tip'           => '
-                                                If this site uses HTTPS protocol for users to connect securely to this site, you should ensable this notice.
-                                               '
-                        ]}
-                        {include file="ui/f6/checkbox.html"}
-
-                        {* cookie_opt_logged_in *}
-                        {$ui = [
-                            'field'         => 'cookie_opt_logged_in',
-                            'value'         => {$cookie_opt_logged_in},
-                            'label'         => 'Logged-In Users',
-                            'tip'           => '
-                                                If this site permits users to log into the site or a portion of the site with some type of password, you
-                                                should enable this notice.
-                                               '
-                        ]}
-                        {include file="ui/f6/checkbox.html"}
-
-                        {* cookie_opt_forms *}
-                        {$ui = [
-                            'field'         => 'cookie_opt_forms',
-                            'value'         => {$cookie_opt_forms},
-                            'label'         => 'Submission Forms',
-                            'tip'           => '
-                                                If this site has any entry forms that users may submit, you should enable this notice.
-                                               '
-                        ]}
-                        {include file="ui/f6/checkbox.html"}
-
-                        {* cookie_opt_payment *}
-                        {$ui = [
-                            'field'         => 'cookie_opt_payment',
-                            'value'         => {$cookie_opt_payment},
-                            'label'         => 'Payment Forms',
-                            'tip'           => '
-                                                If this site accepts payments in any way, you should enable this notice.
-                                               '
-                        ]}
-                        {include file="ui/f6/checkbox.html"}
-
-                    {include file="ui/f6/section-end.html"}
-
-                    {* Section Start *}
-                    {$ui = [
-                        'title'     => 'Database Connection',
-                        'tip'       => '
-                                        This section sets paramters required to connect to the Usage and Disk Space
-                                        database. There is only one of these for all customers. This data should be
-                                        the same for all sites using this plugin. Contact Gaslight Media Engineering
-                                        if you need help with these settings.
-                                        '
-                    ]}
-                    {include file="ui/f6/section-start.html"}
-
-                        {if $connectError}
-
-                            {* Text Line *}
-                            {$ui = [
-                                'text'  => '
-                                            <p class="glm-failure-notice"><b>NOTICE</b>: Unable To Connect - Please check "Database Connection" below</p>
-                                            <p>
-                                                Database connection failures may also be due to the Web server not being able to communicate with the GLM Data Usage
-                                                database. If necessary, please check with Gaslight Media Engineering for assistance.
-                                            </p>
-                                            '
-                            ]}
-                            {include file="ui/f6/text-line.html"}
-
-                        {else}
-
-                            {* Text Line *}
-                            {$ui = [
-                                'text'         => 'Please ask Gaslight Media Engineering if you need assistance with these settings.'
-                            ]}
-                            {include file="ui/f6/text-line.html"}
-
-                        {/if}
-
-                        {* db_name *}
-                        {$ui = [
-                            'field'         => 'db_name',
-                            'value'         => {$db_name},
-                            'label'         => 'Database Name',
-                            'required'      => true,
-                            'placeholder'   => 'Try: bandwidth',
-                            'errorText'     => 'The database name is required for connecting to the usage database.'
-                        ]}
-                        {include file="ui/f6/text.html"}
-
-                        {* db_host *}
-                        {$ui = [
-                            'field'         => 'db_host',
-                            'value'         => {$db_host},
-                            'label'         => 'Database Server Hostname',
-                            'placeholder'   => 'Try: bandwidth.gaslightmedia.com',
-                            'required'      => true,
-                            'maxWidth'      => 20,
-                            'errorText'     => 'The database host name is required for connecting to the usage database.'
-                        ]}
-                        {include file="ui/f6/text.html"}
-
-                        {* db_user *}
-                        {$ui = [
-                            'field'         => 'db_user',
-                            'value'         => {$db_user},
-                            'label'         => 'Database Username',
-                            'placeholder'   => 'Try: bandwidthRO',
-                            'required'      => true,
-                            'maxWidth'      => 20,
-                            'errorText'     => 'The database username is required for connecting to the usage database.'
-                        ]}
-                        {include file="ui/f6/text.html"}
-
-                        {* db_pass *}
-                        {$ui = [
-                            'field'         => 'db_pass',
-                            'value'         => {$db_pass},
-                            'label'         => 'Database Password',
-                            'placeholder'   => 'Try: ,Wv4W*~^bL_vF3F4PbGsS',
-                            'required'      => true,
-                            'errorText'     => 'The database password for the above username is required for connecting to the usage database.'
-                        ]}
-                        {include file="ui/f6/text.html"}
-
-                        {* website *}
-                        {$ui = [
-                            'field'         => 'website',
-                            'value'         => {$website},
-                            'label'         => 'Website Name',
-                            'placeholder'   => 'i,e, www.gaslightmedia.com',
-                            'required'      => true,
-                            'errorText'     => 'The website host name is required to access settings for this site.'
-                        ]}
-                        {include file="ui/f6/text.html"}
-
-                    {include file="ui/f6/section-end.html"}
-
-                    {* Section Start *}
-                    {$ui = [
-                        'title'     => 'Usage and Notifications',
-                        'tip'       => '
-                                        This section controls display of site usage and generation of various notifcations to customers.
-                                       '
-                    ]}
-                    {include file="ui/f6/section-start.html"}
-
-                        {* show_usage *}
-                        {$ui = [
-                            'field'         => 'show_usage',
-                            'value'         => {!empty($show_usage)},
-                            'label'         => 'Show Traffic and Disk Usage Information & Graphs',
-                            'helpText'      => 'Turn this on to show traffic and disk ussage information for this site.'
-
-                        ]}
-                        {include file="ui/f6/checkbox.html"}
-
-                        {* show_notifications *}
-                        {$ui = [
-                            'field'         => 'show_notifications',
-                            'value'         => {!empty($show_notifications)},
-                            'label'         => 'Show Customer Notiifications',
-                            'helpText'      => 'Turn this on to have general Gaslight Media messages displayed on this site.'
-                        ]}
-                        {include file="ui/f6/checkbox.html"}
-
-                    {include file="ui/f6/section-end.html"}
-
-                    {* Submit Button *}
-                    {$ui = [
-                        'class'     => 'primary',
-                        'label'     => 'Save Changes',
-                        'submit'    => true
-                    ]}
-                    {include file="ui/f6/submit.html"}
-
-                {include file="ui/f6/grid-end.html"}
-
-            {include file="ui/f6/form-end.html"}
-
-        </div>
-        {* End of user interface using view UI elements *}
-
-
-    <script>
-
-
-        jQuery(document).ready(function($) {
-
-            {if $forceReload}
-                alert('Redirecting due to menu change. Click "OK" to continue.');
-                window.location.href = '{$adminUrl}{$reloadUrl}';
-            {/if}
-
-            // Flash certain elements for a short time after display
-            $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
-
-        });
-    </script>
-
-
-{include file='footer.html'}
index a0b3cb9..5b2e9f9 100644 (file)
@@ -2,7 +2,7 @@
     <div class="glm-usage-copyright">
         {$glmPluginName}<br>
         Copyright &copy; 2014-{$thisYear} Gaslight Media - All Rights Reserved<br>
-        Phone: 231-487-0692 - E-Mail: {$glmPluginsContactEmail}<br>
+        Phone: 231-487-0692 - E-Mail: {$glmFromContact.email}<br>
         <a href="http://www.gaslightmedia.com">http://www.gaslightmedia.com</a>
     </div>
 
index 0abad33..2e4a216 100644 (file)
@@ -12,7 +12,7 @@
         'title'     => string               Optional title
     ]}
 *}
-<div id="{$ui.id}_summary" class="cell small-12 large-{$glm_f6_ui_wrapsize}">
+<div id="{$ui.id}_summary" class="cell small-12 large-{$glm_f6_ui_wrapsize}" styl="display: none;">
     <div class="grid-x">
         <div class="cell small-12 glm-f6-ui-form-summary-start">
             <button id="{$ui.id}_edit_button" type="button" class="button">Edit</button>
@@ -20,6 +20,7 @@
         </div>
         <script>
             jQuery(document).ready(function($){
+                $('#{$ui.id}_summary').show();
                 $('#{$ui.id}_edit_button').click(function(){
                     $('#{$ui.id}_summary').fadeOut('slow', function() {
                         $('#{$ui.id}_edit').fadeIn('slow');
index 6e80e48..c71bbac 100644 (file)
@@ -34,6 +34,9 @@
     .glm-f6-ui-section-start {
         background-color: {$glm_f6_ui_section_color} !important;
     }
+    .glm-f6-ui-section-start-nobackgroundcolor {
+        background-color: transparent !important;
+    }
     .glm-f6-ui-form-summary-start {
         margin-bottom: 1rem;
     }
index 7445ff8..5c95036 100644 (file)
@@ -1,24 +1,32 @@
 {*
-    Foundation 6 UI - Form Section Start
+    Foundation 6 UI - Section Start
 
     {$ui = [
-        'title'     => string Section title text,
-        'helpText'  => string Additional text to describe this section,
-        'tip'       => String to display when hover over question mark on right
+        'title'     => string  Section title text,
+        'wrapSize'  => integer Override width of subsection in columns, 1 to 12 only.,
+        'callout'   => boolean Use callout background - default true - set to false for no callout or background color
+        'helpText'  => string  Additional text to describe this section,
+        'tip'       => string  String to display when hover over question mark on right
     ]}
 *}
-<div class="cell small-12 large-{$glm_f6_ui_wrapsize}">
+{$glm_f6_ui_section_wrapsize = {$glm_f6_ui_wrapsize} scope="global"}
+{if isset($ui.wrapSize) && $ui.wrapSize}
+    {$glm_f6_ui_section_wrapsize = $ui.wrapSize scope="global"}
+{/if}
+<div class="cell small-12 large-{$glm_f6_ui_section_wrapsize}">
     <div class="grid-x grid-margin-x glm-f6-ui-section">
         {if !isset($ui.title)}
             <span class="glm-required">Field Error: Required field information not supplied!</span>
         {else}
             <div class="cell small-12 glm-f6-ui-section-title">
-                {if isset($ui.tip)}
-                    <span style="float:right;" data-tooltip title="{$ui.tip}">?</span>
-                {/if}
-                <h3>{$ui.title}</h3>
+                <h3>
+                    <span style="padding-right: 1rem;">{$ui.title}</span>
+                    {if isset($ui.tip)}
+                        <span data-tooltip title="{$ui.tip}" style="font-size: .7rem;"> ?</span>
+                    {/if}
+                </h3>
                 {if isset($ui.helpText)}<p class="help-text">{$ui.helpText}</p>{/if}
             </div>
         {/if}
-            <div class="cell small-12 callout glm-f6-ui-section-start">
+            <div class="cell small-12 {if !isset($ui.callout) || $ui.callout}callout  glm-f6-ui-section-start{else}  glm-f6-ui-section-start-nobackgroundcolor{/if}">
                 <div class="grid-x grid-margin-x">
diff --git a/views/ui/f6/sub-section-end.html b/views/ui/f6/sub-section-end.html
new file mode 100644 (file)
index 0000000..685ab80
--- /dev/null
@@ -0,0 +1,8 @@
+{*
+    Foundation 6 UI - Form Sub-Section End
+    No parameters are needed for Sub-Section-End
+*}
+            </div>
+        </div>
+    </div>
+</div>
\ No newline at end of file
diff --git a/views/ui/f6/sub-section-start.html b/views/ui/f6/sub-section-start.html
new file mode 100644 (file)
index 0000000..5eb4d76
--- /dev/null
@@ -0,0 +1,29 @@
+{*
+    Foundation 6 UI - Form Sub-Section Start
+
+    {$ui = [
+        'title'     => string  Sub-Section title text,
+        'wrapSize'  => integer Width of subsection in columns, 1 to 12 only.
+        'helpText'  => string  Additional text to describe this sub-section,
+        'tip'       => string  String to display when hover over question mark on right
+    ]}
+*}
+{$glm_f6_ui_subsection_wrapsize = 12 scope="global"}
+{if isset($ui.wrapSize) && $ui.wrapSize}
+    {$glm_f6_ui_subsection_wrapsize = $ui.wrapSize scope="global"}
+{/if}
+<div class="cell small-12 large-{$glm_f6_ui_subsection_wrapsize}">
+    <div class="grid-x grid-margin-x glm-f6-ui-subsection">
+        {if !isset($ui.title)}
+            <span class="glm-required">Field Error: Required field information not supplied!</span>
+        {else}
+            <div class="cell small-12 glm-f6-ui-subsection-title">
+                {if isset($ui.tip)}
+                    <span style="float:right;" data-tooltip title="{$ui.tip}">?</span>
+                {/if}
+                <h3>{$ui.title}</h3>
+                {if isset($ui.helpText)}<p class="help-text">{$ui.helpText}</p>{/if}
+            </div>
+        {/if}
+            <div class="cell small-12 glm-f6-ui-subsection-start">
+                <div class="grid-x grid-margin-x">
index 7d0896a..3a73b39 100644 (file)
@@ -10,7 +10,7 @@
         'pattern'       => string               Pattern attribute ( number, etc. )
         'placeholder'   => string               Placeholder string,
         'required'      => boolean              True if required,
-        'maxWidth'      => string               Size of input field using standard style notation ('900px', '15rem', ...),
+        'maxWidth'      => string               Size of input field using standard style notation ('900px', '15rem', '95%', ...),
         'maxLength'     => integer              Maximum number of characters that may be entered,
         'helpText'      => string               Help text for this input,
         'errorText'     => string               Error text that appears when the field doesn't validate,
@@ -28,7 +28,7 @@
                 {if isset($ui.tip)}
                     <span style="float:right;" data-tooltip aria-haspopup="true" class="has-tip" data-disable-hover="false" title="{$ui.tip}">?</span>
                 {/if}
-                <label for="{$ui.field}" class="{if $ui.required} glm-required{/if} glm-f6-ui-field-label">{$ui.label}</label>
+                <label for="{$ui.field}" class="{if !empty($ui.required)} glm-required{/if} glm-f6-ui-field-label">{$ui.label}</label>
             </div>
             <div class="cell small-12">
                 <input