当前位置: 首页>>代码示例>>PHP>>正文


PHP OpenVBX类代码示例

本文整理汇总了PHP中OpenVBX的典型用法代码示例。如果您正苦于以下问题:PHP OpenVBX类的具体用法?PHP OpenVBX怎么用?PHP OpenVBX使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OpenVBX类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_application

function create_application($name, $tenant_id)
{
    $ci =& get_instance();
    $ci->load->model('vbx_settings');
    $app_name = "OpenVBX :: {$name}";
    $twilio_sid = $ci->vbx_settings->get('twilio_sid', $tenant_id);
    $twilio_token = $ci->vbx_settings->get('twilio_token', $tenant_id);
    // Rare event, sid and/or token may be empty
    if (!empty($twilio_sid) && !empty($twilio_token)) {
        error_log('Processing tenant: ' . $tenant_id);
        $account = OpenVBX::getAccount($twilio_sid, $twilio_token);
        $applications = $account->applications->getIterator(0, 1, array('FriendlyName' => $app_name));
        $application = false;
        foreach ($applications as $_application) {
            if ($_application->friendly_name == $app_name) {
                $application = $_application;
            }
        }
        $params = array('FriendlyName' => $app_name, 'VoiceUrl' => tenant_url('twiml/dial', $tenant_id), 'VoiceFallbackUrl' => asset_url('fallback/voice.php'), 'VoiceMethod' => 'POST', 'SmsUrl' => '', 'SmsFallbackUrl' => '', 'SmsMethod' => 'POST');
        if (!empty($application)) {
            error_log('Modifying app: ' . $app_name);
            $application->update($params);
        } else {
            error_log('Creating app: ' . $app_name);
            $application = $account->applications->create($app_name, $params);
        }
        error_log('Created/Updated app for tenant id: ' . $tenant_id . ' - Application Sid: ' . $application->sid);
        $ci->vbx_settings->add('application_sid', $application->sid, $tenant_id);
    } else {
        error_log('Skipped app creation for tenant "' . $tenant_id . '" - incomplete account Sid/Token pair.');
    }
}
开发者ID:hharrysidhu,项目名称:OpenVBX,代码行数:32,代码来源:50.php

示例2: input_args

 private function input_args()
 {
     $tplvars = array();
     $tplvars['pass'] = true;
     $this->database['username'] = trim($this->input->post('database_user'));
     $this->database['password'] = $this->input->post('database_password');
     $this->database['hostname'] = trim($this->input->post('database_host') == "" ? 'localhost' : $this->input->post('database_host'));
     $this->database['database'] = trim($this->input->post('database_name') == "" ? 'OpenVBX' : $this->input->post('database_name'));
     $this->openvbx_settings = array();
     $this->openvbx = array();
     $this->openvbx_settings['twilio_sid'] = trim($this->input->post('twilio_sid'));
     $this->openvbx_settings['twilio_token'] = trim($this->input->post('twilio_token'));
     $this->openvbx['salt'] = md5(rand(10000, 99999));
     $this->openvbx_settings['from_email'] = trim($this->input->post('from_email') == "" ? '' : $this->input->post('from_email'));
     $this->openvbx_settings['theme'] = $this->input->post('theme');
     $this->openvbx_settings['iphone_theme'] = '';
     $this->openvbx_settings['trial_number'] = '(415) 599-2671';
     $this->openvbx_settings['schema-version'] = OpenVBX::getLatestSchemaVersion();
     $this->openvbx_settings['rewrite_enabled'] = !strlen($this->input->post('rewrite_enabled')) ? 0 : $this->input->post('rewrite_enabled');
     $this->user = array();
     $this->user['email'] = trim($this->input->post('admin_email'));
     $this->user['password'] = $this->input->post('admin_pw');
     $this->user['firstname'] = trim($this->input->post('admin_firstname'));
     $this->user['lastname'] = trim($this->input->post('admin_lastname'));
     $this->user['tenant_id'] = 1;
     $tplvars = array_merge($tplvars, $this->user, $this->database, $this->openvbx, $this->openvbx_settings);
     return $tplvars;
 }
开发者ID:joshgomez,项目名称:OpenVBX,代码行数:28,代码来源:install.php

示例3: index

 public function index()
 {
     $args = func_get_args();
     $page = implode('/', $args);
     $this->section = '/p/' . $page;
     $data = $this->init_view_data();
     $title = '';
     /* Find Plugin matching page */
     $plugins = Plugin::all();
     foreach ($plugins as $plugin) {
         try {
             // First plugin wins
             $data['script'] = $plugin->getScript($page);
             if (!empty($data['script'])) {
                 PluginData::setPluginId($plugin->getPluginId());
                 OpenVBX::$currentPlugin = $plugin;
                 $plugin_info = $plugin->getInfo();
                 $page_title = $plugin->getPluginPageName($page);
                 $title = !empty($page_title) ? $page_title : $plugin_info['name'];
                 break;
             }
         } catch (PluginException $e) {
             error_log($e->getMessage());
             $ci =& get_instance();
             $ci->session->set_flashdata('error', $e->getMessage());
         }
     }
     $this->respond($title, 'page/index', $data);
 }
开发者ID:hharrysidhu,项目名称:OpenVBX,代码行数:29,代码来源:page.php

示例4: get_greeting

 private function get_greeting()
 {
     $user = OpenVBX::getCurrentUser();
     $voicemail_value = $user->voicemail;
     $json['mode'] = '';
     $json['play'] = '';
     $json['say'] = '';
     if (!empty($voicemail_value)) {
         if (preg_match('/^http/i', $voicemail_value) || preg_match('/^vbx-audio-upload/i', $voicemail_value)) {
             $json['mode'] = 'play';
             $json['play'] = $voicemail_value;
             if (preg_match('/^vbx-audio-upload:\\/\\/(.*)/i', $voicemail_value, $matches)) {
                 // This is a locally hosted file, and we need to return the correct
                 // absolute URL for the file.
                 $json['play'] = real_site_url("audio-uploads/" . $matches[1]);
             }
         } else {
             $json['mode'] = 'say';
             $json['say'] = $voicemail_value;
         }
     }
     $data['json'] = $json;
     if ($this->response_type != 'json') {
         return redirect('voicemail');
     }
     $this->respond('', 'voicemail/greeting', $data);
 }
开发者ID:JeffaCubed,项目名称:OpenVBX,代码行数:27,代码来源:voicemail.php

示例5: login

 private function login($redirect)
 {
     try {
         $user = VBX_User::authenticate($this->input->post('email'), $this->input->post('pw'), $this->input->post('captcha'), $this->input->post('captcha_token'));
         if ($user) {
             $connect_auth = OpenVBX::connectAuthTenant($user->tenant_id);
             // we kick out non-admins, admins will have an opportunity to re-auth the account
             if (!$connect_auth && !$user->is_admin) {
                 $this->session->set_flashdata('error', 'Connect auth denied');
                 return redirect('auth/connect/account_deauthorized');
             }
             $userdata = array('email' => $user->email, 'user_id' => $user->id, 'is_admin' => $user->is_admin, 'loggedin' => TRUE, 'signature' => VBX_User::signature($user->id));
             $this->session->set_userdata($userdata);
             if (OpenVBX::schemaVersion() >= 24) {
                 return $this->after_login_completed($user, $redirect);
             }
             return $this->redirect($redirect);
         }
         $this->session->set_flashdata('error', 'Email address and/or password is incorrect');
         return redirect('auth/login?redirect=' . urlencode($redirect));
     } catch (GoogleCaptchaChallengeException $e) {
         $this->session->set_flashdata('error', $e->getMessage());
         $data['error'] = $e->getMessage();
         $data['captcha_url'] = $e->captcha_url;
         $data['captcha_token'] = $e->captcha_token;
     }
 }
开发者ID:ryanlarrabure,项目名称:OpenVBX,代码行数:27,代码来源:login.php

示例6: runUpdate_55_update_tenant_type_status

/**
 * Update each tenant to sub-account status
 * Pull full list of sub-accounts to make sure that accounts being upgraded are sub-accounts
 * Any account found to not be a sub-account of tenant 1 is assumed to be a full account
 * 
 * @return void
 */
function runUpdate_55_update_tenant_type_status()
{
    $ci =& get_instance();
    $parent_account_sid = $ci->vbx_settings->get('twilio_sid', 1);
    $parent_account_token = $ci->vbx_settings->get('twilio_token', 1);
    $parent_account = OpenVBX::getAccount($parent_account_sid, $parent_account_token);
    $subaccount_sids = array();
    foreach ($parent_account->accounts as $account) {
        array_push($subaccount_sids, $account->sid);
    }
    $tenants = $ci->db->from('tenants')->where('id >', '1')->get()->result();
    if (!empty($tenants)) {
        foreach ($tenants as $tenant) {
            $tenant_sid = $ci->vbx_settings->get('twilio_sid', $tenant->id);
            $tenant_token = $ci->vbx_settings->get('twilio_token', $tenant->id);
            if (in_array($tenant_sid, $subaccount_sids)) {
                // tenant is a sub-account of the parent
                $type = 2;
            } else {
                // tenant is a regular account, not a sub-account
                // may still be a sub of someone else, but not of this parent
                $type = 1;
            }
            $ci->db->set('type', $type)->where('id', $tenant->id)->update('tenants');
        }
    }
}
开发者ID:hharrysidhu,项目名称:OpenVBX,代码行数:34,代码来源:55.php

示例7: get_updates

 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);
 }
开发者ID:howethomas,项目名称:OpenVBX,代码行数:26,代码来源:client.php

示例8: getFlows

 public function getFlows()
 {
     $flows = array();
     foreach (OpenVBX::getFlows() as $flow) {
         $flows[$flow->values['id']] = $flow->values['name'];
     }
     return $flows;
 }
开发者ID:HighTechTorres,项目名称:TwilioCookbook,代码行数:8,代码来源:Tester.class.php

示例9: setup

 public function setup()
 {
     $json['success'] = true;
     $json['message'] = '';
     try {
         $currentSchemaVersion = OpenVBX::schemaVersion();
         $upgradingToSchemaVersion = OpenVBX::getLatestSchemaVersion();
         $upgradeScriptPath = VBX_ROOT . '/updates/';
         $updates = scandir($upgradeScriptPath);
         $updatesToRun = array();
         // Collect all files named numerically in /updates and key sort the list of updates
         foreach ($updates as $i => $update) {
             if (preg_match('/^(\\d+).(sql|php)$/', $update, $matches)) {
                 $updateExtension = $matches[2];
                 $rev = $matches[1];
                 $updatesToRun[$rev] = array('type' => $updateExtension, 'filename' => $update, 'revision' => $rev);
             }
         }
         ksort($updatesToRun);
         // Cut the updates by the current schema version.
         $updatesToRun = array_slice($updatesToRun, $currentSchemaVersion);
         $tplvars = array('originalVersion' => $currentSchemaVersion, 'version' => $upgradingToSchemaVersion, 'updates' => $updatesToRun);
         foreach ($updatesToRun as $updateToRun) {
             $file = $updateToRun['filename'];
             $type = $updateToRun['type'];
             $revision = $updateToRun['revision'];
             switch ($type) {
                 case 'php':
                     require_once $upgradeScriptPath . $file;
                     $runUpdateMethod = "runUpdate_{$revision}";
                     if (!function_exists($runUpdateMethod)) {
                         throw new UpgradeException('runUpdate method missing from ' . $file . ': ' . $runUpdateMethod);
                     }
                     call_user_func($runUpdateMethod);
                     break;
                 case 'sql':
                     $sql = @file_get_contents($upgradeScriptPath . $file);
                     if (empty($sql)) {
                         throw new UpgradeException("Unable to read update: {$file}", 1);
                     }
                     foreach (explode(";", $sql) as $stmt) {
                         $stmt = trim($stmt);
                         if (!empty($stmt)) {
                             PluginData::sqlQuery($stmt);
                         }
                     }
                     break;
             }
         }
         flush_minify_caches();
     } catch (Exception $e) {
         $json['success'] = false;
         $json['message'] = $e->getMessage();
         $json['step'] = $e->getCode();
     }
     $json['tplvars'] = $tplvars;
     echo json_encode($json);
 }
开发者ID:hharrysidhu,项目名称:OpenVBX,代码行数:58,代码来源:upgrade.php

示例10: validate_rest_request

 /**
  * Validate that an incoming rest request is from Twilio
  *
  * @param string $failure_message
  * @return void
  */
 function validate_rest_request($failure_message = 'Could not validate this request. Goodbye.')
 {
     $ci =& get_instance();
     if ($ci->tenant->type == VBX_Settings::AUTH_TYPE_CONNECT) {
         return;
     }
     if (!OpenVBX::validateRequest()) {
         $response = new TwimlResponse();
         $response->say($failure_message, array('voice' => $ci->vbx_settings->get('voice', $ci->tenant->id), 'language' => $ci->vbx_settings->get('voice_language', $ci->tenant->id)));
         $response->hangup();
         $response->respond();
         exit;
     }
 }
开发者ID:tjoozey,项目名称:openvbx,代码行数:20,代码来源:twilio_helper.php

示例11: send_message

 function send_message($from, $to, $message)
 {
     $from = PhoneNumber::normalizePhoneNumberToE164($from);
     $to = PhoneNumber::normalizePhoneNumberToE164($to);
     try {
         $account = OpenVBX::getAccount();
         $response = $account->messages->sendMessage($from, $to, $message);
     } catch (Exception $e) {
         throw new VBX_Sms_messageException($e->getMessage());
     }
     if (!in_array($response->status, array('sent', 'queued'))) {
         throw new VBX_Sms_messageException('SMS delivery failed. An unknown error occurred' . ' during delivery.');
     }
 }
开发者ID:tjoozey,项目名称:openvbx,代码行数:14,代码来源:vbx_sms_message.php

示例12: getAccountType

 function getAccountType()
 {
     $ci =& get_instance();
     if ($cache = $ci->api_cache->get('account-type', __CLASS__, $ci->tenant->id)) {
         return $cache;
     }
     try {
         $account = OpenVBX::getAccount();
         $account_type = $account->type;
     } catch (Exception $e) {
         throw new VBX_AccountsException($e->getMessage());
     }
     $ci->api_cache->set('account-type', $account_type, __CLASS__, $ci->tenant->id);
     return $account_type;
 }
开发者ID:hharrysidhu,项目名称:OpenVBX,代码行数:15,代码来源:vbx_accounts.php

示例13: openvbx_mail

/**
 * @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);
}
开发者ID:rhyselsmore,项目名称:OpenVBX,代码行数:23,代码来源:mail_helper.php

示例14: index

 public function index($plugin)
 {
     $this->admin_only('plugin config');
     $data = $this->init_view_data();
     $plugin = Plugin::get($plugin);
     PluginData::setPluginId($plugin->getPluginId());
     OpenVBX::$currentPlugin = $plugin;
     try {
         $data['info'] = $plugin->getInfo();
         $data['script'] = $plugin->getScript('config');
     } catch (PluginException $e) {
         error_log($e->getMessage());
         $data['script'] = null;
     }
     $this->respond('', 'page/config', $data);
 }
开发者ID:hharrysidhu,项目名称:OpenVBX,代码行数:16,代码来源:config.php

示例15: getMatches

 public function getMatches($digits)
 {
     $indexes = array();
     $matches = array();
     $users = OpenVBX::getUsers(array('is_active' => 1));
     foreach ($users as $user) {
         $fname = $user->values['first_name'];
         $lname = $user->values['last_name'];
         $fdigits = $this->stringToDigits($fname);
         $ldigits = $this->stringToDigits($lname);
         if (stristr($fdigits, $digits) || stristr($ldigits, $digits)) {
             $matches[] = $user;
         }
     }
     return $matches;
 }
开发者ID:HighTechTorres,项目名称:TwilioCookbook,代码行数:16,代码来源:directory.class.php


注:本文中的OpenVBX类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。