From 74fc1fe80e742d8584159c1059fdfa32f61c9364 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Sun, 28 Jan 2024 18:29:40 +0100 Subject: [PATCH] move code server side --- .htaccess | 4 ++ ics.php | 156 ++++++++++++++++++++++------------------ settings.php.sample.php | 1 + 3 files changed, 91 insertions(+), 70 deletions(-) create mode 100644 .htaccess diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..53cac3b --- /dev/null +++ b/.htaccess @@ -0,0 +1,4 @@ + +RewriteEngine on +RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] + \ No newline at end of file diff --git a/ics.php b/ics.php index 10e5c96..0c8e833 100644 --- a/ics.php +++ b/ics.php @@ -1,78 +1,94 @@ - -
Evénements à venir
+Access denied.

'); + } + + /*function ics2json($input) + { + $id = 0; + $root = array(); + $curr = root; + input.split("\r\n").forEach(l => + { + var key = l.split(":")[0].split(";")[0]; + var val = l.split(":")[1]; + if (key == "BEGIN") + { + if (curr[val]) + { + val += "_" + (id++); + } + curr[val] = { + parent: curr + }; + curr = curr[val]; + } + else if (key == "END") + { + var parent = curr.parent; + delete curr.parent; + curr = parent; + } + else + { + curr[key] = key.startsWith("DT") ? dt(val) : val; + } + + }); + + root.VCALENDAR.VEVENTS = []; + Object.keys(root.VCALENDAR) + .filter(k => (k == "VEVENT" || k.startsWith("VEVENT_"))) + .forEach(k => + { + root.VCALENDAR.VEVENTS.push(root.VCALENDAR[k]); + delete root.VCALENDAR[k]; + }); + + return root.VCALENDAR; + }*/ + + // Get ics file + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_USERPWD, $user . ':' . $password); + curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + $result = curl_exec($curl); + + if (!$result) + { + die('

Error while getting ics file from caldav server.

'); + } + curl_close($curl); + + // port "showresult" js function: + $recent = 7; + if (isset($_GET['recent'])) + { + $recent = $_GET['recent']; + } + $recentonly = isset($_GET['recentonly']); + + echo '

Evénements à venir

'; + +?> + + + +
Récupération du calendrier...
- - diff --git a/settings.php.sample.php b/settings.php.sample.php index 3de1331..564c3d6 100644 --- a/settings.php.sample.php +++ b/settings.php.sample.php @@ -1,4 +1,5 @@