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
|
<?php
|
||||||
require 'settings.php';
|
require 'settings.php';
|
||||||
|
|
||||||
if (isset($_POST['password']))
|
if ($password && (!isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] != $password)) {
|
||||||
{
|
header('WWW-Authenticate: Basic realm="bbn"');
|
||||||
$password = $_POST['password'];
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
|
die('<p>Access denied.</p></body></html>');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get ics file
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
|
|
||||||
curl_setopt($curl, CURLOPT_URL, $url);
|
curl_setopt($curl, CURLOPT_URL, $url);
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||||
curl_setopt($curl, CURLOPT_USERPWD, $user . ':' . $password);
|
curl_setopt($curl, CURLOPT_USERPWD, $user . ':' . $password);
|
||||||
|
@ -15,18 +22,25 @@
|
||||||
|
|
||||||
if (!$result)
|
if (!$result)
|
||||||
{
|
{
|
||||||
die('error');
|
die('<p>Error while getting ics file from caldav server.</p></body></html>');
|
||||||
}
|
}
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
die($result);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<html>
|
// port "showresult" js function:
|
||||||
<header>
|
$recent = 7;
|
||||||
<title>Evénements à venir</title>
|
if (isset($_GET['recent']))
|
||||||
</header>
|
{
|
||||||
<body style="font-family: helvetica; line-height: 24px; font-size: 16px;">
|
$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>
|
<div id="content">Récupération du calendrier...</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function ics2json(input)
|
function ics2json(input)
|
||||||
|
@ -165,5 +179,3 @@ xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||||
xhr.send("password=" + password);
|
xhr.send("password=" + password);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
$url = 'https://caldav.example.com/path/to/calendar';
|
$url = 'https://caldav.example.com/path/to/calendar';
|
||||||
$user = 'caldavuser';
|
$user = 'caldavuser';
|
||||||
|
$password = 'caldavpassword';
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue