本文整理汇总了PHP中Idno\Common\Entity::isLocalUUID方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::isLocalUUID方法的具体用法?PHP Entity::isLocalUUID怎么用?PHP Entity::isLocalUUID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Idno\Common\Entity
的用法示例。
在下文中一共展示了Entity::isLocalUUID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
function post()
{
parse_str(trim(file_get_contents("php://input")), $vars);
// Check that both source and target are non-empty
if (!empty($vars['source']) && !empty($vars['target']) && $vars['source'] != $vars['target']) {
$source = $vars['source'];
$target = $vars['target'];
// Remove anchors from target URL, but save them to '#' input so we can still reference them later
if (strpos($target, '#')) {
list($target, $fragment) = explode('#', $target, 2);
if (!empty($fragment)) {
$this->setInput('#', $fragment);
}
}
// Get the page handler for target
if ($page = \Idno\Core\Idno::site()->getPageHandler($target)) {
// First of all, make sure the target page isn't the source page. Let's not webmention ourselves!
$webmention_ok = true;
if (\Idno\Common\Entity::isLocalUUID($source)) {
if ($source_page = \Idno\Core\Idno::site()->getPageHandler($source)) {
if ($source_page == $page) {
$webmention_ok = false;
}
}
}
// Check that source exists, parse it for mf2 content,
// and ensure that it genuinely mentions this page
if ($webmention_ok) {
if ($source_content = \Idno\Core\Webservice::get($source)) {
if (substr_count($source_content['content'], $target) || $source_content['response'] == 410) {
$source_mf2 = \Idno\Core\Webmention::parseContent($source_content['content'], $source);
// Set source and target information as input variables
$page->setPermalink();
if ($page->webmentionContent($source, $target, $source_content, $source_mf2)) {
$this->setResponse(202);
// Webmention received a-ok.
exit;
} else {
$error = 'target_not_supported';
$error_text = 'This is not webmentionable.';
}
} else {
$error = 'no_link_found';
$error_text = 'The source URI does not contain a link to the target URI.';
\Idno\Core\Idno::site()->logging->warning('No link from ' . $source . ' to ' . $target);
}
} else {
$error = 'source_not_found';
$error_text = 'The source content for ' . $source . ' could not be obtained.';
\Idno\Core\Idno::site()->logging->warning('No content from ' . $source);
}
} else {
$error = 'target_not_supported';
$error_text = 'A page can\'t webmention itself.';
}
} else {
$error = 'target_not_found';
$error_text = 'The target page ' . $target . ' does not exist.';
\Idno\Core\Idno::site()->logging()->error('Could not find handler for ' . $target);
}
}
$this->setResponse(400);
// Webmention failed.
if (empty($error)) {
$error = 'unknown_error';
$error_text = 'Not all the required webmention variables were set.';
}
echo json_encode(array('error' => $error, 'error_text' => $error_text));
}