Advertisement
Guest User

Untitled

a guest
Jan 14th, 2011
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.00 KB | None | 0 0
  1. <?php
  2.  
  3. $descriptorspec = array(
  4.    0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
  5.    1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
  6.    2 => array("pipe", "w")   // stderr is a file to write to
  7. );
  8.  
  9. $newenv = $_ENV;
  10. $newenv["SCRIPT_FILENAME"] = $_ENV["X_SCRIPT_FILENAME"];
  11. $newenv["SCRIPT_NAME"] = $_ENV["X_SCRIPT_NAME"];
  12.  
  13. if (is_executable($_ENV["X_SCRIPT_FILENAME"])) {
  14.   $process = proc_open($_ENV["X_SCRIPT_FILENAME"], $descriptorspec, $pipes, NULL, $newenv);
  15.   if (is_resource($process)) {
  16.     fclose($pipes[0]);
  17.     $head = fgets($pipes[1]);
  18.     while (strcmp($head, "\n")) {
  19.       header($head);
  20.       $head = fgets($pipes[1]);
  21.     }
  22.     fpassthru($pipes[1]);
  23.     fclose($pipes[1]);
  24.     fclose($pipes[2]);
  25.     $return_value = proc_close($process);
  26.   }
  27.   else {
  28.     header("Status: 500 Internal Server Error");
  29.     echo("Internal Server Error");
  30.   }
  31. }
  32. else {
  33.   header("Status: 404 Page Not Found");
  34.   echo("Page Not Found");
  35. }
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement