News:

Wondering if this will always be free?  See why free is better.

Main Menu

Automatically Code a Link

Started by Rohan_, May 29, 2009, 05:05:11 PM

Previous topic - Next topic

Rohan_

#60
i got this after doing this .. i changed the CODEBBC to code

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')'


EDIT : well i just changed the url tag to code tag in the code u provided with my default code and no errors .. all links are getting coded .. but every link make a separate block .. :( i think u understand how i want them
Proud To Be An Indian

Arantor

Yes, because you cannot quote [code] inside a code tag (because [/code] ends the tag!), so I had to use a different tag that you could copy.

And in fact, BBcode handling between 1.1 and 2.0 is almost identical, when I'm writing mods with BBcode I just copy/paste the code.

Rohan_

so please tell me what do i need to do now
Proud To Be An Indian

Arantor

So have you made that change and what result does it give you for URLs?

Rohan_

ya i made the change see it for yourself

before
if (!isset($disabled['url']) && (strpos($data, '://') !== false || strpos($data, 'www.') !== false))
{
// Switch out quotes really quick because they can cause problems.
$data = strtr($data, array(''' => '\'', '&nbsp;' => $context['utf8'] ? "\xC2\xA0" : "\xA0", '&quot;' => '>">', '"' => '<"<', '&lt;' => '<lt<'));
$data = preg_replace(array('~(?<=[\s>\.(;\'"]|^)((?:http|https|ftp|ftps)://[\w\-_%@:|]+(?:\.[\w\-_%]+)*(?::\d+)?(?:/[\w\-_\~%\.@,\?&;=#+:\'\\\\]*|[\(\{][\w\-_\~%\.@,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i', '~(?<=[\s>(\'<]|^)(www(?:\.[\w\-_]+)+(?::\d+)?(?:/[\w\-_\~%\.@,\?&;=#+:\'\\\\]*|[\(\{][\w\-_\~%\.@,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i'), array('[url]$1[/url]', '[url=http://$1]$1[/url]'), $data);
$data = strtr($data, array('\'' => ''', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;', '>">' => '&quot;', '<"<' => '"', '<lt<' => '&lt;'));
}


After
if (!isset($disabled['url']) && (strpos($data, '://') !== false || strpos($data, 'www.') !== false))
{
// Switch out quotes really quick because they can cause problems.
$data = strtr($data, array(''' => '\'', '&nbsp;' => $context['utf8'] ? "\xC2\xA0" : "\xA0", '&quot;' => '>">', '"' => '<"<', '&lt;' => '<lt<'));
$data = preg_replace(array('~(?<=[\s>\.(;\'"]|^)((?:http|https|ftp|ftps)://[\w\-_%@:|]+(?:\.[\w\-_%]+)*(?::\d+)?(?:/[\w\-_\~%\.@,\?&;=#+:\'\\\\]*|[\(\{][\w\-_\~%\.@,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i', '~(?<=[\s>(\'<]|^)(www(?:\.[\w\-_]+)+(?::\d+)?(?:/[\w\-_\~%\.@,\?&;=#+:\'\\\\]*|[\(\{][\w\-_\~%\.@,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i'), array('[codebbc]$1[/codebbc]', '[codebbc]$1[/codebbc]'), $data);
$data = strtr($data, array('\'' => ''', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;', '>">' => '&quot;', '<"<' => '"', '<lt<' => '&lt;'));
}


The Codebbc in this code is code i edited it here just for posting this correctly
Proud To Be An Indian

Arantor

And does that give you the right result for all URLs in your forum (barring the multiple line issue which needs addressing)?

I also note that my comment earlier was not addressed.

Aleksi "Lex" Kilpinen

Would it not do to simply disable the automatic URL linking, and disallow the use of URL -tags?

Admin -> Posts and topics -> Bulletin Board Code -> Automatically link posted URLs (Uncheck this)
Admin -> Posts and topics -> Bulletin Board Code -> Enabled BBC tags (Uncheck "url" )

Then all you would get is inactive links like http://www.example.com
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Arantor

That would do that, sure, but it wouldn't wrap them in code tags as requested.

I would still like to know the logic behind it though.

Aleksi "Lex" Kilpinen

Quote from: Arantor on September 21, 2009, 08:02:01 AM
I would still like to know the logic behind it though.
That's why I asked, I don't see the real difference either.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Rohan_

i want the links in code blocks  .. i like it and its usable i have designed my code blocks ..and specially all the site uses this feature :( .. please help ..


Arantor the results are simple like the autocode link mod does .. the code u provided just making all the links in code blocks .. but all in separate blocks ..

not like i requested
Proud To Be An Indian

Arantor

I never said it would be in combined blocks like you requested, in fact if you read what I wrote, I specifically said it was only HALF of it.

What other sites use this feature?

The only sites I know that use this feature are ones you know full well I do not support.

Rohan_

Arantor .. this is not a topic for the warez site .. i have other professional good legal sites too .. and not only me there are a lot of people who wants this feature in their SMF Forum .. this is not only my request this is the request of thousands of SMF users
Proud To Be An Indian

Arantor

OK, so what is the reason behind having it outside of a warez site?

(For that matter, what is the reason for having it IN a warez site?)

Rohan_

#73
the main reason is that this is a rule in all my forums to code the links .. because the code blocks look different and user can easily find where the links are without concentrating on the page .. and some users spam and post phishing links usng url tags that makes a link to another site and they name it something other like www.this.com .. links in code blocks clears everything and the link under code blocks cant carry a spam link under them the links in code blocks are always be the same as they looks


and my code blocks are modified .. their text size is also bigger than the default .. see this

Proud To Be An Indian

Arantor

If phishing prevention is the aim, it's simple; you disable the second form of the url tag which allows [url=real_url]display_url[/url].

The one thing that bothers me is your claim of "thousands of SMF users". I have seen only two requests for this including yours, and the other was for a warez site so I still cannot understand the argument for this.

Rohan_

not everyone come here , register , open topics , requests , wait for replies , wait for the solution .. u know that there are some lazy and some noobs .. they just know the feature nothing else .. but believe me . there are really thousands of people who want this ... there are some people who see this topic for a solution .. as u can see 2000+ views ... just make a mod for this and see for yourself
Proud To Be An Indian

Arantor

OK - show me one, any one, non-warez forum that does this.

MrPhil

Please folks, let's calm down. I don't understand the level of venom going back and forth here. Regardless of whether this is to be used in a warez site, I would think that it could be at least partially implemented. Somewhere in the bowels of SMF is code to detect a string of characters that appears to be a URL, or at least, a domain name. The current code wraps a link around it: <a href="http://text">text</a>. Rohan is requesting a change to, instead of putting a link around the URL, put a full-width <div> around the text, with different background color and a border. It could be similar to what's put out by a [code] block, but without the "Code:" header. That should be fairly simple (although I have no interest (or time) in doing it myself). To combine multiple lines into one block at a time would be a bit more difficult -- you'd probably buffer the output in a string so that you could go back and fuse together the enclosing <div>s into one, and put <br> or something to separate the lines. Something like "find </div><div class="URL"> and replace it with <br>".

A bit easier would just be to, instead of wrapping a link around a URL, to put a <span> around it with a different color scheme, if all you want to do is 1) disable URLs and 2) make them stand out.

I don't know if "thousands" of SMF users would like something like this, but at times I wish automatic conversion to links could be shut off, so maybe there would be interest in a mod to do this. A full-fledged system could turn auto-linking back on for members in a group with more than a minimum number of posts.

Rohan_

the content under the code blocks are hidden from the guests .. what about that ?
Proud To Be An Indian

Arantor

MrPhil: Turning it off is an option in the BBCode menu.

Rohan_: Hiding code blocks from guests is something I'm sure has been covered; there's definitely a mod to hide links from guests too, and combining this should be straightforward.

The actual change that's being requested is to have it generate:
[code]link
link
link[/code]

instead of
[code]link[/code]
[code]link[/code]
[code]link[/code]


Wrapping it in a DIV would work but wouldn't solve the core problem, which ultimately is a regex replace on [/code]<br />[code], which is why I asked several posts back if the first half of what I had already asked about had been implemented by Rohan_ because the changes already covered are the first half of doing this.

Advertisement: