public function w3tc_ajax_cdn_rackspace_intro_done() { $user_name = $_REQUEST['user_name']; $api_key = $_REQUEST['api_key']; try { $r = Cdn_RackSpace_Api_Tokens::authenticate($user_name, $api_key); } catch (\Exception $ex) { $details = array('user_name' => $user_name, 'api_key' => $api_key, 'error_message' => 'Can\'t authenticate: ' . $ex->getMessage()); include W3TC_DIR . '/Cdn_RackSpaceCloudFiles_Popup_View_Intro.php'; exit; } $r['regions'] = Cdn_RackSpace_Api_Tokens::cloudfiles_services_by_region($r['services']); $details = array('user_name' => $user_name, 'api_key' => $api_key, 'access_token' => $r['access_token'], 'region_descriptors' => $r['regions'], 'region_descriptors_serialized' => strtr(json_encode($r['regions']), '"\\', '!^')); include W3TC_DIR . '/Cdn_RackSpaceCloudFiles_Popup_View_Regions.php'; exit; }
private function _on_new_access_requested() { $r = Cdn_RackSpace_Api_Tokens::authenticate($this->_config['user_name'], $this->_config['api_key']); if (!isset($r['access_token']) || !isset($r['services'])) { throw new \Exception('Authentication failed'); } $r['regions'] = Cdn_RackSpace_Api_Tokens::cloudfiles_services_by_region($r['services']); if (!isset($r['regions'][$this->_config['region']])) { throw new \Exception('Region ' . $this->_config['region'] . ' not found'); } $this->_access_state['access_token'] = $r['access_token']; $this->_access_state['access_region_descriptor'] = $r['regions'][$this->_config['region']]; $this->_create_api(array($this, '_on_new_access_requested_second_time'), array($this, '_on_new_access_requested_second_time')); $c = $this->_api_cdn->container_get($this->_config['container']); $this->_access_state['host_http'] = substr($c['x-cdn-uri'], 7); $this->_access_state['host_https'] = substr($c['x-cdn-ssl-uri'], 8); call_user_func($this->_new_access_state_callback, json_encode($this->_access_state)); }