forked from pyrus/Pyrus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
stub.php
70 lines (63 loc) · 2.16 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
#!/usr/bin/env php
<?php
if (version_compare(phpversion(), '5.3.1', '<')) {
if (substr(phpversion(), 0, 5) != '5.3.1') {
// this small hack is because of running RCs of 5.3.1
echo "Pyrus requires PHP 5.3.1 or newer.\n";
exit(1);
}
}
$missing_extensions = array();
foreach (array('phar', 'spl', 'pcre', 'simplexml', 'libxml', 'xmlreader', 'sqlite3')
as $ext) {
if (!extension_loaded($ext)) {
$missing_extensions[] = $ext;
}
}
if ($missing_extensions) {
echo "You must compile PHP with the following extensions enabled:\n",
implode(', ', $missing_extensions), "\n",
"or install the necessary extensions for your distribution.\n";
exit(1);
}
unset($missing_extensions);
// Reject old libxml installations
// moved to version 2.6.20 so XMLReader::setSchema can be used.
if (version_compare(LIBXML_DOTTED_VERSION, '2.6.20', '<')) {
echo "Pyrus requires libxml >= 2.6.20."
. " Version detected: " . LIBXML_DOTTED_VERSION . "\n";
exit(1);
}
// Make sure phar:// includes are available
if (extension_loaded('suhosin')) {
if (strpos(ini_get('suhosin.executor.include.whitelist'), 'phar') === false
|| strpos(ini_get('suhosin.executor.include.blacklist'), 'phar') !== false
) {
echo "Pyrus requires phar:// includes to be enabled.\n\n"
. "Add suhosin.executor.include.whitelist=\"phar\" to your php.ini.\n";
exit(1);
}
}
try {
Phar::mapPhar();
} catch (Exception $e) {
echo "Cannot process Pyrus phar:\n";
echo $e->getMessage(), "\n";
exit(1);
}
function pyrus_autoload($class)
{
$class = str_replace(array('_','\\'), '/', $class);
if (file_exists('phar://' . __FILE__ . '/PEAR2_Pyrus-@PACKAGE_VERSION@/php/' . $class . '.php')) {
include 'phar://' . __FILE__ . '/PEAR2_Pyrus-@PACKAGE_VERSION@/php/' . $class . '.php';
}
}
spl_autoload_register("pyrus_autoload");
$phar = new Phar(__FILE__);
$sig = $phar->getSignature();
define('PYRUS_SIG', $sig['hash']);
define('PYRUS_SIGTYPE', $sig['hash_type']);
$frontend = new \Pyrus\ScriptFrontend\Commands;
@array_shift($_SERVER['argv']);
$frontend->run($_SERVER['argv']);
__HALT_COMPILER();