Formatting
rodzic
811ad7828f
commit
ad781e6fab
28
index.php
28
index.php
|
@ -110,7 +110,7 @@
|
|||
// Routing:
|
||||
// The .htaccess changes /whatever to /?path=whatever
|
||||
// This runs the function of the path requested.
|
||||
switch ($path) {
|
||||
switch ( $path ) {
|
||||
case ".well-known/webfinger":
|
||||
webfinger(); // Mandatory. Static.
|
||||
case rawurldecode( $username ):
|
||||
|
@ -181,7 +181,7 @@
|
|||
"followers" => "https://{$server}/followers",
|
||||
"inbox" => "https://{$server}/inbox",
|
||||
"outbox" => "https://{$server}/outbox",
|
||||
"preferredUsername" => rawurldecode($username),
|
||||
"preferredUsername" => rawurldecode( $username ),
|
||||
"name" => "{$realName}",
|
||||
"summary" => "{$summary}",
|
||||
"url" => "https://{$server}/{$username}",
|
||||
|
@ -577,8 +577,8 @@ HTML;
|
|||
if ( isset( $message["published"] ) ) {
|
||||
$published = $message["published"];
|
||||
} else {
|
||||
$segments = explode("/", explode("-", $inbox_file ?? "")[0]);
|
||||
$published_hexstamp = end($segments);
|
||||
$segments = explode( "/", explode( "-", $message_file ?? "" )[0]);
|
||||
$published_hexstamp = end( $segments );
|
||||
$published_time = hexdec( $published_hexstamp );
|
||||
$published = date( "c", $published_time );
|
||||
|
||||
|
@ -1038,7 +1038,7 @@ HTML;
|
|||
file_put_contents( $directories["logs"] . "/{$timestamp}.Error.txt", curl_error( $ch ) );
|
||||
return false;
|
||||
}
|
||||
curl_close($ch);
|
||||
curl_close( $ch );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1089,7 +1089,7 @@ HTML;
|
|||
$ch = curl_init( $inbox );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
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_USERAGENT, "activitypub-single-php-file/0.0" );
|
||||
|
||||
|
@ -1128,7 +1128,7 @@ HTML;
|
|||
$hashtags = [];
|
||||
$hashtag_pattern = '/(?:^|\s)\#(\w+)/'; // Beginning of string, or whitespace, followed by #
|
||||
preg_match_all( $hashtag_pattern, $content, $hashtag_matches );
|
||||
foreach ($hashtag_matches[1] as $match) {
|
||||
foreach ( $hashtag_matches[1] as $match ) {
|
||||
$hashtags[] = $match;
|
||||
}
|
||||
|
||||
|
@ -1256,7 +1256,7 @@ HTML;
|
|||
$totalItems = count( $posts );
|
||||
// Create an ordered list
|
||||
$orderedItems = [];
|
||||
foreach ($posts as $post) {
|
||||
foreach ( $posts as $post ) {
|
||||
$orderedItems[] = array(
|
||||
"type" => "Create",
|
||||
"actor" => "https://{$server}/{$username}",
|
||||
|
@ -1387,8 +1387,8 @@ HTML;
|
|||
$currentDatetime = new DateTime();
|
||||
|
||||
// Calculate the time difference in seconds
|
||||
$timeDifference = abs($currentDatetime->getTimestamp() - $headerDatetime->getTimestamp());
|
||||
if ($timeDifference > 30) {
|
||||
$timeDifference = abs( $currentDatetime->getTimestamp() - $headerDatetime->getTimestamp() );
|
||||
if ( $timeDifference > 30 ) {
|
||||
// Write a log detailing the error
|
||||
$timestamp = ( new DateTime() )->format( DATE_RFC3339_EXTENDED );
|
||||
// Filename for the log
|
||||
|
@ -1448,14 +1448,14 @@ HTML;
|
|||
// Converts 'a=b,c=d e f' into ["a"=>"b", "c"=>"d e f"]
|
||||
// word="text"
|
||||
preg_match_all('/(\w+)="([^"]+)"/', $signatureHeader, $matches);
|
||||
foreach ($matches[1] as $index => $key) {
|
||||
foreach ( $matches[1] as $index => $key ) {
|
||||
$signatureParts[$key] = $matches[2][$index];
|
||||
}
|
||||
|
||||
// Manually reconstruct the header string
|
||||
$signatureHeaders = explode(" ", $signatureParts["headers"] );
|
||||
$signatureString = "";
|
||||
foreach ($signatureHeaders as $signatureHeader) {
|
||||
foreach ( $signatureHeaders as $signatureHeader ) {
|
||||
if ( "(request-target)" == $signatureHeader ) {
|
||||
$method = strtolower( $_SERVER["REQUEST_METHOD"] );
|
||||
$target = $_SERVER["REQUEST_URI"];
|
||||
|
@ -1496,9 +1496,9 @@ HTML;
|
|||
);
|
||||
|
||||
// Convert to boolean
|
||||
if ($verified === 1) {
|
||||
if ( $verified === 1 ) {
|
||||
$verified = true;
|
||||
} elseif ($verified === 0) {
|
||||
} elseif ( $verified === 0 ) {
|
||||
$verified = false;
|
||||
} else {
|
||||
$verified = null;
|
||||
|
|
Ładowanie…
Reference in New Issue