Exemplo n.º 1
0
 /**
  * Alert when a Display is up
  * @param int $displayId
  * @param string $display
  * @param int $loggedIn
  * @param int $emailAlert
  */
 private function AlertDisplayUp($displayId, $display, $loggedIn, $emailAlert)
 {
     $maintenanceEnabled = Config::GetSetting('MAINTENANCE_ENABLED');
     if ($loggedIn == 0) {
         // Log display up
         $statObject = new Stat();
         $statObject->displayUp($displayId);
         // Do we need to email?
         if ($emailAlert == 1 && ($maintenanceEnabled == 'On' || $maintenanceEnabled == 'Protected') && Config::GetSetting('MAINTENANCE_EMAIL_ALERTS') == 'On') {
             $msgTo = Kit::ValidateParam(Config::GetSetting("mail_to"), _PASSWORD);
             $msgFrom = Kit::ValidateParam(Config::GetSetting("mail_from"), _PASSWORD);
             $subject = sprintf(__("Recovery for Display %s"), $display);
             $body = sprintf(__("Display %s with ID %d is now back online."), $display, $displayId);
             // Get a list of people that have view access to the display?
             if (Config::GetSetting('MAINTENANCE_ALERTS_FOR_VIEW_USERS') == 1) {
                 foreach (Display::getUsers($displayId) as $user) {
                     if ($user['email'] != '') {
                         Kit::SendEmail($user['email'], $msgFrom, $subject, $body);
                     }
                 }
             }
             // Send to the original admin contact
             Kit::SendEmail($msgTo, $msgFrom, $subject, $body);
         }
     }
 }
Exemplo n.º 2
0
 // Should we send an email?
 if ($emailAlerts) {
     if (Kit::ValidateParam($display['email_alert'], _INT) == 1) {
         if ($displayGoneOffline || $alwaysAlert) {
             // Fields for email
             $subject = sprintf(__("Email Alert for Display %s"), Kit::ValidateParam($display['display'], _STRING));
             $body = sprintf(__("Display %s with ID %d was last seen at %s."), Kit::ValidateParam($display['display'], _STRING), Kit::ValidateParam($display['displayid'], _INT), date("Y-m-d H:i:s", Kit::ValidateParam($display['lastaccessed'], _INT)));
             // Get a list of people that have view access to the display?
             if ($alertForViewUsers) {
                 foreach (Display::getUsers($display['displayid']) as $user) {
                     if ($user['email'] != '') {
                         Kit::SendEmail($user['email'], $msgFrom, $subject, $body);
                     }
                 }
             }
             if (Kit::SendEmail($msgTo, $msgFrom, $subject, $body)) {
                 // Successful Alert
                 print "A";
             } else {
                 // Error sending Alert
                 print "E";
             }
         }
     } else {
         // Alert disabled for this display
         print "D";
     }
 } else {
     // Email alerts disabled globally
     print "X";
 }
Exemplo n.º 3
0
 /**
  * Authenticates the display
  * @param <type> $hardwareKey
  * @return <type>
  */
 private function AuthDisplay($hardwareKey)
 {
     $db =& $this->db;
     // check in the database for this hardwareKey
     $SQL = "SELECT licensed, inc_schedule, isAuditing, displayID, defaultlayoutid, loggedin, email_alert, display, version_instructions FROM display WHERE license = '{$hardwareKey}'";
     if (!($result = $db->query($SQL))) {
         trigger_error("License key query failed:" . $db->error());
         return false;
     }
     //Is it there?
     if ($db->num_rows($result) == 0) {
         return false;
     }
     //we have seen this display before, so check the licensed value
     $row = $db->get_row($result);
     if ($row[0] == 0) {
         return false;
     }
     // Pull the client IP address
     $clientAddress = Kit::GetParam('REMOTE_ADDR', $_SERVER, _STRING);
     // See if the client was offline and if appropriate send an alert
     // to say that it has come back online
     if ($row[5] == 0 && $row[6] == 1 && Config::GetSetting('MAINTENANCE_ENABLED') == 'On' && Config::GetSetting('MAINTENANCE_EMAIL_ALERTS') == 'On') {
         $msgTo = Kit::ValidateParam(Config::GetSetting("mail_to"), _PASSWORD);
         $msgFrom = Kit::ValidateParam(Config::GetSetting("mail_from"), _PASSWORD);
         $subject = sprintf(__("Recovery for Display %s"), $row[7]);
         $body = sprintf(__("Display %s with ID %d is now back online."), $row[7], $row[3]);
         Kit::SendEmail($msgTo, $msgFrom, $subject, $body);
     }
     // Last accessed date on the display
     $displayObject = new Display($db);
     $displayObject->Touch($hardwareKey, $clientAddress);
     // It is licensed?
     $this->licensed = true;
     $this->includeSchedule = $row[1];
     $this->isAuditing = $row[2];
     $this->displayId = $row[3];
     $this->defaultLayoutId = $row[4];
     $this->version_instructions = $row[8];
     return true;
 }