Example #1
0
        /* DESCRIPTION if any (folded to 76 char) */
        if ($description != "") {
            $description = "DESCRIPTION:" . $description;
            $array = export_fold_lines($description, "utf8");
            while (list($key, $value) = each($array)) {
                echo "{$value}\r\n";
            }
        }
        /* CLASS either "PRIVATE" or "PUBLIC" (the default) */
        if ($access == "R") {
            echo "CLASS:PRIVATE\r\n";
        } else {
            echo "CLASS:PUBLIC\r\n";
        }
        /* Time - all times are utc */
        export_time($date, $duration, $time, "ical");
        /* Recurrence */
        export_recurrence_ical($uid, $date);
        /* handle alarms */
        export_alarm_ical($uid, $description);
        /* Goodbye event */
        echo "END:VEVENT\r\n";
    }
    if ($count > 0) {
        echo "END:VCALENDAR\r\n";
    }
}
//header ( "Content-Type: text/plain" );
header("Content-Type: text/calendar");
export_ical();
$fromyear = $HTTP_POST_VARS["fromyear"];
$frommonth = $HTTP_POST_VARS["frommonth"];
$fromday = $HTTP_POST_VARS["fromday"];
$endyear = $HTTP_POST_VARS["endyear"];
$endmonth = $HTTP_POST_VARS["endmonth"];
$endday = $HTTP_POST_VARS["endday"];
$modyear = $HTTP_POST_VARS["modyear"];
$modmonth = $HTTP_POST_VARS["modmonth"];
$modday = $HTTP_POST_VARS["modday"];
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 " ";
function export_install_datebook($res)
{
    while ($row = dbi_fetch_row($res)) {
        $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";
?>
    foreach ($GLOBALS as $K => $V) {
        do_debug("GLOBALS[{$K}] => " . (strlen($V) < 70 ? $V : '(too long)'));
    }
    foreach ($GLOBALS['HTTP_POST_VARS'] as $K => $V) {
        do_debug("GLOBALS[{$_POST[$K]}] => " . (strlen($V) < 70 ? $V : '(too long)'));
    }
}
switch ($_SERVER['REQUEST_METHOD']) {
    case 'PUT':
        // do_debug ( "Importing updated remote calendar" );
        $calUser = $login;
        $overwrite = true;
        $type = 'icalclient';
        $data = parse_ical('', $type);
        import_data($data, $overwrite, $type);
        break;
    case 'GET':
        // do_debug ( "Exporting updated remote calendar" );
        header('Content-Type: text/calendar');
        header('Content-Disposition: attachment; filename="' . $login . '.ics"');
        $use_all_dates = true;
        echo export_ical();
        break;
    case 'OPTIONS':
        header('Allow: GET, PUT, OPTIONS');
        break;
    default:
        header('Allow: GET, PUT, OPTIONS');
        header('HTTP/1.0 405 Method Not Allowed');
        break;
}
/************************************/
/*************************************/
// recup des parametres reçus :
// SERVER
$PHP_SELF = $_SERVER['PHP_SELF'];
// GET	/ POST
$action = getpost_variable('action');
$user_login = getpost_variable('user_login');
$date_debut = getpost_variable('date_debut');
$date_fin = getpost_variable('date_fin');
$choix_format = getpost_variable('choix_format');
/*************************************/
//connexion mysql
if ($action == "export") {
    if ($choix_format == "ical") {
        export_ical($user_login, $date_debut, $date_fin, $DEBUG);
    } else {
        export_vcal($user_login, $date_debut, $date_fin, $DEBUG);
    }
    $comment_log = "export ical/vcal ({$date_debut} -> {$date_fin}) ";
    log_action(0, "", $user_login, $comment_log, $DEBUG);
} else {
    form_saisie($user_login, $date_debut, $date_fin, $DEBUG);
}
/*******************************************************************************/
/**********  FONCTIONS  ********************************************************/
function form_saisie($user, $date_debut, $date_fin, $DEBUG = FALSE)
{
    $PHP_SELF = $_SERVER['PHP_SELF'];
    $session = session_id();
    $date_today = date("d-m-Y");