SHARE
TWEET

Untitled

a guest Sep 19th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     $infoUrl = "https://hplanning2019.umons.ac.be/Telechargements/ical/Edt__Bloc_compl__MA___Sc__informatiques.ics?version=2019.0.4.0&idICal=FD9359EA644C91D7986857F73C12D3AD&param=643d5b312e2e36325d2666683d3126663d3131303030";
  3.     $copyInfoFile = dirname(__FILE__)."/copyInfo.ics";
  4.     $restUrl = [];
  5.     $restUrl[] = ["https://hplanning2019.umons.ac.be/Telechargements/ical/Edt_OptmLin.ics?version=2019.0.4.0&idICal=64759DF405E76003FE2D93D12CE75CD9&param=643d5b312e2e36325d2666683d3126663d31", "copyOpti.ics", "OptmLin"];
  6.     $restUrl[] = ["https://hplanning2019.umons.ac.be/Telechargements/ical/Edt_GraphOptComb.ics?version=2019.0.4.0&idICal=424A11296D9F258CA2F7CDB93028AAEE&param=643d5b312e2e36325d2666683d3126663d31", "copyGraph.ics", "GraphOptComb"];
  7.    
  8.     // Download file from UMons
  9.     $content = @file_get_contents($infoUrl, false, stream_context_create([
  10.         'http' => [
  11.             'timeout' => 10
  12.         ]
  13.     ]));
  14.     if (!$content) {
  15.         // Use copy file if cannot download from the server
  16.         $content = file_get_contents($copyInfoFile);
  17.     } else {
  18.         // Save file
  19.         file_put_contents($copyInfoFile, $content);
  20.     }
  21.     // Remove "END:VCALENDAR" from the string
  22.     $content = substr($content, 0, strpos($content, "END:VCALENDAR"));
  23.     echo $content;
  24.     echo "\n";
  25.     foreach ($restUrl as $item) {
  26.         // Download file
  27.         $download = @file_get_contents($item[0], false, stream_context_create([
  28.             'http' => [
  29.                 'timeout' => 10
  30.             ]
  31.         ]));
  32.         if (!$download) {
  33.             // Use copy file if cannot download from the server
  34.             $download = file_get_contents($item[1]);
  35.         } else {
  36.             // Save file
  37.             file_put_contents($item[1], $download);
  38.         }
  39.         // Remove before first "BEGIN:VEVENT"
  40.         $download = strstr($download, "BEGIN:VEVENT");
  41.         $download = substr($download, 0, strpos($download, "END:VCALENDAR"));
  42.         // print
  43.         $split = explode("\n", $download);
  44.         foreach($split as $line){
  45.             if (substr($line, 0, 24) == "DESCRIPTION;LANGUAGE=fr:") {
  46.                 echo "DESCRIPTION;LANGUAGE=fr:Matière : ".$item[2]."\\n".substr($line, 24);
  47.             } else if (substr($line, 0, 20) == "SUMMARY;LANGUAGE=fr:") {
  48.                 echo "SUMMARY;LANGUAGE=fr:".$item[2]." - ".substr($line, 20);
  49.             } else
  50.                 echo $line."\n";
  51.         }
  52.         //echo $download;
  53.         echo "\n";
  54.     }
  55.     echo "END:VCALENDAR";
  56. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top