隐藏链接在论坛


Hide Links In Forums

我试图隐藏链接从没有注册的成员,BBcode工作,它隐藏,但HTML代码不工作。

例如,

[link=http://www.brandbucket.com/]Brand Bucket[/link]

这个藏得好。

另一方面……

<a href="http://www.char5.com/" target="_blank">http://www.char5.com</a>

这根本不隐藏,超链接工作得很好。

下面的代码如有任何帮助,请,谢谢。

    $text = preg_replace("/'[file'=(.*?)'](.*?)'['/file']/is", $rep, $text);
$text = preg_replace("/'[link'=(.*?)'](.*?)'['/link']/is", $rep, $text);
$text = preg_replace("/'[url'=(.*?)'](.*?)'['/url']/is", $rep, $text);
$text = preg_replace("#(^|['n ])(['w]+?://[^ '"'n'r't<,]*)#is", "''1".$rep, $text);
$text = preg_replace("#(^|['n ']])((www|ftp)'.['w+-]+?'.['w+'-.]*(?(?=/)(/.+?(?='s|,'s))|(?='W)))#is", "''1".$rep, $text);

我的建议是在满足条件的情况下使用if else语句和echo将元素放到页面上。

例如在我的网站上,我有一个注销按钮。它只显示用户是否登录。

<?php
    if(/*user is logged in*/) {
        echo 'This is where the element code is placed';
    }
    else {
        //user is not logged in so don't echo the element
    }
?>

这个php块将被放置在你想要显示的元素通常所在的容器元素中。注意,如果语句的else部分为空,则可以将其省略。

这也可以用于特定的id或类,你想应用到一个元素(如改变一个div的背景颜色)插入块的id或类定义。

<div id="testdiv" <?php if(/*condition*/) {echo 'class="addedclass"';} ?> ><div>