mt_srand((double) microtime() * 1000000);
if (empty($id)) {
    $id = "all";
}
if ($format == "ical") {
    transmit_header('text/ical', "webcalendar-{$id}.ics");
    export_ical($id);
} elseif ($format == "vcal") {
    transmit_header('text/vcal', "webcalendar-{$id}.vcs");
    export_vcal($id);
} elseif ($format == "pilot-csv") {
    transmit_header('text/csv', "webcalendar-{$id}.csv");
    export_pilot_csv($id);
} elseif ($format == "pilot-text") {
    transmit_header('text/plain', "webcalendar-{$id}.txt");
    export_install_datebook($id);
} else {
    //exit;
    print_header();
    echo "<h2>";
    etranslate("Export");
    echo " ";
    etranslate("Error");
    echo "</h2>\n";
    echo "<span style=\"font-weight:bold;\">";
    etranslate("Error");
    echo ":</span> ";
    echo translate("export format not defined or incorrect") . ".";
    echo "<br />\n";
    print_trailer();
    echo " </body>\n";
        $start_time = pilot_date_time($row[3], $row[4], 0);
        $end_time = pilot_date_time($row[3], $row[4], $row[8]);
        printf("%s\t%s\t\t%s\n", $start_time, $end_time, $row[1]);
        echo "Start time: {$start_time}\n";
        echo "End time: {$end_time}\n";
        echo "Duration: {$row['8']}\n";
        echo "Name: {$row['1']}\n";
    }
}
//echo "SQL: $sql\n";
if ($format == "ical") {
    header("Content-Type: text/calendar");
    export_ical($res);
} else {
    header("Content-Type: text/plain");
    export_install_datebook($res);
}
exit;
?>
<HTML>
<HEAD>
<TITLE><?php 
etranslate("Export");
?>
</TITLE>
<?php 
include "includes/styles.php";
?>
</HEAD>
<BODY BGCOLOR="<?php 
echo $BGCOLOR;