share.php 890 B

12345678910111213141516171819202122
  1. <?php
  2. $token = strip_tags($_GET['t']);
  3. $shared = OC_Calendar_Share::getElementByToken($token);
  4. $nl = "\n\r";
  5. if($shared['type'] == OC_Calendar_Share::CALENDAR){
  6. $calendar = OC_Calendar_App::getCalendar($shared['id'], false);
  7. $calobjects = OC_Calendar_Object::all($shared['id']);
  8. header('Content-Type: text/Calendar');
  9. header('Content-Disposition: inline; filename=' . $calendar['displayname'] . '.ics');
  10. foreach($calobjects as $calobject){
  11. echo $calobject['calendardata'] . $nl;
  12. }
  13. }elseif($shared['type'] == OC_Calendar_Share::EVENT){
  14. $data = OC_Calendar_App::getEventObject($shared['id'], false);
  15. $calendarid = $data['calendarid'];
  16. $calendar = OC_Calendar_App::getCalendar($calendarid);
  17. header('Content-Type: text/Calendar');
  18. header('Content-Disposition: inline; filename=' . $data['summary'] . '.ics');
  19. echo $data['calendardata'];
  20. }else{
  21. header('Error 404: Not Found');
  22. }