Site selection and settings form are only displayed for admins on the following site.
www.gaslightmedia.com and 192.168.44.80 (Chuck's development system)
See bottom of classes/serverBandwidthSupport.php.
$thisMonthTime = false;
$websiteId = false;
$websites = false;
+ $settings = false;
+
+ // If an update was submitted
+ $option = 'none';
+ if (isset($_REQUEST['option'])) {
+ $option = $_REQUEST['option'];
+ }
// Check for a selected site or use website in config
$config = $this->getConfig();
break;
}
+ 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_VALIDATE_EMAIL,
+ 'cust_contact' => FILTER_VALIDATE_EMAIL
+ )
+ );
+ $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'];
+
+ }
+
+ // Get sort order
+ switch ($_REQUEST['site_sort']) {
+ case 'site_name':
+ $sortBy = 'name';
+ $site_sort = 'site_name';
+ break;
+
+ case 'data_total':
+ $sortBy = 'data_total DESC';
+ $site_sort = 'data_total';
+ break;
+
+ default:
+ $sortBy = 'target_percent DESC';
+ $site_sort = 'target_percent';
+ break;
+ }
+
+ // Get the settings for the currently selected site
+ $settings = $this->bandwidthGetWebsiteSettingsFromName($selectedSite);
+
// Get list of sites in the bandwidth database
$websites = $this->bandwidthLastMonthAllSites($sortBy);
'websiteId' => $this->siteId,
'target' => $this->target,
'websites' => $websites,
- 'isProvider' => $this->isProvider(),
+ 'isProvider' => $this->isProvider(),
'site_sort' => $site_sort,
- 'selectedSite' => $selectedSite
+ 'selectedSite' => $selectedSite,
+ 'settings' => $settings
);
// Return status, suggested view, and data to controller
*/
public function __construct()
{
- $this->bandwidthDataConnect();
}
/*
$connectError = False;
$connectionUpdated = false;
- $settingsUpdated = false;
- $settingsUpdateError = false;
- $websites = false;
- $selectedSite = false;
- $settings = false;
// If an update was submitted
$option = 'none';
$connectError = $this->connectError;
}
- // Check for a selected site or use website in config
- $selectedSite = filter_input(INPUT_GET, 'selected_site', FILTER_SANITIZE_STRING);
- if (!$selectedSite) {
- $selectedSite = $config['website'];
- }
-
- // If it's OK for the user to update the settings for this site
- if ($this->isProvider()) {
-
- 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_VALIDATE_EMAIL,
- 'cust_contact' => FILTER_VALIDATE_EMAIL
- )
- );
- $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'];
-
- }
-
- // Get sort order
- switch ($_REQUEST['site_sort']) {
- case 'site_name':
- $sortBy = 'name';
- $site_sort = 'site_name';
- break;
-
- case 'data_total':
- $sortBy = 'data_total DESC';
- $site_sort = 'data_total';
- break;
-
- default:
- $sortBy = 'target_percent DESC';
- $site_sort = 'target_percent';
- break;
- }
-
- // Get list of sites in the bandwidth database
- $websites = $this->bandwidthLastMonthAllSites($sortBy);
-
- // Get the settings for the currently selected site
- $settings = $this->bandwidthGetWebsiteSettingsFromName($selectedSite);
-
- } // if OK to update site settings
// Compile template data
$templateData = array_merge(
'isProvider' => $this->isProvider(),
'connectionUpdated' => $connectionUpdated,
'connectError' => $connectError,
- 'settingsUpdated' => $settingsUpdated,
- 'settingsUpdateError' => $settingsUpdateError,
- 'site_sort' => $site_sort,
- 'websites' => $websites,
- 'selectedSite' => $selectedSite,
- 'settings' => $settings
)
);
{else}
{if $isProvider}
- <form href="#">
- <h3>Select a site to display (service provider only)</h3>
+ <center><h1>Service Provider Section</h1></center>
+ <form action="{$thisUrl}?page={$thisPage}&selected_site={$selectedSite}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="option" value="update_site">
+ <input type="hidden" name="site_sort" value="$site_sort">
+ <input type="hidden" name="selected_site" value="{$selectedSite}">
+ <h3>Select a site to display</h3>
<p>
Sort by:
<input type="radio" name="site_sort" {if $site_sort == 'target_percent'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=target_percent&selected_site={$selectedSite}';">Percent of Target
<input type="radio" name="site_sort" {if $site_sort == 'data_total'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=data_total&selected_site={$selectedSite}';">Total Traffic
<input type="radio" name="site_sort" {if $site_sort == 'site_name'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=site_name&selected_site={$selectedSite}';">Site Name
</p>
- </form>
<div class="pseudoPick">
<pre style="text-decoration: underline;">Website Last Month Target </pre>
{foreach $websites as $site}
-->
{/foreach}
</div>
+ {if $selectedSite}
+ <table class="glm-admin-table" style="width: 100%">
+ <tr><td> </td><th><h2>Settings for Selected Site</h2></th></tr>
+ <tr>
+ <th class="glm-required">Monthly Target Traffic:</th>
+ <td>
+ <input type="text" name="target" value="{$settings.target|string_format:"%.1f"}" class="glm-form-text-input-medium" placeholder="i.e. 2.000 for 2 Gigabytes">
+ <br>Monthly target traffic is entered in Gigabytes.
+ </td>
+ </tr>
+ <tr>
+ <th class="glm-required">Target Disk Space Used:</th>
+ <td>
+ <input type="text" name="disk_target" value="{$settings.disk_target|string_format:"%.1f"}" class="glm-form-text-input-medium" placeholder="i.e. 2.000 for 2 Gigabytes">
+ <br>Disk Space is entered in Gigabytes.
+ </td>
+ </tr>
+ <tr>
+ <th class="glm-required">Gaslight Media Contact E-Mail:</th>
+ <td>
+ <input type="text" name="glm_contact" value="{$settings.glm_contact}" class="glm-form-text-input-medium">
+ <br>E-mail address of Gaslight Media contact who will receive over-target E-Mail.
+ </td>
+ </tr>
+ <tr>
+ <th class="glm-required">Customer Contact E-Mail:</th>
+ <td>
+ <input type="text" name="cust_contact" value="{$settings.cust_contact}" class="glm-form-text-input-medium">
+ <br>E-mail address of customer contact who will receive over-target E-Mail.
+ </td>
+ </tr>
+ </table>
+ <input type="submit" value="Update Site Settings" class="button-primary">
+ <hr>
+ {/if}
+ <center><h1>Customer Section</h1></center>
{/if}
<!-- Server Data Usage Stats -->
<div style="width: 95%;">
{/if}
<input type="submit" value="Update Database Connection" class="button-primary">
</form>
-
-{if !$connectError && $isProvider}
- <form action="{$thisUrl}?page={$thisPage}&selected_site={$selectedSite}" method="post" enctype="multipart/form-data">
- <input type="hidden" name="option" value="update_site">
- <input type="hidden" name="selected_site" value="{$selectedSite}">
- <table class="glm-admin-table" style="width: 100%">
- <tr><td colspan="2"><hr></td></tr>
- <tr><td> </td><th><h2>Site Selection (service provider only)</h2></th></tr>
- <tr>
- <th>Select Site to Configure</th>
- <td>
- <p>
- Sort by:
- <input type="radio" name="site_sort" value="data_total" {if $site_sort == 'data_total'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=data_total&selected_site={$site.name}';">Total Traffic
- <input type="radio" name="site_sort" value="target_percent" {if $site_sort == 'target_percent'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=target_percent&selected_site={$site.name}';">Percent of Target
- <input type="radio" name="site_sort" value="site_name" {if $site_sort == 'site_name'} checked="checked"{/if} onClick="location.href='{$thisUrl}?page={$thisPage}&site_sort=site_name&selected_site={$site.name}';">Site Name
- </p>
- <div class="pseudoPick">
- <pre style="text-decoration: underline;">Website Last Month Target </pre>
- {foreach $websites as $site}
- <pre class="pseudoPickOption"></span>{if $site.name == $selectedSite}<a name="selectedSite"></a>{/if}<a href="{$thisUrl}?page={$thisPage}&selected_site={$site.name}&site_sort={$site_sort}" class="pseudoPickOption" {if $site.name == $selectedSite}onClick="return false;"{/if}><span{if $site.name == $selectedSite} style="background-color: LightGray;"{/if}>{$site.name|string_format:"%-50s"} {$site.data_total|string_format:"%6.1f"} Gigabytes {$site.target|string_format:"%8.1f"} Gigabytes <span {if $site.target_percent > 80}style="color: red;"{/if}>{$site.target_percent|string_format:"%6.0f"}%</span></span></a></pre>
- {/foreach}
- </div>
- </td>
- {if $selectedSite}
- <tr><td colspan="2"><hr></td></tr>
- <tr><td> </td><th><h2>Settings for Selected Site (service provider only)</h2></th></tr>
- <tr>
- <th class="glm-required">Monthly Target Traffic:</th>
- <td>
- <input type="text" name="target" value="{$settings.target|string_format:"%.1f"}" class="glm-form-text-input-medium" placeholder="i.e. 2.000 for 2 Gigabytes">
- <br>Monthly target traffic is entered in Gigabytes.
- </td>
- </tr>
- <tr>
- <th class="glm-required">Target Disk Space Used:</th>
- <td>
- <input type="text" name="disk_target" value="{$settings.disk_target|string_format:"%.1f"}" class="glm-form-text-input-medium" placeholder="i.e. 2.000 for 2 Gigabytes">
- <br>Disk Space is entered in Gigabytes.
- </td>
- </tr>
- <tr>
- <th class="glm-required">Gaslight Media Contact E-Mail:</th>
- <td>
- <input type="text" name="glm_contact" value="{$settings.glm_contact}" class="glm-form-text-input-medium">
- <br>E-mail address of Gaslight Media contact who will receive over-target E-Mail.
- </td>
- </tr>
- <tr>
- <th class="glm-required">Customer Contact E-Mail:</th>
- <td>
- <input type="text" name="cust_contact" value="{$settings.cust_contact}" class="glm-form-text-input-medium">
- <br>E-mail address of customer contact who will receive over-target E-Mail.
- </td>
- </tr>
- {/if}
- </table>
- {if $selectedSite}
- <input type="submit" value="Update Site Settings" class="button-primary">
- {/if}
- </form>
-{/if}
</div>
<script type="text/javascript">