hello
i need this modification (well at least where to do it) I'll explain below:
when we post something like this [*url=http://www.siemens-mobiles.org/forum/index.php][*img]http://membres.lycos.fr/redouane171/Resize%20of%20wael.jpg[/*img][*/url]
it give the following image which is assigned to an URL like this
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fmembres.lycos.fr%2Fredouane171%2FResize%2520of%2520wael.jpg&hash=6e209e5ec0e9dab17b9b201c9310d0d396b02100) (http://www.siemens-mobiles.org/forum/index.php)
i need to disallow guest from viewing URLs but they still can view the images which i mean the above code will be visible to guests like this (an image without a link)
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fmembres.lycos.fr%2Fredouane171%2FResize%2520of%2520wael.jpg&hash=6e209e5ec0e9dab17b9b201c9310d0d396b02100)
, in other world the guests view the message just like if we typed ONLY [*img]http://membres.lycos.fr/redouane171/Resize%20of%20wael.jpg[*img] so how to do it???
thanks
Find, Sources/Subs.php:
// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
'~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie' => isset($disabled['url']) ? 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'' : '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'@\'))) . \'</a>\'',
'~\[url=(.+?)\](.+?)\[/url\]~ie' => isset($disabled['url']) ? '\'$2 ($1)\'' : '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'@\')) . \'</a>\'',
'~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i' => isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>',
Replace:
// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
'~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie' => $context['user']['is_guest'] ? '\'$2\'' : (isset($disabled['url']) ? 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'' : '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'@\'))) . \'</a>\''),
'~\[url=(.+?)\](.+?)\[/url\]~ie' => $context['user']['is_guest'] ? '\'$2\'' : (isset($disabled['url']) ? '\'$2 ($1)\'' : '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'@\')) . \'</a>\''),
'~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i' => $context['user']['is_guest'] ? '' : (isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>'),
How do I modify files? (http://www.simplemachines.org/community/index.php?topic=24110.0)
-[Unknown]
thanks man i'll try it and i'll tell you :D
it works perfect just like i want
Respect to you [Unknown] :)
[unknown] i've removed this patch because i need to install Faster Parse Code mod so the new (original code) is // Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
if(isset($add['[url='])){
$arr1[] = '~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie';
$arr1[] = '~\[url=(.+?)\](.+?)\[/url\]~ie';
if(isset($disabled['url'])){
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'';
$arr2[] = '\'$2 ($1)\'';
}else{
$arr2[] = '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'@\'))) . \'</a>\'';
$arr2[] = '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'@\')) . \'</a>\'';
}
}
if(isset($add['[url]'])){
$arr1[] = '~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i';
$arr2[] = isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>';
}
so how to patch in this case??? thanks
if(isset($add['[url='])){
$arr1[] = '~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie';
$arr1[] = '~\[url=(.+?)\](.+?)\[/url\]~ie';
if(isset($disabled['url'])){
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'';
$arr2[] = '\'$2 ($1)\'';
}
if(isset($context['user']['is_guest'])){
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'';
$arr2[] = '\'$2 ($1)\'';
}
else{
$arr2[] = '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'@\'))) . \'</a>\'';
$arr2[] = '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'@\')) . \'</a>\'';
}
}
if(isset($add['[url]'])){
$arr1[] = '~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i';
$arr2[] = isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>';
}
this may work
thanks i'll try it
that one didn't work!!!
i get under the image the URL in text, in case if you ask i added $context to the global instruction of theis function,so there's something worg with [*url=http://..][*img]..[*/img][*/url]
and nothing happens with [*url]...[*/url]
any other suggestions???
no answer??? please guys come on....
Try:
// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
if(isset($add['[url='])){
$arr1[] = '~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie';
$arr1[] = '~\[url=(.+?)\](.+?)\[/url\]~ie';
if ($context['user']['is_guest'])
{
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\')';
$arr2[] = '$2';
}
elseif (isset($disabled['url'])){
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'';
$arr2[] = '\'$2 ($1)\'';
}else{
$arr2[] = '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'@\'))) . \'</a>\'';
$arr2[] = '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'@\')) . \'</a>\'';
}
}
if(isset($add['[url]'])){
$arr1[] = '~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i';
$arr2[] = $context['user']['is_guest'] ? '' : (isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>');
}
-[Unknown]
thank you i'll try it now
i get the following error
Parse error: parse error, unexpected '[' in /var/www/virtual/siemens-mobiles.org/htdocs/slash/Sources/Subs.php(1237) : regexp code on line 1
Fatal error: Failed evaluating code: [img]http://www.siemens-mobiles.org/patchgen/patchgen.jpg[/img] in /var/www/virtual/siemens-mobiles.org/htdocs/slash/Sources/Subs.php on line 1237
test forum url : http://www.siemens-mobiles.org/slash/index.php
i made a .mod file so i can install and test easly without having to do it manually, i'll include the file in case you want to test it/verify it
.mod contents
<id>
Disable URL from guests
</id>
<version>
1.0
</version>
<mod info>
This mod will disable URL from guests
</mod info>
<author>
Gandalf code givin by [Unknown]
</author>
<homepage>
http://www.siemens-mobiles.org/
</homepage>
<edit file>
Sources/Subs.php
</edit file>
<search>
// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
if(isset($add['[url='])){
$arr1[] = '~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie';
$arr1[] = '~\[url=(.+?)\](.+?)\[/url\]~ie';
if(isset($disabled['url'])){
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'';
$arr2[] = '\'$2 ($1)\'';
}else{
$arr2[] = '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'@\'))) . \'</a>\'';
$arr2[] = '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'@\')) . \'</a>\'';
}
}
if(isset($add['[url]'])){
$arr1[] = '~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i';
$arr2[] = isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>';
}
</search>
<replace>
// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
if(isset($add['[url='])){
$arr1[] = '~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie';
$arr1[] = '~\[url=(.+?)\](.+?)\[/url\]~ie';
if ($context['user']['is_guest'])
{
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\')';
$arr2[] = '$2';
}
elseif (isset($disabled['url'])){
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'';
$arr2[] = '\'$2 ($1)\'';
}else{
$arr2[] = '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'@\'))) . \'</a>\'';
$arr2[] = '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'@\')) . \'</a>\'';
}
}
if(isset($add['[url]'])){
$arr1[] = '~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i';
$arr2[] = $context['user']['is_guest'] ? '' : (isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>');
}
</replace>
I think you want this, then:
// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
if(isset($add['[url='])){
$arr1[] = '~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie';
$arr1[] = '~\[url=(.+?)\](.+?)\[/url\]~ie';
if ($context['user']['is_guest'])
{
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\')';
$arr2[] = '\'$2\'';
}
elseif (isset($disabled['url'])){
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'';
$arr2[] = '\'$2 ($1)\'';
}else{
$arr2[] = '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'@\'))) . \'</a>\'';
$arr2[] = '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'@\')) . \'</a>\'';
}
}
if(isset($add['[url]'])){
$arr1[] = '~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i';
$arr2[] = $context['user']['is_guest'] ? '' : (isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>');
}
-[Unknown]
exactly, in fact i repaired it two days ago the problem was
$arr2[] = '\'$2\'';
instead of
$arr2[] = '$2';
but there's something weird that i couldn't figure out myself, when viewing an url with spaces before and after it, it works, but if there's an url with letter before or after it, without spaces, it doesn't work and i couldn't figure out why
see those two topics to know what i mean
http://www.siemens-mobiles.org/forum/index.php/topic,1255.0.html where the weird thing is
http://www.siemens-mobiles.org/forum/index.php/topic,1657.0.html where it works
login with smf as username, programming as password if you need to see the topics as a user
the code that i used
// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
if(isset($add['[url='])){
$arr1[] = '~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie';
$arr1[] = '~\[url=(.+?)\](.+?)\[/url\]~ie';
if ($context['user']['is_guest'])
{
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\')';
$arr2[] = '\'$2\'';
}
elseif (isset($disabled['url'])){
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'';
$arr2[] = '\'$2 ($1)\'';
}else{
$arr2[] = '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'@\'))) . \'</a>\'';
$arr2[] = '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'@\')) . \'</a>\'';
}
}
if(isset($add['[url]'])){
$arr1[] = '~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i';
$arr2[] = $context['user']['is_guest'] ? '[URL REMOVED BECAUSE YOU ARE VISITING THE SITE AS A GUEST, PLEASE LOGIN TO SEE THE URLs]' : (isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>');
}
BTW thanks master [Unknown] so nice from you to help...
Try changing this:
$arr2[] = '\'$2\'';
To:
$arr2[] = '\'[URL REMOVED BECAUSE YOU ARE VISITING THE SITE AS A GUEST, PLEASE LOGIN TO SEE THE URLs]\'';
-[Unknown]
nope same thing http://www.siemens-mobiles.org/slash/index.php/topic,1255.0.html
Sorry, sorry, I see where I'm misunderstanding that code. Replace this one too with the same:
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\')';
-[Unknown]
again not working :'(
http://www.siemens-mobiles.org/slash/index.php/topic,1255.0.html
code that i used
// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
if(isset($add['[url='])){
$arr1[] = '~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie';
$arr1[] = '~\[url=(.+?)\](.+?)\[/url\]~ie';
if ($context['user']['is_guest'])
{
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\')';
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\')';
}
elseif (isset($disabled['url'])){
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'';
$arr2[] = '\'$2 ($1)\'';
}else{
$arr2[] = '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'@\'))) . \'</a>\'';
$arr2[] = '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'@\')) . \'</a>\'';
}
}
if(isset($add['[url]'])){
$arr1[] = '~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i';
$arr2[] = $context['user']['is_guest'] ? '[URL REMOVED BECAUSE YOU ARE VISITING THE SITE AS A GUEST, PLEASE LOGIN TO SEE THE URLs]' : (isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>');
}
in case you need the original code to compare
// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
if(isset($add['[url='])){
$arr1[] = '~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie';
$arr1[] = '~\[url=(.+?)\](.+?)\[/url\]~ie';
if(isset($disabled['url'])){
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'';
$arr2[] = '\'$2 ($1)\'';
}else{
$arr2[] = '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'@\'))) . \'</a>\'';
$arr2[] = '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'@\')) . \'</a>\'';
}
}
if(isset($add['[url]'])){
$arr1[] = '~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i';
$arr2[] = isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>';
}
No, no, you did it backwards. I meant to replace that with this:
$arr2[] = '\'[URL REMOVED BECAUSE YOU ARE VISITING THE SITE AS A GUEST, PLEASE LOGIN TO SEE THE URLs]\'';
Meaning, both lines should be that.
-[Unknown]
Zitat von: [Unknown] in März 19, 2005, 01:48:16 VORMITTAG
No, no, you did it backwards. I meant to replace that with this:
$arr2[] = '\'[URL REMOVED BECAUSE YOU ARE VISITING THE SITE AS A GUEST, PLEASE LOGIN TO SEE THE URLs]\'';
Meaning, both lines should be that.
-[Unknown]
nope that didn't work and now it's not a good idea
compare these two topics (from two version of the forum, same topic)
http://www.siemens-mobiles.org/slash/index.php/topic,1524.0.html
http://www.siemens-mobiles.org/forum/index.php/topic,1657.0.html
see? the images which supposed to have an url, when a guest visit it he must see the image without an url like the above topic, but replacing the code as you said it just replaced both and it don't work also http://www.siemens-mobiles.org/slash/index.php/topic,1255.0.html
but really thanks, i'm sorry to disturbe you again
code used now:
// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
if(isset($add['[url='])){
$arr1[] = '~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie';
$arr1[] = '~\[url=(.+?)\](.+?)\[/url\]~ie';
if ($context['user']['is_guest'])
{
$arr2[] = '\'[URL REMOVED BECAUSE YOU ARE VISITING THE SITE AS A GUEST, PLEASE LOGIN TO SEE THE URLs]\'';
$arr2[] = '\'[URL REMOVED BECAUSE YOU ARE VISITING THE SITE AS A GUEST, PLEASE LOGIN TO SEE THE URLs]\'';
}
elseif (isset($disabled['url'])){
$arr2[] = 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'';
$arr2[] = '\'$2 ($1)\'';
}else{
$arr2[] = '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'@\'))) . \'</a>\'';
$arr2[] = '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'@\')) . \'</a>\'';
}
}
if(isset($add['[url]'])){
$arr1[] = '~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i';
$arr2[] = $context['user']['is_guest'] ? '[URL REMOVED BECAUSE YOU ARE VISITING THE SITE AS A GUEST, PLEASE LOGIN TO SEE THE URLs]' : (isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>');
}
man i'm really sorry it's my mistake i just discovered the error now, and i appreciate also if you tell me how to bypass it
in fact that topic is posted with html not with bbcode like this :
<a href="http://www.siemens-mobiles.org/forum/index.php/topic,302.0.html">Available firmware</a>
i'm really sorry it's my mistake, i apologise again
can you give me please the code to bypass html code also if it's possible if not i just disable html and edit this unique post like this
thank you man again
And how to do the same in SMF 1.1 RC2?
Any idea for my last post?
Thanks.
Does this work for 1.1 RC2? Anyone?
it dosent work for RC2
can someone do a conversion?
this is a really cool feature to have!
Does it work just for picture links or for any kind of urls?
Zitat von: Farmacija in Juni 02, 2006, 05:03:55 VORMITTAG
Does it work just for picture links or for any kind of urls?
there is a mod available for this now which works with links and linked pictures
check the mod forum
sorry in a bit of a hurry or i would have provided u with a link
..any recent updates for this code?
http://custom.simplemachines.org/mods/index.php?mod=342