Previous Thread
Next Thread
Print Thread
Rate Thread
#274780 06/10/2004 1:05 AM
Joined: Mar 2004
Posts: 118
Journeyman
Journeyman
Offline
Joined: Mar 2004
Posts: 118
Does anyone know why this URL is broken:
Google


Kind regards,
PaNTerSan
Sponsored Links
Brandon Long #274781 06/10/2004 1:16 AM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
No quotes allowed - a security risk.

Daine #274782 06/10/2004 1:17 AM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Google

You have to encode it so that the " marks get chnaged to " then it'll work.

Daine #274783 06/10/2004 1:41 AM
Joined: Mar 2004
Posts: 118
Journeyman
Journeyman
Offline
Joined: Mar 2004
Posts: 118
[]JoshPet said:
You have to encode it so that the " marks get chnaged to " then it'll work. [/]
Whoa It does work

How could this be done via "Convert www -> html" in ubbt.inc.php
Code
 <br />$Body = preg_replace("#([\n\r ])([a-z]+?)://([^ \n\r]+)#i",  "\\1<a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>", $Body);<br /> 

My knowledge of regular expressions is worse than my knowledge of ballet []http://pages.prodigy.net/rogerlori1/emoticons/bigblush.gif[/]


Kind regards,
PaNTerSan
Brandon Long #274784 06/10/2004 6:02 AM
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
...

Sponsored Links
smoknz28 #274785 06/10/2004 6:41 AM
Joined: Mar 2004
Posts: 118
Journeyman
Journeyman
Offline
Joined: Mar 2004
Posts: 118
Tnx

You should update URL broken mod


Kind regards,
PaNTerSan
Brandon Long #274786 06/10/2004 7:20 AM
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Actually I just realized that it won't work correctly for those who have HTML enabled on their forums :-(

Another solution will have to be found after all. If I come up with one I'll post it here.

smoknz28 #274787 06/10/2004 8:59 AM
Joined: Mar 2004
Posts: 118
Journeyman
Journeyman
Offline
Joined: Mar 2004
Posts: 118
[]Twisty said:
Actually I just realized that it won't work correctly for those who have HTML enabled on their forums :-( [/]
Well - it works fine without html After all if you are using html you could user <a href>

[]Twisty said:
Another solution will have to be found after all. If I come up with one I'll post it here. [/]
Suit yourself I think you should repost the solution and make a note that if using html use <a href> ...

Last edited by PaNTerSan; 06/10/2004 9:09 AM.

Kind regards,
PaNTerSan
Brandon Long #274788 06/10/2004 9:56 AM
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Phew, ok I figured it out. Here's how (I have coded in alternative security measures on my own boards so that this doesn't
pose a problem btw - see my other mod right here).

In ubbt.inc.php...

1-A) CHANGE THIS:

Code
    // -----------------------------------------------------------------<br />    // Make sure we don't get any quotes in our urls.  Javascript is bad<br />       preg_match_all("/\[url=(.*?)\]/is",$Body,$matches1);<br />       $bad = "";<br />       for ($i=0; $i < count($matches1['0']); $i++) {<br />          if (strstr($matches1['0'][$i],"\"")) {<br />             $bad = 1;<br />          }<br />       }<br />       if (!$bad) {<br />          $Body = preg_replace("/\[url=http:\/\/(.*?)\](.*?)\[\/url\]/i","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$Body);<br />          $Body = preg_replace("/\[url=https:\/\/(.*?)\](.*?)\[\/url\]/i","<a href=\"https://\\1\" target=\"_blank\">\\2</a>",$Body);<br />          $Body = preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/i","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$Body);<br />      }<br />   

TO THIS:

Code
          $Body = preg_replace("/\[url=http:\/\/(.*?)\](.*?)\[\/url\]/i","<a href=http://\\1 target=_blank>\\2</a>",$Body);<br />          $Body = preg_replace("/\[url=https:\/\/(.*?)\](.*?)\[\/url\]/i","<a href=https://\\1 target=_blank>\\2</a>",$Body);<br />          $Body = preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/i","<a href=http://\\1 target=_blank>\\2</a>",$Body);



1-B) CHANGE THIS:

Code
    // ---------------------------<br />    // Convert www -> html<br />        $Body = " " . $Body;<br />        $Body = preg_replace("#([\n\r ])([a-z]+?)://([^ \n\r]+)#i", "\\1<a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>", $Body);<br />        $Body = preg_replace("#([\n\r ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^, \n\r]*)?)#i", "\\1<a href=\"http://www.\\2.\\3\\4\" target=\"_blank\">www.\\2.\\3\\4</a>", $Body);<br />        $Body = preg_replace("#([\n\r ])([a-z0-9\-_.]+?)@([^, \n\r]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $Body);<br />        $Body = substr($Body, 1);<br />

TO THIS:

Code
    // ---------------------------<br />    // Convert www -> html<br />        $Body = " " . $Body;<br />        $Body = preg_replace("#([\n\r ])([a-z]+?)://([^ \n\r]+)#i", "\\1<a href=\\2://\\3 target=_blank>\\2://\\3</a>", $Body);<br />        $Body = preg_replace("#([\n\r ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^, \n\r]*)?)#i", "\\1<a href=http://www.\\2.\\3\\4 target=_blank>www.\\2.\\3\\4</a>", $Body);<br />        $Body = preg_replace("#([\n\r ])([a-z0-9\-_.]+?)@([^, \n\r]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $Body);<br />        $Body = substr($Body, 1);<br />


That's some real nasty hacking, but it does the job brilliantly

NOTE: If you have Joshpet's short URL mod installed, then do the following in ubbt.inc.php as well...

CHANGE THIS:

Code
	// ---------------------------------------------------------<br />	// Truncate the URL if it's too long - by JoshPet & Gardener<br />		preg_match_all("/<a href=(\"|&quot;)([^\">]*?)(\"|&quot;)([^>]*?)>([^<]*?)<\/a>/i", $Body, $urlmatches, PREG_SET_ORDER);<br />		$matchcount = count($urlmatches);<br />		if ($matchcount) {<br />		   for ($i = 0; $i<$matchcount; $i++) {<br />		      $shorturl = $urlmatches[$i][5];<br />		      if ((preg_match("#^(http|https|ftp)://#i",$shorturl)) && (strlen($shorturl) > 100)) {<br />		         $shortenedurl = substr($shorturl, 0, 40) . "..." . substr($shorturl, -15);<br />		         $shorturl = preg_quote($shorturl, "#");<br />		         $Body = preg_replace("#>$shorturl</a>#i", ">$shortenedurl</a>", $Body, 1);      <br />		      }<br />		   }<br />		}  

TO THIS:

Code
	// ---------------------------------------------------------<br />	// Truncate the URL if it's too long - by JoshPet & Gardener<br />		preg_match_all("/<a href=([^\">]*?)([^>]*?)>([^<]*?)<\/a>/i", $Body, $urlmatches, PREG_SET_ORDER);<br />		$matchcount = count($urlmatches);<br />		if ($matchcount) {<br />		   for ($i = 0; $i<$matchcount; $i++) {<br />		      $shorturl = $urlmatches[$i][3];<br />		      if ((preg_match("#^(http|https|ftp)://#i",$shorturl)) && (strlen($shorturl) > 100)) {<br />		         $shortenedurl = substr($shorturl, 0, 40) . "..." . substr($shorturl, -15);<br />		         $shorturl = preg_quote($shorturl, "#");<br />		         $Body = preg_replace("#>$shorturl</a>#i", ">$shortenedurl</a>", $Body, 1);      <br />		      }<br />		   }<br />		}<br />


Take it for a test drive and lemme know what you think.

Brandon Long #274789 06/10/2004 9:59 AM
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
[]PaNTerSan said:
[]Twisty said:
Actually I just realized that it won't work correctly for those who have HTML enabled on their forums :-( [/]
Well - it works fine without html After all if you are using html you could user <a href>

[]Twisty said:
Another solution will have to be found after all. If I come up with one I'll post it here. [/]
Suit yourself I think you should repost the solution and make a note that if using html use <a href> ... [/]

Ohh I have a much, much better solution now which is compatible with anything See my post above.

Try the new one out. I did a lot of testing with it and can't find any bugs.

Sponsored Links

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Zarzal
Zarzal
Berlin, Germany
Posts: 808
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240506)