move all the zid related stuff to one file
This commit is contained in:
@@ -290,78 +290,6 @@ function add_source_route($iid, $hash) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief preg_match function when fixing 'naked' links in mod item.php.
|
||||
*
|
||||
* Check if we've got a hubloc for the site and use a zrl if we do, a url if we don't.
|
||||
* Remove any existing zid= param which may have been pasted by mistake - and will have
|
||||
* the author's credentials. zid's are dynamic and can't really be passed around like
|
||||
* that.
|
||||
*
|
||||
* @param array $matches
|
||||
* @return string
|
||||
*/
|
||||
function red_zrl_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($matches[1] === '#^')
|
||||
$matches[1] = '';
|
||||
if($zrl)
|
||||
return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]';
|
||||
|
||||
return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]';
|
||||
}
|
||||
|
||||
/**
|
||||
* If we've got a url or zrl tag with a naked url somewhere in the link text,
|
||||
* escape it with quotes unless the naked url is a linked photo.
|
||||
*
|
||||
* @param array $matches
|
||||
* @return string
|
||||
*/
|
||||
function red_escape_zrl_callback($matches) {
|
||||
|
||||
// Uncertain why the url/zrl forms weren't picked up by the non-greedy regex.
|
||||
|
||||
if((strpos($matches[3], 'zmg') !== false) || (strpos($matches[3], 'img') !== false) || (strpos($matches[3],'zrl') !== false) || (strpos($matches[3],'url') !== false))
|
||||
return $matches[0];
|
||||
|
||||
return '[' . $matches[1] . 'rl' . $matches[2] . ']' . $matches[3] . '"' . $matches[4] . '"' . $matches[5] . '[/' . $matches[6] . 'rl]';
|
||||
}
|
||||
|
||||
function red_escape_codeblock($m) {
|
||||
return '[$b64' . $m[2] . base64_encode($m[1]) . '[/' . $m[2] . ']';
|
||||
}
|
||||
|
||||
function red_unescape_codeblock($m) {
|
||||
return '[' . $m[2] . base64_decode($m[1]) . '[/' . $m[2] . ']';
|
||||
}
|
||||
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Post an activity.
|
||||
*
|
||||
|
Reference in New Issue
Block a user