aboutsummaryrefslogtreecommitdiff
path: root/guestbook/submit.php
diff options
context:
space:
mode:
Diffstat (limited to 'guestbook/submit.php')
-rw-r--r--guestbook/submit.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/guestbook/submit.php b/guestbook/submit.php
index 0e53fb3..bb745a2 100644
--- a/guestbook/submit.php
+++ b/guestbook/submit.php
@@ -52,6 +52,38 @@ error_reporting(E_ALL);
$returnCode = "review";
}
+ $button = ""; // URL for the submitter's .well-known/button.json
+ if($_POST["website"]) {
+ $buttonjson = "";
+ $buttonjsonurl = 'https://'.parse_url($_POST["website"], PHP_URL_HOST).'/.well-known/button.json';
+
+ $ch = curl_init($buttonjsonurl);
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+
+ $buttonjson = curl_exec($ch);
+ if(curl_error($ch)) {
+ //echo curl_error($ch);
+ $buttonjson = "";
+ }
+ curl_close($ch);
+
+ if($buttonjson) {
+ $buttonobj = json_decode($buttonjson);
+ if($buttonobj->default) {
+ foreach ($buttonobj->buttons as $btn) {
+ if($btn->id === $buttonobj->default) {
+ $button = $btn->uri;
+ break;
+ }
+ }
+ } else {
+ $button = $buttonobj->buttons[0]->uri;
+ }
+ }
+ }
+
$currentPost = array(
"entry" => $_POST["entry"],
"sourceip" => $sourceip,
@@ -61,6 +93,7 @@ error_reporting(E_ALL);
"found" => $_POST["found"],
"website" => $_POST["website"],
+ "button" => $button,
"cool" => $_POST["cool"],
"reply" => "",
"modstatus" => $modstatus