示例#1
0
		<?php 
Util_Ui::button_config_save('cdn_general');
?>
		<?php 
Util_Ui::postbox_footer();
?>

		<?php 
Util_Ui::postbox_header(__('Configuration', 'w3-total-cache'), '', 'configuration');
?>
		<table class="form-table">
			<?php 
if ($cdn_engine == 'google_drive' || $cdn_engine == 'highwinds' || $cdn_engine == 'rackspace_cdn' || $cdn_engine == 'rscf') {
    do_action('w3tc_settings_cdn_boxarea_configuration');
} else {
    if (Cdn_Util::is_engine($cdn_engine)) {
        include W3TC_INC_DIR . '/options/cdn/' . $cdn_engine . '.php';
    }
}
?>
		</table>

		<?php 
Util_Ui::button_config_save('cdn_configuration');
?>
		<?php 
Util_Ui::postbox_footer();
?>

		<?php 
Util_Ui::postbox_header(__('Advanced', 'w3-total-cache'), '', 'advanced');
 /**
  * CDN Test action
  *
  * @return void
  */
 function w3tc_cdn_test()
 {
     $engine = Util_Request::get_string('engine');
     $config = Util_Request::get_array('config');
     //TODO: Workaround to support test case cdn/a04
     if ($engine == 'ftp' && !isset($config['host'])) {
         $config = Util_Request::get_string('config');
         $config = json_decode($config, true);
     }
     $config = array_merge($config, array('debug' => false));
     if (isset($config['domain']) && !is_array($config['domain'])) {
         $config['domain'] = explode(',', $config['domain']);
     }
     if (Cdn_Util::is_engine($engine)) {
         $result = true;
         $error = null;
     } else {
         $result = false;
         $error = __('Incorrect engine ' . $engine, 'w3-total-cache');
     }
     if (!isset($config['docroot'])) {
         $config['docroot'] = Util_Environment::document_root();
     }
     if ($result) {
         if ($engine == 'google_drive' || $engine == 'highwinds' || $engine == 'rackspace_cdn' || $engine == 'rscf' || $engine == 's3_compatible') {
             // those use already stored w3tc config
             $w3_cdn = Dispatcher::component('Cdn_Core')->get_cdn();
         } else {
             // those use dynamic config from the page
             $w3_cdn = CdnEngine::instance($engine, $config);
         }
         @set_time_limit($this->_config->get_integer('timelimit.cdn_test'));
         if ($w3_cdn->test($error)) {
             $result = true;
             $error = __('Test passed', 'w3-total-cache');
         } else {
             $result = false;
             $error = sprintf(__('Error: %s', 'w3-total-cache'), $error);
         }
     }
     $response = array('result' => $result, 'error' => $error);
     echo json_encode($response);
 }