From eeff8375d73485d7631122139e9283dd818a4162 Mon Sep 17 00:00:00 2001 From: Jeff Welch Date: Sat, 11 Sep 2010 16:42:16 -0500 Subject: [PATCH] Added dependency checks for the PHP script. --- src/phpsh.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/phpsh.php b/src/phpsh.php index aa051b3..84d4a00 100755 --- a/src/phpsh.php +++ b/src/phpsh.php @@ -20,6 +20,16 @@ // this is probably not the right fix, but we need it for now ini_set('memory_limit', ini_get('memory_limit') * 2 . 'M'); +if (version_compare(PHP_VERSION, '5.0.0', '<')) { + fwrite(STDERR, 'Fatal error: phpsh requires PHP 5 or greater'); + exit; +} + +if ($missing = array_diff(array('pcntl','pcre','posix','tokenizer'), get_loaded_extensions())) { + fwrite(STDERR, 'Fatal error: phpsh requires the following extensions: ' . implode(', ', $missing)); + exit; +} + // we buffer the output on includes so that output that gets generated by // includes doesn't interfere with the secret messages we pass between php and // python we'll capture any output and show it when we construct the shell