|
5 | 5 | '@PACKAGE_NAME@-@PACKAGE_VERSION@' . DIRECTORY_SEPARATOR . 'src' |
6 | 6 | . DIRECTORY_SEPARATOR . 'PEAR2' . DIRECTORY_SEPARATOR . 'Autoload.php'; |
7 | 7 | } else { |
8 | | - $isNotCli = PHP_SAPI !== 'cli'; |
9 | | - if ($isNotCli) { |
| 8 | + $isHttp = isset($_SERVER['REQUEST_URI']); |
| 9 | + if ($isHttp) { |
10 | 10 | header('Content-Type: text/plain;charset=UTF-8'); |
11 | 11 | } |
12 | 12 | echo "PEAR2_Cache_SHM @PACKAGE_VERSION@\n"; |
|
17 | 17 | } |
18 | 18 |
|
19 | 19 | $available_extensions = array(); |
20 | | - foreach (array('phar', 'apc', 'wincache') as $ext) { |
| 20 | + foreach (array('apc', 'wincache') as $ext) { |
21 | 21 | if (extension_loaded($ext)) { |
22 | 22 | $available_extensions[] = $ext; |
23 | 23 | } |
24 | 24 | } |
25 | 25 |
|
26 | | - if (in_array('phar', $available_extensions)) { |
| 26 | + if (extension_loaded('phar')) { |
27 | 27 | $phar = new Phar(__FILE__); |
28 | 28 | $sig = $phar->getSignature(); |
29 | 29 | echo "{$sig['hash_type']} hash: {$sig['hash']}\n\n"; |
30 | | - |
31 | | - unset($available_extensions[ |
32 | | - array_search('phar', $available_extensions) |
33 | | - ]); |
| 30 | + } else { |
| 31 | + echo <<<HEREDOC |
| 32 | +If you wish to use this package from this archive, you need to install and |
| 33 | +enable the PHAR extension. Otherwise, you must extract this archive, and include |
| 34 | +the autoloader instead. |
| 35 | +HEREDOC; |
34 | 36 | } |
35 | 37 |
|
36 | 38 | if (in_array('apc', $available_extensions)) { |
37 | 39 | if (version_compare(phpversion('apc'), '3.0.13', '>=')) { |
38 | 40 | echo "A compatible APC version is available on this server.\n"; |
39 | | - if ($isNotCli || 1 == ini_get('apc.enable_cli')) { |
| 41 | + if ($isHttp || 1 == ini_get('apc.enable_cli')) { |
40 | 42 | echo "You should be able to use it under this SAPI (", PHP_SAPI, |
41 | 43 | ").\n"; |
42 | 44 | } else { |
43 | | - echo "You can't use it under this SAPI (cli).\n"; |
| 45 | + echo "You can't use it under this SAPI (", PHP_SAPI, ").\n"; |
44 | 46 | } |
45 | 47 | echo "\n"; |
46 | 48 | } |
|
49 | 51 | if (in_array('wincache', $available_extensions)) { |
50 | 52 | if (version_compare(phpversion('wincache'), '1.1.0', '>=')) { |
51 | 53 | echo "A compatible WinCache version is available on this server.\n"; |
52 | | - if ($isNotCli) { |
| 54 | + if ($isHttp) { |
53 | 55 | echo "You should be able to use it under this SAPI (", PHP_SAPI, |
54 | 56 | ").\n"; |
55 | 57 | } else { |
56 | | - echo "You can't use it under this SAPI (cli).\n"; |
| 58 | + echo "You can't use it under this SAPI (", PHP_SAPI, ").\n"; |
57 | 59 | } |
58 | 60 | echo "\n"; |
59 | 61 | } |
60 | 62 | } |
61 | 63 |
|
62 | | - if ($isNotCli) { |
| 64 | + if ($isHttp) { |
63 | 65 | if (empty($available_extensions)) { |
64 | 66 | echo "You don't have any compatible extensions for this SAPI (", |
65 | 67 | PHP_SAPI, |
66 | 68 | ").\nInstall one of APC (>= 3.0.13) or WinCache (>= 1.1.0)."; |
67 | 69 | } |
68 | 70 | } else { |
69 | | - echo "You can use the Placebo adapter under this SAPI (cli).\n"; |
| 71 | + echo "You should be able to use the Placebo adapter under this SAPI (", |
| 72 | + PHP_SAPI, ").\n"; |
70 | 73 | } |
71 | 74 | } |
72 | 75 |
|
|
0 commit comments