MyBB.de Forum
Plugin-wunsch: Threats mit PW - Druckversion

+- MyBB.de Forum (https://www.mybb.de/forum)
+-- Forum: Anpassungen (https://www.mybb.de/forum/forum-47.html)
+--- Forum: Plugin-Diskussionen (https://www.mybb.de/forum/forum-38.html)
+--- Thema: Plugin-wunsch: Threats mit PW (/thread-19725.html)

Seiten: Seiten: 1 2


RE: Plugin-wunsch: Threats mit PW - bmr - 31.07.2007

Ich habe es anders gelöst, das es an der entsprechenden Stelle keinen Hook gibt.
Herausgekommen ist folgendes PlugIn: http://www.mybbcoder.de/showthread.php?tid=1138


RE: Plugin-wunsch: Threats mit PW - Laello - 05.03.2008

jetzt suche ich genau das erstgenannte Plug In.
Findes aber nicht,
kann mir jemand sagen wie das hieß?
ODer den Link?


RE: Plugin-wunsch: Threats mit PW - StefanT - 06.03.2008

Das Plugin "Thread Protected By Password" wurde wohl vom Autor gelöscht. Ich kann es nicht mehr finden.


RE: Plugin-wunsch: Threats mit PW - Laello - 07.03.2008

Schade, aber da kann man nichts mehr machen.....


RE: Plugin-wunsch: Threats mit PW - Der Prophet - 13.12.2008

Da mcih das Thema Passwort für Thread auch interessiert, habe ich anhand des genauen Namen bei Google rechachiert und auch gefunden

Adresse: Thread Protected By Password for MyBB 1.2.9

WARNUNG: Bei der aktivierung wird das feld passwort angelegt bei einer deaktivierung erfolgt die entfernung

Script funktioniert im MyBB 1.4.4

PHP-Code:
<?php
/*

 * Thread Protected By Password for MyBB 1.2.9
 * By: LeX-
 * Website: http://www.thingiej.be
 * Version: 1.0

*/

// ADD HOOK FOR NEW THREAD [SHOWING PASSWORDBOX]
$plugins->add_hook('newthread_start''tp');

// ADD HOOK FOR NEW THREAD [INSERT NEW THREAD]
$plugins->add_hook('newthread_do_newthread_end''tp_thread');

// ADD HOOK FOR SHOW THREAD [CHECK PASSWORD]
$plugins->add_hook('showthread_start''tp_show');

// ADD HOOK FOR EDITPOST [SHOWING PASSWORDBOX]
$plugins->add_hook('editpost_start''tp_edit');

// ADD HOOK FOR EDITPOST [UPDATING PASSWORD]
$plugins->add_hook('editpost_do_editpost_end''tp_do_edit');

function 
tp_info()
{
    return array(
        
'name'            => 'Thread Protected By Password v1.0',
        
'description'    => 'Makes It Possible So Certain UserGroups Can Enter A Thread Protecting Password.',
        
'website'        => 'http://www.thingiej.be/',
        
'author'        => 'LeX-',
        
'authorsite'    => 'http://www.thingiej.be/',
        
'version'        => '1.0',
    );
}

function 
tp_activate()
{
    global 
$db$mybb;

    
// SETTINGS 
    
$tp_group = array(
        
"gid"            => "NULL",
        
"name"            => "tp_options",
        
"title" =>"ThreadPassword Settings",
        
"description"    => "Settings for the TP Plugin.",
        
"disporder"        => "3",
        
"isdefault"        => "no",
    );

    
$db->insert_query("settinggroups"$tp_group);
    
$gid $db->insert_id();

    
$new_setting = array(
        
'name'            => 'tp_status',
        
'title'            => 'ThreadPassword__ Status',
        
'description'    => 'Makes It Possible So Certain UserGroups Can Enter A Thread Protecting Password.',
        
'optionscode'    => 'yesno',
        
'value'            => 'yes',
        
'disporder'        => '1',
        
'gid'            => intval($gid),
    );

    
$db->insert_query('settings'$new_setting);

    
$new_setting2 = array(
        
'name'            => 'tp_groups',
        
'title'            => 'ThreadPassword__ Groups',
        
'description'    => 'Which Groups Can Enter A Password For ThreadProtection. [Seperate By Comma]',
        
'optionscode'    => 'text',
        
'value'            => '',
        
'disporder'        => '2',
        
'gid'            => intval($gid),
    );

    
$db->insert_query('settings'$new_setting2);

    
$new_setting3 = array(
        
'name'            => 'tp_excludes',
        
'title'            => 'ThreadPassword__ Excludes',
        
'description'    => 'Which Groups Dont Need A Check When Trying To View A Thread. [Seperate By Comma]',
        
'optionscode'    => 'text',
        
'value'            => '',
        
'disporder'        => '3',
        
'gid'            => intval($gid),
    );

    
$db->insert_query('settings'$new_setting3);

    
rebuildsettings();

    
// ALTERING
    //$db->query("ALTER TABLE `".TABLE_PREFIX."threads` ADD `password` VARCHAR(20) NOT NULL;");

    // TEMPLATES
    
$tp_template = array(
        
"tid"        => NULL,
        
"title"        => 'newthread_tp',
        
"template"    => $db->escape_string('<tr>
<td class="trow2" width="20%"><strong>Password:</strong></td>
<td class="trow2"><input type="text" class="textbox" id="password" name="password" size="40"  value="{$password}" tabindex="1" /><span class=\"smalltext\"> [ Password Length :: Min. 3; Max. 20 ]</span></td>
</tr>'
),
        
"sid"        => "-1",
        
"version"    => "1.0",
        
"dateline"    => "1148741714",
    );
    
$db->insert_query("templates"$tp_template);

    require 
MYBB_ROOT.'/inc/adminfunctions_templates.php';
    
// ADD TPBOX [ NEWTHREAD ]
    
find_replace_templatesets("newthread"'#{\$posticons}#'"{\$tp}{\$posticons}");
    
// ADD TPBOX [ EDITPOST ]
    
find_replace_templatesets("editpost"'#{\$posticons}#'"{\$tp}{\$posticons}");
    
}

function 
tp_deactivate()
{
    global 
$db$mybb;
    
    
// SETTINGS
    
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tp_status'");
    
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tp_groups'");
    
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tp_excludes'");
    
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='tp_options'");
    
rebuildsettings();
    
// ALTERING
    //$db->query("ALTER TABLE `"."threads` DROP `password`;");
    // TEMPLATES
    
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title = 'newthread_tp'");
    
// TEMPLATECHANGES
    
require MYBB_ROOT.'/inc/adminfunctions_templates.php';
    
// REMOVE PASSWORDBOX [ NEWTHREAD ]
    
find_replace_templatesets("newthread"'#'.preg_quote('{$tp}').'#''',0);
    
// REMOVE PASSWORDBOX [ EDITPOST ]
    
find_replace_templatesets("editpost"'#'.preg_quote('{$tp}').'#''',0);
}

function 
tp()
{
    global 
$db$mybb$templates$tp$status;

    
$status '';
    if(
$mybb->settings['tp_status'] != "no")
    {
        if(
$mybb->settings['tp_groups'] != "")
        {
            
// EXPLODE
            
$groups explode(","$mybb->settings['tp_groups']);
            
// USERGROUP
            
$usergroup $mybb->user['usergroup'];
            
// CHECK
            
if(in_array($usergroup$groups) || $usergroup == || $usergroup == || $usergroup == 6)
            {
                
$status "ok";    
            }    
        }        
        else if(
$mybb->user['usergroup'] == 4)
        {
            
$status "ok";
        }
else if(
$mybb->user['usergroup'] == 3)
        {
            
$status "ok";
        }
else if(
$mybb->user['usergroup'] == 6)
        {
            
$status "ok";
        }

        if(
$status == "ok")
        {
            eval(
"\$tp = \"".$templates->get("newthread_tp")."\";");
        }
    }
}

function 
tp_thread()
{
    global 
$db$mybb$thread_info;

    
// INCOMING
    
$password $db->escape_string($mybb->input['password']);
    
// LENGTH
    
$length my_strlen($password);
    
// CHECK
    
if($password && $length >= && $length 20)
    {
        
// TID
        
$tid intval($thread_info['tid']);
        
// ENTER PASSWORD IN DB
         
$update = array( 
            
"password" => $password
                     
); 
        
$u_check $db->update_query("threads"$update"tid='".$tid."'");
        if(!
$u_check)
        {
            
error("Error While Tryin' To Enter The Password Into The Database""Thread Protection System");
        }
        
// SET COOKIE
        
my_setcookie("threadpass[$tid]"md5($mybb->user['uid'].$password), nulltrue);
    }
    
/*
    else
    {
        error("Thread Has Been Made But Is Not Protected Because The Password Didn't Meet The Standards", "Thread Protection System");
    }
    */
}

function 
tp_show()
{
    global 
$db$mybb$thread$status;

    
$status '';
    if(
$mybb->settings['tp_status'] != "no")
    {
        if(
$mybb->settings['tp_excludes'] != "")
        {
            
// EXPLODE
            
$groups explode(","$mybb->settings['tp_excludes']);
            
// USERGROUP
            
$usergroup $mybb->user['usergroup'];
            
// CHECK
            
if(in_array($usergroup$groups) || $usergroup == || $usergroup == || $usergroup == 6)
            {
                
$status "ok";    
            }    
            else if(
$mybb->user['usergroup'] == 4)
            {
                
$status "ok";
            }
else if(
$mybb->user['usergroup'] == 3)
        {
            
$status "ok";
        }
else if(
$mybb->user['usergroup'] == 6)
        {
            
$status "ok";
        }
            if(
$status == "")
            {
                
$password $thread['password'];
                
check_thread_password($thread['tid'], $password);
            }
        }
        else
        {
                
$password $thread['password'];
                
check_thread_password($thread['tid'], $password);
        }
    }
}
function 
tp_edit()
{
    global 
$db$mybb$templates$tp$status;

    
$status '';
    if(
$mybb->settings['tp_status'] != "no")
    {
        
// CHECK IF THERE WAS A PASSWORD SET
        // INCOMING 
        
$pid intval($mybb->input['pid']);
        
$query $db->query(
                SELECT t.password, p.tid
                FROM "
.TABLE_PREFIX."posts p
                LEFT JOIN "
.TABLE_PREFIX."threads t ON (p.tid=t.tid) 
                WHERE t.firstpost = 
{$pid}
         "
); 
        
$password $db->fetch_field($query"password");
        if(
$password != "")
        {
            if(
$mybb->settings['tp_groups'] != "")
            {
                
// EXPLODE
                
$groups explode(","$mybb->settings['tp_groups']);
                
// USERGROUP
                
$usergroup $mybb->user['usergroup'];
                
// CHECK
                
if(in_array($usergroup$groups) || $usergroup == || $usergroup == || $usergroup == 6)
                {
                    
$status "ok";    
                }    
            }        
            else if(
$mybb->user['usergroup'] == 4)
            {
                
$status "ok";
            }
            else if(
$mybb->user['usergroup'] == 3)
        {
            
$status "ok";
        }
else if(
$mybb->user['usergroup'] == 6)
        {
            
$status "ok";
        }
        }

        if(
$status == "ok")
        {
            eval(
"\$tp = \"".$templates->get("newthread_tp")."\";");
        }
    }
}

function 
tp_do_edit()
{
    global 
$db$mybb$templates$tp$tid;

    
//INCOMING
    
$password $db->escape_string($mybb->input['password']);
    
// LENGTH
    
$length my_strlen($password);
    
// CHECK
    
if($password && $length >= && $length 20)
    {
        
// ENTER PASSWORD IN DB
         
$update = array( 
            
"password" => $password
                     
); 
        
$u_check $db->update_query("threads"$update"tid='".$tid."'");
        if(!
$u_check)
        {
            
error("Error While Tryin' To Enter The Password Into The Database""Thread Protection System");
        }
        
// SET COOKIE
        
my_setcookie("threadpass[$tid]"md5($mybb->user['uid'].$password), nulltrue);
    }
}

function 
check_thread_password($tid$password="")
{
    global 
$mybb$header$footer$headerinclude$theme$templates$lang;
    
$showform 1;

    if(
$password)
    {
        if(
$mybb->input['pwverify'])
        {
            if(
$password == $mybb->input['pwverify'])
            {
                
my_setcookie("threadpass[$tid]"md5($mybb->user['uid'].$mybb->input['pwverify']), nulltrue);
                
$showform 0;
            }
            else
            {
                eval(
"\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");
                
$showform 1;
            }
        }
        else
        {
            if(!
$_COOKIE['threadpass'][$tid] || ($_COOKIE['threadpass'][$tid] && md5($mybb->user['uid'].$password) != $_COOKIE['threadpass'][$tid]))
            {
                
$showform 1;
            }
            else
            {
                
$showform 0;
            }
        }
    }
    else
    {
        
$showform 0;
    }
    if(
$showform)
    {
        
$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
        eval(
"\$pwform = \"".$templates->get("forumdisplay_password")."\";");
        
output_page($pwform);
        exit;
    }
}
?>



RE: Plugin-wunsch: Threats mit PW - aTCWiki - 11.04.2009

Hmm... :undecided:

Hallo,

ich verwende seit Kurzem das Plug-In "Thread Protected By Password v1.0 (1.0)"

Es erscheint beim Erstellen eines neuen Themas auch das Passwort-Feld aber wenn ich dann auf Beitrag erstellen klick kommt folgendes:

MyBB has experienced an internal SQL error and cannot continue.

Zitat:SQL Error:
1054 - Unknown column 'password' in 'field list'
Query:
UPDATE mybb_threads SET `password`='test' WHERE tid='102'


Woran liegt das? Sad

Edit:

Exclamation Ich kann mit dem Editor auch keine Beiträge mehr bearbeiten.

Zitat:MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1054 - Unknown column 't.password' in 'field list'
Query:
SELECT t.password, p.tid FROM mybb_posts p LEFT JOIN mybb_threads t ON (p.tid=t.tid) WHERE t.firstpost = 94


Mit dem Inlineeditor geht es noch, aber mit dem geht ja alles, damit kann man sogar Themen in geschlossenen Foren bearbeiten.


RE: Plugin-wunsch: Threats mit PW - StefanT - 12.04.2009

Im Code oben wurden die entsprechenden Zeilen auskommentiert. Probiere:
PHP-Code:
<?php
/*

 * Thread Protected By Password for MyBB 1.2.9
 * By: LeX-
 * Website: http://www.thingiej.be
 * Version: 1.0

*/

// ADD HOOK FOR NEW THREAD [SHOWING PASSWORDBOX]
$plugins->add_hook('newthread_start''tp');

// ADD HOOK FOR NEW THREAD [INSERT NEW THREAD]
$plugins->add_hook('newthread_do_newthread_end''tp_thread');

// ADD HOOK FOR SHOW THREAD [CHECK PASSWORD]
$plugins->add_hook('showthread_start''tp_show');

// ADD HOOK FOR EDITPOST [SHOWING PASSWORDBOX]
$plugins->add_hook('editpost_start''tp_edit');

// ADD HOOK FOR EDITPOST [UPDATING PASSWORD]
$plugins->add_hook('editpost_do_editpost_end''tp_do_edit');

function 
tp_info()
{
    return array(
        
'name'            => 'Thread Protected By Password v1.0',
        
'description'    => 'Makes It Possible So Certain UserGroups Can Enter A Thread Protecting Password.',
        
'website'        => 'http://www.thingiej.be/',
        
'author'        => 'LeX-',
        
'authorsite'    => 'http://www.thingiej.be/',
        
'version'        => '1.0',
    );
}

function 
tp_activate()
{
    global 
$db$mybb;

    
// SETTINGS 
    
$tp_group = array(
        
"gid"            => "NULL",
        
"name"            => "tp_options",
        
"title" =>"ThreadPassword Settings",
        
"description"    => "Settings for the TP Plugin.",
        
"disporder"        => "3",
        
"isdefault"        => "no",
    );

    
$db->insert_query("settinggroups"$tp_group);
    
$gid $db->insert_id();

    
$new_setting = array(
        
'name'            => 'tp_status',
        
'title'            => 'ThreadPassword__ Status',
        
'description'    => 'Makes It Possible So Certain UserGroups Can Enter A Thread Protecting Password.',
        
'optionscode'    => 'yesno',
        
'value'            => 'yes',
        
'disporder'        => '1',
        
'gid'            => intval($gid),
    );

    
$db->insert_query('settings'$new_setting);

    
$new_setting2 = array(
        
'name'            => 'tp_groups',
        
'title'            => 'ThreadPassword__ Groups',
        
'description'    => 'Which Groups Can Enter A Password For ThreadProtection. [Seperate By Comma]',
        
'optionscode'    => 'text',
        
'value'            => '',
        
'disporder'        => '2',
        
'gid'            => intval($gid),
    );

    
$db->insert_query('settings'$new_setting2);

    
$new_setting3 = array(
        
'name'            => 'tp_excludes',
        
'title'            => 'ThreadPassword__ Excludes',
        
'description'    => 'Which Groups Dont Need A Check When Trying To View A Thread. [Seperate By Comma]',
        
'optionscode'    => 'text',
        
'value'            => '',
        
'disporder'        => '3',
        
'gid'            => intval($gid),
    );

    
$db->insert_query('settings'$new_setting3);

    
rebuildsettings();

    
// ALTERING
    
$db->query("ALTER TABLE `".TABLE_PREFIX."threads` ADD `password` VARCHAR(20) NOT NULL;");

    
// TEMPLATES
    
$tp_template = array(
        
"tid"        => NULL,
        
"title"        => 'newthread_tp',
        
"template"    => $db->escape_string('<tr>
<td class="trow2" width="20%"><strong>Password:</strong></td>
<td class="trow2"><input type="text" class="textbox" id="password" name="password" size="40"  value="{$password}" tabindex="1" /><span class=\"smalltext\"> [ Password Length :: Min. 3; Max. 20 ]</span></td>
</tr>'
),
        
"sid"        => "-1",
        
"version"    => "1.0",
        
"dateline"    => "1148741714",
    );
    
$db->insert_query("templates"$tp_template);

    require 
MYBB_ROOT.'/inc/adminfunctions_templates.php';
    
// ADD TPBOX [ NEWTHREAD ]
    
find_replace_templatesets("newthread"'#{\$posticons}#'"{\$tp}{\$posticons}");
    
// ADD TPBOX [ EDITPOST ]
    
find_replace_templatesets("editpost"'#{\$posticons}#'"{\$tp}{\$posticons}");
    
}

function 
tp_deactivate()
{
    global 
$db$mybb;
    
    
// SETTINGS
    
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tp_status'");
    
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tp_groups'");
    
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='tp_excludes'");
    
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='tp_options'");
    
rebuildsettings();
    
// ALTERING
    
$db->query("ALTER TABLE `".TABLE_PREFIX."threads` DROP `password`;");
    
// TEMPLATES
    
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title = 'newthread_tp'");
    
// TEMPLATECHANGES
    
require MYBB_ROOT.'/inc/adminfunctions_templates.php';
    
// REMOVE PASSWORDBOX [ NEWTHREAD ]
    
find_replace_templatesets("newthread"'#'.preg_quote('{$tp}').'#''',0);
    
// REMOVE PASSWORDBOX [ EDITPOST ]
    
find_replace_templatesets("editpost"'#'.preg_quote('{$tp}').'#''',0);
}

function 
tp()
{
    global 
$db$mybb$templates$tp$status;

    
$status '';
    if(
$mybb->settings['tp_status'] != "no")
    {
        if(
$mybb->settings['tp_groups'] != "")
        {
            
// EXPLODE
            
$groups explode(","$mybb->settings['tp_groups']);
            
// USERGROUP
            
$usergroup $mybb->user['usergroup'];
            
// CHECK
            
if(in_array($usergroup$groups) || $usergroup == || $usergroup == || $usergroup == 6)
            {
                
$status "ok";    
            }    
        }        
        else if(
$mybb->user['usergroup'] == 4)
        {
            
$status "ok";
        }
else if(
$mybb->user['usergroup'] == 3)
        {
            
$status "ok";
        }
else if(
$mybb->user['usergroup'] == 6)
        {
            
$status "ok";
        }

        if(
$status == "ok")
        {
            eval(
"\$tp = \"".$templates->get("newthread_tp")."\";");
        }
    }
}

function 
tp_thread()
{
    global 
$db$mybb$thread_info;

    
// INCOMING
    
$password $db->escape_string($mybb->input['password']);
    
// LENGTH
    
$length my_strlen($password);
    
// CHECK
    
if($password && $length >= && $length 20)
    {
        
// TID
        
$tid intval($thread_info['tid']);
        
// ENTER PASSWORD IN DB
         
$update = array( 
            
"password" => $password
                     
); 
        
$u_check $db->update_query("threads"$update"tid='".$tid."'");
        if(!
$u_check)
        {
            
error("Error While Tryin' To Enter The Password Into The Database""Thread Protection System");
        }
        
// SET COOKIE
        
my_setcookie("threadpass[$tid]"md5($mybb->user['uid'].$password), nulltrue);
    }
    
/*
    else
    {
        error("Thread Has Been Made But Is Not Protected Because The Password Didn't Meet The Standards", "Thread Protection System");
    }
    */
}

function 
tp_show()
{
    global 
$db$mybb$thread$status;

    
$status '';
    if(
$mybb->settings['tp_status'] != "no")
    {
        if(
$mybb->settings['tp_excludes'] != "")
        {
            
// EXPLODE
            
$groups explode(","$mybb->settings['tp_excludes']);
            
// USERGROUP
            
$usergroup $mybb->user['usergroup'];
            
// CHECK
            
if(in_array($usergroup$groups) || $usergroup == || $usergroup == || $usergroup == 6)
            {
                
$status "ok";    
            }    
            else if(
$mybb->user['usergroup'] == 4)
            {
                
$status "ok";
            }
else if(
$mybb->user['usergroup'] == 3)
        {
            
$status "ok";
        }
else if(
$mybb->user['usergroup'] == 6)
        {
            
$status "ok";
        }
            if(
$status == "")
            {
                
$password $thread['password'];
                
check_thread_password($thread['tid'], $password);
            }
        }
        else
        {
                
$password $thread['password'];
                
check_thread_password($thread['tid'], $password);
        }
    }
}
function 
tp_edit()
{
    global 
$db$mybb$templates$tp$status;

    
$status '';
    if(
$mybb->settings['tp_status'] != "no")
    {
        
// CHECK IF THERE WAS A PASSWORD SET
        // INCOMING 
        
$pid intval($mybb->input['pid']);
        
$query $db->query(
                SELECT t.password, p.tid
                FROM "
.TABLE_PREFIX."posts p
                LEFT JOIN "
.TABLE_PREFIX."threads t ON (p.tid=t.tid) 
                WHERE t.firstpost = 
{$pid}
         "
); 
        
$password $db->fetch_field($query"password");
        if(
$password != "")
        {
            if(
$mybb->settings['tp_groups'] != "")
            {
                
// EXPLODE
                
$groups explode(","$mybb->settings['tp_groups']);
                
// USERGROUP
                
$usergroup $mybb->user['usergroup'];
                
// CHECK
                
if(in_array($usergroup$groups) || $usergroup == || $usergroup == || $usergroup == 6)
                {
                    
$status "ok";    
                }    
            }        
            else if(
$mybb->user['usergroup'] == 4)
            {
                
$status "ok";
            }
            else if(
$mybb->user['usergroup'] == 3)
        {
            
$status "ok";
        }
else if(
$mybb->user['usergroup'] == 6)
        {
            
$status "ok";
        }
        }

        if(
$status == "ok")
        {
            eval(
"\$tp = \"".$templates->get("newthread_tp")."\";");
        }
    }
}

function 
tp_do_edit()
{
    global 
$db$mybb$templates$tp$tid;

    
//INCOMING
    
$password $db->escape_string($mybb->input['password']);
    
// LENGTH
    
$length my_strlen($password);
    
// CHECK
    
if($password && $length >= && $length 20)
    {
        
// ENTER PASSWORD IN DB
         
$update = array( 
            
"password" => $password
                     
); 
        
$u_check $db->update_query("threads"$update"tid='".$tid."'");
        if(!
$u_check)
        {
            
error("Error While Tryin' To Enter The Password Into The Database""Thread Protection System");
        }
        
// SET COOKIE
        
my_setcookie("threadpass[$tid]"md5($mybb->user['uid'].$password), nulltrue);
    }
}

function 
check_thread_password($tid$password="")
{
    global 
$mybb$header$footer$headerinclude$theme$templates$lang;
    
$showform 1;

    if(
$password)
    {
        if(
$mybb->input['pwverify'])
        {
            if(
$password == $mybb->input['pwverify'])
            {
                
my_setcookie("threadpass[$tid]"md5($mybb->user['uid'].$mybb->input['pwverify']), nulltrue);
                
$showform 0;
            }
            else
            {
                eval(
"\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");
                
$showform 1;
            }
        }
        else
        {
            if(!
$_COOKIE['threadpass'][$tid] || ($_COOKIE['threadpass'][$tid] && md5($mybb->user['uid'].$password) != $_COOKIE['threadpass'][$tid]))
            {
                
$showform 1;
            }
            else
            {
                
$showform 0;
            }
        }
    }
    else
    {
        
$showform 0;
    }
    if(
$showform)
    {
        
$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
        eval(
"\$pwform = \"".$templates->get("forumdisplay_password")."\";");
        
output_page($pwform);
        exit;
    }
}
?>