/** * Handle all external requests detecting if they're a mobile * device otherwise pass-thru to target url * * @param $url * @param array $alternativeURLs */ protected function request($url, $alternativeURLs = array()) { set_last_known_url($url); $iphoneURL = $alternativeURLs['iphone']; $site_url = site_url(); $data = compact('iphoneURL', 'url', 'site_url'); echo $this->load->view('external-js-redirect', $data, true); exit; }
function index() { $data = $this->init_view_data(); $data = array_merge($data, array('site_title' => 'OpenVBX', 'iframe_url' => site_url('/messages'), 'users' => $this->get_users(), 'twilio_js' => $this->twilio_js_baseurl . '/libs/twiliojs/1.0/' . $this->twilio_js_file, 'client_capability' => null)); // if the 'last_known_url' cookie is set then we've been redirected IN to frames mode if (!empty($_COOKIE['last_known_url'])) { $data['iframe_url'] = $_COOKIE['last_known_url']; set_last_known_url('', time() - 3600); } if (!empty($this->application_sid)) { $user_id = intval($this->session->userdata('user_id')); $user = VBX_user::get(array('id' => $user_id)); $data['client_capability'] = generate_capability_token(); } // internal dev haxies if (function_exists('twilio_dev_mods')) { $data = twilio_dev_mods($data); } $data['browserphone'] = $this->init_browserphone_data($data['callerid_numbers']); $this->load->view('iframe', $data); }
function index() { $data = $this->init_view_data(); $twilio_js = sprintf('%s://static.twilio.com/libs/twiliojs/%s/twilio%s.js', 'http' . (is_ssl() ? 's' : ''), $this->twilio_js_version, $this->config->item('use_unminimized_js') ? '' : '.min'); $data = array_merge($data, array('site_title' => 'OpenVBX', 'iframe_url' => site_url('/messages'), 'users' => $this->get_users(), 'twilio_js' => $twilio_js, 'client_capability' => null)); // if the 'last_known_url' cookie is set then we've been redirected IN to frames mode if (!empty($_COOKIE['last_known_url'])) { $data['iframe_url'] = $_COOKIE['last_known_url']; set_last_known_url('', time() - 3600); } if (!empty($this->application_sid)) { $user_id = intval($this->session->userdata('user_id')); $user = VBX_user::get(array('id' => $user_id)); $data['client_capability'] = generate_capability_token(); } // internal dev haxies if (function_exists('twilio_dev_mods')) { $data = twilio_dev_mods($data); } $data['site_rev'] = $this->config->item('site_rev'); $data['browserphone'] = $this->init_browserphone_data($data['callerid_numbers']); $this->load->view('iframe', $data); }
protected function after_login_completed($user, $redirect) { $last_seen = $user->last_seen; // if the redirect would take us back to // the iframe the nuke it if ($redirect == site_url()) { $redirect = ''; } // Redirect to flows if this is an admin and his inbox is zero // (but not if the caller is hitting the REST api) if ($this->response_type != 'json' && empty($redirect)) { $is_admin = $this->session->userdata('is_admin'); if ($is_admin) { $this->load->model('vbx_incoming_numbers'); $twilio_numbers = array(); try { $twilio_numbers = $this->vbx_incoming_numbers->get_numbers(); if (empty($twilio_numbers)) { $banner = array('id' => 'first-login', 'html' => 'To start setting up OpenVBX, we suggest you start out with building your first <a href="' . site_url('flows') . '">call flow</a>. ', 'title' => 'Welcome to OpenVBX'); $path = '/' . ($this->tenant->id > 1 ? $this->tenant->name : ''); setrawcookie('banner', rawurlencode(json_encode($banner)), 0, $path); set_last_known_url(site_url('/numbers')); return redirect(''); } } catch (VBX_IncomingNumberException $e) { /* Handle gracefully but log it */ log_message('error', $e->getMessage()); } } $devices = VBX_Device::search(array('user_id' => $user->id)); if (empty($devices)) { set_last_known_url(site_url('/devices')); return redirect(''); } } set_last_known_url($redirect); return $this->redirect(''); }
public function __construct() { parent::__construct(); $this->config_check(); $this->config->load('openvbx'); // check for required configuration values $this->load->database(); $this->load->library('ErrorMessages'); // deprecated in 1.2 $this->load->model('vbx_rest_access'); $this->load->model('vbx_message'); // When we're in testing mode, allow access to set Hiccup configuration $this->testing_mode = !empty($_REQUEST['vbx_testing_key']) ? $_REQUEST['vbx_testing_key'] == $this->config->item('testing-key') : false; $this->config->set_item('sess_cookie_name', $this->tenant->id . '-' . $this->config->item('sess_cookie_name')); $this->load->library('session'); $keys = array('base_url', 'salt'); foreach ($keys as $key) { $item[$key] = $this->config->item($key); if (empty($item[$key])) { redirect('install'); } } /* Rest API Authentication - one time pass only */ $singlepass = $this->input->cookie('singlepass'); if (!empty($singlepass)) { $ra = new VBX_Rest_Access(); $user_id = $ra->auth_key($singlepass); unset($_COOKIE['singlepass']); if ($user_id) { $this->session->set_userdata('user_id', $user_id); $this->session->set_userdata('loggedin', true); $this->session->set_userdata('signature', VBX_User::signature($user_id)); } } $user_id = $this->session->userdata('user_id'); // Signature check if (!empty($user_id)) { $signature = $this->session->userdata('signature'); if (!VBX_User::check_signature($user_id, $signature)) { $this->session->set_flashdata('error', 'Your session has expired'); $this->session->set_userdata('loggedin', false); } } if ($this->response_type == 'json') { $this->attempt_digest_auth(); } if (!$this->session->userdata('loggedin') && $this->response_type != 'json') { $redirect = site_url($this->uri->uri_string()); if (!empty($_COOKIE['last_known_url'])) { $redirect = $_COOKIE['last_known_url']; set_last_known_url('', time() - 3600); } return redirect('auth/login?redirect=' . urlencode($redirect)); } $this->user_id = $this->session->userdata('user_id'); $this->set_request_method(); /* Mark the user as seen */ if (!empty($this->user_id)) { try { $user = VBX_User::get($this->user_id); $user->setting_set('last_seen', new MY_ModelLiteral('UTC_TIMESTAMP()')); } catch (VBX_UserException $e) { /* Handle this gracefully, but report the error. */ error_log($e->getMessage()); } $this->connect_check(); /* Check for first run */ if ($this->session->userdata('is_admin') && $this->uri->segment(1) != 'welcome') { $this->welcome_check(); } /* Check for updates if an admin */ if ($this->session->userdata('is_admin') && $this->uri->segment(1) != "upgrade") { $this->upgrade_check(); } } }