本文整理汇总了PHP中is_matrix_url函数的典型用法代码示例。如果您正苦于以下问题:PHP is_matrix_url函数的具体用法?PHP is_matrix_url怎么用?PHP is_matrix_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_matrix_url函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: oembed_fetch_url
function oembed_fetch_url($embedurl)
{
$a = get_app();
$txt = Cache::get($a->videowidth . $embedurl);
if (strstr($txt, 'youtu')) {
$txt = str_replace('http:', 'https:', $txt);
}
// These media files should now be caught in bbcode.php
// left here as a fallback in case this is called from another source
$noexts = array("mp3", "mp4", "ogg", "ogv", "oga", "ogm", "webm");
$ext = pathinfo(strtolower($embedurl), PATHINFO_EXTENSION);
if (is_null($txt)) {
$txt = "";
if (in_array($ext, $noexts)) {
require_once 'include/hubloc.php';
$zrl = is_matrix_url($embedurl);
if ($zrl) {
$embedurl = zid($embedurl);
}
} else {
// try oembed autodiscovery
$redirects = 0;
$result = z_fetch_url($embedurl, false, $redirects, array('timeout' => 15, 'accept_content' => "text/*", 'novalidate' => true));
if ($result['success']) {
$html_text = $result['body'];
}
if ($html_text) {
$dom = @DOMDocument::loadHTML($html_text);
if ($dom) {
$xpath = new DOMXPath($dom);
$attr = "oembed";
$xattr = oe_build_xpath("class", "oembed");
$entries = $xpath->query("//link[@type='application/json+oembed']");
foreach ($entries as $e) {
$href = $e->getAttributeNode("href")->nodeValue;
$x = z_fetch_url($href . '&maxwidth=' . $a->videowidth);
$txt = $x['body'];
break;
}
}
}
}
if ($txt == false || $txt == "") {
$x = array('url' => $embedurl, 'videowidth' => $a->videowidth);
call_hooks('oembed_probe', $x);
if (array_key_exists('embed', $x)) {
$txt = $x['embed'];
}
}
$txt = trim($txt);
if ($txt[0] != "{") {
$txt = '{"type":"error"}';
}
//save in cache
Cache::set($a->videowidth . $embedurl, $txt);
}
$j = json_decode($txt);
$j->embedurl = $embedurl;
return $j;
}
示例2: tryzrlvideo
function tryzrlvideo($match)
{
$link = $match[1];
$zrl = is_matrix_url($link);
if ($zrl) {
$link = zid($link);
}
return '<video controls="controls" preload="none" src="' . str_replace(' ', '%20', $link) . '" style="width:100%; max-width:' . App::$videowidth . 'px"><a href="' . str_replace(' ', '%20', $link) . '">' . $link . '</a></video>';
}
示例3: tryzrlvideo
function tryzrlvideo($match)
{
$link = $match[1];
$zrl = is_matrix_url($link);
if ($zrl) {
$link = zid($link);
}
return '<video controls="controls" src="' . $link . '" style="width:100%; max-width:' . get_app()->videowidth . 'px"><a href="' . $link . '">' . $link . '</a></video>';
}
示例4: bookmark_add
function bookmark_add($channel, $sender, $taxonomy, $private, $opts = null)
{
$menu_id = 0;
$menu_name = '';
$ischat = false;
if (is_array($opts)) {
$menu_id = x($opts, 'menu_id') ? intval($opts['menu_id']) : 0;
$menu_name = x($opts, 'menu_name') ? escape_tags($opts['menu_name']) : '';
$ischat = x($opts, 'ischat') ? intval($opts['ischat']) : 0;
}
$iarr = array();
$channel_id = $channel['channel_id'];
if ($private) {
$iarr['contact_allow'] = array($channel['channel_hash']);
}
$iarr['mitem_link'] = $taxonomy['url'];
$iarr['mitem_desc'] = $taxonomy['term'];
$iarr['mitem_flags'] = $ischat ? MENU_ITEM_CHATROOM : 0;
require_once 'include/hubloc.php';
$zrl = is_matrix_url($taxonomy['url']);
if ($zrl) {
$iarr['mitem_flags'] |= MENU_ITEM_ZID;
}
$arr = array();
if (!$menu_name) {
$arr['menu_name'] = substr($sender['xchan_hash'], 0, 16) . ' ' . $sender['xchan_name'];
$arr['menu_desc'] = sprintf(t('%1$s\'s bookmarks'), $sender['xchan_name']);
} else {
$arr['menu_name'] = $arr['menu_desc'] = $menu_name;
}
$arr['menu_flags'] = $sender['xchan_hash'] === $channel['channel_hash'] ? MENU_BOOKMARK : MENU_SYSTEM | MENU_BOOKMARK;
$arr['menu_channel_id'] = $channel_id;
if (!$menu_id) {
$x = menu_list($arr['menu_channel_id'], $arr['menu_name'], $arr['menu_flags']);
if ($x) {
$menu_id = $x[0]['menu_id'];
} else {
$menu_id = menu_create($arr);
}
}
if (!$menu_id) {
logger('bookmark_add: unable to create menu ' . $arr['menu_name']);
return;
}
logger('add_bookmark: menu_id ' . $menu_id);
$r = q("select * from menu_item where mitem_link = '%s' and mitem_menu_id = %d and mitem_channel_id = %d limit 1", dbesc($iarr['mitem_link']), intval($menu_id), intval($channel_id));
if ($r) {
logger('add_bookmark: duplicate menu entry', LOGGER_DEBUG);
}
if (!$r) {
$r = menu_add_item($menu_id, $channel_id, $iarr);
}
return $r;
}
示例5: red_zrlify_img_callback
function red_zrlify_img_callback($matches)
{
require_once 'include/hubloc.php';
$zrl = is_matrix_url($matches[2]);
$t = strip_zids($matches[2]);
if ($t !== $matches[2]) {
$zrl = true;
$matches[2] = $t;
}
if ($zrl) {
return '[zmg' . $matches[1] . ']' . $matches[2] . '[/zmg]';
}
return $matches[0];
}
示例6: get
function get()
{
logger('linkinfo: ' . print_r($_REQUEST, true));
$text = null;
$str_tags = '';
$br = "\n";
if (x($_GET, 'binurl')) {
$url = trim(hex2bin($_GET['binurl']));
} else {
$url = trim($_GET['url']);
}
$url = strip_zids($url);
if (substr($url, 0, 1) != '/' && substr($url, 0, 4) != 'http') {
$url = 'http://' . $url;
}
if ($_GET['title']) {
$title = strip_tags(trim($_GET['title']));
}
if ($_GET['description']) {
$text = strip_tags(trim($_GET['description']));
}
if ($_GET['tags']) {
$arr_tags = str_getcsv($_GET['tags']);
if (count($arr_tags)) {
array_walk($arr_tags, 'self::arr_add_hashes');
$str_tags = $br . implode(' ', $arr_tags) . $br;
}
}
logger('linkinfo: ' . $url);
$result = z_fetch_url($url, false, 0, array('novalidate' => true, 'nobody' => true));
if ($result['success']) {
$hdrs = array();
$h = explode("\n", $result['header']);
foreach ($h as $l) {
list($k, $v) = array_map("trim", explode(":", trim($l), 2));
$hdrs[$k] = $v;
}
if (array_key_exists('Content-Type', $hdrs)) {
$type = $hdrs['Content-Type'];
}
if ($type) {
$zrl = is_matrix_url($url);
if (stripos($type, 'image/') !== false) {
if ($zrl) {
echo $br . '[zmg]' . $url . '[/zmg]' . $br;
} else {
echo $br . '[img]' . $url . '[/img]' . $br;
}
killme();
}
if (stripos($type, 'video/') !== false) {
if ($zrl) {
echo $br . '[zvideo]' . $url . '[/zvideo]' . $br;
} else {
echo $br . '[video]' . $url . '[/video]' . $br;
}
killme();
}
if (stripos($type, 'audio/') !== false) {
if ($zrl) {
echo $br . '[zaudio]' . $url . '[/zaudio]' . $br;
} else {
echo $br . '[audio]' . $url . '[/audio]' . $br;
}
killme();
}
}
}
$template = $br . '#^[url=%s]%s[/url]%s' . $br;
$arr = array('url' => $url, 'text' => '');
call_hooks('parse_link', $arr);
if (strlen($arr['text'])) {
echo $arr['text'];
killme();
}
$x = oembed_process($url);
if ($x) {
echo $x;
killme();
}
if ($url && $title && $text) {
$text = $br . '[quote]' . trim($text) . '[/quote]' . $br;
$title = str_replace(array("\r", "\n"), array('', ''), $title);
$result = sprintf($template, $url, $title ? $title : $url, $text) . $str_tags;
logger('linkinfo (unparsed): returns: ' . $result);
echo $result;
killme();
}
$siteinfo = self::parseurl_getsiteinfo($url);
// If this is a Red site, use zrl rather than url so they get zids sent to them by default
if (x($siteinfo, 'generator') && strpos($siteinfo['generator'], \Zotlabs\Project\System::get_platform_name() . ' ') === 0) {
$template = str_replace('url', 'zrl', $template);
}
if ($siteinfo["title"] == "") {
echo sprintf($template, $url, $url, '') . $str_tags;
killme();
} else {
$text = $siteinfo["text"];
$title = $siteinfo["title"];
}
//.........这里部分代码省略.........
示例7: oembed_format_object
function oembed_format_object($j)
{
$a = get_app();
$embedurl = $j->embedurl;
// logger('format: ' . print_r($j,true));
$jhtml = oembed_iframe($j->embedurl, isset($j->width) ? $j->width : null, isset($j->height) ? $j->height : null);
$ret = "<span class='oembed " . $j->type . "'>";
switch ($j->type) {
case "video":
if (isset($j->thumbnail_url)) {
$tw = isset($j->thumbnail_width) ? $j->thumbnail_width : 200;
$th = isset($j->thumbnail_height) ? $j->thumbnail_height : 180;
$tr = $tw / $th;
$th = 120;
$tw = $th * $tr;
$tpl = get_markup_template('oembed_video.tpl');
if (strstr($embedurl, 'youtu') && strstr(z_root(), 'https:')) {
$embedurl = str_replace('http:', 'https:', $embedurl);
$j->thumbnail_url = str_replace('http:', 'https:', $j->thumbnail_url);
$jhtml = str_replace('http:', 'https:', $jhtml);
$j->html = str_replace('http:', 'https:', $j->html);
}
$ret .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$embedurl' => $embedurl, '$escapedhtml' => base64_encode($jhtml), '$tw' => $tw, '$th' => $th, '$turl' => $j->thumbnail_url));
} else {
$ret = $jhtml;
}
$ret .= "<br>";
break;
case "photo":
$ret .= "<img width='" . $j->width . "' src='" . $j->url . "'>";
$ret .= "<br>";
break;
case "link":
if ($j->thumbnail_url) {
if (is_matrix_url($embedurl)) {
$embedurl = zid($embedurl);
$j->thumbnail_url = zid($j->thumbnail_url);
}
$ret = '<a href="' . $embedurl . '" ><img src="' . $j->thumbnail_url . '" alt="thumbnail" /></a><br /><br />';
}
//$ret = "<a href='".$embedurl."'>".$j->title."</a>";
break;
case "rich":
// not so safe..
$ret .= $jhtml;
break;
}
// add link to source if not present in "rich" type
if ($j->type != 'rich' || !strpos($j->html, $embedurl)) {
$embedlink = isset($j->title) ? $j->title : $embedurl;
$ret .= '<br /><span class="bookmark-identifier">#^</span>' . "<a href='{$embedurl}' rel='oembed'>{$embedlink}</a>";
$ret .= "<br />";
if (isset($j->author_name)) {
$ret .= " by " . $j->author_name;
}
if (isset($j->provider_name)) {
$ret .= " on " . $j->provider_name;
}
} else {
// add <a> for html2bbcode conversion
$ret .= "<br /><a href='{$embedurl}' rel='oembed'>{$embedurl}</a>";
}
$ret .= "<br style='clear:left'></span>";
return mb_convert_encoding($ret, 'HTML-ENTITIES', mb_detect_encoding($ret));
}