function doSendFileWithResume($file)
{
    global $g_debug;
    $range = "";
    $bytes_to = 0;
    $bytes_from = 0;
    $how_many_bytes_to_send = 0;
    // See if the file exists
    if (!is_file($file)) {
        die("<b>404 File not found!</b>");
    }
    // Gather relevent info about file
    $len = filesize($file);
    $filename = basename($file);
    $file_extension = strtolower(substr(strrchr($filename, "."), 1));
    $file_size = filesize($file);
    // Write some headers
    header("Cache-Control:");
    header("Cache-Control: public");
    header("Content-Type: audio/mp3");
    header('Content-Disposition: attachment; filename="' . $filename . '"');
    header("Accept-Ranges: bytes");
    if ($g_debug) {
        doDebugFile('HTTP_RANGE ' . $_SERVER['HTTP_RANGE']);
    }
    if (isset($_SERVER['HTTP_RANGE'])) {
        list($a, $range) = explode("=", $_SERVER['HTTP_RANGE']);
        list($bytes_from, $bytes_to) = split("-", $range);
        if ($bytes_to < 1) {
            $bytes_to = $file_size;
        }
        $how_many_bytes_to_send = $bytes_to - $bytes_from;
        if ($how_many_bytes_to_send != $file_size) {
            $how_many_bytes_to_send++;
        }
        if ($g_debug) {
            doDebugFile('Bytes From: ' . $bytes_from);
        }
        if ($g_debug) {
            doDebugFile('Bytes To: ' . $bytes_to);
        }
        header('HTTP/1.1 206 Partial Content');
        header('Content-Range: bytes ' . $bytes_from . '-' . $bytes_to . '/' . $file_size);
        // header('Content-Length: '.$file_size);
        header('Content_Length: ' . $how_many_bytes_to_send);
        if ($g_debug) {
            doDebugFile('HTTP/1.1 206 Partial Content');
        }
        if ($g_debug) {
            doDebugFile('Content-Range: bytes ' . $bytes_from . '-' . $bytes_to . '/' . $file_size);
        }
        if ($g_debug) {
            doDebugFile('Content-Length: ' . $file_size);
        }
        if ($g_debug) {
            doDebugFile("how_many_bytes_to_send: " . $how_many_bytes_to_send);
        }
        if ($g_debug) {
            doDebugFile('Sending bits from ' . $bytes_from . ' to ' . $bytes_to);
        }
    } else {
        $how_many_bytes_to_send = $file_size;
        header("HTTP/1.1 200 OK");
        header('Content-Range: bytes 0-' . ($file_size - 1) . '/' . $file_size);
        header("Content-Length: " . $file_size);
        if ($g_debug) {
            doDebugFile("HTTP/1.1 200 OK");
        }
        if ($g_debug) {
            doDebugFile('Content-Range: bytes 0-' . ($file_size - 1) . '/' . $file_size);
        }
        if ($g_debug) {
            doDebugFile("Content-Length: " . $file_size);
        }
        if ($g_debug) {
            doDebugFile("how_many_bytes_to_send: " . $how_many_bytes_to_send);
        }
        if ($g_debug) {
            doDebugFile('Sending bits from 0 to ' . $how_many_bytes_to_send);
        }
    }
    // Send the file
    $fp = fopen($file, "rb");
    fseek($fp, $bytes_from);
    $i = 0;
    while ($i < $how_many_bytes_to_send) {
        print fread($fp, 1);
        $i++;
    }
    fclose($fp);
    if ($g_debug) {
        doDebugFile("Sent Byte Count: " . $i);
    }
    exit;
}
if ($g_debug) {
    doDebugFile('--------------------------------------------------------');
    foreach ($_SERVER as $name => $vaule) {
        doDebugFile('SERVER:[' . $name . '][' . $vaule . ']');
    }
}
// Parse out the Request URI to get the variables we need.
$garbage1 = "";
$garbage2 = "";
$garbage3 = "";
$p_secret = "";
$p_mailbox = "";
$p_folder = "";
$p_file = "";
list($garbage1, $garbage2, $garbage3, $p_secret, $p_mailbox, $p_folder, $p_file) = split("/", $_SERVER['REQUEST_URI']);
// Hash their IP, with the secret salt, and compare.
$secret_key = md5($_SERVER['REMOTE_ADDR'] . $g_secret_salt);
if ($secret_key != $p_secret) {
    // Failed the security test, exit
    if ($g_debug) {
        doDebugFile('listen.php - FAILED SECURITY TEST!');
    }
    exit;
}
// Compile the full file path
$sound_file = $g_voicemail_context_path . $p_mailbox . "/" . $p_folder . "/" . $p_file;
if ($g_debug) {
    doDebugFile('listen.php - Calling doSendFileWithResume ' . $sound_file);
}
// Send the file down to the iPhone
doSendFileWithResume($sound_file);