Exemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     // log the attempt
     stdlog();
     # ensure our URL doesn't have a trailing / as this may break image (and other) relative paths
     $this->load->helper('url');
     if (strrpos($_SERVER['REQUEST_URI'], '/') === strlen($_SERVER['REQUEST_URI']) - 1) {
         redirect(uri_string());
     }
     $this->load->helper('input');
     $this->load->helper('output');
     $this->load->helper('error');
     $this->load->model('m_networks');
     inputRead();
     $this->output->url = $this->config->item('oa_web_index');
 }
Exemplo n.º 2
0
 public function index()
 {
     if (stripos($_SERVER['HTTP_ACCEPT'], 'json') !== false) {
         // JSON request to the base URL
         // return a document providing futher links
         $this->load->helper('input');
         $this->load->helper('output');
         $this->load->helper('error');
         inputRead();
         $this->response->links->related = array();
         $this->response->links->related[]['href'] = $this->response->links->self . 'devices';
         $this->response->links->related[]['href'] = $this->response->links->self . 'networks';
         $this->response->links->related[]['href'] = $this->response->links->self . 'credentials';
         output($this->response);
     } else {
         redirect('main/list_groups/');
     }
 }
Exemplo n.º 3
0
 public function __construct()
 {
     parent::__construct();
     // log the attempt
     stdlog();
     # ensure our URL doesn't have a trailing / as this may break image (and other) relative paths
     $this->load->helper('url');
     if (strrpos($_SERVER['REQUEST_URI'], '/') === strlen($_SERVER['REQUEST_URI']) - 1) {
         redirect(uri_string());
     }
     $this->load->helper('network');
     $this->load->helper('output');
     $this->load->helper('error');
     $this->load->helper('input');
     $this->load->model('m_devices');
     $this->load->model('m_orgs');
     inputRead();
     $this->output->url = $this->config->item('oa_web_index');
     if ($this->response->meta->id != '') {
         $access_level = $this->m_devices->get_user_device_org_access();
         if ($access_level < 1) {
             // we should determine if the device does actually exist or not
             // then we can throw the correct status code of 404 or 403
             $sql = "SELECT system.id FROM system WHERE system.id = ?";
             $data = array($this->response->meta->id);
             $query = $this->db->query($sql, $data);
             $result = $query->result();
             if (count($result) == 0) {
                 $this->response->errors[] = getError('ERR-0007');
             } else {
                 $this->response->errors[] = getError('ERR-0008');
             }
             $this->response->meta->header = $this->response->errors[0]->status;
             output($this->response);
             exit;
         }
     }
 }