Skip to content

Instantly share code, notes, and snippets.

@soimort
Created September 14, 2011 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soimort/1216567 to your computer and use it in GitHub Desktop.
Save soimort/1216567 to your computer and use it in GitHub Desktop.
HKR kursschema ics converter
<?php
$file = file_get_contents($_GET['URL'], "r") or die("Error. File not found");
$lower = html_entity_decode(strstr($file, "</tr><tr"), ENT_QUOTES);
$line = (explode("</tr>", $lower));
echo "BEGIN:VCALENDAR\n";
echo "VERSION:2.0\n";
echo "PRODID:PHP\n";
foreach ($line as $i) {
$value = (explode("</td>", $i));
if (sizeof($value) == 12) {
echo "BEGIN:VEVENT\n";
echo "DTSTAMP:".date('Ymd').'T'.date('His')."Z\n";
if (strlen(strip_tags($value[3])) > 1)
$vDate = strip_tags($value[3]);
echo "DTSTART:";
$vTime = substr(strip_tags($value[4]), 0, strlen(strip_tags($value[4]) ) - 1);
$vTime = explode("-", $vTime);
echo "20".$vDate."T".str_replace(":", "", $vTime[0])."00\n";
echo "DTEND:";
$vTime = substr(strip_tags($value[4]), 0, strlen(strip_tags($value[4]) ) - 1);
$vTime = explode("-", $vTime);
echo "20".$vDate."T".str_replace(":", "", $vTime[1])."00\n";
echo "DESCRIPTION:".substr(strip_tags($value[7]), 0, strlen(strip_tags($value[7]) ) - 1)."\n";
echo "SUMMARY:".substr(strip_tags($value[9]), 0, strlen(strip_tags($value[9]) ) - 1)."\n";
echo "END:VEVENT\n";
}
}
echo "END:VCALENDAR\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment