コード例 #1
0
ファイル: icalendar.php プロジェクト: arno06/FFVB
define('TARGET', 'CSM EAUBONNE');
$items = file_get_contents('http://www.arnaud-nicolas.fr/projects/Volley/src/php/proxy.ffvb.php?gzip=0');
$data = json_decode($items, true);
$agenda = $data["agenda"];
$ic = new ICalendar("-//arnaud-nicolas.fr/Volley/LIIDF", "1.0");
foreach ($agenda as $day) {
    $name = $day['label'];
    foreach ($day['matches'] as $match) {
        if ($match['home']['name'] == TARGET || $match['guest']['name'] == TARGET) {
            $vs = $match['home']['name'] . " - " . $match['guest']['name'];
            $d = explode('/', $match['date']);
            $h = explode(':', $match['hour']);
            if (count($h) < 2) {
                $h = array("12", "0");
            }
            $ic->addEvent("Volley : " . $vs, time(), mktime($h[0], $h[1], 0, $d[1], $d[0], "20" . $d[2]))->setDTEnd(mktime($h[0] + 2, $h[1], 0, $d[1], $d[0], "20" . $d[2]))->setCategories("Volley")->setDescription($name . " : " . $vs);
        }
    }
}
header("Content-Type:text/plain;charset=UTF-8");
$content = $ic->render();
$length = strlen($content);
header("content-disposition: attachment; filename=\"Volley_CSM.ics\"");
header('Content-Type: application/force-download');
header('Content-Transfer-Encoding: binary');
header("Content-Length: " . $length);
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
header("Expires: 0");
echo $content;
exit;