1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/rainloop_ynh.git synced 2024-09-03 20:16:18 +02:00
rainloop_ynh/sources/pgpback/fav.php
scith c17c585a01 PGPback
Allows user to backup/restore their PGP private keys from the browser
storage to the server using https://github.com/chtixof/pgpback_ynh
2016-12-18 02:22:23 +01:00

23 lines
628 B
PHP

<?php
$text=file_get_contents('php://input');
$user=$_SERVER["PHP_AUTH_USER"];
$file='keys/pk_'.$user.'.json';
if ($user=="") {
$out='{"rc":-2,"pk":[]}';
} else if ($text=="") {
$fread=file_get_contents($file);
if ($fread==""){
$out='{"rc":-3,"pk":[]}';
} else {
$out='{"rc":-1,"pk":'.file_get_contents($file).'}';
}
} else {
$fstatus=file_put_contents($file,$text) ;
$out='{"rc":'.$fstatus.',"pk":[]}';
}
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Type: application/json; charset=utf-8");
echo json_encode($out);
?>