diff options
author | Tom N Harris <tnharris@whoopdedo.org> | 2010-11-18 13:55:55 -0500 |
---|---|---|
committer | Tom N Harris <tnharris@whoopdedo.org> | 2010-11-18 13:55:55 -0500 |
commit | 420edfd639fb3d0a0f6a2504ecb2f8f6b68be1f7 (patch) | |
tree | 786e15e1b51698288746cca25a05cc7034caa515 | |
parent | 7c2ef4e8d524fb9262c5a08831220f9fb2dc11fe (diff) | |
download | rpg-420edfd639fb3d0a0f6a2504ecb2f8f6b68be1f7.tar.gz rpg-420edfd639fb3d0a0f6a2504ecb2f8f6b68be1f7.tar.bz2 |
Restore io_runcmd, use io_exec for exec with pipes
-rw-r--r-- | inc/indexer.php | 4 | ||||
-rw-r--r-- | inc/io.php | 22 |
2 files changed, 22 insertions, 4 deletions
diff --git a/inc/indexer.php b/inc/indexer.php index 4914c9fc6..32fbf4a1a 100644 --- a/inc/indexer.php +++ b/inc/indexer.php @@ -484,7 +484,7 @@ function idx_indexLengths(&$filter){ } else { $lengths = idx_listIndexLengths(); foreach ( $lengths as $key => $length) { - // we keep all the values equal or superior + // we keep all the values equal or superior if ((int)$length >= (int)$filter) { $idx[] = $length; } @@ -689,7 +689,7 @@ function idx_tokenizer($string,&$stopwords,$wc=false){ $sw =& $stopwords; if ($conf['external_tokenizer']) { - if (0 == io_runcmd($conf['tokenizer_cmd'], $string, $output)) + if (0 == io_exec($conf['tokenizer_cmd'], $string, $output)) $string = $output; } else { if(preg_match('/[^0-9A-Za-z ]/u', $string)) { diff --git a/inc/io.php b/inc/io.php index 9b797ebf2..a0be00da3 100644 --- a/inc/io.php +++ b/inc/io.php @@ -529,12 +529,30 @@ 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> + * @deprecated */ -function io_runcmd($cmd, $input, &$output){ +function io_runcmd($cmd){ + $fh = popen($cmd, "r"); + if(!$fh) return false; + $ret = ''; + while (!feof($fh)) { + $ret .= fread($fh, 8192); + } + pclose($fh); + return $ret; +} + +/** + * 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"), |