PunBB Resource

Your ultimate PunBB resource!

Keywords:

    (Extended)

You are not logged in.

#1 2007-09-10 04:24:58

Heckza
Member
Registered: 2007-09-10
Posts: 11

REAL Hide Tag Mod

Finally ... The Real Hide Tag Mod

First I want to say that I HAVE NOT Create this Code! I Found it on Punbb.fr and the Author have modified the "tag hide mods" using [hide=X]text[/hide]

So thx to BOTH of Them and specially Lyconide for this version that Everyone wants!!

This version is THE version you all want!!

Users Need to Reply to The Topic to be able to see the hidden text. It doesn't used the users Post count in their stats or hide text to only guest ... IT DOES WANT IT SUPPOSED TO DO!!!

So here's the Code! I have translate French to English for you all!

Code:

#
#---------[ 2. OPEN ]-----------------------------------------------------
#
    include/parser.php
#
#---------[ 3. FIND ]-----------------------------------------------------
#

//
// Convert BBCodes to their HTML equivalent
//
function do_bbcode($text)
{
    global $lang_common, $pun_user;
    
#
#---------[ 4. AFTER, ADD ]------------------------------------------------
#

// MOD HIDE TAG begin
require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
// MOD HIDE TAG end

#
#---------[ 5. FIND ]-----------------------------------------------------
#

    $pattern = array('#\[b\](.*?)\[/b\]#s',
    
#
#---------[ 6. BEFORE, ADD ]-----------------------------------------------
#

// MOD HIDE TAG begin
    if (strpos($text, 'hide') !== false && strpos($text, '/hide') !== false)
    {
        if ($pun_user['is_guest'])
        {
                $text = preg_replace("#\[hide\](.+?)\[/hide\]#is", '<b>['.$lang_topic['Hidden text guest'].']</b>', $text);
        }
        else if(($pun_user['g_id'] == PUN_MOD) || ($pun_user['g_id'] == PUN_ADMIN) || ($pun_user['num_post_in_topic'] > 0))
        {
            $text = str_replace('[hide]', '<blockquote>'.$lang_topic['Hidden text'].':<br><i>', $text);
            $text = preg_replace('#\[\/hide\]\s*#', '</i></blockquote>', $text);

        }
        else 
        {
                $text = preg_replace("#\[hide\](.+?)\[/hide\]#is", '<b>['.$lang_topic['Hidden text num_post'].']</b>', $text);
        }
    }    
// MOD HIDE TAG end

#
#---------[ 7. OPEN ]-----------------------------------------------------
#
    post.php
#
#---------[ 8. FIND ]-----------------------------------------------------
#

        $q_message = str_replace('[img]', '[url]', $q_message);
        $q_message = str_replace('[/img]', '[/url]', $q_message);

#
#---------[ 9. ADD, AFTER ]------------------------------------------------
#

// MOD HIDE TAG begin
        $q_message = preg_replace("#\[hide](.+?)\[/hide\]#is", '[b][[i]'.$lang_topic['Hidden text'].'.[/i]][/b]', $q_message);
// MOD HIDE TAG end

#
#---------[ 10. OPEN ]----------------------------------------------------
#
    viewtopic.php

#
#---------[ 11. FIND ]----------------------------------------------------
#
 LIMIT '.$start_from.','.$pun_user['disp_posts'], true

#
#---------[ 12. REPLACE WITH ]-----------------------------------------------
#
 LIMIT '.$start_from.','.$pun_user['disp_posts']

#
#---------[ 13. FIND ]----------------------------------------------------
#
$cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);

#
#---------[ 14. BEFORE, ADD ]-----------------------------------------------
#
// MOD HIDE TAG begin
$result_num_post = $db->query('SELECT count(message) as num_message FROM  '.$db->prefix.'posts WHERE poster_id='.$pun_user['id'].' AND topic_id='.$id, true) or error('Cannot found the amount of message of the user', __FILE__, __LINE__, $db->error());
$num_post_user_in_topic = $db->fetch_assoc($result_num_post);
$pun_user['num_post_in_topic'] = $num_post_user_in_topic['num_message'];
// MOD HIDE TAG end

#
#---------[ 15. OPEN ]----------------------------------------------------
#
    lang/LANGUAGE/topic.php
#
#---------[ 16. FIND ]----------------------------------------------------
#

'Quick post'        =>    'Quick post',

#
#---------[ 17. AFTER, ADD ]-----------------------------------------------
#

// MOD HIDE TAG begin
'Hidden text guest'            =>    'You must login to view hidden text\link.',
'Hidden text'                =>    'Hidden Text\Link',
'Hidden text num_post'           =>  'You need to reply to this post to see the hidden text\link.',

#
#---------[ 18.  OPEN ]---------------------------------------------------
#
    search.php

#
#---------[ 19. FIND ]----------------------------------------------------
#
                $message = str_replace("\n", '<br />', pun_htmlspecialchars($search_set[$i]['message']));

#
#---------[ 20. BEFORE, ADD ]-----------------------------------------------
#
                // MOD HIDE TAG begin
                require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
                $search_set[$i]['message'] = preg_replace('#\[hide\](.*?)\[/hide\]#s',$lang_topic['Hidden text'],$search_set[$i]['message']);
                $search_set[$i]['message'] = preg_replace('#\[hide\](.*?)$#s',$lang_topic['Hidden text'],$search_set[$i]['message']);
                // MOD HIDE TAG end
#
#---------[ 21. SAVE/UPLOAD ]---------------------------------------------------
#

I just installed it and it looks to work perfectly!!

ENJOY!!!

Last edited by Heckza (2007-09-10 04:46:02)

Offline

 

#2 2007-09-27 02:32:58

madeira
New member
Registered: 2007-09-27
Posts: 4

Re: REAL Hide Tag Mod

I made a couple changes to the mod so that it can hide text from all users but one:
[hide=madeira]I'm the only one that can read this[/hide]

Code:

#
#---------[ 2. OPEN ]-----------------------------------------------------
#
    include/parser.php
#
#---------[ 3. FIND ]-----------------------------------------------------
#

//
// Convert BBCodes to their HTML equivalent
//
function do_bbcode($text)
{
    global $lang_common, $pun_user;
    
#
#---------[ 4. AFTER, ADD ]------------------------------------------------
#

// MOD HIDE TAG begin
require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
// MOD HIDE TAG end

#
#---------[ 5. FIND ]-----------------------------------------------------
#

    $pattern = array('#\[b\](.*?)\[/b\]#s',
    
#
#---------[ 6. BEFORE, ADD ]-----------------------------------------------
#

// MOD HIDE TAG begin
    if (strpos($text, 'hide') !== false && strpos($text, '/hide') !== false)
    {
        if ($pun_user['is_guest'])
        {
                $text = preg_replace("#\[hide\](.+?)\[/hide\]#is", '<b>['.$lang_topic['Hidden text guest'].']</b>', $text);
                $text = preg_replace("#\[hide\=\"(.+?)\"\](.+?)\[/hide\]#is", '<b>['.$lang_topic['Hidden text guest'].']</b>', $text);
        }
        else if(($pun_user['g_id'] == PUN_MOD) || ($pun_user['g_id'] == PUN_ADMIN))
        {
            $text = preg_replace("#\[hide\=(.+?)\](.+?)\[/hide\]#is", '[hide]$2[/hide]', $text);
            $text = str_replace('[hide]', '<blockquote>'.$lang_topic['Hidden text'].':<br><i>', $text);
            $text = preg_replace('#\[\/hide\]\s*#', '</i></blockquote>', $text);

        }
        else 
        {

            $occurances = preg_match_all("#\[hide\=.+?\](.+?)\[/hide\]#is", $text, $temp); 
            for($i=0;$i<=$occurances;$i++) 
            { 
                preg_match("#\[hide\=(.+?)\].+?\[/hide\]#i", $text,$user_post);
                
                    $text = preg_replace("#\[hide\=(.+?)\](.+?)\[/hide\]#i", '[hide]$2[/hide]', $text,1);
                if (strcmp($user_post[1],$pun_user['username']) == 0 ){
                    $text = str_replace('[hide]', '<blockquote>'.$lang_topic['Hidden text'].':<br><i>', $text);
                    $text = preg_replace('#\[\/hide\]\s*#', '</i></blockquote>', $text,1);        
                }else{
                    $text = preg_replace("#\[hide\](.+?)\[/hide\]#i", '<b>['.$lang_topic['Hidden text'].']</b>', $text,1);
                    
                }
            }
            

        }
    }    
// MOD HIDE TAG end

#
#---------[ 7. OPEN ]-----------------------------------------------------
#
    post.php
#
#---------[ 8. FIND ]-----------------------------------------------------
#

        $q_message = str_replace('[img]', '[url]', $q_message);
        $q_message = str_replace('[/img]', '[/url]', $q_message);

#
#---------[ 9. ADD, AFTER ]------------------------------------------------
#

// MOD HIDE TAG begin
        $q_message = preg_replace("#\[hide](.+?)\[/hide\]#is", '[b][[i]'.$lang_topic['Hidden text'].'.[/i]][/b]', $q_message);
        $q_message = preg_replace("#\[hide\=.+?].+?\[/hide\]#is", '[b][[i]'.$lang_topic['Hidden text'].'.[/i]][/b]', $q_message);

// MOD HIDE TAG end

#
#---------[ 10. OPEN ]----------------------------------------------------
#
    viewtopic.php

#
#---------[ 11. FIND ]----------------------------------------------------
#
 LIMIT '.$start_from.','.$pun_user['disp_posts'], true

#
#---------[ 12. REPLACE WITH ]-----------------------------------------------
#
 LIMIT '.$start_from.','.$pun_user['disp_posts']

#
#---------[ 13. FIND ]----------------------------------------------------
#
$cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);

#
#---------[ 14. BEFORE, ADD ]-----------------------------------------------
#
// MOD HIDE TAG begin
$result_num_post = $db->query('SELECT count(message) as num_message FROM  '.$db->prefix.'posts WHERE poster_id='.$pun_user['id'].' AND topic_id='.$id, true) or error('Cannot found the amount of message of the user', __FILE__, __LINE__, $db->error());
$num_post_user_in_topic = $db->fetch_assoc($result_num_post);
$pun_user['num_post_in_topic'] = $num_post_user_in_topic['num_message'];
// MOD HIDE TAG end

#
#---------[ 15. OPEN ]----------------------------------------------------
#
    lang/LANGUAGE/topic.php
#
#---------[ 16. FIND ]----------------------------------------------------
#

'Quick post'        =>    'Quick post',

#
#---------[ 17. AFTER, ADD ]-----------------------------------------------
#

// MOD HIDE TAG begin
'Hidden text guest'            =>    'You must login to view hidden text\link.',
'Hidden text'                =>    'Hidden Text\Link',
'Hidden text num_post'           =>  'You need to reply to this post to see the hidden text\link.',

#
#---------[ 18.  OPEN ]---------------------------------------------------
#
    search.php

#
#---------[ 19. FIND ]----------------------------------------------------
#
                $message = str_replace("\n", '<br />', pun_htmlspecialchars($search_set[$i]['message']));

#
#---------[ 20. BEFORE, ADD ]-----------------------------------------------
#
                // MOD HIDE TAG begin
                require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
                $search_set[$i]['message'] = preg_replace('#\[hide\](.*?)\[/hide\]#s',$lang_topic['Hidden text'],$search_set[$i]['message']);
                $search_set[$i]['message'] = preg_replace('#\[hide\](.*?)$#s',$lang_topic['Hidden text'],$search_set[$i]['message']);
                // MOD HIDE TAG end
#
#---------[ 21. SAVE/UPLOAD ]---------------------------------------------------
#

Offline

 

#3 2007-09-27 06:54:24

Kiso
New member
Registered: 2007-09-21
Posts: 9

Re: REAL Hide Tag Mod

That's great, thanks you.

Offline

 

#4 2007-09-27 07:27:56

Dr.Jeckyl
Member
Registered: 2005-06-17
Posts: 230

Re: REAL Hide Tag Mod

madeira wrote:

I made a couple changes to the mod so that it can hide text from all users but one:
[hide=madeira]I'm the only one that can read this[/hide]

ingenious! does it work with more than one user? i suppose you could do more than one tag, just curious.

Last edited by Dr.Jeckyl (2007-09-27 07:28:21)

Offline

 

#5 2007-09-27 10:44:43

madeira
New member
Registered: 2007-09-27
Posts: 4

Re: REAL Hide Tag Mod

here's a bug correction

on search.php
find

Code:

$search_set[$i]['message'] = preg_replace('#\[hide\](.*?)\[/hide\]#s',$lang_topic['Hidden text'],$search_set[$i]['message']);

and before add

Code:

$search_set[$i]['message'] = preg_replace("#\[hide\=(.+?)\](.+?)\[/hide\]#is", '[hide]$2[/hide]',$search_set[$i]['message']);

Offline

 

#6 2007-09-27 10:46:39

madeira
New member
Registered: 2007-09-27
Posts: 4

Re: REAL Hide Tag Mod

Dr.Jeckyl wrote:

ingenious! does it work with more than one user? i suppose you could do more than one tag, just curious.

It could. I just spent 30 minutes hacking the code tongue
I'll try that later.

Offline

 

#7 2007-09-27 22:24:09

madeira
New member
Registered: 2007-09-27
Posts: 4

Re: REAL Hide Tag Mod

major bug tongue
just solved it

find

Code:

         }else{
              $text = preg_replace("#\[hide\](.+?)\[/hide\]#i", '<b>['.$lang_topic['Hidden text'].']</b>', $text,1);
         }
     }

replace with:

Code:

        }
     } 
     $text = preg_replace("#\[hide\](.+?)\[/hide\]#i", '<b>['.$lang_topic['Hidden text'].']</b>', $text,1);

Offline

 

#8 2008-05-30 10:31:24

BastienBuy
New member
Registered: 2008-05-30
Posts: 1

Re: REAL Hide Tag Mod

Hello,

I have a problem with your code because installation ok but when i try hide i can see  [Hiden Text/LinK] no "You need to reply to this post to see the hidden text\link."

sorry i'm french and i speak little in english smile

Offline

 

#9 2008-08-24 20:13:20

Jesse
Member
Registered: 2007-06-06
Posts: 14

Re: REAL Hide Tag Mod

Awesome, will give this a try.

Offline

 

Board footer

Based on PunBB
© Copyright 2002–2005 Rickard Andersson

© Copyright 2004–2006 Kristoffer Jansson

User contributed files are property of their respective owners.