This repository has been archived on 2024-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
BiblioMxWeb/server/up.php
2022-01-31 10:25:34 +01:00

34 lines
881 B
PHP

<?php
require("processCsv.php");
if (!function_exists('getallheaders')) {
function getallheaders() {
$headers = [];
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
}
$headers = getallheaders();
$f = file_get_contents($_FILES['file']['tmp_name']);
$AUTH="3";
file_put_contents("dump.txt",$f,FILE_APPEND);
if(trim($headers["Authorization"])!=$AUTH) echo "UNAUTHORIZED";
$nonce = md5($headers["X-Nonce"]);
$intent = $headers["X-Intent"];
switch($intent){
case "W":
file_put_contents("data/".$nonce.".csv",FILE_APPEND);
break;
case "C":
rename("data/".$nonce.".csv","data/current.csv");
processCsv();
echo "OK";
break;
default:
echo "UNKNOWN";
break;
}