From 79181e6d9c0b974ca59a8391fb5f24fae52a48a7 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 9 Sep 2019 17:08:27 -0400 Subject: [PATCH] Completed rework of bandwidth (usage) plugin 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 --- classes/serverBandwidthSupport.php | 327 ++------ defines.php | 28 +- index.php | 114 ++- models/adminServerStats.php | 289 ++++--- models/adminServerStatsConfig.php | 167 ---- models/ajaxSendUsageReport.php | 25 +- models/ajaxServerBandwidthGraphs.php | 19 +- models/frontCookiePopUp.php | 3 +- models/serverUsageTargetCheck.php | 3 - setup/adminHooks.php | 5 +- setup/adminMenus.php | 89 +- setup/standardTemplateParams.php | 1 - views/adminServerStats.html | 1155 ++++++++++++++++---------- views/adminServerStatsConfig.html | 380 --------- views/footer.html | 2 +- views/ui/f6/form-summary-start.html | 3 +- views/ui/f6/grid-start.html | 3 + views/ui/f6/section-start.html | 28 +- views/ui/f6/sub-section-end.html | 8 + views/ui/f6/sub-section-start.html | 29 + views/ui/f6/text.html | 4 +- 21 files changed, 1160 insertions(+), 1522 deletions(-) delete mode 100755 models/adminServerStatsConfig.php delete mode 100755 views/adminServerStatsConfig.html create mode 100644 views/ui/f6/sub-section-end.html create mode 100644 views/ui/f6/sub-section-start.html diff --git a/classes/serverBandwidthSupport.php b/classes/serverBandwidthSupport.php index 9075b08..f4d0900 100755 --- a/classes/serverBandwidthSupport.php +++ b/classes/serverBandwidthSupport.php @@ -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

Gaslight Media:

The following is a summary of usage report(s) sent for '.$month.'.

'.$glmMesg.'
'; - $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; diff --git a/defines.php b/defines.php index bf0c2d9..6661ba5 100755 --- a/defines.php +++ b/defines.php @@ -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'); diff --git a/index.php b/index.php index 96f5663..4dfc05b 100755 --- 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; } diff --git a/models/adminServerStats.php b/models/adminServerStats.php index b340620..2cb1f47 100755 --- a/models/adminServerStats.php +++ b/models/adminServerStats.php @@ -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'] = + '

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".

If you\'re on a public computer, ' + .'be sure to close all Web Browsers when you\'re done!

'; } - //echo "
".print_r($websites,1)."
"; + // echo "
".print_r($currentSite,1)."
"; // echo "
".print_r($stats,1)."
"; // 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 "
".print_r($templateData,1)."
"; diff --git a/models/adminServerStatsConfig.php b/models/adminServerStatsConfig.php deleted file mode 100755 index 5e3749e..0000000 --- a/models/adminServerStatsConfig.php +++ /dev/null @@ -1,167 +0,0 @@ - - * @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 - * @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'] = - '

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".

If you\'re on a public computer, ' - .'be sure to close all Web Browsers when you\'re done!

'; - $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 "
".var_dump($templateData,1)."
"; - - // Return status, suggested view, and data to controller - return array( - 'view' => 'adminServerStatsConfig', - 'data' => $templateData - ); - - } - - - -} - -?> \ No newline at end of file diff --git a/models/ajaxSendUsageReport.php b/models/ajaxSendUsageReport.php index 18b3297..1c01242 100755 --- a/models/ajaxSendUsageReport.php +++ b/models/ajaxSendUsageReport.php @@ -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 "

Sending of notification E-Mail is dissabled!

"; wp_die(); }; @@ -75,12 +69,6 @@ class ajaxSendUsageReport extends glmServerStatsBandwidthSupport echo "

".($displayOnly?'Displaying':'Sending')." requested usage notificaton.

"; - $this->connected = $this->bandwidthDataConnect($site); - if (!$this->connected) { - echo "

ERROR: Failed to connect to usage database.

"; - wp_die(); - } - echo "
"; $res = $this->checkEmailNotifications(true, true, true, $site, $displayOnly); @@ -91,13 +79,6 @@ class ajaxSendUsageReport extends glmServerStatsBandwidthSupport echo "

".($displayOnly?'Displaying':'Sending')." all usage notificatons above notification target.

"; - $this->connected = $this->bandwidthDataConnect(); - - if (!$this->connected) { - echo "

ERROR: Failed to connect to usage database.

"; - wp_die(); - } - $res = $this->checkEmailNotifications(true, true, false, false, $displayOnly); } diff --git a/models/ajaxServerBandwidthGraphs.php b/models/ajaxServerBandwidthGraphs.php index a888883..ae84436 100755 --- a/models/ajaxServerBandwidthGraphs.php +++ b/models/ajaxServerBandwidthGraphs.php @@ -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)); diff --git a/models/frontCookiePopUp.php b/models/frontCookiePopUp.php index 0d0f250..3d28d84 100755 --- a/models/frontCookiePopUp.php +++ b/models/frontCookiePopUp.php @@ -1,8 +1,9 @@ -{if !$connected} -

Server Data Usage Unavailable

-

{$connectError}

+{if !$haveStats} +

This application has not been configured. Please ask Gaslight Media this for your Website.

+

Error: {$connectError}

+{else} {if apply_filters('glm-serverstats-is-provider', false)} -

Please check GLM Server Usage configuration menu!

- {else} -

Please contact your system administrator for assistance.

- {/if} +
Service Provider Section
-{else} + {* Grid Start *} + {$ui = [ + 'sectionColor' => '#ffE', + 'nowrap' => true + ]} + {include file="ui/f6/grid-start.html"} - {if !$haveStats} -

This application has not been configured. Please ask Gaslight Media this for your Website.

-

Error: {$connectError}

- {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"} + +
+
+ Sort By: + Site Name +
+
+ Traffic: + Total + Percent +
+
+ Storage: + Maximum + Percent +
+
+
+ +
+

Click on a site above to display settings and charts.

+
+
+ Send Usage Report for Selected Site: + Send for selected site +
+ +
+
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. +
+
+ + {include file="ui/f6/form-end.html"} + + {include file="ui/f6/miscContainer-end.html"} - {if apply_filters('glm-serverstats-is-provider', false)} -
Service Provider Section
+ {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"} + + + + {* Grid Start *} {$ui = [ @@ -117,144 +196,127 @@ ]} {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"} +
+
- {* Form Start *} - {$ui = [ - 'action' => "{$thisUrl}?page={$thisPage}&selected_site={$selectedSite}", - 'method' => 'POST' - ]} - {include file="ui/f6/form-start.html"} - -
-
- Sort By: - Site Name -
-
- Traffic: - Total - Percent -
-
- Storage: - Maximum - Percent -
-
-
- -
-

Click on a site above to display settings and charts.

- {if $selectedSite} -
-
- Send E-Mail: - Send for selected site -
- + {* Sub-Section Start *} + {$ui = [ + 'title' => {'Settings For: '|cat:$currentSite.name}, + 'wrapSize' => 6 + ]} + {include file="ui/f6/sub-section-start.html"} + +
Usage Reporting
+ +
Monthly Traffic Target:
+
{$currentSite.target|string_format:"%.1f"} GB
+
Disk Space Usage Target:
+
{$currentSite.disk_target|string_format:"%.1f"} GB
+
Show Usage Graphs:
+
{if $currentSite.show_usage}Yes{else}No{/if}
+
Send Usage Reports:
+
{if $currentSite.send_enabled}Yes{else}No{/if}
+
Customer Usage/Notify Address:
+
{if !empty($currentSite.cust_contact)}{$currentSite.cust_contact}{else}(Not supplied){/if}
+ +

Cookie Pop-Up
+ +
Show Cookie Pop-Up:
+
{if $currentSite.show_cookie_popup}Yes{else}No{/if}
+
Cookie Pop-Up Timeout:
+
{$currentSite.cookie_popup_timeout} Days
+
Cookie Message:
+
{$currentSite.cookie_message|nl2br}
+ +

Privacy/Policy Page
+ +
Privacy and Policy Contact:
+
{if !empty($currentSite.contact_name)}{$currentSite.contact_name}{else}(Name not set){/if}
+
 
+
{if !empty($currentSite.contact_org)}{$currentSite.contact_org}{else}(Organization not set){/if}
+
 
+
{if !empty($currentSite.contact_address)}{$currentSite.contact_address}{else}(Address line 1 not set){/if}
+
 
+
{if !empty($currentSite.contact_address2)}{$currentSite.contact_address2}{else}(Address line 2 not set){/if}
+
 
+
+ {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},
- {/if} - - {include file="ui/f6/form-end.html"} +
Contact Phone:
+
{if !empty($currentSite.contact_phone)}{$currentSite.contact_phone}{else}(Phone not set){/if}
+
Contact E-Mail Address:
+
{if !empty($currentSite.contact_email)}{$currentSite.contact_email}{else}(Email not set){/if}
+
Privacy/Policy Page:
+ + + {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"} +
Monthly Reporting Threshold:
+
At or above {$threshold|string_format:"%.0f"}% of site's target levels
+
Enable Sending Usage Reports:
+
{if $sendReportsEnabled}YES{else}NO{/if}
- {include file="ui/f6/section-end.html"} +

Usage Report E-Mail "From:" Settings
- {* Grid End *} - {$ui = [ - 'noFoundationInit' => true - ]} - {include file="ui/f6/grid-end.html"} +
Name:
+
{if !empty($glmFromContact.name)}{$glmFromContact.name}{else}(Name not set){/if}
+
E-Mail Address:
+
{if !empty($glmFromContact.name)}{$glmFromContact.email}{else}(Email not set){/if}
+
Subject:
+
{if !empty($glmFromContact.subject)}{$glmFromContact.subject}{else}(Subject not set){/if}
- {* 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"} +
+
- - - + {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"} - -
-
-

For Selected Site

-
Selected Site:
-
{$selectedSite}
-
Monthly Traffic Target:
-
{$settings.target|string_format:"%.1f"}
-
Disk Space Usage Target:
-
{$settings.disk_target|string_format:"%.1f"}
-
Customer Contact:
-
{if !empty($settings.cust_contact)}{$settings.cust_contact}{else}(not supplied){/if}
-

Global Settings

-
Monthly Reporting Threshold:
-
At or above {$threshold|string_format:"%.0f"}% of site's target levels
-
Send Notices Enabled:
-
{if !empty($send_enabled)}YES{else}NO{/if}
-
-
+ {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' => 'NOTE: 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' ]} @@ -263,30 +325,205 @@ {* 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 "Cookie Popup" 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 "Additional Notices" 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. + Do not set to a real high number. Consider 10-30 days. Set to 0 to test Cookie Popups.', + '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' => {'Link to display Privacy/Policy Page'} + ]} + {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' => 'NOTE: The settings below affect all sites!' ]} - {include file="ui/f6/section-start.html"} + {include file="ui/f6/sub-section-start.html"} {* Reporting Threshold *} {$ui = [ @@ -305,346 +542,378 @@ ]} {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"} -
Customer Section
+ {* 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"} -
Website Data Usage
+ {include file="ui/f6/form-end.html"} - {/if} {* /is provider *} +
Customer Section
- -
-
- Explanation of Usage and Graphs -   Print Page -
-
-
-
Traffic
-
- The data sent and received by this Web site. - Traffic is displayed below in Megabytes or Gigabytes. - A byte is roughly equivalent to one character, a Megabyte is roughly one Million characters, - and a Gigabyte is roughtly one Trillion characters. -
+ {else} + +
Website Data Usage
+ + {/if} {* /is provider *} + + +
+
+ Explanation of Usage and Graphs +   Print Page +
+
+
+
Traffic
+
+ The data sent and received by this Web site. + Traffic is displayed below in Megabytes or Gigabytes. + A byte is roughly equivalent to one character, a Megabyte is roughly one Million characters, + and a Gigabyte is roughtly one Trillion characters.
-
-
Incoming
-
- The data sent and received by this Web site. - Traffic is displayed below in Megabytes or Gigabytes. - A byte is roughly equivalent to one character, a Megabyte is roughly one Million characters, - and a Gigabyte is roughtly one Trillion characters. -
+
+
+
Incoming
+
+ The data sent and received by this Web site. + Traffic is displayed below in Megabytes or Gigabytes. + A byte is roughly equivalent to one character, a Megabyte is roughly one Million characters, + and a Gigabyte is roughtly one Trillion characters.
-
-
Outgoing
-
- 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. -
+
+
+
Outgoing
+
+ 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.
-
-
Total
-
- Total of all incoming and outgoing data. This is the value that is compared to the - the Target data traffic for billing purposes. -
+
+
+
Total
+
+ Total of all incoming and outgoing data. This is the value that is compared to the + the Target data traffic for billing purposes.
-
-
Traffic Target
-
- 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. -
+
+
+
Traffic Target
+
+ 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.
-
-
Disk Space Used
-
- 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 Gigabytes. -
+
+
+
Disk Space Used
+
+ 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 Gigabytes.
-
-
Disk Space Target
-
- 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. -
+
+
+
Disk Space Target
+
+ 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.
-
-
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Time frameTrafficTarget% of TargetStoragetarget% of Target
Yesterday: - {$serverStats.yesterday.data_total|string_format:"%.3f"} Megabytes
-
   - {$serverStats.yesterday.storage|string_format:"%.3f"} Gigabytes -   
This Month: - {$serverStats.thisMonth.data_total|string_format:"%.3f"} Gigabytes
-
   - {$serverStats.thisMonth.storage|string_format:"%.3f"} Gigabytes -   
Last Month: - {$serverStats.lastMonth.data_total|string_format:"%.3f"} Gigabytes - {$target|string_format:"%.1f"} Gigabytes{$serverStats.trafficDiff.percent|string_format:"%.0f"}% - {$serverStats.lastMonth.storage*1000|string_format:"%.1f"} Gigabytes - {$diskTarget|string_format:"%.3f"} Gigabytes{$serverStats.trafficDiff.diskPercent|string_format:"%.0f"}%
-

- Color Key: Target, Storage, Incoming, Outgoing, Total
-

-
-
-
- Monthly traffic totals for the past year. The dotted line is our current/planned billing level. -
+ } + .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; + } + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Time frameTrafficTarget% of TargetStoragetarget% of Target
Yesterday: + {$serverStats.yesterday.data_total|string_format:"%.3f"} Megabytes
+
   + {$serverStats.yesterday.storage|string_format:"%.3f"} Gigabytes +   
This Month: + {$serverStats.thisMonth.data_total|string_format:"%.3f"} Gigabytes
+
   + {$serverStats.thisMonth.storage|string_format:"%.3f"} Gigabytes +   
Last Month: + {$serverStats.lastMonth.data_total|string_format:"%.3f"} Gigabytes + {$currentSite.target|string_format:"%.1f"} Gigabytes{$serverStats.trafficDiff.percent|string_format:"%.0f"}% + {$serverStats.lastMonth.storage*1000|string_format:"%.1f"} Gigabytes + {$currentSite.disk_target|string_format:"%.3f"} Gigabytes{$serverStats.trafficDiff.diskPercent|string_format:"%.0f"}%
+

+ Color Key: Target, Storage, Incoming, Outgoing, Total
+

+
+
+
+ Monthly traffic totals for the past year. The dotted line is our current/planned billing level.
-
-
-
- Monthly maximum disk space used for past year. The dotted line is our current/planned billing level. -
+
+
+
+
+ Monthly maximum disk space used for past year. The dotted line is our current/planned billing level.
-
-
-
- Detail traffic for past 24 hours. -
+
+
+
+
+ Detail traffic for past 24 hours.
-
-
-
- Daily traffic for past two months. -
+
+
+
+
+ Daily traffic for past two months.
-
-
-
-
- - {/if} {* /!$haveStats *} - - - - + + + // Do an initial load of usage graphs + updateGraphs('{$thisDate}'); + $('.datePrintInclude').hide(); -{/if} {* /!$connected *} + location.href='#selectedSite'; + location.href='#glmPageTop'; + }); + {include file='footer.html'} diff --git a/views/adminServerStatsConfig.html b/views/adminServerStatsConfig.html deleted file mode 100755 index c22e1aa..0000000 --- a/views/adminServerStatsConfig.html +++ /dev/null @@ -1,380 +0,0 @@ -{include file='header.html'} - - - {if $connectionUpdated} {* Place Settings Updatd after first title line *} - Settings Updated - {/if} -

Server Usage Statistics Configuration

- - {* 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"} - - - - {* 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 "Cookie Popup" 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 "Additional Notices" 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. - Do not set to a real high number. Consider 10-30 days. Set to 0 to test Cookie Popups.', - '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 "Show more" 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' => ' -

NOTICE: Unable To Connect - Please check "Database Connection" below

-

- 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. -

- ' - ]} - {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"} - -
- {* End of user interface using view UI elements *} - - - - - -{include file='footer.html'} diff --git a/views/footer.html b/views/footer.html index a0b3cb9..5b2e9f9 100644 --- a/views/footer.html +++ b/views/footer.html @@ -2,7 +2,7 @@ diff --git a/views/ui/f6/form-summary-start.html b/views/ui/f6/form-summary-start.html index 0abad33..2e4a216 100644 --- a/views/ui/f6/form-summary-start.html +++ b/views/ui/f6/form-summary-start.html @@ -12,7 +12,7 @@ 'title' => string Optional title ]} *} -
+
@@ -20,6 +20,7 @@