Moved provider site addresses to defines.php and other updates and fixes.
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 30 Jul 2019 18:43:27 +0000 (14:43 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 30 Jul 2019 18:43:27 +0000 (14:43 -0400)
classes/serverBandwidthSupport.php
defines.php
setup/commonHooks.php
views/adminServerStats.html
views/adminServerStatsConfig.html

index 21087c5..75a894c 100755 (executable)
@@ -142,6 +142,9 @@ class glmServerStatsBandwidthSupport
                 trigger_error('GLM Usage: bandwidthDataConnect() - '.$this->connectError, E_USER_NOTICE);
             } else {
 
+                // Get global send percentage - Notify if above this
+                $this->threshold = $config['send_percent'] - 0;
+
                 if (!$website) {
                     $website = $config['website'];
                 }
@@ -360,7 +363,7 @@ class glmServerStatsBandwidthSupport
         if ($this->bwdb == false) {
             return false;
         }
-//This one done
+
         // Get stats for yesterday in Megabytes for traffic and Gigabytes for Storage
         $yesterday = date('Y-m-d 0:0:0.0', strtotime(date('Y-m-d')." - 1day"));
         $today = date('Y-m-d 0:0:0.0');
@@ -898,6 +901,7 @@ class glmServerStatsBandwidthSupport
         // For each website retrieved
         foreach ($websites as $site) {
 
+
             $mesg = '';
 
             // If targets had exceeded target
@@ -922,7 +926,7 @@ class glmServerStatsBandwidthSupport
                 ';
 
                 // If customer contact provided
-                if (trim($site['cust_contact']) != '' && $sendToCustContact) {
+                if ($sendAll || (trim($site['cust_contact']) != '' && $sendToCustContact)) {
 
                     $numbReportingWithContactEmail++;
 
@@ -1044,6 +1048,16 @@ class glmServerStatsBandwidthSupport
     public function sendHtmlEmail( $to, $from, $subject, $mesg, $forceDisplay = false )
     {
 
+        if (trim($to) == '') {
+
+            if (!$forceDisplay) {
+                echo '<br><b>E-Mail Not Sent - No "To:" address!</b>';
+                return;
+            }
+            $to = "( *** E-Mail Address Not Supplied - This E-Mail would not have been sent. *** )";
+
+        }
+
         // On development servers, force display
         if (GLM_SERVERSTATS_PLUGIN_HOST == 'DEVELOPMENT') {
             $forceDisplay = true;
index 7e6286b..a5a4cb0 100755 (executable)
@@ -5,6 +5,11 @@
  * 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');
+
+
 define('GLM_SERVERSTATS_CONTACT_EMAIL', "plugins.gaslightmedia.com");
 
 // Set to true to add more debug messages to the error log
index e66a9db..7a65fdf 100644 (file)
@@ -37,7 +37,7 @@
  * and be able to connect to the server usage statistics database.
  */
 add_filter('glm-serverstats-is-provider', function() {
-        return ((strpos(GLM_SERVERSTATS_SITE_BASE_URL, '192.168.44.82') !== false || strpos(GLM_SERVERSTATS_SITE_BASE_URL, 'www.gaslightmedia.com') !== false));
+    return ((strpos(GLM_SERVERSTATS_SITE_BASE_URL, GLM_SERVERSTATS_PROVIDER_1) !== false || strpos(GLM_SERVERSTATS_SITE_BASE_URL, GLM_SERVERSTATS_PROVIDER_2) !== false));
     },
     10,
     2
index ca6425e..5d79c6c 100755 (executable)
         font-size: 1.2rem;
     }
     .graphContainer {
-        position: relative;
     }
     .graphContainer .graphTitle {
-        position: absolute;
-        top: -10px;
-        width: 100%;
-        margin-top: 10px;
-        font-weight: bold;
         font-size: 1.1rem;
+        font-weight: bold;
+        margin-bottom: 10px;
     }
     .graph {
-        margin-top: 20px;
     }
 
 </style>
                                 {if $selectedSite}
     
                                     <div>
-                                        <a href="{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxSendUsageReport&selected_site={$selectedSite}" target="usageEmail" class="button button-secondary">Send usage E-mail for site selected above</a>
-                                        &nbsp;&nbsp;<a href="{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxSendUsageReport&selected_site={$selectedSite}&display_only=true" target="usageEmail" class="button button-secondary">Display usage E-mail for site selected above</a>
+                                        Send: 
+                                        <a href="{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxSendUsageReport&selected_site={$selectedSite}" target="usageEmail" class="button button-secondary button-small">Send usage E-mail for site selected above</a>
+                                        &nbsp;&nbsp;
+                                        Review:
+                                        <a href="{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxSendUsageReport&selected_site={$selectedSite}&display_only=true" target="usageEmail" class="button button-secondary button-small">Display usage E-mail for site selected above</a>
+                                        &nbsp;&nbsp;
+                                        <a href="{$ajaxUrl}?action=glm_server_stats&glm_action=ajaxSendUsageReport&display_only=true" target="usageEmail" class="button button-secondary button-small">Display usage E-mail for all sites above threashold percentage</a>
                                     </div>
     
                                 {/if}
                                 'field'         => 'cust_contact',
                                 'value'         => {$settings.cust_contact},
                                 'label'         => 'Customer Contact E-Mail',
-                                'required'      => true
+                                'required'      => false,
+                                'helpText'      => 'Leave empty to prevent any E-mail from being sent for this site.'
                             ]}
                             {include file="ui/f6/text.html"}
     
                             text-align: left;
                             vertical-align: top;
                             padding: 0px;
+                            margin: 0px;
                         }
                         .glmbw-table tr {
+                            margin-bottom: 0px;
+                            padding-bottom: 0px;
                         }
                         .glmbw-image {
                             max-width: 90%;
                             font-size: 1em;
                             text-align: center;
                         }
+                        #key-line {
+                            margin: 0px;
+                            padding: 0px;
+                        }
+                        #print-date {
+                            font-size: 1em;
+                            padding: 0px;
+                            margin: 0px;
+                        }
+                        .graphContainer {
+                        }
+                        .graphContainer .graphTitle {
+                            font-weight: bold;
+                            margin-bottom: 5px;
+                        }
+                        .graph {
+                        }
+                                            
                     </style>
                     <div class="print-title" style="text-align: center;">
                         Usage statistics for site:&nbsp;&nbsp;{$selectedSite|upper}&nbsp;&nbsp;&nbsp;&nbsp;Date:
-                        <input style="width: 7rem;" data-id="graphDate" type="text" name="graph_date" value="{$thisDate}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time" tabindex="2">
+                        <input id="print-date" style="width: 7rem;" data-id="graphDate" type="text" name="graph_date" value="{$thisDate}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time" tabindex="2">
                     </div>
                     <center>
                         <table class="glmbw-table unstriped">
                             <tr>
-                                <th>&nbsp;</th><th>Traffic</th><th>Target</th><th>% of Target</th><th>Storage</th><th>target</th><th>% of Target</th></tr>
+                                <th>&nbsp;</th><th>Traffic</th><th>Target</th><th>% of Target</th><th>Storage</th><th>target</th><th>% of Target</th>
+                            </tr>
                             <tr>
                                 <th>Yesterday: </th>
                                 <td>
                                 <td{if $serverStats.trafficDiff.diskExceeded} style="color: red;"{/if}>{$serverStats.trafficDiff.diskPercent|string_format:"%.0f"}%</td>
                             </tr>
                         </table>
-                        <span class="datePrintInclude" style="margin-bottom: 0em;">
-                            <p>
+                        <span class="datePrintInclude">
+                            <p id="key-line">
                                 Color Key: <span style="color: maroon;">Target</span>, <span style="color: gray;">Storage</span>, <span style="color: red;">Incoming</span>, <span style="color: green;">Outgoing</span>, <span style="color: blue;">Total</span><br>
                             </p>
                         </span>
 
                         <div class="graphContainer">
+                            <div class="graph"><img id="twoYearImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
                             <div class="graphTitle">
                                 Monthly traffic totals for the past year. The dotted line is our current/planned billing level.
                             </div>
-                            <div class="graph" style="padding-top: 0px;"><img id="twoYearImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
                         </div>
                         <div class="graphContainer">
+                            <div class="graph"><img id="twoYearStorageImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
                             <div class="graphTitle">
                                 Montlhy maximum disk space used for past year. The dotted line is our current/planned billing level.
                             </div>
-                            <div class="graph" style="padding-top: 0px;"><img id="twoYearStorageImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
                         </div>
                         <div class="graphContainer">
+                            <div class="graph"><img id="twoDayImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
                             <div class="graphTitle">
                                 Detail traffic for past 24 hours.
                             </div>
-                            <div class="graph" style="padding-top: 0px;"><img id="twoDayImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
                         </div>
                         <div class="graphContainer">
+                            <div class="graph""><img id="twoMonthImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
                             <div class="graphTitle">
                                 Daily traffic for past two months.
                             </div>
-                            <div class="graph" style="padding-top: 0px;"><img id="twoMonthImg" src="{$assetsUrl}/graph.png" class="glmbw-image"></div>
                         </div>
                     </center>
                 </div>
index 447ad0c..b88f7db 100755 (executable)
                                 'field'         => 'show_notifications',
                                 'value'         => {!empty($show_notifications)},
                                 'label'         => 'Customer Notiifications',
-                                'helpText'      => 'Turn this on to have general Gaslight Media messages displayed on this site.',
+                                'helpText'      => 'Turn this on to have general Gaslight Media messages displayed on this site.'
                             ]}
                             {include file="ui/f6/checkbox.html"}