Prep for Gemini

This commit is contained in:
2023-10-05 18:19:12 -04:00
parent 22d79165b2
commit 2131076545
4 changed files with 51 additions and 0 deletions

View File

@@ -61,6 +61,42 @@ if (isset($_REQUEST["act"])) {
returnError("Incorrect Verify Query");
}
break;
case "gemproxy":
if (isset($_REQUEST["token"])){
// Verify Encrypted Token
$EncTokenData = $_REQUEST["token"];
$TokenData = verifyEncToken($EncTokenData);
if (gettype($TokenData) == "string") {
// Invalid Token
returnError($TokenData);
}else{
// Valid Token
if (isset($_REQUEST["enable"])){
$userHomeDir = shell_exec("eval echo ~".$TokenData["MastodonData"]->username);
if (!file_exists($userHomeDir)){
returnError("User Home Directory Not Found, try making a new SSH key.");
} else {
if (file_exists($userHomeDir."/public_gemini")){
mkdir($userHomeDir."/public_gemini", 0755);
}
$EnableFile = $userHomeDir."/public_gemini/.serve_ok";
if ($_REQUEST["enable"] == 1){
if (!file_exists($EnableFile)){
file_put_contents($EnableFile, "web_gen");
}
}else{
if (file_exists($EnableFile)){
unlink($EnableFile);
}
}
}
}else {
returnError("Incorrect Gemini Proxy Query");
}
}
}
break;
default:
returnError("Incorrect Action Query");
break;