This repository has been archived by the owner on Feb 23, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
opcache.php
57 lines (50 loc) · 1.52 KB
/
opcache.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* W3 Total Cache APC
*/
if ( !defined( 'ABSPATH' ) ) {
if ( file_exists( dirname( __FILE__ ) . '/../../../../wp-load.php' ) ) {
require_once dirname( __FILE__ ) . '/../../../../wp-load.php';
}
else {
require_once dirname( __FILE__ ) . '/../../w3tc-wp-loader.php';
}
}
if ( !defined( 'W3TC_DIR' ) ) {
define( 'W3TC_DIR', WP_PLUGIN_DIR . '/w3-total-cache' );
}
if ( !@is_dir( W3TC_DIR ) || !file_exists( W3TC_DIR . '/w3-total-cache-api.php' ) ) {
@header( 'X-Robots-Tag: noarchive, noodp, nosnippet' );
echo sprintf( '<strong>W3 Total Cache Error:</strong> some files appear to be missing or out of place. Please re-install plugin or remove <strong>%s</strong>.<br />', dirname( __FILE__ ) );
}
$command = \W3TC\Util_Request::get_string( 'command' );
$nonce = \W3TC\Util_Request::get_string( 'nonce' );
$uri = $_SERVER['REQUEST_URI'];
if ( hash_equals( wp_hash( $uri ), $nonce ) ) {
/**
*
*
* @var $w3_cache W3_CacheFlush
*/
$w3_cache = \W3TC\Dispatcher::component( 'CacheFlush' );
$result = false;
switch ( $command ) {
case 'flush':
$result = $w3_cache->opcache_flush();
break;
case 'flush_file':
$file = \W3TC\Util_Request::get_string( 'file' );
$result = $w3_cache->opcache_flush_file( $file );
break;
}
if ( $result ) {
header( $_SERVER["SERVER_PROTOCOL"] . " 200 OK" );
die( 'Success' );
} else {
header( $_SERVER["SERVER_PROTOCOL"] . " 500 OK" );
die( $command . ' could not be executed' );
}
} else {
header( $_SERVER["SERVER_PROTOCOL"] . " 401" );
die( "Unauthorized access. " );
}