Ejemplo n.º 1
0
 /**
  * Display Wake On LAN
  * @return <XiboAPIResponse>
  */
 public function DisplayWakeOnLan()
 {
     if (!$this->user->PageAuth('display')) {
         return $this->Error(1, 'Access Denied');
     }
     Kit::ClassLoader('Display');
     $displayObject = new Display();
     $displayId = $this->GetParam('displayId', _INT);
     // Try to issue the WOL command
     if (!$displayObject->WakeOnLan($displayId)) {
         return $this->Error($displayObject->GetErrorNumber(), $displayObject->GetErrorMessage());
     }
     // Return True
     return $this->Respond($this->ReturnId('success', true));
 }
Ejemplo n.º 2
0
 /**
  * Wake on LAN
  */
 public function WakeOnLan()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
     }
     $db =& $this->db;
     $response = new ResponseManager();
     $displayObject = new Display($db);
     $displayId = Kit::GetParam('DisplayId', _POST, _INT);
     if (!$displayObject->WakeOnLan($displayId)) {
         trigger_error($displayObject->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse(__('Wake on Lan command sent.'));
     $response->Respond();
 }
Ejemplo n.º 3
0
     $sth = $dbh->prepare('SELECT DisplayID, Display, WakeOnLanTime, LastWakeOnLanCommandSent FROM `display` WHERE WakeOnLan = 1');
     $sth->execute(array());
     foreach ($sth->fetchAll() as $row) {
         $displayId = Kit::ValidateParam($row['DisplayID'], _INT);
         $display = Kit::ValidateParam($row['Display'], _STRING);
         $wakeOnLanTime = Kit::ValidateParam($row['WakeOnLanTime'], _STRING);
         $lastWakeOnLan = Kit::ValidateParam($row['LastWakeOnLanCommandSent'], _INT);
         // Time to WOL (with respect to today)
         $timeToWake = strtotime(date('Y-m-d') . ' ' . $wakeOnLanTime);
         $timeNow = time();
         // Should the display be awake?
         if ($timeNow >= $timeToWake) {
             // Client should be awake, so has this displays WOL time been passed
             if ($lastWakeOnLan < $timeToWake) {
                 // Call the Wake On Lan method of the display object
                 if (!$displayObject->WakeOnLan($displayId)) {
                     print $display . ':Error=' . $displayObject->GetErrorMessage() . '<br/>\\n';
                 } else {
                     print $display . ':Sent WOL Message. Previous WOL send time: ' . date('Y-m-d H:i:s', $lastWakeOnLan) . '<br/>\\n';
                 }
             } else {
                 print $display . ':Display already awake. Previous WOL send time: ' . date('Y-m-d H:i:s', $lastWakeOnLan) . '<br/>\\n';
             }
         } else {
             print $display . ':Sleeping<br/>\\n';
         }
         print $display . ':N/A<br/>\\n';
     }
     print __('Done.');
 } catch (Exception $e) {
     Debug::LogEntry('error', $e->getMessage());