Skip to content

Instantly share code, notes, and snippets.

@gong023
Created February 18, 2017 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gong023/7c8266cab00d5948db8df7f2d0a74570 to your computer and use it in GitHub Desktop.
Save gong023/7c8266cab00d5948db8df7f2d0a74570 to your computer and use it in GitHub Desktop.
bug?
<?php
$p = new Phar('test.phar', FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME);
$p->startBuffering();
$stub = <<<STR
#!/usr/bin/env php
<?php
Phar::mapPhar();
include "phar://test.phar/parent.php";
__HALT_COMPILER();
STR;
$p->setStub($stub);
$parent = <<<STR
<?php
\$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
\$path = realpath(__DIR__ . '/child.php');
\$process = proc_open('php ' . \$path, \$descriptorspec, \$pipes);
if (is_resource(\$process)) {
fclose(\$pipes[0]);
\$stdout = stream_get_contents(\$pipes[1]);
fclose(\$pipes[1]);
fclose(\$pipes[2]);
\$return_value = proc_close(\$process);
var_dump(\$stdout);
var_dump(\$return_value);
}
STR;
$p['parent.php'] = $parent;
$child = <<<STR
<?php
file_put_contents(sys_get_temp_dir() . '/child', "child");
echo "child";
STR;
$p['child.php'] = $child;
$p->stopBuffering();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment