View Full Version : Anyone have this working....
cobradude
05-13-2002, 08:04 PM
...I run one of my vb licenses on a corporate network and people will post links to docs and tools on other machines within the network. So they will post in the message something to the affect of \\mycomputer\docs\mydoc.doc which vbulletin doesn't recognize as a hyperlink.
How can I set up the software to do this? It appears that this code in functions.php (around line 686) is what makes http:// turn into a hyperlink in the posts (could be wrong about this being the code that does it--I'm not a coder). How can I modify this to also recognize \\ as a link too?
$replacearray = array(
"<ol type=\"\\5\">\\7</ol>",
"<ul>\\4</ul>",
"<li>",
"<a href=\"http://www.\\6\" target=\"_blank\">\\8</a>",
"<a href=\"\\5\" target=\"_blank\">\\7</a>",
"<a href=\"http://www.\\5\" target=\"_blank\">\\5</a>",
"<a href=\"\\4\" target=\"_blank\">\\4</a>",
"</normalfont><blockquote><pre><smallfont>code:</smallfont><hr>\\5<hr></pre></blockquote><normalfont>",
"</normalfont><blockquote><pre><smallfont>code:</smallfont><hr>\\5<hr></pre></blockquote><normalfont>",
"java script:",
"about :",
"vbscript :"
);
} else {
$searcharray = array(
"/(\[)(list)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/list)(((=)(\\4)([^\"']*)(\\4]))|(\]))/esiU",
"/(\[)(list)(])(.*)(\[\/list\])/esiU",
"/(\[)(url)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/url\])/esiU",
"/(\[)(url)(])([^\"]*)(\[\/url\])/esiU",
"/(\[)(code)(])(\r\n)*(.*)(\[\/code\])/esiU",
"/(\[)(php)(])(\r\n)*(.*)(\[\/php\])/esiU",
"/javascript:/si",
"/about:/si",
"/vbscript:/si"
);
$replacearray = array(
"createlists('\\7', '\\5')",
"createlists('\\4')",
"checkurl('\\5', '\\7')",
"checkurl('\\4')",
"stripbrsfromcode('\\5')",
"phphighlite('\\5')",
"java script:",
"about :",
"vbscript :"
);
} // end version check
cobradude
05-13-2002, 11:48 PM
Ok, so I added a custom vbcode "share"
[quote]<a href="file://{param}">{param}</a>[quote]
So now I just need to make this a no hassel thing just like typing in your favorite url. vBulletin automatically parses the text and puts the "url" tags around it for the person who posted (no extra work or knowlege of the vbcodes necessary).
I still think it has to do with the stuff in the functions.php, but correct me if I'm wrong. :)
Admin
05-14-2002, 08:49 AM
The parseurl() function does that, IIRC.
cobradude
05-14-2002, 05:02 PM
Thanks firefly! Here is probably a quick question for you then.
So I think I am supposed to add another function see code below (copy of parseurl just changed to reflect different bbcode)....
// ###################### Start parseSHARE #######################
unset($shareSearchArray);
unset($shareReplaceArray);
function parseshare($messagetext)
{ // the auto parser - adds tags around neccessary things
global $shareSearchArray, $shareReplaceArray;
if (!isset($shareSearchArray)) {
$shareSearchArray = array(
"/([^]_a-z0-9-=\"'\/])((https?|ftp|gopher|news|telnet):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si",
"/^((https?|ftp|gopher|news|telnet):\/\/|\\)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si"
);
$shareReplaceArray = array(
"\\1[share]\\2\\4",
"\\1\\3"
);
$text = preg_replace($shareSearchArray, $shareReplaceArray, $messagetext);
}
return $text;
}
If I want to add my share tags around any string starting with "\\", how would I do it? It looks like the lines with www\. in them is where I need to make this modification, but there's a bunch of \/\ stuff that seems like it would get all hosed up if I throw a \\ in the mix...This is all pretty foreign to me, but at least I am trying.
Any help is appreciated! :)
cobradude
05-14-2002, 06:19 PM
Actually I guess I wouldn't need to have a separate function.
Here's what I have so far, and there's no errors, but it's not adding the [ share] [ /share] brackets around \\blah\blah either. :cheeky:
// ###################### Start parseurl #######################
unset($urlSearchArray);
unset($urlReplaceArray);
unset($emailSearchArray);
unset($emailReplaceArray);
unset($shareSearchArray);
unset($shareReplaceArray);
function parseurl($messagetext)
{ // the auto parser - adds tags around neccessary things
global $urlSearchArray, $urlReplaceArray, $emailSearchArray, $emailReplaceArray, $shareSearchArray, $shareReplaceArray;
if (!isset($urlSearchArray)) {
$urlSearchArray = array(
"/([^]_a-z0-9-=\"'\/])((https?|ftp|gopher|news|telnet):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si",
"/^((https?|ftp|gopher|news|telnet):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si"
);
$urlReplaceArray = array(
"\\1[url]\\2\\4",
"\\1\\3"
);
$emailSearchArray = array(
"/([ \n\r\t])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4}))/si",
"/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4}))/si"
);
$emailReplaceArray = array(
"\\1\\2",
"\\0"
);
$shareSearchArray = array(
"/([^]_a-z0-9-=\"'\/])((https?|ftp|gopher|news|telnet):\/\/|\\)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si",
"/^((https?|ftp|gopher|news|telnet):\/\/|\\)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si"
);
$shareReplaceArray = array(
"\\1\\2\\4",
"\\1\\3"
);
}
$text = preg_replace($urlSearchArray, $urlReplaceArray, $messagetext);
if (strpos($text, "@"))
$text = preg_replace($emailSearchArray, $emailReplaceArray, $text);
if (strpos($text, "\\")) {
$text = preg_replace($shareSearchArray, $shareReplaceArray, $text);
}
return $text;
}
cobradude
05-14-2002, 08:23 PM
With a bit of help from a friend, here's what we came up with that seems to work fine...
// ###################### Start parseurl #######################
unset($urlSearchArray);
unset($urlReplaceArray);
unset($emailSearchArray);
unset($emailReplaceArray);
unset($shareSearchArray);
unset($shareReplaceArray);
function parseurl($messagetext)
{ // the auto parser - adds tags around neccessary things
global $urlSearchArray, $urlReplaceArray, $emailSearchArray, $emailReplaceArray, $shareSearchArray, $shareReplaceArray;
if (!isset($urlSearchArray)) {
$urlSearchArray = array(
"/([^]_a-z0-9-=\"'\/])((https?|ftp|gopher|news|telnet):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si",
"/^((https?|ftp|gopher|news|telnet):\/\/|www\.)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si"
);
$urlReplaceArray = array(
"\\1[url]\\2\\4",
"\\1\\3"
);
$emailSearchArray = array(
"/([ \n\r\t])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4}))/si",
"/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4}))/si"
);
$emailReplaceArray = array(
"\\1\\2",
"\\0"
);
$shareSearchArray = array(
"/([^]_a-z0-9-=\"'\/])((https?|ftp|gopher|news|telnet):\/\/|\\\\)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si",
"/^((https?|ftp|gopher|news|telnet):\/\/|\\\\)([^ \r\n\(\)\^\$!`\"'\|\[\]\{\}<>]*)/si"
);
$shareReplaceArray = array(
"\\2\\2\\4"
);
}
$text = preg_replace($urlSearchArray, $urlReplaceArray, $messagetext);
if (strpos($text, "@"))
$text = preg_replace($emailSearchArray, $emailReplaceArray, $text);
if (strncmp($text, "\\",1) == 0) {
$text = preg_replace($shareSearchArray, $shareReplaceArray, $text);
}
return $text;
}
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.