Minor tidy up
rodzic
51c71edf1e
commit
7269503af6
11
index.php
11
index.php
|
@ -73,8 +73,6 @@
|
||||||
// This runs the function of the path requested.
|
// This runs the function of the path requested.
|
||||||
!empty( $_GET["path"] ) ? $path = $_GET["path"] : die();
|
!empty( $_GET["path"] ) ? $path = $_GET["path"] : die();
|
||||||
switch ($path) {
|
switch ($path) {
|
||||||
case "":
|
|
||||||
die();
|
|
||||||
case ".well-known/webfinger":
|
case ".well-known/webfinger":
|
||||||
webfinger();
|
webfinger();
|
||||||
case rawurldecode( $username ):
|
case rawurldecode( $username ):
|
||||||
|
@ -256,7 +254,7 @@
|
||||||
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
|
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
|
||||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($message) );
|
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($message) );
|
||||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
|
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
|
||||||
$response = curl_exec( $ch );
|
curl_exec( $ch );
|
||||||
|
|
||||||
// Check for errors
|
// Check for errors
|
||||||
if( curl_errno( $ch ) ) {
|
if( curl_errno( $ch ) ) {
|
||||||
|
@ -346,7 +344,7 @@ echo <<< HTML
|
||||||
<body>
|
<body>
|
||||||
<form action="/send" method="post" enctype="multipart/form-data">
|
<form action="/send" method="post" enctype="multipart/form-data">
|
||||||
<label for="content">Your message:</label><br>
|
<label for="content">Your message:</label><br>
|
||||||
<textarea id="content" name="content" rows="5" cols="32"></textarea><br>
|
<textarea id="content" name="content" rows="5" cols="32"></textarea><br>
|
||||||
<label for="password">Password</label><br>
|
<label for="password">Password</label><br>
|
||||||
<input type="password" name="password" id="password" size="32"><br>
|
<input type="password" name="password" id="password" size="32"><br>
|
||||||
<input type="submit" value="Post Message">
|
<input type="submit" value="Post Message">
|
||||||
|
@ -392,6 +390,7 @@ HTML;
|
||||||
];
|
];
|
||||||
|
|
||||||
// Construct the Message
|
// Construct the Message
|
||||||
|
// The audience is public and it is sent to all followers
|
||||||
$message = [
|
$message = [
|
||||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||||
"id" => "https://{$server}/posts/{$guid}.json",
|
"id" => "https://{$server}/posts/{$guid}.json",
|
||||||
|
@ -427,6 +426,7 @@ HTML;
|
||||||
// Each server needs its own cURL handle
|
// Each server needs its own cURL handle
|
||||||
// Each POST to an inbox needs to be signed separately
|
// Each POST to an inbox needs to be signed separately
|
||||||
foreach ( $hosts as $host ) {
|
foreach ( $hosts as $host ) {
|
||||||
|
// TODO: Not every host uses /inbox
|
||||||
$path = "/inbox";
|
$path = "/inbox";
|
||||||
|
|
||||||
// Get the signed headers
|
// Get the signed headers
|
||||||
|
@ -436,8 +436,7 @@ HTML;
|
||||||
$remoteServerUrl = "https://{$host}{$path}";
|
$remoteServerUrl = "https://{$host}{$path}";
|
||||||
|
|
||||||
// POST the message and header to the requester's inbox
|
// POST the message and header to the requester's inbox
|
||||||
$ch = curl_init( $remoteServerUrl );
|
$ch = curl_init( $remoteServerUrl );
|
||||||
|
|
||||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||||
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
|
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
|
||||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($message) );
|
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($message) );
|
||||||
|
|
Ładowanie…
Reference in New Issue