5 course="$_POST[\"course\"]"
6 tempfile="temp/$course"
7 coursefile="ical/$course"
12 tzid=$(cat /etc/timezone)
13 tstamp=$(TZ="$tzid" date +%Y%m%dT%H%M%S)
15 dts_year="$_POST[\"DTSYEAR\"]"
16 dts_month="$_POST[\"DTSMONTH\"]"
17 dts_day="$_POST[\"DTSDAY\"]"
18 [ -n "$_POST[\"DTSDAY0\"]" ] && dts_day="$_POST[\"DTSDAY0\"]"
19 dts_hour="$_POST[\"DTSHOUR\"]"
20 dts_minute="$_POST[\"DTSMINUTE\"]"
22 [ -z $dts_year ] && dts_year=$(date +%Y)
23 [ -z $dts_month ] && dts_month=$(date +%m)
24 [ -z $dts_day ] && dts_day=$(date +%d)
25 date -d ${dts_year}-${dts_month}-${dts_day} >/dev/null 2>/dev/null || dts_day="01"
26 [ -z $dts_hour ] && dts_hour=$(date +%H)
27 [ -z $dts_minute ] && dts_minute=$(date +%M)
29 dtstart="TZID=${tzid}:${dts_year}${dts_month}${dts_day}T${dts_hour}${dts_minute}00"
31 rr_int="$_POST[\"RRULE_INTERVAL\"]"
32 rr_freq="$_POST[\"RRULE_FREQ\"]"
33 rr_limit="$_POST[\"RRULE_LIMIT\"]"
36 rrule="FREQ=$rr_freq;INTERVAL=$rr_int"
39 t="$_POST[\"RRULE_COUNT\"]"
40 rrule="FREQ=$rr_freq;INTERVAL=$rr_int;COUNT=$t"
43 uy="$_POST[\"RRULE_UYEAR\"]"
44 um="$_POST[\"RRULE_UMONTH\"]"
45 ud="$_POST[\"RRULE_UDAY\"]"
46 rrule="FREQ=$rr_freq;INTERVAL=$rr_int;UNTIL=${uy}${um}${ud}T000000Z"
50 echo "BEGIN:VCALENDAR\r" >"$tempfile"
51 echo "VERSION:2.0\r" >>"$tempfile"
52 echo "PRODID:Berlin RAW Confetti\r" >>"$tempfile"
53 echo "BEGIN:VEVENT\r" >>"$tempfile"
54 echo "UID:$uid\r" >>"$tempfile"
55 echo "DTSTAMP:TZID=${tzid}:${tstamp}\r" >>"$tempfile"
56 echo "DTSTART:${dtstart}\r" >>"$tempfile"
57 echo "RRULE:${rrule}\r" >>"$tempfile"
58 for field in SUMMARY COMMENT; do
59 value="$_POST[\"$field\"]"
61 while [ -n "$value" ]; do
62 value="$(echo "$value" |sed -r ':a;N;$!ba;s:\n:\\\\n:g;s:\r:\\\\r:g')"
63 echo "${field}:${value}\r"
64 value="$_POST[\"$field$n\"]"
69 case "$_POST[\"action\"]" in
71 echo "$_POST[\"newfield\"]:\r" >>"$tempfile"
72 echo "END:VEVENT\r" >>"$tempfile"
73 echo "END:VCALENDAR\r" >>"$tempfile"
74 echo -n "Location: http://$HTTP_HOST/?page=courses&edit=$course\n\n"
77 echo "END:VEVENT\r" >>"$tempfile"
78 echo "END:VCALENDAR\r" >>"$tempfile"
79 mv "$tempfile" "$coursefile"
80 echo -n "Location: http://$HTTP_HOST/?page=courses#$course\n\n"
84 [ -f "$coursefile" ] \
85 && echo -n "Location: http://$HTTP_HOST/?page=courses#$course\n\n" \
86 || echo -n "Location: http://$HTTP_HOST/?page=courses\n\n"
89 rm "$tempfile" "$coursefile"
90 echo -n "Location: http://$HTTP_HOST/?page=courses\n\n"
93 echo "END:VEVENT\r" >>"$tempfile"
94 echo "END:VCALENDAR\r" >>"$tempfile"
95 echo -n "Location: http://$HTTP_HOST/?page=courses&edit=$course\n\n"