Connection warning still shows if unable to connect to the specified database.
return false;
}
+ if (!$website) {
+ $website = $config['website'];
+ }
+
// Connect to MySQL
- $res = $this->bwdb->real_connect(
+ if ($this->bwdb->real_connect(
$config['db_host'],
$config['db_user'],
$config['db_pass'],
$config['db_name']
- );
-
- if (!$website) {
- $website = $config['website'];
- }
-
- // If there was an error connecting
- if (!$res) {
- $this->connectError = mysqli_connect_error();
- } else {
+ )) {
$this->connected = true;
// Get Website Settings
$this->disk_target = $settings['disk_target'];
$this->glm_contact = $settings['glm_contact'];
$this->cust_contact = $settings['cust_contact'];
-
+ } else {
+ $this->connectError = mysqli_connect_error();
}
return $this->connected;
class adminServerStats extends glmServerStatsBandwidthSupport
{
+
+ /**
+ * Config data
+ *
+ * @var $sortBy
+ * @access public
+ */
+ public $config = false;
+
/*
* Constructor
- *
+
* No work is performed by this contructor
*/
public function __construct()
{
+ $this->config = $this->getConfig();
+
$websiteSelected = false;
if (current_user_can('administrator')) {
}
// Connect to Bandwidth Database selected in the Configure page
- $this->bandwidthDataConnect($websiteSelected);
+ $this->connected = $this->bandwidthDataConnect($websiteSelected);
}
{
$haveStats = false;
+ $stats = false;
+ $site_sort = false;
$thisDate = false;
$thisDateTime = false;
$thisMonth = false;
}
// Check for a selected site or use website in config
- $config = $this->getConfig();
$selectedSite = filter_input(INPUT_GET, 'selected_site', FILTER_SANITIZE_STRING);
if (!$selectedSite) {
- $selectedSite = $config['website'];
+ $selectedSite = $this->config['website'];
}
- $this->siteId = $this->bandwidthGetWebsiteID($selectedSite);
-
if ($this->connected) {
+ $this->siteId = $this->bandwidthGetWebsiteID($selectedSite);
+
// If user is an admin, then get a list of Websites with Bandwidth Stats
if ($this->isProvider()) {
+ // Get submitted parameters
+ $site_sort = 'default';
+ if (isset($_REQUEST['site_sort'])) {
+ $site_sort = $_REQUEST['site_sort'];
+ }
+
// Get sort order
- switch ($_REQUEST['site_sort']) {
+ switch ($site_sort) {
case 'site_name':
$sortBy = 'name';
$site_sort = 'site_name';
}
// Get sort order
- switch ($_REQUEST['site_sort']) {
+ switch ($site_sort) {
case 'site_name':
$sortBy = 'name';
$site_sort = 'site_name';
// Get bandwidth data for today
$data = $this->bandwidthGetGraphData($graphType, $this->siteId, $refDate);
+ if (!$data || !is_array($data) || count($data) == 0) {
+ die("Unable to get data. Is connection configured?");
+ }
+
// Load PHPGraphLib
require_once GLM_SERVERSTATS_PLUGIN_LIB_PATH.'/phpgraphlib-master/phpgraphlib.php';
$graph->addData($data['data_in']);
$graph->addData($data['data_out']);
- if ($graphType != 'oneDay') {
+ if (isset($data['disk_space'])) {
$graph->addData($data['disk_space']);
}
<style>
.pseudoPick {
-
- height: 150px;
- padding-left: 2px;
- overflow-y: auto;
+
+ height: 150px;
+ padding-left: 2px;
+ overflow-y: auto;
overflow-x: hidden;
display: inline-block;
margin-top: 1em;
<h2>Server Usage Statistics Configuration</h2>
<form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
<input type="hidden" name="option" value="update_connection">
- <input type="hidden" name="selected_site" value="{$selectedSite}">
<table class="glm-admin-table" style="width: 95%">
<tr>
- <td>
- {if $connectionUpdated}<h2 class="glm-notice glm-flash-updated">Settings Updated</h2>{/if}
-
+ <td colspan="2">
+ <span class="glm-notice glm-flash-updated" style="font-size: 1.5em;">Settings Updated</span>
</td>
- <th>
- <h2>Database Connection</h2>
- {if $connectionUpdateError}<br><span class="glm-error">Error {$connectionUpdateError}{/if}
+ </tr>
+ <tr>
+ <th colspan="2">
+ {if $connectError}<br><span class="glm-error" style="font-size: 1.5em; border: 1px solid black; padding: 5px; margin-bottom: 4em;">Error {$connectError}</span>{/if}
</th>
</tr>
<tr>
</table>
{if $connectError}
<h2 class="glm-error">Unable to connect to database! Please check connection settings.</h2>
-{/if}
+{/if}
<input type="submit" value="Update Database Connection" class="button-primary">
</form>
-
+
</div>
<script type="text/javascript">
location.href='#glmPageTop';
}, 500);
-
-
+
+
});
</script>