Пример #1
0
 public function send_iphone_guide()
 {
     $user = VBX_user::get(array('id' => $this->user_id));
     $this->data = array('error' => false, 'message' => 'OK');
     openvbx_mail($user->email, "iPhone installation Guide", 'iphone-guide', array('email' => $user->email));
     echo json_encode($this->data);
 }
Пример #2
0
 /**
  * Generate a capability token for Twilio Client
  *
  * @param string $allow_incoming 
  * @return string
  */
 function generate_capability_token($allow_incoming = true)
 {
     $ci =& get_instance();
     $capability = new Services_Twilio_Capability($ci->twilio_sid, $ci->twilio_token);
     $user_id = intval($ci->session->userdata('user_id'));
     $user = VBX_user::get(array('id' => $user_id));
     $params = array('user_id' => $user->user_id);
     $token = null;
     try {
         $capability->allowClientOutgoing($ci->application_sid, $params);
         if ($allow_incoming) {
             $capability->allowClientIncoming($user->id);
         }
         $token = $capability->generateToken(VBX_Settings::CLIENT_TOKEN_TIMEOUT);
     } catch (Exception $e) {
         log_message('error', $e->getMessage());
     }
     return $token;
 }
Пример #3
0
 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);
 }
Пример #4
0
 public function index()
 {
     $data = $this->init_view_data();
     $user = VBX_user::get(array('id' => $this->user_id));
     $data['user'] = $user;
     $this->template->add_js('assets/j/account.js');
     $this->template->add_js('assets/j/devices.js');
     $voicemail_value = $data['user']->voicemail;
     $data['voicemail_mode'] = '';
     $data['voicemail_play'] = '';
     $data['voicemail_say'] = '';
     if (!empty($voicemail_value)) {
         if (preg_match('/^http/i', $voicemail_value) || preg_match('/^vbx-audio-upload/i', $voicemail_value)) {
             $data['voicemail_mode'] = 'play';
             $data['voicemail_play'] = $voicemail_value;
         } else {
             $data['voicemail_mode'] = 'say';
             $data['voicemail_say'] = $voicemail_value;
         }
     }
     $this->respond('', 'voicemail', $data);
 }
Пример #5
0
 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);
 }
Пример #6
0
 public function password($user_id)
 {
     $user_id = intval($user_id);
     $is_admin = $this->session->userdata('is_admin');
     if ($user_id != $this->session->userdata('user_id') && !$is_admin) {
         $this->session->set_flashdata('message_edit', 'You are not allowed to update' . ' other users');
         redirect('/');
     }
     $user = VBX_user::get(array('id' => $user_id));
     $old_pw = $this->input->post('old_pw');
     $new_pw = $this->input->post('new_pw1');
     $new_pw2 = $this->input->post('new_pw2');
     $this->data['error'] = false;
     $message = '';
     if (VBX_User::authenticate($user, $old_pw)) {
         try {
             $user->set_password($new_pw, $new_pw2);
             $message = 'Password Updated';
         } catch (Exception $e) {
             $this->data['error'] = true;
             $message = $e->getMessage();
         }
     } else {
         $this->data['error'] = true;
         $message = 'Incorrect Password';
     }
     if ($user_id == $this->session->userdata('user_id')) {
         $this->session->set_userdata('signature', VBX_User::signature($user_id));
     }
     $this->data['message'] = $message;
     echo json_encode($this->data);
 }
Пример #7
0
 protected function template_respond($title, $section, $payload, $layout, $layout_dir = 'content')
 {
     $this->template->write('title', $title);
     if (isset($payload['json'])) {
         unset($payload['json']);
     }
     $theme = $this->getTheme();
     if (empty($payload['user'])) {
         $payload['user'] = VBX_user::get(array('id' => $this->session->userdata('user_id')));
     }
     $css = array("themes/{$theme}/style");
     $theme_config = $this->getThemeConfig($theme);
     $payload['session_id'] = $this->session->userdata('session_id');
     $payload['theme'] = $theme;
     $payload['site_title'] = isset($theme_config['site_title']) ? $theme_config['site_title'] : '';
     $payload['css'] = $css;
     $payload['is_admin'] = $this->session->userdata('is_admin');
     $payload['email'] = $this->session->userdata('email');
     $payload['logged_in'] = $this->session->userdata('loggedin');
     $payload['site_rev'] = $this->config->item('site_rev');
     $payload['asset_root'] = ASSET_ROOT;
     $payload['layout'] = $layout;
     if ($layout == 'yui-t2') {
         $payload['layout_override'] = 'yui-override-main-margin';
     } else {
         $payload['layout_override'] = '';
     }
     if ($user = VBX_User::get($this->session->userdata('user_id'))) {
         if ($user->setting('online') == 9) {
             $payload['user_online'] = 'client-first-run';
         } else {
             $payload['user_online'] = (bool) $user->setting('online');
         }
     }
     $navigation = $this->get_navigation($this->session->userdata('loggedin'), $this->session->userdata('is_admin'));
     $payload = array_merge($payload, $navigation);
     $payload = $this->template->clean_output($payload);
     $this->template->write_view('wrapper_header', $layout_dir . '/wrapper_header', $payload);
     $this->template->write_view('header', $layout_dir . '/header', $payload);
     $this->template->write_view('utility_menu', $layout_dir . '/utility_menu', $payload);
     $this->template->write_view('context_menu', $layout_dir . '/context_menu', $payload);
     $this->template->write_view('content_header', $layout_dir . '/content_header', $payload);
     $this->template->write_view('content_sidebar', $layout_dir . '/content_sidebar', $payload);
     $this->template->write_view('content_footer', $layout_dir . '/content_footer', $payload);
     $this->template->write_view('footer', $layout_dir . '/footer', $payload);
     $this->template->write_view('wrapper_footer', $layout_dir . '/wrapper_footer', $payload);
     $this->template->write_view('error_dialog', $layout_dir . '/error_dialog', $payload);
     $this->template->write_view('analytics', $layout_dir . '/analytics', $payload);
     $this->template->write_view('content', $section, $payload);
     $content = $this->template->render('content');
     $this->template->write_view('content_main', $layout_dir . '/content_main', compact('content'));
     if ($this->input->get_post('no_layout') == 1) {
         echo $this->template->render('content_main');
         return;
     }
     if ($this->input->get_post('barebones') == 1) {
         echo $this->template->render('content');
         return;
     }
     return $this->template->render();
 }
Пример #8
0
 protected function template_respond($title, $section, $payload, $layout, $layout_dir = 'content')
 {
     if (isset($payload['json'])) {
         unset($payload['json']);
     }
     $theme = $this->getTheme();
     if (empty($payload['user'])) {
         $payload['user'] = VBX_user::get(array('id' => $this->session->userdata('user_id')));
     }
     $css = array("themes/{$theme}/style");
     $theme_config = $this->getThemeConfig($theme);
     $payload['session_id'] = $this->session->userdata('session_id');
     $payload['theme'] = $theme;
     $payload['site_title'] = isset($theme_config['site_title']) ? $theme_config['site_title'] : '';
     $payload['css'] = $css;
     $payload['is_admin'] = $this->session->userdata('is_admin');
     $payload['email'] = $this->session->userdata('email');
     $payload['logged_in'] = $this->session->userdata('loggedin');
     $payload['site_rev'] = $this->config->item('site_rev');
     $payload['asset_root'] = ASSET_ROOT;
     $payload['layout'] = $layout;
     if ($layout == 'yui-t2') {
         $payload['layout_override'] = 'yui-override-main-margin';
     } else {
         $payload['layout_override'] = '';
     }
     if ($user = VBX_User::get($this->session->userdata('user_id'))) {
         if ($user->setting('online') == 9) {
             $payload['user_online'] = 'client-first-run';
         } else {
             $payload['user_online'] = (bool) $user->setting('online');
         }
     }
     $navigation = $this->get_navigation($this->session->userdata('loggedin'), $this->session->userdata('is_admin'));
     $payload = array_merge($payload, $navigation);
     $payload = $this->template->clean_output($payload);
     $template_regions = $this->template->get_regions();
     foreach (array_keys($template_regions) as $region) {
         if (strpos($region, '_') === 0) {
             continue;
         }
         if ($region == 'title') {
             $this->template->write('title', $title);
             continue;
         }
         $view = $layout_dir . '/' . $region;
         $content = $payload;
         if ($region == 'content_main') {
             $content = array('content' => $this->template->render('content'));
             $view = $layout_dir . '/content_main';
         } elseif ($region == 'content') {
             $view = $section;
         }
         $this->template->write_view($region, $view, $content);
     }
     if ($this->input->get_post('no_layout') == 1) {
         return $this->template->render('content_main');
     }
     if ($this->input->get_post('barebones') == 1) {
         $this->template->render('content');
     }
     return $this->template->render();
 }
Пример #9
0
 public function password()
 {
     if (!$this->session->userdata('loggedin')) {
         redirect('auth/login');
     }
     $user = VBX_user::get(array('id' => $this->user_id));
     $old_pw = $this->input->post('old_pw');
     $new_pw = $this->input->post('new_pw1');
     $new_pw2 = $this->input->post('new_pw2');
     $this->data['error'] = false;
     $message = '';
     if ($user->password != VBX_User::salt_encrypt($old_pw)) {
         $this->data['error'] = true;
         $message = 'Password incorrect';
     } else {
         if ($new_pw != $new_pw2) {
             $this->data['error'] = true;
             $message = 'Password mismatch';
         } else {
             $user->password = VBX_User::salt_encrypt($new_pw);
             try {
                 $user->save();
                 $message = 'Password changed';
                 $this->session->set_userdata('signature', VBX_User::signature($user->id));
             } catch (VBX_UserException $e) {
                 $this->data['error'] = true;
                 $message = 'Unable to set password, please try again later.';
                 error_log($e->getMessage());
             }
         }
     }
     $this->data['message'] = $message;
     echo json_encode($this->data);
 }
Пример #10
0
 /**
  * Init support for Twilio Client
  * This method manually loads in the Twilio Client library due to lack of support
  * for multiple parameters passing in CodeIgniters Loader.
  *
  * Application SID is always set by the parent tenant
  *
  * @since 0.93
  * @return void
  */
 protected function set_client_support()
 {
     $this->application_sid = $this->settings->get('application_sid', VBX_PARENT_TENANT);
     if (!empty($this->application_sid)) {
         if (!class_exists('Services_Twilio_Capability')) {
             include_once APPPATH . 'libraries/Capability.php';
         }
         $this->capability = new Services_Twilio_Capability($this->twilio_sid, $this->twilio_token);
         $user_id = intval($this->session->userdata('user_id'));
         $user = VBX_user::get(array('id' => $user_id));
         $params = array('user_id' => $user->user_id, 'rest_access' => $this->make_rest_access());
         try {
             $this->capability->allowClientOutgoing($this->application_sid, $params);
             $this->capability->allowClientIncoming($user->id);
         } catch (Exception $e) {
             //throw new User_ControllerException($e->getMessage());
             // this shouldn't be fatal, log instead of fail
             error_log($e->getMessage());
         }
     }
 }