Permalink
Browse files

Merge branch 'php_dependencies' of http://github.com/whatthejeff/phpsh

…into stufffromgithub
  • Loading branch information...
2 parents 572f632 + eeff837 commit c481110a16dfd27390bfde99eef475872477715c adonohue committed Sep 15, 2010
Showing with 34 additions and 27 deletions.
  1. +13 −0 README.md
  2. +11 −27 src/__init__.py
  3. +10 −0 src/phpsh.php
View
@@ -1,5 +1,18 @@
Mailing list at: [http://groups.google.com/group/phpsh]([http://groups.google.com/group/phpsh])
+PHP Dependencies
+===================
+__Version:__
+
+ * PHP 5+
+
+__Modules:__
+
+ * [pcntl](http://php.net/manual/en/book.pcntl.php)
+ * [pcre](http://php.net/manual/en/book.pcre.php)
+ * [posix](http://php.net/manual/en/book.posix.php)
+ * [tokenizer](http://php.net/manual/en/book.tokenizer.php)
+
Python Dependencies
===================
* sqlite
View
@@ -630,12 +630,8 @@ def php_open_and_check(self):
phpsh failed to initialize PHP.
Fix the problem and hit enter to reload or ctrl-C to quit.""")
- if e.stdout_lines:
- print("PHP output: %(output)s" %
- {'output' : "\n".join(e.stdout_lines)})
- if e.stderr_lines:
- print("PHP error output: %(output)s" %
- {'output' : "\n".join(e.stderr_lines)})
+ print self.clr_err
+ print "".join(filter(lambda x: x != "", e.stdout_lines + e.stderr_lines))
if e.line_num:
print("\
@@ -692,32 +688,20 @@ def php_open(self):
err_lines = self.p.stderr.readlines()
out_lines = self.p.stdout.readlines()
- err_str = "\
-UNKNOWN ERROR (maybe php build does not support signals/tokenizer?)"
parse_error_re = re.compile(
"PHP Parse error: .* in (.*) on line ([0-9]*)")
m = None
for line in reversed(err_lines):
- err_line = line.rstrip()
- m = parse_error_re.match(err_line)
+ m = parse_error_re.match(line)
if m:
- err_str = err_line
- break
-
- print self.clr_err
- for err_line in err_lines:
- print err_line,
- print self.clr_default
-
- if m:
- file_name, line_num = m.groups()
- raise ProblemStartingPhp(file_name,
- line_num,
- stdout_lines=out_lines,
- stderr_lines=err_lines)
- else:
- raise ProblemStartingPhp(stdout_lines=out_lines,
- stderr_lines=err_lines)
+ file_name, line_num = m.groups()
+ raise ProblemStartingPhp(file_name,
+ line_num,
+ stdout_lines=out_lines,
+ stderr_lines=err_lines)
+
+ raise ProblemStartingPhp(stdout_lines=out_lines,
+ stderr_lines=err_lines)
while True:
p_line = self.p.stdout.readline().rstrip()
View
@@ -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

0 comments on commit c481110

Please sign in to comment.