| |
| | |

CodersClub

 Forgot password?
 Register
Search
View: 9225|Reply: 6
Collapse the left

making secret bbcode

[Copy link]

 Korea, Republic of

Post time: 2012-02-25 06:57
| Show all posts |Read mode
Edited by ionobgy at 2012-2-25 11:44

I need occasionally secret bbcode.
And then I made my secret bbcode as below.

1st step:
create custom static file.
pass_check.php in root folder.
  1. <?php
  2. require './source/class/class_core.php';
  3. $discuz = & discuz_core::instance();
  4. $discuz->cachelist = $cachelist;
  5. $discuz->init();

  6. $password = $_REQUEST["pass"];

  7. include template('diy:custom/pass_check');               
  8. ?>
Copy the Code
pass_check.htm in /template/default/custom folder.
  1. {template common/header}

  2. <div style="width:300px; height:200px;">
  3.         <div class="mtm mbm">
  4.                 <ul class="tb tb_s cl" style="margin-top: 0;">
  5.                         <li class="y"><span class="flbc" onclick="document.getElementById('fwin_pass').style.display='none'">Close</span></li>
  6.                         <li style="height:28px;font-weight:bold;font-size:1.3em;">Password Check</li>
  7.                 </ul>
  8.         </div>
  9.         <div style="padding-left:10px; font-size:1.2em; line-height:2.0">
  10.                 Enter the password<br>
  11.                  <input type=text name='password2' id='password2' value='' style='vertical-align:middle; padding:3px; width:140px;background-color:#ffffff; font-size:1.0em;border:1px solid #cccccc;'>
  12.                 <input type=submit value='Submit' style='margin-left:10px;vertical-align:middle; padding:3px; width:100px;border:1px solid #cccccc; font-size:1.0em;background-color:#eeeeee; color:#000000;white-space:pre;' onclick='code_check();' >
  13.         </div>        
  14.         <div style="padding:10px; font-size:1.2em; line-height:2.0">
  15. This content is secret. Please enter the password for view content.
  16.         </div>
  17. </div>

  18. <script>

  19. function code_check() {
  20.         value1=<!--{$password}-->;
  21.         value2=document.getElementById('password2').value;

  22.         if(value1==value2) {
  23.                 hideWindow("pass");
  24.                 document.getElementById('mysecretdiv').style.display="block";
  25.         }
  26.         else {
  27.                 alert("Incorrect password.");
  28.         }
  29. }

  30. </script>

  31. {template common/footer}
Copy the Code

2nd step:
create secret bbcode in admin panel.
and enter below code in replacement content of secret bbcode.
  1. <script>showWindow('pass','/user/pass_check.php?pass={1}');</script><div id="mysecretdiv" style="display:none">
Copy the Code

3rd step:
At thead edit window, use as below.

[secret]1234[/secret]
secret content.

(1234 is a password that you want to set. secret content is the content that you want to hide.)

4rd step: (optional)
make nosecret bbcode for  password nocheck content.
bbcode name: nosecret
relacement content: </div>
use: [nosecret] [/nosecret]

 Russia

Post time: 2012-02-25 09:50
| Show all posts
My suggestion:
X2 have a built-in BB-code:
[hide=NNN] hidden content [/hide]

I think it would be nice to make the "secret" BB-code by the same manner,
i.e.
  1. [secret=mypassword]
  2. secret content.
  3. [/secret]
  4. public content.
Copy the Code

 Korea, Republic of

 Author| Post time: 2012-02-25 09:59
| Show all posts
Edited by ionobgy at 2012-2-25 11:27
vot replied at 2012-2-25 10:50
My suggestion:
X2 have a built-in BB-code:
[hide=NNN] hidden content [/hide]

I already tried the method that you suggest.
Your suggesting method is  more simple.
It is possible  by changing of parameter count. (1st parameter =password, 2nd parameter=content)

But that method (envelope the content with secret bbcode) have a limitation.
The limitation is that nested bbcode is not working in discuz.
[secret=1234][attach]....[/attach][/secret]
[secret=1234][media=x..][/media][/secret]
Above code all is not working.
In other words, member cannot use bbcode within bbcode.

But I want that some media file or image including bbcode is hided by password.
Therefore I made a secret bbcode like above.


 Russia

Post time: 2012-02-25 11:55
| Show all posts
But that method (envelope the content with secret bbcode) have a limitation.
The limitation is that nested bbcode is not working in discuz.

Why you think so?
Just try this sample:
  1. [hide=NNN]
  2. Hidden content and hidden attachment:
  3. [attach]....[/attach]
  4. [/hide]
  5. public content
Copy the Code

 Russia

Post time: 2012-02-25 11:58
| Show all posts
Hide Test (hide=10):
Guest, hidden content will be shown only to users with 10 points and above. Your current points: 0

Here is public content

This post contains more resources

You have to Login for download or view attachment(s). No Account? Register

x

 Russia

Post time: 2012-02-25 12:00
| Show all posts
The previous post screenshot for guests (non registered):

This post contains more resources

You have to Login for download or view attachment(s). No Account? Register

x

 Korea, Republic of

 Author| Post time: 2012-02-25 13:18
| Show all posts
Edited by ionobgy at 2012-2-25 15:22
vot replied at 2012-2-25 13:00
The previous post screenshot for guests (non registered):

My mistake.
Original "hide" bbcode and "attach" bbcode is possible to nest.
But my custom bbcode is not nested.

Example:
I made [secret] bbcode to hide content as like your suggestion at past.
And I made another bbcode [ifr] to steam a video.
Therefore I wrote in editor.
[secret=100][ifr=700]500[/ifr][/secret]

The screen display as


[secret] bbcode is not converted to replacement content.
and then content stream video is not hided.
Therefore I wrote secret bbcode as above code.

I think that the cause is a parameter interpretation.
[secret] bbcode has a one parameter and [ifr] bbcode has a two parameter.

Other example:
"hide" bbcode or "secret" bbcode is OK alone.
But "hide" bbcode and "secret" bbcode at same time is not OK.
  1. [secret=1000][hide=100]500[/hide][/secret]
Copy the Code
display as below (Not OK)


But,
  1. [hide=100][secret=1000]aaaa[/secret][/hide]
Copy the Code
display as below (OK)

Nesting of original bbcode with parameter have no problem.
But nested my custom bbcodes with parameter is not displayed well.
I can't solve this problem.

This post contains more resources

You have to Login for download or view attachment(s). No Account? Register

x
You have to log in before you can reply Login | Register

Points Rules

Archive|Mobile|Dark room|CodersClub

Top.Mail.Ru
Top.Mail.Ru

2024-11-22 15:35 GMT+3 , Processed in 0.068564 sec., 8 queries .

Powered by Discuz! X3.4 Release 20230520

© 2001-2024 Discuz! Team.

MultiLingual version, Rev. 4301, © codersclub.org

Quick Reply To Top Return to the list