Ejemplo n.º 1
0
if (wpe_param('file-perms')) {
    check_admin_referer(PWP_NAME . '-config');
    $url = "https://api.wpengine.com/1.2/?method=file-permissions&account_name=" . PWP_NAME . "&wpe_apikey=" . WPE_APIKEY;
    $http = new WP_Http();
    $msg = $http->get($url);
    if (is_a($msg, 'WP_Error')) {
        return false;
    }
    if (!isset($msg['body'])) {
        return false;
    }
    $data = json_decode($msg['body'], true);
    $message = @$data['message'];
}
// Process purging all caches
if (wpe_param('purge-all')) {
    check_admin_referer(PWP_NAME . '-config');
    // check_admin_referer(PWP_NAME.'-config');		DO NOT CHECK because it's OK to just hit it from anywhere, and in fact we do.
    WpeCommon::purge_memcached();
    WpeCommon::clear_maxcdn_cache();
    WpeCommon::purge_varnish_cache();
    // refresh our own cache (after CDN purge, in case that needed to clear before we access new content)
    $message = "All of these caches have been purged: HTML-page-caching, CDN (statics), and WordPress Object/Transient Caches.";
}
if (is_wpe_snapshot()) {
    $error = "Cannot use the standard WPEngine controls from a staging server!<br/><br/>This is valid only from your live site.";
    $have_snapshot = FALSE;
} else {
    $snapshot_state = $plugin->get_staging_status();
    if ($just_started_snapshot && $snapshot_state['have_snapshot']) {
        // if this, fake it!
Ejemplo n.º 2
0
 public function process_internal_command()
 {
     // Ensure this is an internal command; process normally otherwise
     $cmd = wpe_param('wp-cmd');
     if (!$cmd) {
         return;
         // without a command, it's not an internal request
     }
     if (!$this->from_allowed_ip()) {
         print "Ignoring request from non-local host: " . $_SERVER['REMOTE_ADDR'] . " to " . $_SERVER['SERVER_ADDR'] . "\n";
         exit(0);
         // local requests only -- security! Meaning our public IP address or localhost
     }
     @ob_get_clean();
     error_reporting(-1);
     header("Content-Type: text/plain");
     // just in case we're viewing inside a browser, but typically is commandline
     define('WPE_NO_HTML_FILTER', TRUE);
     // Execute command
     switch ($cmd) {
         case 'ping':
             header("Content-Type: text/plain");
             header("X-WPE-Host: " . gethostname() . " " . $_SERVER['SERVER_ADDR']);
             print "pong\n";
             break;
         case 'ensure':
             header("Content-Type: text/plain");
             $this->ensure_standard_settings();
             break;
         case 'ensure-user':
             header("Content-Type: text/plain");
             $this->ensure_account_user();
             break;
         case 'nada':
             return;
             // ignore, just to get into some other page
         // ignore, just to get into some other page
         case 'cron':
             header("Content-Type: text/plain");
             $this->do_frequently();
             break;
         case 'refresh-notices':
             delete_option('wpe_notices_ttl');
             delete_transient('wpe_notices_ttl');
             wp_cache_delete('wpe_notices_ttl', 'transient');
             break;
         case 'sso':
             $key = $_POST['key'];
             if (sha1('wpe-sso|' . WPE_APIKEY . '|' . PWP_NAME) == $key) {
                 global $wpdb;
                 $token = sha1($key . mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand());
                 set_transient('wpe_sso', $token, 60);
                 echo $token;
             }
             break;
         case 'purge-all-caches':
             ob_start();
             WpeCommon::purge_memcached();
             WpeCommon::clear_maxcdn_cache();
             WpeCommon::purge_varnish_cache();
             // refresh our own cache (after CDN purge, in case that needed to clear before we access new content)
             $this->empty_all_caches();
             $errors = ob_get_contents();
             ob_end_clean();
             header("Content-Type: text/plain");
             header("X-WPE-Host: " . gethostname() . " " . $_SERVER['SERVER_ADDR']);
             print "All Caches were purged!";
             break;
         case 'purge-varnish-cache':
             WpeCommon::purge_varnish_cache();
             print "Varnish cache was purged! ";
             break;
         case 'purge-object-cache':
             WpeCommon::purge_memcached();
             print "Object cache was purged! ";
             break;
         default:
             die("ERROR: unknown command: `{$cmd}`\n");
     }
     // Stop processing
     exit(0);
 }
function __rocket_run_rocket_bot_after_wpengine()
{
    if (function_exists('wpe_param') && wpe_param('purge-all') && defined('PWP_NAME') && check_admin_referer(PWP_NAME . '-config')) {
        // Preload cache
        run_rocket_bot('cache-preload');
    }
}