mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-22 23:09:29 -07:00
33 lines
874 B
PHP
33 lines
874 B
PHP
<?php
|
|
|
|
$fingerprint = urlencode($_GET["fp"]);
|
|
$url = htmlspecialchars($_GET["url"]);
|
|
|
|
$urlProof = $url.".json";
|
|
$check = "\[Verifying my OpenPGP key: openpgp4fpr:$fingerprint\]";
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_URL, $urlProof);
|
|
$result = curl_exec($ch);
|
|
curl_close($ch);
|
|
$data = json_decode($result, true);
|
|
|
|
$response = array();
|
|
$response["isDiscourse"] = false;
|
|
|
|
if (isset($data) && array_key_exists("user", $data) && array_key_exists("bio_raw", $data["user"])) {
|
|
$response["isDiscourse"] = true;
|
|
$response["fingerprint"] = $fingerprint;
|
|
$response["user"] = $data["user"]["username"];
|
|
$response["verified"] = false;
|
|
}
|
|
|
|
if (preg_match("/{$check}/i", $data["user"]["bio_raw"])) {
|
|
$response["verified"] = true;
|
|
}
|
|
|
|
echo json_encode($response);
|
|
|
|
?>
|