~fabiocbalbuquerque/sahana-agasti/web-services

« back to all changes in this revision

Viewing changes to web/wiki/inc/io.php

  • Committer: Chad Heuschober
  • Date: 2011-06-06 13:37:45 UTC
  • mfrom: (1.1.1244 trunk)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: chad.heuschober@mail.cuny.edu-20110606133745-850mdvnjtv392zta
Pulled in most recent batch of changes from the cuny sps trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
486
486
                    preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)) {
487
487
 
488
488
                $name = basename($match[1]);
489
 
        }
 
489
            }
490
490
 
491
491
        }
492
492
 
529
529
 
530
530
 
531
531
/**
532
 
 * Runs an external command and returns it's output as string
 
532
 * Runs an external command and returns its output as string
533
533
 *
534
534
 * @author Harry Brueckner <harry_b@eml.cc>
535
535
 * @author Andreas Gohr <andi@splitbrain.org>
547
547
}
548
548
 
549
549
/**
 
550
 * Runs an external command with input and output pipes.
 
551
 * Returns the exit code from the process.
 
552
 *
 
553
 * @author Tom N Harris <tnharris@whoopdedo.org>
 
554
 */
 
555
function io_exec($cmd, $input, &$output){
 
556
    $descspec = array(
 
557
            0=>array("pipe","r"),
 
558
            1=>array("pipe","w"),
 
559
            2=>array("pipe","w"));
 
560
    $ph = proc_open($cmd, $descspec, $pipes);
 
561
    if(!$ph) return -1;
 
562
    fclose($pipes[2]); // ignore stderr
 
563
    fwrite($pipes[0], $input);
 
564
    fclose($pipes[0]);
 
565
    $output = stream_get_contents($pipes[1]);
 
566
    fclose($pipes[1]);
 
567
    return proc_close($ph);
 
568
}
 
569
 
 
570
/**
550
571
 * Search a file for matching lines
551
572
 *
552
573
 * This is probably not faster than file()+preg_grep() but less