Une application en ligne pour créer des feuilles de calcul collaboratives à partir d'un serveur Ethercalc
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
digicalc/generer_document.php

34 lines
1.1 KiB

<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 1000");
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With");
if (!empty($_POST["creation"])) {
$config = file_get_contents("../../config-digicalc.json");
$json = json_decode($config, true);
$ethercalc_server = $json["ETHERCALC_SERVER"];
$id = uniqid("", false);
$url = $ethercalc_server . "/_";
$data = array("room" => $id, "snapshot" => $id);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0");
$reponse = curl_exec($curl);
if (curl_errno($curl)) {
$reponse = 'erreur';
}
curl_close($curl);
if ($reponse !== 'erreur') {
echo $ethercalc_server . "/" . $id;
} else {
echo $reponse;
}
exit();
} else {
header("Location: /");
}
?>