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 call_cmp($a, $b)
59 if (!empty($a['read']) && empty($b['read']))
61 elseif (!empty($b['read']) && empty($a['read']))
63 elseif ($a['timestamp'] > $b['timestamp'])
70 function read_directory($directory)
74 if ($dir = opendir(SPOOL_DIR . '/' . $directory)) {
75 while (($filename = readdir($dir)) !== false) {
76 if (($pos = strpos($filename, '.vmsg')) !== false) {
77 $fname = substr($filename,0,$pos);
78 $info = message_info($directory, $fname);
79 $info['fname'] = $fname;
86 usort($result, "call_cmp");
90 function callinfo($dir, $call)
92 return read_info($dir, $call);
95 function send_call($dir, $call)
97 $dir = str_replace('/','x',$dir);
98 $call = str_replace('/','x',$call);
99 $fname = SPOOL_DIR . '/' . $dir . '/' . $call . '.vmsg';
101 if (!is_file($fname)) {
102 printf("<html><body><h3>Anruf %s in %s nicht gefunden!</h3></body></html>", $call, $dir);
106 if (($p = popen('vboxtoau < ' . $fname, 'r')) === false) {
107 printf("<html><body><h3>Anruf %s in %s konnte geoeffnet werden!</h3></body></html>", $call, $dir);
111 $info = read_info($dir, $call);
112 if (empty($info['read'])) {
113 $info['read'] = date('U');
114 write_info($dir, $call, $info);
117 header(sprintf('Content-disposition: inline; filename="%s.au"', $call));
118 header('Content-Type: audio/basic');
119 header("Cache-Control: ");
127 function archive_call($call)
129 $basename = SPOOL_DIR . '/' . 'incoming' . '/' . $call;
130 $basenew = SPOOL_DIR . '/' . 'archive' . '/' . $call;
132 rename($basename . '.vmsg', $basenew . '.vmsg');
133 rename($basename . '.info', $basenew . '.info');
136 function delete_call($dir, $call)
138 $basename = SPOOL_DIR . '/' . $dir . '/' . $call;
140 unlink($basename . '.vmsg');
141 unlink($basename . '.info');