$config->oauth->key)); exit(); break; case "login": if (isset($_REQUEST["code"])){ // Mastodon callback (Authorization Code from /oauth/authorize) $authCode = $_REQUEST["code"]; $Auth = oauthToken($authCode, $config); if(isset($Auth->token_type)){ // Valid Auth? $User = verifyCredentials($Auth->access_token); if (gettype($User) == "object" && isset($User->id)) { // Congrats! returnSuccess($User, buildEncToken($Auth->access_token, $User->id, $_SERVER["REMOTE_ADDR"], $_SERVER["HTTP_USER_AGENT"])); }else{ // invalid auth // $User contains error string returnError($User); } }else{ // invalid auth returnError($Auth); } }else{ returnError("Incorrect Login Query"); } break; case "verify": if (isset($_REQUEST["token"])){ // Verify Encrypted Token $EncTokenData = $_REQUEST["token"]; $TokenData = verifyEncToken($EncTokenData); if (gettype($TokenData) == "string") { // Invalid Token returnError($TokenData); }else{ // Valid Token returnSuccess($TokenData["MastodonData"], buildEncToken($TokenData["AuthToken"], $TokenData["UserID"], $_SERVER["REMOTE_ADDR"], $_SERVER["HTTP_USER_AGENT"] ) ); } }else{ 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; } }else { returnError("Incorrect Empty Query"); } ?>