2
   

[ SOLVED ] external links viewable only if logged in

 
 
Reply Thu 28 Oct, 2004 06:23 pm
Hi all im italian so sorry for my english or if i wasnt able to find this argoment if exist.
I would like to make all external links in posts viewable only to registered users.
Better if guests sees in the place of the url a red message like "EXTERNAL LINKS APPEARS ONLY IF U REGISTER".
Are u able to make this script?
Thaks 4 your patience.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 2 • Views: 1,481 • Replies: 6
No top replies

 
Craven de Kere
 
  1  
Reply Fri 29 Oct, 2004 12:00 am
I have already made this script in the past, but never finished ironing out a couple of quirks.

When I get the chance, I'll dig through my code libraries and find my work and post it unfinished (no time and interest in completing it).
0 Replies
 
Craven de Kere
 
  1  
Reply Fri 29 Oct, 2004 12:27 am
I searched, and can't find my code. I don't think I saved it.

But if it's any help to you most of my code changes for that feature were in bbcode.php
0 Replies
 
DAIKAMURA
 
  1  
Reply Fri 29 Oct, 2004 03:20 am
Craven de Kere wrote:
I searched, and can't find my code. I don't think I saved it.

Its a pity cause i think it could be very very usefull: so google does not sees external links ( and our PR does not goes down ) and in the same time all logged in users can see external urls that in some cases ( in my forum for exemple ) its very important that exists.
I hope that sone someone could develop this feature soon!
Thanks again
0 Replies
 
DAIKAMURA
 
  1  
Reply Fri 29 Oct, 2004 08:07 am
Craven need your help! Crying or Very sad
I tried this in bbcode but does not work!
In this way it does NEVER show the link even if a user is logged in-


Code:
if ( $userdata['session_logged_in'] )
{
function make_clickable($text)
{

// pad it with a space so we can match things at the start of the 1st line.
$ret = " " . $text;

// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, or comma.
$ret = preg_replace("#([\n ])([a-z]+?)://([a-z0-9\-\.,\?!%\*_\#:;~\\&[email protected]\/=\+]+)#i", "\\1<a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>", $ret);

// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// yyyy contains either alphanum, "-", or "."
// zzzz is optional.. will contain everything up to the first space, newline, or comma.
// This is slightly restrictive - it's not going to match stuff like "forums.foo.com"
// This is to keep it from getting annoying and matching stuff that's not meant to be a link.
$ret = preg_replace("#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[a-z0-9\-\.,\?!%\*_\#:;~\\&[email protected]\/=\+]*)?)#i", "\\1<a href=\"http://www.\\2.\\3\\4\" target=\"_blank\">www.\\2.\\3\\4</a>", $ret);

// matches an [email protected] type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
$ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", "\\1<a href=\"mailto:\\[email protected]\\3\">\\[email protected]\\3</a>", $ret);

// Remove our padding..
$ret = substr($ret, 1);

return($ret);
}
}

else
{
function make_clickable($text)
{
// pad it with a space so we can match things at the start of the 1st line.
$ret = " " . $text;

// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, or comma.
$ret = preg_replace("#([\n ])([a-z]+?)://([a-z0-9\-\.,\?!%\*_\#:;~\\&[email protected]\/=\+]+)#i", "\\1<font color=\"#FFFF00\"\>LINK VISIBILE SOLO SE LOGGATI</font>", $ret);

// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// yyyy contains either alphanum, "-", or "."
// zzzz is optional.. will contain everything up to the first space, newline, or comma.
// This is slightly restrictive - it's not going to match stuff like "forums.foo.com"
// This is to keep it from getting annoying and matching stuff that's not meant to be a link.
$ret = preg_replace("#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[a-z0-9\-\.,\?!%\*_\#:;~\\&[email protected]\/=\+]*)?)#i", "\\1<font color=\"#FFFF00\"\>LINK VISIBILE SOLO SE LOGGATI</font>", $ret);

// matches an [email protected] type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
$ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", "\\1<font color=\"#FFFF00\"\>LINK VISIBILE SOLO SE LOGGATI</font>", $ret);

// Remove our padding..
$ret = substr($ret, 1);

return($ret);
}

}
0 Replies
 
DAIKAMURA
 
  1  
Reply Sat 30 Oct, 2004 04:35 am
I really cant find the problem in this script..
Anyone can help me?

I mean that:

4 examples these links:
http://www.phpbb.it
www.phpbb.it
[email protected]

IF im logged in the forum i can see these links.

http://www.phpbb.it
www.phpbb.it
[email protected]



IF im a guest ( so not logged in )i CANT see them but i see in the place of them:

YOU HAVE TO LOG IN TO SEE THIS LINK
YOU HAVE TO LOG IN TO SEE THIS LINK
YOU HAVE TO LOG IN TO SEE THIS LINK
0 Replies
 
DAIKAMURA
 
  1  
Reply Fri 5 Nov, 2004 05:39 am
Finally SOLVED!
I made myself this mod so im very PROUD ( it's my FIRST ONE ).




Open includes bbcode.php

find:
Code:
function make_clickable($text)
{

// pad it with a space so we can match things at the start of the 1st line.
$ret = " " . $text;

// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, or comma.
$ret = preg_replace("#([\n ])([a-z]+?)://([a-z0-9\-\.,\?!%\*_\#:;~\\&[email protected]\/=\+]+)#i", "\\1<a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>", $ret);

// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// yyyy contains either alphanum, "-", or "."
// zzzz is optional.. will contain everything up to the first space, newline, or comma.
// This is slightly restrictive - it's not going to match stuff like "forums.foo.com"
// This is to keep it from getting annoying and matching stuff that's not meant to be a link.
$ret = preg_replace("#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[a-z0-9\-\.,\?!%\*_\#:;~\\&[email protected]\/=\+]*)?)#i", "\\1<a href=\"http://www.\\2.\\3\\4\" target=\"_blank\">www.\\2.\\3\\4</a>", $ret);

// matches an [email protected] type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
$ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", "\\1<a href=\"mailto:\\[email protected]\\3\">\\[email protected]\\3</a>", $ret);

// Remove our padding..
$ret = substr($ret, 1);

return($ret);

}


After add:

Code:

function make_clickable1($text)
{
// pad it with a space so we can match things at the start of the 1st line.
$ret = " " . $text;

// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, or comma.
$tret = preg_replace("#([\n ])([a-z]+?)://([a-z0-9\-\.,\?!%\*_\#:;~\\&[email protected]\/=\+]+)#i", "\\1<font color=\"#FFFF00\"\><i>LINK VISIBILE SOLO AGLI UTENTI REGISTRATI</i></font>", $ret);

// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// yyyy contains either alphanum, "-", or "."
// zzzz is optional.. will contain everything up to the first space, newline, or comma.
// This is slightly restrictive - it's not going to match stuff like "forums.foo.com"
// This is to keep it from getting annoying and matching stuff that's not meant to be a link.
$ret = preg_replace("#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[a-z0-9\-\.,\?!%\*_\#:;~\\&[email protected]\/=\+]*)?)#i", "\\1<font color=\"#FFFF00\"\><i>LINK VISIBILE SOLO AGLI UTENTI REGISTRATI</i></font>", $ret);

// matches an [email protected] type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
$ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", "\\1<font color=\"#FFFF00\"\><i>LINK VISIBILE SOLO AGLI UTENTI REGISTRATI</i></font>", $ret);

// Remove our padding..
$ret = substr($ret, 1);

return($ret);
}



Open viewtopic.php

find:

Code:
{$message = make_clickable($message);}


replace with:

Code:


if ( $userdata['session_logged_in'] )
{$message = make_clickable($message);}
else
{$message = make_clickable1($message);}



Save and upload


If u want to remove also the BBcode urls:

Open templates/subSilver/bbcode.tpl

find:
Code:
<!-- BEGIN url --><a href="{URL}" target="_blank" class="postlink">{DESCRIPTION}</a><!-- END url -->


replace with:

Code:
<!-- BEGIN url -->{DESCRIPTION} {URL}<!-- END url -->


Save and upload
0 Replies
 
 

Related Topics

In How much time a website can be developed? - Question by aussiejumpingcastle
Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » [ SOLVED ] external links viewable only if logged in
Copyright © 2021 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 07/28/2021 at 07:00:49