Compare commits

..

No commits in common. "e4ca4b5e3d0858d3159390ee6e8290af762cf2b9" and "aa967da8578cbe3fbaf6eba746e21dd61938d3e8" have entirely different histories.

3 changed files with 69 additions and 88 deletions

View File

@ -1,4 +0,0 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>

78
ics.php
View File

@ -1,22 +1,39 @@
<?php
require 'settings.php';
if (isset($_POST['password']))
{
$password = $_POST['password'];
$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');
}
curl_close($curl);
die($result);
}
?>
<html>
<header>
<title>Evénements à venir</title>
</header>
<body style="font-family: helvetica; line-height: 24px; font-size: 16px;">
<?php
require 'settings.php';
if ($password && (!isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] != $password)) {
header('WWW-Authenticate: Basic realm="bbn"');
header('HTTP/1.0 401 Unauthorized');
die('<p>Access denied.</p></body></html>');
}
/*function ics2json($input)
<div id="content">Récupération du calendrier...</div>
<script type="text/javascript">
function ics2json(input)
{
$id = 0;
$root = array();
$curr = root;
var id = 0;
var root = {};
var curr = root;
input.split("\r\n").forEach(l =>
{
var key = l.split(":")[0].split(";")[0];
@ -55,40 +72,7 @@
});
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)
{
@ -181,3 +165,5 @@ xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.send("password=" + password);
</script>
</body>
</html>

View File

@ -1,5 +1,4 @@
<?php
$url = 'https://caldav.example.com/path/to/calendar';
$user = 'caldavuser';
$password = 'caldavpassword';
?>