Add php script to check HackerNews if javascript fails

This commit is contained in:
Supernova 2020-07-29 01:06:56 +00:00
parent e97fb27c0e
commit b7c2b05214
2 changed files with 46 additions and 2 deletions

View file

@ -464,9 +464,25 @@ async function verifyProof(url, fingerprint) {
output.isVerified = true; output.isVerified = true;
} }
} catch (e) { } catch (e) {
} finally {
return output;
} }
if(output.isVerified == false) {
output.proofUrlFetch = `/server/verifyHackerNews.php?user=${match[1]}&fp=${fingerprint}`;
try {
response = await fetch(output.proofUrlFetch, {
headers: {
Accept: 'application/json'
},
credentials: 'omit'
});
if (!response.ok) {
throw new Error('Response failed: ' + response.status);
}
json = await response.json();
output.isVerified = json.verified;
} catch (e) { }
}
return output;
} }
// dev.to // dev.to
if (/^https:\/\/dev\.to\//.test(url)) { if (/^https:\/\/dev\.to\//.test(url)) {

View file

@ -0,0 +1,28 @@
<?php
$fingerprint = urlencode($_GET["fp"]);
$user = urlencode($_GET["user"]);
$url = "https://hacker-news.firebaseio.com/v0/user/$user.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, $url);
$result = curl_exec($ch);
curl_close($ch);
$data = json_decode($result, true);
$response = array();
$response["verified"] = false;
$response["fingerprint"] = $fingerprint;
$response["user"] = $user;
if (preg_match("/{$check}/i", $data["about"])) {
$response["verified"] = true;
}
echo json_encode($response);
?>