porting code to server side (in progress)
This commit is contained in:
parent
aa967da857
commit
58b3bfa487
|
@ -0,0 +1,4 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
|
||||
</IfModule>
|
42
ics.php
42
ics.php
|
@ -1,12 +1,19 @@
|
|||
<html>
|
||||
<header>
|
||||
<title>Evénements à venir</title>
|
||||
</header>
|
||||
<body style="font-family: helvetica; line-height: 24px; font-size: 16px;">
|
||||
<?php
|
||||
require 'settings.php';
|
||||
|
||||
if (isset($_POST['password']))
|
||||
{
|
||||
$password = $_POST['password'];
|
||||
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>');
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
@ -15,18 +22,25 @@
|
|||
|
||||
if (!$result)
|
||||
{
|
||||
die('error');
|
||||
die('<p>Error while getting ics file from caldav server.</p></body></html>');
|
||||
}
|
||||
curl_close($curl);
|
||||
die($result);
|
||||
}
|
||||
?>
|
||||
|
||||
<html>
|
||||
<header>
|
||||
<title>Evénements à venir</title>
|
||||
</header>
|
||||
<body style="font-family: helvetica; line-height: 24px; font-size: 16px;">
|
||||
// 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)
|
||||
|
@ -165,5 +179,3 @@ xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
|||
xhr.send("password=" + password);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
$url = 'https://caldav.example.com/path/to/calendar';
|
||||
$user = 'caldavuser';
|
||||
$password = 'caldavpassword';
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue