2 define('SPOOL_DIR', '/var/spool/vbox/ttyI6');
4 function read_info($dir, $call)
7 if (($f = fopen(SPOOL_DIR . '/' . $dir . '/' . $call . '.info', 'r')) !== false) {
8 $line = fgets($f, 1024);
10 $info = unserialize($line);
11 if (empty($info['note'])) $info['note'] = '';
16 function write_info($dir,$fname,$info)
18 if (($f = fopen(SPOOL_DIR . '/' . $dir . '/' . $fname . '.info', 'w')) !== false) {
19 fwrite($f, serialize($info)."\n");
24 function message_info($dir,$fname)
27 $basename = SPOOL_DIR . '/' . $dir . '/' . $fname;
29 if (is_file($basename . '.vmsg')) {
30 if (!is_file($basename . '.info')) {
31 if (($p = popen('vboxmode ' . $basename . '.vmsg', 'r')) !== false) {
33 $line = chop(fgets($p, 1024));
34 $pos = strpos($line, ':')+2;
35 if (strpos($line, 'Speaker name............: ') !== false) {
36 $info['name'] = utf8_encode(substr($line, $pos));
37 } elseif (strpos($line, 'Length..................: ') !== false) {
38 $info['length'] = substr($line, $pos);
39 } elseif (strpos($line, 'Speaker caller number...: ') !== false) {
40 $info['number'] = substr($line, $pos);
41 } elseif (strpos($line, 'Creation time...........: ') !== false) {
42 $info['date'] = substr($line, $pos);
46 $s = stat($basename . '.vmsg');
47 $info['timestamp'] = $s['mtime'];
48 write_info($dir,$fname,$info);
51 $info = read_info($dir,$fname);
57 function get_incoming()
61 if ($dir = opendir(SPOOL_DIR . '/incoming')) {
62 while (($filename = readdir($dir)) !== false) {
63 if (($pos = strpos($filename, '.vmsg')) !== false) {
64 $fname = substr($filename,0,$pos);
65 $info = message_info('incoming', $fname);
66 $info['fname'] = $fname;
75 function callinfo($dir, $call)
77 return read_info($dir, $call);
80 function send_call($dir, $call)
82 $dir = str_replace('/','x',$dir);
83 $call = str_replace('/','x',$call);
84 $fname = SPOOL_DIR . '/' . $dir . '/' . $call . '.vmsg';
86 if (!is_file($fname)) {
87 printf("<html><body><h3>Anruf %s in %s nicht gefunden!</h3></body></html>", $call, $dir);
91 if (($p = popen('vboxtoau < ' . $fname, 'r')) === false) {
92 printf("<html><body><h3>Anruf %s in %s konnte geoeffnet werden!</h3></body></html>", $call, $dir);
96 header(sprintf('Content-disposition: inline; filename="%s.au"', $call));
97 header('Content-Type: audio/basic');
98 header("Cache-Control: ");