Untitled
public text v1 · immutablefunction 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;
}
}