-
Notifications
You must be signed in to change notification settings - Fork 5
/
stub.php
160 lines (142 loc) · 4.78 KB
/
stub.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
/**
* stub for PEAR2_Cache_SHM.
*
* PHP version 5.3
*
* @category Caching
* @package PEAR2_Cache_SHM
* @author Vasil Rangelov <[email protected]>
* @copyright 2011 Vasil Rangelov
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version GIT: $Id$
* @link http://pear2.php.net/PEAR2_Cache_SHM
*/
if (count(get_included_files()) > 1) {
Phar::mapPhar();
include_once 'phar://' . __FILE__ . DIRECTORY_SEPARATOR .
'@PACKAGE_NAME@-@PACKAGE_VERSION@' . DIRECTORY_SEPARATOR . 'src'
. DIRECTORY_SEPARATOR . 'PEAR2' . DIRECTORY_SEPARATOR . 'Autoload.php';
return;
}
$isHttp = isset($_SERVER['REQUEST_URI']);
if ($isHttp) {
header('Content-Type: text/plain;charset=UTF-8');
}
echo "@PACKAGE_NAME@ @PACKAGE_VERSION@\n";
if (version_compare(phpversion(), '5.3.0', '<')) {
echo "\nERROR: This package requires PHP 5.3.0 or later.\n";
exit(1);
}
$available_extensions = array();
foreach (array('apc', 'apcu', 'wincache') as $ext) {
if (extension_loaded($ext)) {
$available_extensions[] = $ext;
}
}
if (extension_loaded('phar')) {
try {
$phar = new Phar(__FILE__);
$sig = $phar->getSignature();
echo "{$sig['hash_type']} hash: {$sig['hash']}\n\n";
} catch (Exception $e) {
echo <<<HEREDOC
The PHAR extension is available, but was unable to read this PHAR file's hash.
HEREDOC;
if (false !== strpos($e->getMessage(), 'file extension')) {
echo <<<HEREDOC
This can happen if you've renamed the file to ".php" instead of ".phar".
Regardless, you should be able to include this file without problems.
HEREDOC;
}
echo "\n";
}
} else {
echo <<<HEREDOC
WARNING: If you wish to use this package directly from this archive, you need
to install and enable the PHAR extension. Otherwise, you must instead
extract this archive, and include the autoloader.
HEREDOC;
}
if (in_array('apc', $available_extensions)) {
if (version_compare(phpversion('apc'), '3.1.1', '>=')) {
echo <<<HEREDOC
A compatible APC version is available on this server.
HEREDOC;
if (ini_get('apc.enabled')) {
if ($isHttp || ini_get('apc.enable_cli')) {
echo "You should be able to use it under this SAPI (", PHP_SAPI,
").\n";
} else {
echo "\nWARNING: You can't use it under this SAPI (", PHP_SAPI,
").\n";
}
echo "\n";
} else {
echo <<<HEREDOC
WARNING: Although present, the APC extension is disabled via the apc.enabled
INI setting, making this package unusable with it.
You need to enable it from php.ini.
HEREDOC;
}
}
}
if (in_array('apcu', $available_extensions)) {
if (version_compare(phpversion('apcu'), '5.0.0', '>=')) {
echo <<<HEREDOC
A compatible APCu version is available on this server.
HEREDOC;
if (ini_get('apc.enabled')) {
if ($isHttp || ini_get('apc.enable_cli')) {
echo "You should be able to use it under this SAPI (", PHP_SAPI,
").\n";
} else {
echo "\nWARNING: You can't use it under this SAPI (", PHP_SAPI,
").\n";
}
echo "\n";
} else {
echo <<<HEREDOC
WARNING: Although present, the APCu extension is disabled via the apc.enabled
INI setting, making this package unusable with it.
You need to enable it from php.ini.
HEREDOC;
}
}
}
if (in_array('wincache', $available_extensions)) {
if (version_compare(phpversion('wincache'), '1.1.0', '>=')) {
echo <<<HEREDOC
A compatible WinCache version is available on this server.
HEREDOC;
if (ini_get('wincache.ucenabled')) {
if ($isHttp || ini_get('wincache.enablecli')) {
echo "You should be able to use it under this SAPI (", PHP_SAPI,
").\n";
} else {
echo "\nWARNING: You can't use it under this SAPI (", PHP_SAPI,
").\n";
}
echo "\n";
} else {
echo <<<HEREDOC
WARNING: The user cache of the WinCache is disabled via the wincache.ucenabled
INI setting, making this package unusable with it.
You need to enable it from php.ini.
HEREDOC;
}
}
}
if ($isHttp) {
if (empty($available_extensions)) {
echo <<<HEREDOC
WARNING: You don't have any compatible extensions for this SAPI.
Install one of APC (>= 3.1.1), APCu (>=5.0.0) or WinCache (>= 1.1.0).
HEREDOC;
echo ' (The current SAPI is "', PHP_SAPI, ").\n\n";
}
} else {
echo "You should be able to use the Placebo adapter under this SAPI (",
PHP_SAPI, ").\n\n";
}
__HALT_COMPILER();