示例#1
0
 /**
  * APC UPS ajax status controller
  *
  * @return view
  */
 function status()
 {
     // Load libraries
     //---------------
     $this->lang->load('apcups');
     $this->load->library('apcups/Apc');
     header('Cache-Control: no-cache, must-revalidate');
     header('Content-type: application/json');
     try {
         echo json_encode(array('code' => 0, 'status' => $this->apc->get_status()));
     } catch (Exception $e) {
         echo json_encode(array('code' => clearos_exception_code($e), 'errmsg' => clearos_exception_message($e)));
     }
 }
示例#2
0
 /**
  * Returns connection status.
  *
  * @return JSON
  */
 function get_status()
 {
     // Load dependencies
     //------------------
     $this->load->library('web_proxy/Squid');
     // Run synchronize
     //----------------
     try {
         sleep(2);
         $data['error_code'] = 0;
         $data['status_code'] = $this->squid->get_connection_status();
         $data['status_message'] = $this->squid->get_connection_status_message();
     } catch (Exception $e) {
         $data['error_code'] = clearos_exception_code($e);
         $data['error_message'] = clearos_exception_message($e);
     }
     // Return status message
     //----------------------
     $this->output->set_header("Content-Type: application/json");
     $this->output->set_output(json_encode($data));
 }