public function bandwidthDataConnect($host, $user, $pass, $database, $website)
{
+ // Initialize MySQLi
+ $this->bwdb = mysqli_init();
+
+ // Set a short timeout
+ $this->bwdb->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
+
// Connect to MySQL
- $this->bwdb = mysqli_connect($host, $user, $pass, $database);
+ $this->bwdb->real_connect($host, $user, $pass, $database);
- if (!$this->bwdb) {
- $this->bwdb = false;
+ // If there was an error connecting
+ if ($this->bwdb->connect_errno) {
return mysqli_connect_error();
}
$this->bandwidthGetWebsiteID($website);
if (!$this->siteId) {
- $this->bwdb = false;
return "Website Name not found: ".$website;
}
* Plugin Name: GLM ServerStats - Stand Alone
* Plugin URI: http://www.gaslightmedia.com/
* Description: Gaslight Media Server Stats Display.
- * Version: 1.0.10
+ * Version: 1.1.0
* Author: Gaslight Media
* Author URI: http://www.gaslightmedia.com/
* License: GPL2
* @package glmServerStats
* @author Chuck Scott <cscott@gaslightmedia.com>
* @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.0.10
+ * @version 1.1.0
*/
-define('GLM_SERVERSTATS_PLUGIN_VERSION', '1.0.10');
+define('GLM_SERVERSTATS_PLUGIN_VERSION', '1.1.0');
// Check that we're being called by WordPress.
if (!defined('ABSPATH')) {
{
$haveStats = false;
+ $connectError = '';
$thisDate = false;
$thisDateTime = false;
$thisMonth = false;
if ($config != false) {
// Connect to the bandwidth database
- $this->bandwidthDataConnect(
+ $err = $this->bandwidthDataConnect(
$config['db_host'],
$config['db_user'],
$config['db_pass'],
$config['website']
);
- // Get the current bandwidth stats
- $stats = $this->bandwidthGetStats();
+ // Check for connection error
+ if ($err != '') {
+ $connectError = $err;
+ } else {
- if ($stats != false) {
+ // Get the current bandwidth stats
+ $stats = $this->bandwidthGetStats();
- // Build summary info
- $thisDate = date('m/d/Y');
- $thisDateTime = strtotime($thisDate);
- $thisMonth = date('m/Y');
- $thisMonthTime = strtotime(date('m/01/Y'));
- $websiteId = $this->siteId;
+ if ($stats != false) {
- $haveStats = true;
+ // Build summary info
+ $thisDate = date('m/d/Y');
+ $thisDateTime = strtotime($thisDate);
+ $thisMonth = date('m/Y');
+ $thisMonthTime = strtotime(date('m/01/Y'));
+ $websiteId = $this->siteId;
- }
+ $haveStats = true;
+
+ }
+ }
}
// Compile template data
$templateData = array(
'haveStats' => $haveStats,
+ 'connectError' => $connectError,
'serverStats' => $stats,
'thisDate' => $thisDate,
'thisDateTime' => $thisDateTime,
</script>
{else}
<h3 class="glm-error">Server Bandwidth has not been configured. Please ask system administrator to configure this plugin.</h3>
+ <p><b>Error:</b> {$connectError}</p>
{/if}
{include file='footer.html'}