All pastes #404382 Raw Edit

Untitled

public text v1 · immutable
·published 2007-03-20 23:55 UTC
rendered paste body
function execute_agi($command) { 
 GLOBAL $stdin, $stdout; 
 
         fputs( $stdout, $command . "\n" ); 
        fflush( $stdout ); 
         $resp = fgets( $stdin, 4096 ); 
         if ( preg_match("/^([0-9]{1,3}) (.*)/", $resp, $matches) )  { 
                if (preg_match('/result=([-0-9a-zA-Z]*)(.*)/', $matches[2], $match))  { 
                        $arr['code'] = $matches[1]; 
                     $arr['result'] = $match[1]; 
                    return $arr; 
               }else{ 
                         $arr['code'] = $matches[1]; 
                         $arr['result'] = 0; 
                       return $arr; 
                } 
         }else{ 
               $arr['code'] = -1; 
          $arr['result'] = -1; 
                return $arr; 
        } 
 }