starting to move code server side

This commit is contained in:
Simon Marcellin 2024-03-18 16:37:50 +01:00
parent 58b3bfa487
commit e4ca4b5e3d
1 changed files with 45 additions and 43 deletions

74
ics.php
View File

@ -12,42 +12,11 @@
die('<p>Access denied.</p></body></html>'); die('<p>Access denied.</p></body></html>');
} }
// Get ics file /*function ics2json($input)
$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('<p>Error while getting ics file from caldav server.</p></body></html>'); $id = 0;
} $root = array();
curl_close($curl); $curr = root;
// port "showresult" js function:
$recent = 7;
if (isset($_GET['recent']))
{
$recent = $_GET['recent'];
}
$recentonly = isset($_GET['recentonly']);
echo '<h1>Evénements à venir</h1>';
?>
</body>
</html>
<!-- old -->
<div id="content">Récupération du calendrier...</div>
<script type="text/javascript">
function ics2json(input)
{
var id = 0;
var root = {};
var curr = root;
input.split("\r\n").forEach(l => input.split("\r\n").forEach(l =>
{ {
var key = l.split(":")[0].split(";")[0]; var key = l.split(":")[0].split(";")[0];
@ -86,7 +55,40 @@ function ics2json(input)
}); });
return root.VCALENDAR; 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('<p>Error while getting ics file from caldav server.</p></body></html>');
}
curl_close($curl);
// port "showresult" js function:
$recent = 7;
if (isset($_GET['recent']))
{
$recent = $_GET['recent'];
}
$recentonly = isset($_GET['recentonly']);
echo '<h1>Evénements à venir</h1>';
?>
</body>
</html>
<!-- old -->
<div id="content">Récupération du calendrier...</div>
<script type="text/javascript">
function dt(s) function dt(s)
{ {