-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
apc_clear_call.php
31 lines (23 loc) · 991 Bytes
/
apc_clear_call.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
<?php
/**
* This APC cache clearing script is based on http://stackoverflow.com/a/3580939/719023.
*/
$requiredOptions = array('url', 'htmlroot', 'scriptroot');
$options = getopt('', array('url:', 'htmlroot:', 'scriptroot:'));
// check if all required options are given
if (count(array_intersect_key(array_flip($requiredOptions), $options)) !== count($requiredOptions)) {
echo 'Could not clear APC cache since some required options are missing' . PHP_EOL;
exit;
}
$url = rtrim($options['url'], '/');
$htmlRoot = rtrim($options['htmlroot'], '/');
$scriptRoot = rtrim($options['scriptroot'], '/');
copy($scriptRoot . '/apc_clear.php', $htmlRoot . '/apc_clear.php');
$scriptUrl = $url . '/apc_clear.php';
$result = json_decode(file_get_contents($scriptUrl), true);
if (isset($result['success']) && $result['success']) {
echo 'APC cache cleared' . PHP_EOL;
} else {
echo 'Could not clear APC cache' . PHP_EOL;
}
unlink($htmlRoot . '/apc_clear.php');