2023-01-18 12:34:55 +01:00
|
|
|
<?php
|
|
|
|
|
2023-06-19 09:58:21 +02:00
|
|
|
require 'settings.php';
|
2023-01-18 12:34:55 +01:00
|
|
|
|
|
|
|
// check authent
|
|
|
|
if ($password && (!isset($_POST['password']) || $_POST['password'] != $password))
|
|
|
|
{
|
|
|
|
echo '{"error": "authent"}';
|
|
|
|
}
|
|
|
|
else if (isset($_POST['action']))
|
|
|
|
{
|
|
|
|
$action = $_POST['action'];
|
|
|
|
switch ($action)
|
|
|
|
{
|
2023-06-19 14:10:23 +02:00
|
|
|
case 'sms':
|
2023-07-05 13:40:13 +02:00
|
|
|
$res = file_get_contents($smsurl . $_POST['data']);
|
|
|
|
echo '{"result": "' . $res . '"}';
|
2023-06-19 14:10:23 +02:00
|
|
|
break;
|
|
|
|
|
2023-01-18 12:34:55 +01:00
|
|
|
case 'fetch':
|
|
|
|
if (file_exists($datafile))
|
|
|
|
{
|
|
|
|
echo file_get_contents($datafile);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo '[]';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'push':
|
|
|
|
$result = file_put_contents($datafile, $_POST['data']);
|
|
|
|
if ($result === false)
|
|
|
|
{
|
|
|
|
echo '{"error": "could not save ' . $datafile . '"}';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-09-21 08:55:22 +02:00
|
|
|
echo '{"result": "ok"}';
|
2023-09-11 09:57:00 +02:00
|
|
|
}
|
2023-01-18 12:34:55 +01:00
|
|
|
break;
|
|
|
|
|
2023-04-24 09:30:46 +02:00
|
|
|
case 'cal':
|
2023-07-17 09:16:10 +02:00
|
|
|
if ($icsfile)
|
2023-07-11 10:30:38 +02:00
|
|
|
{
|
|
|
|
$result = array();
|
|
|
|
$result["ics"] = file_get_contents($icsfile);
|
|
|
|
echo json_encode($result);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo '{"warning": "cannot load ics file"}';
|
|
|
|
}
|
2023-04-24 09:30:46 +02:00
|
|
|
break;
|
|
|
|
|
2023-01-18 12:34:55 +01:00
|
|
|
default:
|
|
|
|
echo '{"error": "unknown action ' . $action . '"}';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo '{"error": "missing action parameter"}';
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|