-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcacheclear.php
56 lines (45 loc) · 1.54 KB
/
cacheclear.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
#!/usr/bin/env php
<?php
/*
* This file is part of the WordPress Standard project.
*
* Copyright (c) 2015-present LIN3S <info@lin3s.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Gorka Laucirica <gorka.lauzirika@gmail.com>
*/
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], [
// localhost
'127.0.0.1',
'fe80::1',
'::1',
// DEV server IP, PROD server ip...
]) || php_sapi_name() === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file.');
}
echo 'Clearing cache...' . "<br>" . "<br>";
if (function_exists('apcu_clear_cache') && apcu_clear_cache()) {
echo 'APC User Cache: success.' . "<br>";
}
if (function_exists('apc_clear_cache') && function_exists('opcache_reset') && apc_clear_cache()) {
echo 'APC User Cache: success.' . "<br>";
}
if (function_exists('apc_clear_cache') && apc_clear_cache('user')) {
echo 'APC User Cache: success.' . "<br>";
}
if (function_exists('wincache_ucache_clear') && wincache_ucache_clear()) {
echo 'Wincache User Cache: success.' . "<br>";
}
if (function_exists('opcache_reset') && opcache_reset()) {
echo 'Zend OPcache: success.' . "<br>";
}
if (function_exists('apc_clear_cache') && apc_clear_cache('opcode')) {
echo 'APC Opcode Cache: success.' . "<br>";
}
echo "<br>" . 'Cache cleared successfully';