/** * CDN Test action * * @return void */ function action_cdn_test() { w3_require_once(W3TC_LIB_W3_DIR . '/Request.php'); w3_require_once(W3TC_LIB_W3_DIR . '/Cdn.php'); $engine = W3_Request::get_string('engine'); $config = W3_Request::get_array('config'); //TODO: Workaround to support test case cdn/a04 if (!isset($config['host'])) { $config = W3_Request::get_string('config'); $config = json_decode($config, true); } $config = array_merge($config, array('debug' => false)); if (!is_array($config['domain'])) { $config['domain'] = explode(',', $config['domain']); } if (w3_is_cdn_engine($engine)) { $result = true; $error = null; } else { $result = false; $error = __('Incorrect engine.', 'w3-total-cache'); } if (!isset($config['docroot'])) { $config['docroot'] = w3_get_document_root(); } if ($result) { $w3_cdn = W3_Cdn::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); }
<p class="submit"> <?php echo $this->nonce_field('w3tc'); ?> <input type="submit" name="w3tc_save_options" class="w3tc-button-save button-primary" value="Save all settings" /> </p> <?php echo $this->postbox_footer(); ?> <?php echo $this->postbox_header('Configuration'); ?> <table class="form-table"> <?php if (w3_is_cdn_engine($cdn_engine)) { include W3TC_INC_DIR . '/options/cdn/' . $cdn_engine . '.php'; } ?> </table> <p class="submit"> <?php echo $this->nonce_field('w3tc'); ?> <input type="submit" name="w3tc_save_options" class="w3tc-button-save button-primary" value="Save all settings" /> </p> <?php echo $this->postbox_footer(); ?>
/** * CDN Test action * * @return void */ function action_cdn_test() { w3_require_once(W3TC_LIB_W3_DIR . '/Request.php'); w3_require_once(W3TC_LIB_W3_DIR . '/Cdn.php'); $engine = W3_Request::get_string('engine'); $config = W3_Request::get_array('config'); $config = array_merge($config, array('debug' => false)); if (w3_is_cdn_engine($engine)) { $result = true; } else { $result = false; $error = __('Incorrect engine.', 'w3-total-cache'); } if ($result) { $w3_cdn = W3_Cdn::instance($engine, $config); $error = null; @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); }