diff options
author | Adrian Lang <mail@adrianlang.de> | 2011-04-22 22:35:43 +0200 |
---|---|---|
committer | Adrian Lang <mail@adrianlang.de> | 2011-04-22 22:35:43 +0200 |
commit | 8ccf9c9785ec2b626bad30a88a21f02886845418 (patch) | |
tree | 0ecd6103880e3350bd37ba11ae3872805ede1755 /inc/io.php | |
parent | e2092379b1c3200832cb569781ec647db5aeef0f (diff) | |
parent | 23d27376b2a2f6a1ccf0777c48435717494d85b1 (diff) | |
download | rpg-8ccf9c9785ec2b626bad30a88a21f02886845418.tar.gz rpg-8ccf9c9785ec2b626bad30a88a21f02886845418.tar.bz2 |
Merge branch 'master' into stable
Conflicts:
data/deleted.files
doku.php
lib/exe/xmlrpc.php
Diffstat (limited to 'inc/io.php')
-rw-r--r-- | inc/io.php | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/inc/io.php b/inc/io.php index 1d69dabc9..034ac650e 100644 --- a/inc/io.php +++ b/inc/io.php @@ -486,7 +486,7 @@ function io_download($url,$file,$useAttachment=false,$defaultName='',$maxSize=20 preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)) { $name = basename($match[1]); - } + } } @@ -529,7 +529,7 @@ function io_rename($from,$to){ /** - * Runs an external command and returns it's output as string + * Runs an external command and returns its output as string * * @author Harry Brueckner <harry_b@eml.cc> * @author Andreas Gohr <andi@splitbrain.org> @@ -547,6 +547,27 @@ function io_runcmd($cmd){ } /** + * Runs an external command with input and output pipes. + * Returns the exit code from the process. + * + * @author Tom N Harris <tnharris@whoopdedo.org> + */ +function io_exec($cmd, $input, &$output){ + $descspec = array( + 0=>array("pipe","r"), + 1=>array("pipe","w"), + 2=>array("pipe","w")); + $ph = proc_open($cmd, $descspec, $pipes); + if(!$ph) return -1; + fclose($pipes[2]); // ignore stderr + fwrite($pipes[0], $input); + fclose($pipes[0]); + $output = stream_get_contents($pipes[1]); + fclose($pipes[1]); + return proc_close($ph); +} + +/** * Search a file for matching lines * * This is probably not faster than file()+preg_grep() but less |