All pastes #41966 Raw Edit

Unnamed

public php v1 · immutable
#41966 ·published 2006-02-17 17:56 UTC
rendered paste body
<?php///////////////////////////////////////////////////////////////////////////////// lib.php - librairie pour code Asterisk                 version 0.2 12-02-05//     function read() {        global $in, $debug, $stdlog;        $input = str_replace("\n", "", fgets($in, 4096));        if ($debug) fputs($stdlog, "read: $input\n");        return $input;     }     function errlog($line) {        global $err;        echo "VERBOSE \"$line\"\n";     }     function write($line) {        global $debug,$stdlog;         fputs($stdlog, "[".date("d/m/Y H:i:s")."]:[".$agi[uniqueid]."]  $line\n");        echo $line."\n";     }     function write_c($line) {        global $debug,$agi,$stdlog,$in;        if ($debug) fputs($stdlog, "[".date("d/m/Y H:i:s")."]:[".$agi[uniqueid]."].$line\n");        echo "VERBOSE \"".$agi[uniqueid]." - ".str_replace("\n", "###",$line)."\"\n";        $input = str_replace("\n", "", fgets($in, 4096));        return $input;     }     function execute($command) {        GLOBAL $in, $stdlog, $debug,$agi;        if ($debug) fputs($stdlog, "[".date("d/m/Y H:i:s")."]:[".$agi[uniqueid]."] $command\n");        echo $command."\n";        fflush($stdlog);        $data = fgets($in, 4096);        if (preg_match("^([0-9]{1,3}) (.*)", $data, $matches)) {            if (preg_match('^result=([0-9a-zA-Z]*)( ?\((.*)\))?$', $matches[2], $match)) {                $arr['code'] = $matches[1];                $arr['result'] = $match[1];                if (isset($match[3]) && $match[3])                    $arr['data'] = $match[3];                if ($debug) fputs($stdlog, "[".date("d/m/Y H:i:s")."]:[".$agi[uniqueid]."]    code=".$arr['code']." result=".$arr['result']." data=".$arr['data']." \n");                return $arr;            } else return 0;        } else return -1;     }        while (!feof($in)) {            $temp = str_replace("\n","",fgets($in,4096));            $s = split(":",$temp);            $agi[str_replace("agi_","",$s[0])] = trim($s[1]);            if (($temp == "") || ($temp == "\n")) {                break;            }        }?>