Quote:
Originally Posted by teksigns
anyone have any idea how to make
mt site always use the preview code
when someone enters a link .......
that way i dont need to have them use the [preview]
stuff.
i want it to always embed that auto unless its a system
administrator . then i want it to work like normal .
|
ok i have this working by changing the code in :
functions_newpost.php
PHP Code:
// ###################### Start parseurl #######################
function convert_url_to_bbcode($messagetext)
{ // the auto parser - adds [url] tags around neccessary things
global $urlSearchArray, $urlReplaceArray, $emailSearchArray, $emailReplaceArray;
if (!isset($urlSearchArray))
{
$urlSearchArray = array(
"#(^|(?<=[^_a-z0-9-=\]\"'/]))((https?|ftp|gopher|news|telnet)://|www\.)((\[(?!/)|[^\s[()^$!`\"'|{}<>])+)(?!\[/url|\[/img)(?=[,.]*([\s)[]|$))#siU"
);
if($permissions['adminpermissions']){
$urlReplaceArray = array(
"[url]\\2\\4[/url]"
);
}else{
$urlReplaceArray = array(
"[preview]\\2\\4[/preview]"
);
}
$emailSearchArray = array(
"/([ \n\r\t])([_a-z0-9-]+(\.[_a-z0-9-]+)*@[^\s]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/si",
"/^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[^\s]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/si"
);
$emailReplaceArray = array(
"\\1[email]\\2[/email]",
"[email]\\0[/email]"
);
}
$text = preg_replace($urlSearchArray, $urlReplaceArray, $messagetext);
if (strpos($text, "@"))
{
$text = preg_replace($emailSearchArray, $emailReplaceArray, $text);
}
return $text;
}
i have one problem though ......
if a use post a link to something on my site i dont want it to use the preview code .
are there a way to change the if statement above to exclude urls that conatin my site string ?