streams/Code/Lib/Relme.php

42 lines
964 B
PHP
Raw Normal View History

2023-04-22 20:43:08 +00:00
<?php
namespace Code\Lib;
use IndieWeb;
class Relme
{
protected $channel = null;
public function setChannel($channel)
{
$this->channel = $channel;
return $this;
}
public function getChannel()
{
return $this->channel;
}
2023-04-23 05:59:10 +00:00
public function RelmeValidate($otherUrl, $myUrl)
2023-04-22 20:43:08 +00:00
{
2023-04-23 05:59:10 +00:00
$links = [];
list($resolvedProfileUrl, $isSecure, $redirectChain) = IndieWeb\relMeDocumentUrl($otherUrl);
if ($isSecure) {
2023-04-30 05:28:07 +00:00
$htmlResponse = Url::get($resolvedProfileUrl);
2023-04-23 05:59:10 +00:00
if ($htmlResponse['success']) {
$links = IndieWeb\relMeLinks($htmlResponse['body'], $resolvedProfileUrl);
}
2023-04-22 20:43:08 +00:00
}
foreach($links as $link) {
2023-04-23 05:59:10 +00:00
list($matches, $secure, $redirectChain) = IndieWeb\backlinkingRelMeUrlMatches($link, $myUrl);
2023-04-22 20:43:08 +00:00
if ($matches && $secure) {
return true;
}
}
return false;
}
2023-04-23 07:22:00 +00:00
2023-04-22 20:43:08 +00:00
2023-04-23 05:59:10 +00:00
}