/** * Flushes CDN completely */ function flush_all() { if (empty($this->api_key) || empty($this->zone_id)) { throw new \Exception(__('API key not specified.', 'w3-total-cache')); } if (!class_exists('NetDNA')) { require_once W3TC_LIB_NETDNA_DIR . '/NetDNA.php'; } $api = \NetDNA::create($this->api_key); $api->cache_delete($this->zone_id); }
public function w3tc_ajax_cdn_maxcdn_fsd_configure_zone() { $api_key = $_REQUEST['api_key']; $zone_id = Util_Request::get('zone_id', ''); $zone = array('name' => Util_Request::get('name'), 'label' => Util_Request::get('name'), 'url' => Util_Request::get('url'), 'use_stale' => 1, 'queries' => 1, 'compress' => 1, 'backend_compress' => 1, 'dns_check' => Util_Request::get('dns_check'), 'ip' => Util_Request::get('ip')); $api = \NetDNA::create($api_key); try { if (empty($zone_id)) { $response = $api->create_pull_zone($zone); $zone_id = $response['id']; } else { $response = $api->update_pull_zone($zone_id, $zone); } $custom_domains = $api->get_custom_domains($zone_id); $custom_domain = Util_Request::get('custom_domain'); $added = false; foreach ($custom_domains as $d) { if ($d['custom_domain'] == $custom_domain) { $added = true; break; } } if (!$added) { $api->create_custom_domain($zone_id, $custom_domain); } } catch (\Exception $ex) { $this->render_intro(array('api_key' => $api_key, 'error_message' => 'Failed to configure custom domain ' . $custom_domain . ': ' . $ex->getMessage())); exit; } $zone_domain = $response['tmp_url']; $c = Dispatcher::config(); $c->set('cdn.maxcdn_fsd.api_key', $api_key); $c->set('cdn.maxcdn_fsd.zone_id', $zone_id); $c->set('cdn.maxcdn_fsd.zone_domain', $zone_domain); $c->save(); $details = array('name' => $zone['name'], 'home_domain' => Util_Environment::home_url_host(), 'dns_cname_target' => $zone_domain); include W3TC_DIR . '/Cdn_MaxCdnFsd_Popup_View_Success.php'; exit; }