From: Chuck Scott Date: Tue, 23 Aug 2016 17:40:51 +0000 (-0400) Subject: Added target bandwidth value for yearly graph. X-Git-Tag: v1.0.0^2~2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=fd119360ca958c4297c3764595fcc28689acb293;p=WP-Plugins%2Fglm-member-db-serverstats.git Added target bandwidth value for yearly graph. Fixed a couple glitches with the PHPGraphLib. Updated some of the bandwidth graphics. --- diff --git a/classes/data/dataManagement.php b/classes/data/dataManagement.php index 68a4f3c..2cc8b08 100644 --- a/classes/data/dataManagement.php +++ b/classes/data/dataManagement.php @@ -159,13 +159,20 @@ class GlmDataServerStatsManagement extends GlmDataAbstract 'type' => 'text', 'required' => true, 'use' => 'a' + ), + + // Target Bandwidth in Megabytes + 'target' => array ( + 'field' => 'target', + 'type' => 'integer', + 'required' => true, + 'use' => 'a' ) ); } - } ?> \ No newline at end of file diff --git a/classes/serverBandwidthSupport.php b/classes/serverBandwidthSupport.php index 24f4637..d1d3b7e 100644 --- a/classes/serverBandwidthSupport.php +++ b/classes/serverBandwidthSupport.php @@ -164,7 +164,7 @@ class GlmServerBandwidthSupport } /* - * Get bandwidth graph data for Today, This month, Two years + * Get bandwidth graph data for Today, Last two months, Last two years */ public function bandwidthGetGraphData($graphType = false) { @@ -238,7 +238,7 @@ class GlmServerBandwidthSupport FROM rollup WHERE websitefk = ".$this->siteId." AND date BETWEEN '$firstMonth' AND '$lastMonth' - GROUP BY MONTH(date) + GROUP BY YEAR(date), MONTH(date) ORDER BY date ASC ;"; $twoYearData = $this->bwdb->query($sql); diff --git a/index.php b/index.php index cccb1b9..87a8584 100644 --- a/index.php +++ b/index.php @@ -38,10 +38,10 @@ * version from this plugin. */ define('GLM_MEMBERS_SERVERSTATS_PLUGIN_VERSION', '0.0.1'); -define('GLM_MEMBERS_SERVERSTATS_PLUGIN_DB_VERSION', '0.0.1'); +define('GLM_MEMBERS_SERVERSTATS_PLUGIN_DB_VERSION', '1.0.0'); // This is the minimum version of the GLM Members DB plugin require for this plugin. -define('GLM_MEMBERS_SERVERSTATS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.5.0'); +define('GLM_MEMBERS_SERVERSTATS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.5.1'); // Check if plugin version is not current in WordPress option and if needed updated it if (GLM_MEMBERS_SERVERSTATS_PLUGIN_VERSION != get_option('glmMembersDatabaseServerStatsPluginVersion')) { diff --git a/models/admin/ajax/serverBandwidthGraphs.php b/models/admin/ajax/serverBandwidthGraphs.php index d77be8a..4b42861 100644 --- a/models/admin/ajax/serverBandwidthGraphs.php +++ b/models/admin/ajax/serverBandwidthGraphs.php @@ -36,6 +36,13 @@ class GlmMembersAdmin_ajax_serverBandwidthGraphs extends GlmServerBandwidthSupp * @access public */ public $config; + /** + * Target Monthly Bandwidth + * + * @var $target + * @access public + */ + public $target; /* * Constructor @@ -67,6 +74,8 @@ class GlmMembersAdmin_ajax_serverBandwidthGraphs extends GlmServerBandwidthSupp $dbData['website'] ); + $this->target = $dbData['target']; + } /* @@ -86,6 +95,7 @@ class GlmMembersAdmin_ajax_serverBandwidthGraphs extends GlmServerBandwidthSupp $graphType = $_REQUEST['graphType']; $interval = 1; + $useTarget = false; switch($graphType) { case 'twoDay': $interval = 8; @@ -95,6 +105,7 @@ class GlmMembersAdmin_ajax_serverBandwidthGraphs extends GlmServerBandwidthSupp break; case 'twoYear': $interval = 1; + $useTarget = true; break; default: die("Invalid bandwidth graph type: $graphType"); @@ -107,7 +118,7 @@ class GlmMembersAdmin_ajax_serverBandwidthGraphs extends GlmServerBandwidthSupp // Load PHPGraphLib require_once(GLM_MEMBERS_PLUGIN_LIB_PATH.'/phpgraphlib-master/phpgraphlib.php'); - // Create graph object + // Create graph object and set parameters $graph = new PHPGraphLib(1200,300); $graph->setXValues(true); $graph->setYValues(true); @@ -125,6 +136,11 @@ class GlmMembersAdmin_ajax_serverBandwidthGraphs extends GlmServerBandwidthSupp $graph->addData($data['data_in']); $graph->addData($data['data_out']); + // Set target bandwidth line. Must be set after data sets + if ($useTarget) { + $graph->setGoalLine(($this->target/1000), "black", "dashed"); + } + // $graph->setTitle($graphTitle); - In this case the graph title is on the pop-up dialog box. $graph->createGraph(); diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql index 5d7fb94..ad11d0d 100644 --- a/setup/databaseScripts/create_database_V0.0.1.sql +++ b/setup/databaseScripts/create_database_V0.0.1.sql @@ -15,6 +15,7 @@ CREATE TABLE {prefix}management ( db_user TINYTEXT NULL, -- User name for database db_pass TINYTEXT NULL, -- Password for access to database website TINYTEXT NULL, -- Website name as used in database + target INT NULL, -- Target Bandwidth per Month in Megabytes PRIMARY KEY (id) ); @@ -24,5 +25,5 @@ CREATE TABLE {prefix}management ( INSERT INTO {prefix}management ( id, enabled, db_name, db_host, db_user, db_pass, website ) VALUES - ( 1, true, 'bandwidth', 'angelia.gaslightmedia.com', 'bandwidthRO', ',Wv4W*~^bL_vF3F4PbGsS', '' ) + ( 1, true, 'bandwidth', 'angelia.gaslightmedia.com', 'bandwidthRO', ',Wv4W*~^bL_vF3F4PbGsS', '', '500' ) ; diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index adefd76..a844606 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -15,5 +15,6 @@ $glmMembersServerStatsDbVersions = array( '0.0.1' => array('version' => '0.0.1', 'tables' => 1, 'date' => '8/19/16'), + '1.0.0' => array('version' => '1.0.0', 'tables' => 1, 'date' => '8/22/16') ); diff --git a/setup/databaseScripts/drop_database_V0.0.1.sql b/setup/databaseScripts/drop_database_V0.0.1.sql new file mode 100644 index 0000000..fec830b --- /dev/null +++ b/setup/databaseScripts/drop_database_V0.0.1.sql @@ -0,0 +1,12 @@ +-- Gaslight Media Members Database +-- File Created: 12/09/14 15:27:15 +-- Database Version: 1.1.5 +-- Database Deletion Script +-- Note: Tables with DELETE CASCADE must appear before referenced table +-- +-- Multiple tables may be separated by ",". + +DROP TABLE IF EXISTS + {prefix}management +; + diff --git a/setup/databaseScripts/update_database_V0.0.2.sql b/setup/databaseScripts/update_database_V0.0.2.sql new file mode 100644 index 0000000..e5cd062 --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.2.sql @@ -0,0 +1,10 @@ +-- Gaslight Media Members Database +-- File Created: 12/09/14 15:27:15 +-- Database Version: 0.0.2 +-- Database Update From Previous Version Script +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashses + +-- Add target bandwidth for bandwidth reports +ALTER TABLE {prefix}management ADD COLUMN target INT; diff --git a/views/admin/dashboardWidget/serverStats.html b/views/admin/dashboardWidget/serverStats.html index 07502d7..919fb17 100644 --- a/views/admin/dashboardWidget/serverStats.html +++ b/views/admin/dashboardWidget/serverStats.html @@ -56,17 +56,17 @@

{$glmSiteTitle}

{$thisDate} - Server Bandwidth Stats for Today - Megabytes + Server Bandwidth Stats for Today by 10 Min Intervals - Megabytes

{$thisDate} - Server Bandwidth Stats for this Month - Gigabytes + Server Bandwidth Stats for last 2 Months by Day - Gigabytes

{$thisDate} - Server Bandwidth Stats for 2 Years - Gigabytes + Server Bandwidth Stats for last 2 Years by Month - Gigabytes

Color Key: Incoming, Outgoing, Total
diff --git a/views/admin/management/serverStats.html b/views/admin/management/serverStats.html index 7fdd3c8..fb3484b 100644 --- a/views/admin/management/serverStats.html +++ b/views/admin/management/serverStats.html @@ -61,6 +61,14 @@ {if $serverStatsSettings.fieldFail.website}

{$serverStatsSettings.fieldFail.website}

{/if} + + Monthly Target Bandwidth: + + +
Monthly target bandwidth is entered in Megabytes without any fractions. + {if $serverStatsSettings.fieldFail.target}

{$serverStatsSettings.fieldFail.target}

{/if} + +