/** * コマンド実行. * @param string $command 'swf2xml' or 'xml2swf' * @param string $data SWF or XML datastream * @param bool $cp932 内部文字コード=shift_jis * @return XML or SWF datastream */ protected function execCommand($command, $data, $cp932) { $swfmill = mfwServerEnv::swfmill(); if (!$swfmill) { throw new RuntimeException('no swfmill command in serverenv_config'); } $opt = $cp932 ? '-e cp932' : ''; $cmd = "{$swfmill} {$opt} {$command} stdin stdout"; $desc = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')); $process = proc_open($cmd, $desc, $pipes); fwrite($pipes[0], $data); fclose($pipes[0]); $ret = stream_get_contents($pipes[1]); fclose($pipes[1]); $err = stream_get_contents($pipes[2]); fclose($pipes[2]); proc_close($process); if ($err) { error_log($err); } return $ret; }