private function get_updates() { if ($this->session->userdata('loggedin') != 1 || $this->session->userdata('is_admin') != 1) { $data['json'] = array('message' => 'Unable to fetch updates', 'error' => true); return $this->respond('', '', $data); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://openvbx.org/updates/latest.json'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $resp = curl_exec($ch); if (!$resp) { /* Its okay we can't connect to the update system but log it */ error_log('Unable to connect to OpenVBX Update notification server'); } $data['json'] = array('message' => 'Unable to fetch updates', 'error' => true); if ($obj = json_decode($resp)) { $data['json']['upgradeAvailable'] = false; list($current['major'], $current['minor']) = explode('.', OpenVBX::version()); list($latest['major'], $latest['minor']) = explode('.', $obj->version); if ($latest['major'] > $current['major'] || $latest['major'] == $current['major'] && $latest['minor'] > $current['minor']) { $data['json'] = array('error' => false); $data['json']['upgradeAvailable'] = true; } } $this->respond('', '', $data); }
/** * @param string $recipient * @param string $subject * @param string $template * @param array $maildata * @return bool */ function openvbx_mail($recipient, $subject, $template, $maildata = array()) { $ci =& get_instance(); $from_email = $ci->settings->get('from_email', $ci->tenant->id); if (empty($from_email)) { $domain = $ci->config->item('server_name'); $from_email = "{$from} <do-not-reply@{$domain}>"; } $headers = 'From: ' . $from_email . "\r\n"; $headers .= 'Reply-To: ' . $from_email . "\r\n"; $headers .= 'Return-Path: ' . $from_email . "\r\n"; $headers .= 'User-Agent: OpenVBX-' . OpenVBX::version(); $message = $ci->load->view('emails/' . $template, $maildata, true); log_message('debug', 'MAILING -- to: ' . $recipient . ' -- body: ' . $message); return mail($recipient, '[OpenVBX] ' . $subject, $message, $headers); }
public static function getVbxUserAgentString() { return 'openvbx/' . OpenVBX::version(); }
protected function set_response_type($type = null) { header('X-OpenVBX-Version: ' . OpenVBX::version()); if (isset($_SERVER['HTTP_ACCEPT'])) { $accepts = explode(',', $_SERVER['HTTP_ACCEPT']); if (in_array('application/json', $accepts) && strtolower($this->router->class) != 'page') { header('Content-Type: application/json'); $this->response_type = 'json'; } } if ($type) { $this->response_type = $type; } else { if (!$this->response_type) { $this->response_type = 'html'; } } }
private function get_site() { $this->template->add_js('assets/j/settings.js'); $data = $this->init_view_data(); $current_settings = $this->get_current_settings(); // insert the server's default time zone in the event none is saved if (empty($current_settings['server_time_zone'])) { $current_settings['server_time_zone'] = array('id' => null, 'value' => date_default_timezone_get()); } $current_settings['cache_enabled'] = $this->cache->enabled(); $current_settings['api_cache_enabled'] = $this->api_cache->enabled(); $data = array_merge($data, $current_settings); $data['tenant_mode'] = self::MODE_SINGLE; $data['openvbx_version'] = OpenVBX::version(); // determine wether we can successfully use the GitHub api library // to check our current tag against available tags. See ::can_check_upgrade() // for a full explanation. // @todo - find a more graceful way around this // @todo - notify admin that checks can't be made? $data['check_upgrade'] = $this->can_check_upgrade(); if ($this->tenant->name == 'default') { $data['tenant_mode'] = self::MODE_MULTI; $data['tenants'] = $this->settings->get_all_tenants(); if ($data['check_upgrade']) { $data['latest_version'] = $this->get_latest_tag(); if (version_compare($data['openvbx_version'], $data['latest_version'], '<')) { $data['upgrade_notice'] = true; } } } // allow tenants to see the rewrite setting $data['rewrite_enabled'] = array('value' => intval($this->settings->get('rewrite_enabled', VBX_PARENT_TENANT))); if ($this->db->dbdriver == 'mysqli') { $mysql_version = $this->db->conn_id->server_info; } else { $mysql_version = mysql_get_server_info($this->db->conn_id); } $data['server_info'] = array('system_version' => php_uname(), 'php_version' => phpversion(), 'php_sapi' => php_sapi_name(), 'mysql_version' => $mysql_version, 'mysql_driver' => $this->db->dbdriver, 'apache_version' => $_SERVER['SERVER_SOFTWARE'], 'current_url' => site_url($this->uri->uri_string()) . ' (' . $_SERVER['SERVER_ADDR'] . ')'); $data['available_themes'] = $this->get_available_themes(); // get plugin data $plugins = Plugin::all(); foreach ($plugins as $plugin) { $data['plugins'][] = $plugin->getInfo(); } $data['error'] = $this->session->flashdata('error'); $data['json']['settings'] = $current_settings; // build list of time zones $tzs = timezone_identifiers_list(); $data['time_zones'] = array_combine($tzs, $tzs); // makes keys & values match // get list of available countries $this->load->model('vbx_incoming_numbers'); $data['countries'] = array(); try { if ($countrydata = $this->vbx_incoming_numbers->get_available_countries()) { foreach ($countrydata as $country) { $data['countries'][$country->country_code] = $country->country; } } } catch (VBX_IncomingNumberException $e) { $data['error'] = 'Unable to fetch available countries: '; switch ($e->getCode()) { case 0: $data['error'] .= 'Authentication failed.'; break; default: $data['error'] .= $e->getMessage(); } } // load language codes for text-to-speech $this->config->load('langcodes'); $data['lang_codes'] = $this->config->item('lang_codes'); // verify Client Application data $data['client_application_error'] = false; $account = OpenVBX::getAccount(); $application = $account->applications->get($data['application_sid']['value']); if (!empty($data['application_sid']['value'])) { try { // only way to be sure on these is to pull them in to variables, ugh... $application_sid = $application->sid; $application_voice_url = $application->voice_url; $application_voice_fallback_url = $application->voice_fallback_url; if (strlen($application_sid) == 0) { // application missing $data['client_application_error'] = 2; } elseif (strlen($application_voice_url) == 0 || strlen($application_voice_fallback_url) == 0) { // urls are missing $data['client_application_error'] = 3; } elseif ($application_voice_url != site_url('/twiml/dial') || $application_voice_fallback_url != asset_url('fallback/voice.php')) { // url mismatch $data['client_application_error'] = 4; } } catch (Exception $e) { $data['client_application_error'] = 5; $data['error'] = 'Could not validate Client Application data: ' . $e->getMessage(); $data['client_application_error_message'] = $e->getMessage(); log_message($e->getMessage()); } } else { $data['client_application_error'] = 1; } $data['client_application'] = $application; $data['site_revision'] = $this->config->item('site_rev'); $this->respond('Site Settings', 'settings/site', $data); }
</p> </div><!-- .vbx-content-main --> </div><!-- #vbx-main --> </div><!-- .yui-b --> </div> <div class="yui-b"> <div class="vbx-sidebar"> </div><!-- .vbx-sidebar --> </div><!-- .yui-b --> </div><!-- #bd .error-404 --> <div id="ft"> <p class="copyright">OpenVBX • <em>v</em><?php echo OpenVBX::version(); ?> r<?php echo OpenVBX::schemaVersion(); ?> — Powered by <a href="http://twilio.com/">Twilio Inc.</a> • <a href="http://www.twilio.com/legal/tos">Terms</a> • <a href="http://www.twilio.com/legal/privacy">Privacy</a></p> </div><!-- #ft --> </div><!-- #wrapper --> </div><!-- #doc --> </body>
private function get_version() { return OpenVBX::version(); }
/** * Get a set of modified http options for TinyHttp so that we * can modify how the api client identifies itself as well as * inject some debug options * * @return array */ protected static function get_http_opts() { $ci =& get_instance(); $_http_opts = array('host' => 'https://api.twilio.com', 'opts' => array('curlopts' => array(CURLOPT_USERAGENT => 'openvbx/' . OpenVBX::version()))); // optionally load in the included cert for api communication if ($use_certificate = $ci->config->item('twilio_use_certificate')) { $_http_opts['opts']['curlopts'][CURLOPT_CAINFO] = APPPATH . 'libraries/Services/cacert.pem'; } // internal api development override, you'll never need this if ($_http_settings = $ci->config->item('_http_settings')) { if (!empty($_http_settings['host'])) { $_http_opts['host'] = $_http_settings['host']; } } // set debug mode if applicable if ($api_debug = $ci->config->item('api_debug')) { if ($api_debug === true) { $_http_opts['opts']['debug'] = true; } } return $_http_opts; }