��ҹ��Ǣ�͡�͹˹�� :: ��ҹ��Ǣ�ͶѴ� |
����� |
��ͤ��� |
ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Thu Aug 23, 2007 12:34 am ����ͧ: mod ��͹��� |
|
|
Download
��ҧ�ԧ�ҡ: |
MOD "HIDE" (aka lockdown)
Description : this mod allow users to hide a message via some "bbcodes", ex : [hide] message [/hide].
To see a hidden message, you must be a member and you must post a reply to the message...
--------------------------------------------------------------------------------
Files to modify : (click on the filenames below...)
1 - posting.php
2 - viewtopic.php
3 - search.php
4 - topic_review.php // in the "/includes" directory
5 - bbcode.php // in the "/includes" directory
6 - bbcode.tpl // in the Templates/{Used template}/ directory
7 - posting_body.tpl // in the Templates/{Used template}/ directory
8 - If you use more than one language on your board... |
1 - In posting.php
Find
Code: |
if( $attach_sig && $user_sig != '' && $userdata['user_sig_bbcode_uid'] )
{
$user_sig = bbencode_second_pass($user_sig, $userdata['user_sig_bbcode_uid']);
}
if( $bbcode_on )
{
$preview_message = bbencode_second_pass($preview_message, $bbcode_uid);
} |
Replace by
Code: |
$valid = FALSE;
if( $userdata['session_logged_in'] ) {
$sql = "SELECT p.poster_id, p.topic_id
FROM " . POSTS_TABLE . " p
WHERE p.topic_id = $topic_id
AND p.poster_id = " . $userdata['user_id'];
$resultat = $db->sql_query($sql);
$valid = $db->sql_numrows($resultat) ? TRUE : FALSE;}
if( $attach_sig && $user_sig != '' && $userdata['user_sig_bbcode_uid'] )
{
$user_sig = bbencode_second_pass($user_sig, $userdata['user_sig_bbcode_uid']);
$user_sig = bbencode_third_pass($user_sig, $userdata['user_sig_bbcode_uid'], $valid);
}
if( $bbcode_on )
{
$preview_message = bbencode_second_pass($preview_message, $bbcode_uid);
$preview_message = bbencode_third_pass($preview_message, $bbcode_uid, $valid);
} |
Find
Code: |
if ( !preg_match('/^Re:/', $subject) && strlen($subject) > 0 )
{
$subject = 'Re: ' . $subject;
} |
Add Below
Code: |
if( !$userdata['session_logged_in'] ) {$message = hide_in_quote($message);}
else { $sql = "SELECT p.poster_id, p.topic_id
FROM " . POSTS_TABLE . " p
WHERE p.topic_id = $topic_id
AND p.poster_id = " . $userdata['user_id'];
$resultat = $db->sql_query($sql);
if(!$db->sql_numrows($resultat)) {$message = hide_in_quote($message);}
} |
|
|
���仢�ҧ�� |
|
 |
ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Thu Aug 23, 2007 12:36 am ����ͧ: |
|
|
2 - In viewtopic.php
Find
Code: |
//
// Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed
// then get it's value, find the number of topics with dates newer than it (to properly
// handle pagination) and alter the main query
// |
Add below
Code: |
$valid = FALSE;
if( $userdata['session_logged_in'] ) {
$sql = "SELECT p.poster_id, p.topic_id
FROM " . POSTS_TABLE . " p
WHERE p.topic_id = $topic_id
AND p.poster_id = " . $userdata['user_id'];
$resultat = $db->sql_query($sql);
$valid = $db->sql_numrows($resultat) ? TRUE : FALSE;} |
Find
Code: |
if ($user_sig != '' && $user_sig_bbcode_uid != '')
{
$user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig);
}
if ($bbcode_uid != '')
{
$message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $message);
}
Or if you use an older phpBB version :
if ( $user_sig != '' && $user_sig_bbcode_uid != '' )
{
$user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $user_sig);
}
if ( $bbcode_uid != '' )
{
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
} |
Add the lines in heavy type (bold text)
Code: |
if ( $user_sig != '' && $user_sig_bbcode_uid != '' )
{
$user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig);
$user_sig = bbencode_third_pass($user_sig, $user_sig_bbcode_uid, $valid);
}
if ( $bbcode_uid != '' )
{
$message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $message);
$message = bbencode_third_pass($message, $bbcode_uid, $valid);
} |
|
|
���仢�ҧ�� |
|
 |
ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Thu Aug 23, 2007 12:37 am ����ͧ: |
|
|
3 - In search.php
Find
Code: |
//
// If the board has HTML off but the post has HTML
// on then we process it, else leave it alone
//
if ( $return_chars != -1 ) |
And replace it by
Code: |
//
// If the board has HTML off but the post has HTML
// on then we process it, else leave it alone
//
if( $return_chars == -1 ) |
Find
Code: |
if ( $bbcode_uid != '' )
{
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
} |
Replace by
Code: |
if ( $bbcode_uid != '' )
{
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
$message = bbencode_third_pass($message, $bbcode_uid, FALSE);
} |
|
|
���仢�ҧ�� |
|
 |
ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Thu Aug 23, 2007 12:38 am ����ͧ: |
|
|
4 - In topic_review.php
Find
Code: |
//
// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...
//
if ( $row = $db->sql_fetchrow($result) )
{ |
Add below
Code: |
$valid = FALSE;
if( $userdata['session_logged_in'] ) {
$sql = "SELECT p.poster_id, p.topic_id
FROM " . POSTS_TABLE . " p
WHERE p.topic_id = $topic_id
AND p.poster_id = " . $userdata['user_id'];
$resultat = $db->sql_query($sql);
$valid = $db->sql_numrows($resultat) ? TRUE : FALSE;} |
Find
Code: |
if ( $bbcode_uid != "" )
{
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
} |
Replace by
Code: |
if ( $bbcode_uid != "" )
{
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
$message = bbencode_third_pass($message, $bbcode_uid, $valid);
} |
|
|
���仢�ҧ�� |
|
 |
ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Thu Aug 23, 2007 12:40 am ����ͧ: |
|
|
5 - In bbcode.php
Find
Code: |
$bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']); |
Add Below
Code: |
$bbcode_tpl['show'] = str_replace('{HTEXTE}', '\\1', $bbcode_tpl['show']); |
*Before* this text
Code: |
/**
* Does second-pass bbencoding. This should be used before displaying the message in
* a thread. Assumes the message is already first-pass encoded, and we are given the
* correct UID as used in first-pass encoding.
*/ |
Add this functions
Code: |
function hide_in_quote($text)
{
$text = preg_replace("#\[hide\](.*?)\[\/hide\]#si","--- phpBB : The Protected Message is not copied in this quote ---", $text);
return $text;
}
function bbencode_third_pass($text, $uid, $deprotect)
{
global $bbcode_tpl;
// pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
// This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
$text = " " . $text;
// First: If there isn't a "[" and a "]" in the message, don't bother.
if (! (strpos($text, "[") && strpos($text, "]")) )
{
// Remove padding, return.
$text = substr($text, 1);
return $text;
}
// Patterns and replacements for URL and email tags..
$patterns = array();
$replacements = array();
if ( $deprotect ) {
$patterns[0] = "#\[hide:$uid\](.*?)\[/hide:$uid\]#si";
$replacements[0] = $bbcode_tpl['show'];
}
else
{
$patterns[0] = "#\[hide:$uid\](.*?)\[/hide:$uid\]#si";
$replacements[0] = $bbcode_tpl['hide'];
}
$text = preg_replace($patterns, $replacements, $text);
// Remove our padding from the string..
$text = substr($text, 1);
return $text;
} |
Find in function "bbencode_first_pass"
Code: |
// [img]image_url_here[/img] code..
$text = preg_replace("#\[img\](([a-z]+?)://([^ \"\n\r]+?))\[/img\]#si", "[img:$uid]\\1[/img:$uid]", $text); |
Add Below
Code: |
//[hide]message[/hide]
$text = preg_replace("#\[hide\](.*?)\[\/hide\]#si","[hide:$uid]\\1[/hide:$uid]", $text); |
|
|
���仢�ҧ�� |
|
 |
ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Thu Aug 23, 2007 12:42 am ����ͧ: |
|
|
6 - In bbcode.tpl
At the top, add
Code: |
<!-- BEGIN show -->
</span>
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
<td><span class="genmed"><b>Protected Message:</b></span></td>
</tr>
<tr>
<td class="quote">
{HTEXTE}
</td>
</tr>
</table>
<span class="postbody">
<!-- END show -->
<!-- BEGIN hide -->
</span>
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
<td><span class="genmed"><b>Protected Message:</b></span></td>
</tr>
<tr>
<td class="quote">
<center>--- If you are a *registered user* : you need to post in this topic to see the message ---</center>
</td>
</tr>
</table>
<span class="postbody">
<!-- END hide --> |
|
|
���仢�ҧ�� |
|
 |
ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Thu Aug 23, 2007 12:48 am ����ͧ: |
|
|
7 - In posting_body.tpl
��ҧ�ԧ�ҡ: |
- This part add a button in the dialog box (newtopic,...).
In the list of "// Helpline messages", add : |
��ҧ�ԧ�ҡ: |
h_help = "Hide: [hide]message[/hide] (alt+h)"; |
Code: |
Find this line :
bbtags = new Array('[b]','[/b]'...
And add at the end :
'[hide]' and '[/hide]'
You will obtain something like this : |
��ҧ�ԧ�ҡ: |
bbtags = new Array('','','','','','','
','
','','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[hide]','[/hide]'); |
Find
Code: |
<td><span class="genmed">
<input type="button" class="button" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onClick="bbstyle(16)" onMouseOver="helpline('w')" />
</span></td> |
Add Below : (Don't forget to adapt the "addbbcode" numbers if neccesary ! (exemple: addbbcode18 -> addbbcode20, 20 -> 22, etc)
Code: |
<td><span class="genmed">
<input type="button" class="button" accesskey="h" name="addbbcode18" value="Hide" style="width: 40px" onClick="bbstyle(18)" onMouseOver="helpline('h')" />
</span></td> |
��ҧ�ԧ�ҡ: |
Next, you need to modify all the "addbbcodexx" in the rest of the file.
If the preceding input tag is named "addbbcode18" (you will see 'name="addbbcode18"' within the tag) then you will need to change the name attribute value of the input tag you are adding to "addbbcode20". If the preceding tag is "addbbcode20" then you must change your new tag's attribute value to "addbbcode22", if the preceding tag's name attribute value is "addbbcode22", you use "addbbcode24" in the new tag and so on so forth, till death do you part. (addbbcode20 -> addbbcode22, etc)
That's all, Folks !
Philippe |
��ҧ�ԧ�ҡ: |
IF YOU HAVE A PROBLEM ("undefined" instead of [hide]...) - For the 2 last modifications to do, this is an example : |
Code: |
<td><span class="genmed">
<input type="button" class="button" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onClick="bbstyle(0)" onMouseOver="helpline('b')" />
</span></td>
<td><span class="genmed">
<input type="button" class="button" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px" onClick="bbstyle(2)" onMouseOver="helpline('i')" />
</span></td>
<td><span class="genmed">
<input type="button" class="button" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px" onClick="bbstyle(4)" onMouseOver="helpline('u')" />
</span></td>
<td><span class="genmed">
<input type="button" class="button" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px" onClick="bbstyle(6)" onMouseOver="helpline('q')" />
</span></td>
<td><span class="genmed">
<input type="button" class="button" accesskey="c" name="addbbcode8" value="Code" style="width: 40px" onClick="bbstyle(8)" onMouseOver="helpline('c')" />
</span></td>
<td><span class="genmed">
<input type="button" class="button" accesskey="l" name="addbbcode10" value="List" style="width: 40px" onClick="bbstyle(10)" onMouseOver="helpline('l')" />
</span></td>
<td><span class="genmed">
<input type="button" class="button" accesskey="o" name="addbbcode12" value="List=" style="width: 40px" onClick="bbstyle(12)" onMouseOver="helpline('o')" />
</span></td>
<td><span class="genmed">
<input type="button" class="button" accesskey="p" name="addbbcode14" value="Img" style="width: 40px" onClick="bbstyle(14)" onMouseOver="helpline('p')" />
</span></td>
<td><span class="genmed">
<input type="button" class="button" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onClick="bbstyle(16)" onMouseOver="helpline('w')" />
</span></td>
<td><span class="genmed">
<input type="button" class="button" accesskey="h" name="addbbcode18" value="Hide" style="width: 40px" onClick="bbstyle(18)" onMouseOver="helpline('h')" />
</span></td> </tr>
<tr>
<td colspan="9">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span class="genmed"> {L_FONT_COLOR}:
<select name="addbbcode20" onChange="bbfontstyle('[color=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/color]')" onMouseOver="helpline('s')">
<option style="color:black; background-color: #FFFFFF " value="{T_FONTCOLOR1}" class="genmed">{L_COLOR_DEFAULT}</option>
<option style="color:darkred; background-color: #DEE3E7" value="darkred" class="genmed">{L_COLOR_DARK_RED}</option>
<option style="color:red; background-color: #DEE3E7" value="red" class="genmed">{L_COLOR_RED}</option>
<option style="color:orange; background-color: #DEE3E7" value="orange" class="genmed">{L_COLOR_ORANGE}</option>
<option style="color:brown; background-color: #DEE3E7" value="brown" class="genmed">{L_COLOR_BROWN}</option>
<option style="color:yellow; background-color: #DEE3E7" value="yellow" class="genmed">{L_COLOR_YELLOW}</option>
<option style="color:green; background-color: #DEE3E7" value="green" class="genmed">{L_COLOR_GREEN}</option>
<option style="color:olive; background-color: #DEE3E7" value="olive" class="genmed">{L_COLOR_OLIVE}</option>
<option style="color:cyan; background-color: #DEE3E7" value="cyan" class="genmed">{L_COLOR_CYAN}</option>
<option style="color:blue; background-color: #DEE3E7" value="blue" class="genmed">{L_COLOR_BLUE}</option>
<option style="color:darkblue; background-color: #DEE3E7" value="darkblue" class="genmed">{L_COLOR_DARK_BLUE}</option>
<option style="color:indigo; background-color: #DEE3E7" value="indigo" class="genmed">{L_COLOR_INDIGO}</option>
<option style="color:violet; background-color: #DEE3E7" value="violet" class="genmed">{L_COLOR_VIOLET}</option>
<option style="color:white; background-color: #DEE3E7" value="white" class="genmed">{L_COLOR_WHITE}</option>
<option style="color:black; background-color: #DEE3E7" value="black" class="genmed">{L_COLOR_BLACK}</option>
</select> {L_FONT_SIZE}:<select name="addbbcode22" onChange="bbfontstyle('[size=' + this.form.addbbcode22.options[this.form.addbbcode22.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('f')">
<option value="7" class="genmed">{L_FONT_TINY}</option>
<option value="9" class="genmed">{L_FONT_SMALL}</option>
<option value="12" selected class="genmed">{L_FONT_NORMAL}</option>
<option value="18" class="genmed">{L_FONT_LARGE}</option>
<option value="24" class="genmed">{L_FONT_HUGE}</option>
</select>
</span></td> |
Code: |
If you consider that all of your modifications are Ok, try to put back the tags (to the left) in "bbtags = new Array..."
exemple :
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[hide]','[/hide]');
Avec 1 décalage devient :
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[hide]','[/hide]','[url]','[/url]');
Avec 2 décalages :
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[hide]','[/hide]','[img]','[/img]','[url]','[/url]');
Etc... |
|
|
���仢�ҧ�� |
|
 |
ryuozero Site Admin
�������: 13 Jul 2005 �ͺ: 1145
|
�ͺ�����: Thu Aug 23, 2007 12:49 am ����ͧ: |
|
|
If you use more than one language on your board, you can do these modifications :
8a - In "lang_main.php" files (language\lang_xxxxx\lang_main.php)
At the end of the file (ie: English => language\lang_english\lang_main.php), find
//
// That's all, Folks!
// -------------------------------------------------
Add Below
// Mod "Hide"
$lang['modhide_title'] = 'Protected Message :';
$lang['modhide_info'] = '--- If you are a *registered user* : you need to post in this topic to see the message ---';
$lang['modhide_quote'] = '--- phpBB : The Protected Message is not copied in this quote ---';
$lang['bbcode_h_help'] = 'Hide: [hide]message[/hide] (alt+h)';
8b - In "bbcode.tpl" file (Templates/{Used template}/bbcode.tpl)
Find
<!-- BEGIN show -->
</span>
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
<td><span class="genmed"><b>Protected Message:</b></span></td>
</tr>
<tr>
<td class="quote">
{HTEXTE}
</td>
</tr>
</table>
<span class="postbody">
<!-- END show -->
<!-- BEGIN hide -->
</span>
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
<td><span class="genmed"><b>Protected Message:</b></span></td>
</tr>
<tr>
<td class="quote">
<center>--- If you are a *registered user* : you need to post in this topic to see the message ---</center>
</td>
</tr>
</table>
<span class="postbody">
<!-- END hide -->
Replace By
<!-- BEGIN show -->
</span>
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
<td><span class="genmed"><b>{MODHIDE_TITLE}</b></span></td>
</tr>
<tr>
<td class="quote">
{HTEXTE}
</td>
</tr>
</table>
<span class="postbody">
<!-- END show -->
<!-- BEGIN hide -->
</span>
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
<td><span class="genmed"><b>{MODHIDE_TITLE}</b></span></td>
</tr>
<tr>
<td class="quote">
<center>{MODHIDE_INFO}</center>
</td>
</tr>
</table>
<span class="postbody">
<!-- END hide -->
8c - In "posting_body.tpl" (in the Templates/{Used template}/ directory)
Find
h_help = "Hide: [hide]texte[/hide] (alt+h)";
Replace by
h_help = "{L_BBCODE_H_HELP}";
8d - In "bbcode.php" ("includes/" directory)
Find
$bbcode_tpl['show'] = str_replace('{HTEXTE}', '\\1', $bbcode_tpl['show']);
Replace by
$bbcode_tpl['show'] = str_replace('{MODHIDE_TITLE}', $lang['modhide_title'], $bbcode_tpl['show']);
$bbcode_tpl['show'] = str_replace('{HTEXTE}', '\\1', $bbcode_tpl['show']);
$bbcode_tpl['hide'] = str_replace('{MODHIDE_TITLE}', $lang['modhide_title'], $bbcode_tpl['hide']);
$bbcode_tpl['hide'] = str_replace('{MODHIDE_INFO}', $lang['modhide_info'], $bbcode_tpl['hide']);
Find
function hide_in_quote($text)
{
$text = preg_replace("#\[hide\](.*?)\[\/hide\]#si","--- phpBB : Le message protégé n'est pas recopié dans cette citation ---",$text);
return $text;
}
Replace by
function hide_in_quote($text)
{
global $lang;
$text = preg_replace("#\[hide\](.*?)\[\/hide\]#si",$lang['modhide_quote'],$text);
return $text;
}
8e - In "posting.php" ("root" directory)
Find
'L_BBCODE_F_HELP' => $lang['bbcode_f_help'],
Add below
'L_BBCODE_H_HELP' => $lang['bbcode_h_help'],
That's all, Folks!
Philippe |
|
���仢�ҧ�� |
|
 |
|