From: Joey Schulze Date: Sat, 12 Dec 2009 10:52:46 +0000 (+0100) Subject: Sort list of phone calls X-Git-Url: https://git.infodrom.org/?p=infodrom%2Fphone;a=commitdiff_plain;h=d4529b9fd4c06f699b84a0231999b02857000eb4 Sort list of phone calls --- diff --git a/phone.php b/phone.php index 9258c9f..660e0b6 100644 --- a/phone.php +++ b/phone.php @@ -54,6 +54,19 @@ function message_info($dir,$fname) return $info; } +function call_cmp($a, $b) +{ + if (!empty($a['read']) && empty($b['read'])) + return 1; + elseif (!empty($b['read']) && empty($a['read'])) + return -1; + elseif ($a['timestamp'] > $b['timestamp']) + return -1; + else + return 1; + return 0; +} + function read_directory($directory) { $result = array(); @@ -69,6 +82,8 @@ function read_directory($directory) } closedir($dir); } + + usort($result, "call_cmp"); return $result; } @@ -93,6 +108,12 @@ function send_call($dir, $call) return; } + $info = read_info($dir, $call); + if (empty($info['read'])) { + $info['read'] = date('U'); + write_info($dir, $call, $info); + } + header(sprintf('Content-disposition: inline; filename="%s.au"', $call)); header('Content-Type: audio/basic'); header("Cache-Control: ");