/**
  * New Relic tab
  */
 function action_new_relic_view_new_relic_app()
 {
     $nerser = w3_instance('W3_NewRelicService');
     $view_application = W3_Request::get_integer('view_application', 0);
     $dashboard = '';
     if ($view_application) {
         $dashboard = $nerser->get_dashboard($view_application);
     }
     echo $dashboard;
 }
示例#2
0
 function change_filename_length()
 {
     try {
         w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
         $new = W3_Request::get_integer('maxlength');
         $this->_config->set('minify.auto.filename_length', $new);
         set_transient('w3tc_minify_tested_filename_length', true, 3600 * 24);
         $this->_config->save();
         w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/Cache/File.php');
         $cache = new Minify_Cache_File(w3_cache_blog_dir('minify'), array('.htaccess', 'index.php', '*.old'), $this->_config->get_boolean('minify.file.locking'), $this->_config->get_integer('timelimit.cache_flush'), w3_get_blog_id() == 0 ? W3TC_CACHE_MINIFY_DIR : null);
         $cache->flush();
         echo 1;
     } catch (Exception $ex) {
         echo $ex->getMessage();
     }
     exit;
 }
 /**
  * Reads config from request
  */
 function read_request()
 {
     require_once W3TC_LIB_W3_DIR . '/Request.php';
     $request = W3_Request::get_request();
     foreach ($this->_keys as $key => $type) {
         $request_key = str_replace('.', '_', $key);
         if (!isset($request[$request_key])) {
             continue;
         }
         switch ($type) {
             case 'string':
                 $this->set($key, W3_Request::get_string($request_key));
                 break;
             case 'int':
             case 'integer':
                 $this->set($key, W3_Request::get_integer($request_key));
                 break;
             case 'float':
             case 'double':
                 $this->set($key, W3_Request::get_double($request_key));
                 break;
             case 'bool':
             case 'boolean':
                 $this->set($key, W3_Request::get_boolean($request_key));
                 break;
             case 'array':
                 $this->set($key, W3_Request::get_array($request_key));
                 break;
         }
     }
 }
示例#4
0
 /**
  * PgCache purge page
  *
  * @return void
  */
 function action_flush_pgcache_purge_page()
 {
     w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
     $post_id = W3_Request::get_integer('post_id');
     do_action('w3tc_purge_from_pgcache', $post_id);
     w3_admin_redirect(array('w3tc_note' => 'pgcache_purge_page'), true);
 }
 /**
  * CDN Purge Post
  *
  * @return void
  */
 function action_cdn_purge_attachment()
 {
     w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
     $results = array();
     $attachment_id = W3_Request::get_integer('attachment_id');
     $w3_plugin_cdn = w3_instance('W3_Plugin_CdnAdmin');
     if ($w3_plugin_cdn->purge_attachment($attachment_id, $results)) {
         w3_admin_redirect(array('w3tc_note' => 'cdn_purge_attachment'), true);
     } else {
         w3_admin_redirect(array('w3tc_error' => 'cdn_purge_attachment'), true);
     }
 }
示例#6
0
 /**
  * PgCache purge page
  *
  * @return void
  */
 function pgcache_purge_page()
 {
     require_once W3TC_LIB_W3_DIR . '/Request.php';
     require_once W3TC_LIB_W3_DIR . '/PgCache.php';
     $post_id = W3_Request::get_integer('post_id');
     $w3_pgcache =& W3_PgCache::instance();
     if ($w3_pgcache->flush_post($post_id)) {
         $this->redirect(array('w3tc_note' => 'pgcache_purge_page'), true);
     } else {
         $this->redirect(array('w3tc_error' => 'pgcache_purge_page'), true);
     }
 }
示例#7
0
 /**
  * Configures the plugin to use the zone id provided in request
  */
 function action_cdn_use_netdna_maxcdn_pull_zone()
 {
     w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
     w3_require_once(W3TC_LIB_NETDNA_DIR . '/NetDNA.php');
     $cdn_engine = W3_Request::get_string('type');
     $this->validate_cdnengine_is_netdna_maxcdn($cdn_engine);
     $authorization_key = W3_Request::get_string('authorization_key');
     $this->validate_authorization_key($authorization_key);
     $zone_id = W3_Request::get_integer('zone_id');
     $keys = explode('+', $authorization_key);
     list($alias, $consumer_key, $consumer_secret) = $keys;
     $api = new NetDNA($alias, $consumer_key, $consumer_secret);
     $this->validate_account($api);
     try {
         $pull_zone = $api->get_zone($zone_id);
         if ($pull_zone) {
             $custom_domains = $api->get_custom_domains($pull_zone['id']);
             if (sizeof($custom_domains) > 0) {
                 $result = array('result' => 'valid', 'cnames' => array($custom_domains));
                 $test = true;
                 foreach ($custom_domains as $url) {
                     $test = $test && $this->test_cdn_url($url);
                 }
                 if ($test) {
                     $this->_config->set("cdn.enabled", true);
                 }
             } else {
                 $name = $pull_zone['name'];
                 $result = array('result' => 'valid', 'cnames' => array("{$name}.{$alias}.netdna-cdn.com"));
                 $test = $this->test_cdn_url("{$name}.{$alias}.netdna-cdn.com");
                 if ($test) {
                     $this->_config->set("cdn.enabled", true);
                 }
             }
             $this->_config->set("cdn.enabled", true);
             $this->_config->set("cdn.{$cdn_engine}.zone_id", $pull_zone['id']);
             $this->_config->set("cdn.{$cdn_engine}.domain", $result['cnames']);
             $this->_config->save();
         } else {
             $result = array('result' => 'error', 'message' => sprintf(__('The provided zone id was not connected to the provided authorization key.', 'w3-total-cache')));
         }
     } catch (Exception $ex) {
         $result = array('result' => 'error', 'message' => $ex->getMessage());
     }
     echo json_encode($result);
     exit;
 }
示例#8
0
 /**
  * Latest widget control
  *
  * @param integer $widget_id
  * @param array $form_inputs
  * @return void
  */
 function widget_latest_control($widget_id, $form_inputs = array())
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
         $this->_config->set('widget.latest.items', W3_Request::get_integer('w3tc_widget_latest_items', 3));
         $this->_config->save();
         delete_transient($this->_widget_latest_cache_key());
     }
     include W3TC_INC_DIR . '/widget/latest_control.php';
 }
示例#9
0
 /**
  * CDN rename domain process
  */
 function cdn_rename_domain_process()
 {
     set_time_limit(1000);
     require_once W3TC_LIB_W3_DIR . '/Request.php';
     require_once W3TC_LIB_W3_DIR . '/Plugin/Cdn.php';
     $w3_plugin_cdn =& W3_Plugin_Cdn::instance();
     $limit = W3_Request::get_integer('limit');
     $offset = W3_Request::get_integer('offset');
     $names = W3_Request::get_array('names');
     $count = null;
     $total = null;
     $results = array();
     @$w3_plugin_cdn->rename_domain($names, $limit, $offset, $count, $total, $results);
     echo sprintf("{limit: %d, offset: %d, count: %d, total: %s, results: [\r\n", $limit, $offset, $count, $total);
     $results_count = count($results);
     foreach ($results as $index => $result) {
         echo sprintf("\t{old: '%s', new: '%s', result: %d, error: '%s'}", addslashes($result['old']), addslashes($result['new']), addslashes($result['result']), addslashes($result['error']));
         if ($index < $results_count - 1) {
             echo ',';
         }
         echo "\r\n";
     }
     echo ']}';
 }