Пример #1
0
 protected function deleteInactiveVncWindow()
 {
     // print("\n[Daemon]: +++ TODO: deleteInactiveWindow() +++");
     $db = new DBConnector();
     // window_ids in db
     $vnc_windows_in_db = array();
     $client_info = $db->getVNC_ClientInfo();
     foreach ($client_info as $info) {
         $vnc_windows_in_db[] = $info["win_id"];
     }
     // window_ids on screen
     $windows_on_screen = array();
     $windows = explode("\n", shell_exec('wmctrl -l'));
     foreach ($windows as $w) {
         $field = explode(' ', $w);
         $id = $field[0];
         if ($id != '') {
             $windows_on_screen[] = $id;
         }
     }
     // print("[Daemon]: clients in db = " . serialize($vnc_windows_in_db));
     // print("[Daemon]: client on screen = " . serialize($windows_on_screen));
     // window_ids that are in the db, but not on the screen (window already closed)
     $inactive_vnc_window_ids = array_diff($vnc_windows_in_db, $windows_on_screen);
     foreach ($inactive_vnc_window_ids as $inactive_win_id) {
         // define vnc-id
         $inactive_vnc_id = $db->querySingle("SELECT file FROM window WHERE win_id='" . $inactive_win_id . "'");
         // delete from database (send to control.php)
         $curl = curl_init();
         curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => CONFIG_CONTROL_FILE_URL . '?window=vncwin&delete=VNC&vncid=' . $inactive_win_id, CURLOPT_USERAGENT => 'PalMA cURL Request'));
         $resp = curl_exec($curl);
         curl_close($curl);
         // print("[Daemon]: inactive vnc_id = $inactive_vnc_id >> add to list: " .serialize($this->_IGNORE_LIST));
     }
 }