Thread: Chat Modifications - Cyb - ChatBox
View Single Post
  #784  
Old 11-12-2008, 12:47 PM
AdmiralGeek AdmiralGeek is offline
 
Join Date: Jul 2007
Posts: 94
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For people who want permissions for who is allowed to view and not view the chatbox full and the chat box archives can use the following code that I created. It will also stop them from searching the chatbox(as searching the chat box requires access to the archives. A Detailed explanation is giving at the end.

The code is generic and adding user groups can be used if you wish to add them.

1 File edit is required and 1 template edit is required(with 3 sub edits).

1 File = misc.php

Find
PHP Code:
require_once('./global.php');

// redirect in case anyone has linked to it
if ($_REQUEST['do'] == 'attachments')
{
    
exec_header_redirect('profile.php?' $vbulletin->session->vars['sessionurl_js'] . 'do=editattachments');

Below it add the following and save(upload)


Add After:
PHP Code:
// testing chatbox

$urlname1  "ccarc";
$urlname2 "misc.php?do=cchatbox";
$vbuser $vbulletin->userinfo['userid'];
$names = array("2","178","25");
if(
in_array("$vbuser",$names));
$inarray "yes";
$pos strpos($_SERVER['REQUEST_URI'],"misc.php?do=cchatbox");
$self substr($_SERVER['REQUEST_URI'],$pos);
if (
$self == $urlname2 || $urlname1 && $inarray == "yes"){
echo 
"<script language=\"JavaScript\" type=\"text/javascript\">
history.go(-1) </script>"
;

1 Template Edit = cyb_chatbox

Please take note that you need to enter the user ID's that you do not want viewing the archive or full chat box mode. Simply enter the ID's into the below arrays for all three accounts, and remember these ID's have to be the same as the ID's that you entered into the misc.php file.
if condition="!in_array($bbuserinfo[userid],array(25,178,2))"

Find:
PHP Code:
                    <td class="vbmenu_option"><a href="misc.php?do=cchatbox">$vbphrase[cybcb_go_separate]</a></td>
                </
tr
Replace With:
PHP Code:
<!-- test -->
<if 
condition="!in_array($bbuserinfo[userid],array(25,178,2))">

                    <
td class="vbmenu_option"><a href="misc.php?do=cchatbox">$vbphrase[cybcb_go_separate]</a></td>
                </
tr>
<else />
                    <
td class="vbmenu_option"><a href="javascript:alert('You are not allowed to view the full chat box');"><span id="joejoe" style="color: red;">Denied</spanClick here</a></td>
                </
tr>
<!-- 
test --> </if> 
-------------------------------------

Find:
PHP Code:
                    <td class="vbmenu_option"><a href="misc.php?do=ccarc">$vbphrase[cybcb_go_archive]</a></td>
                </
tr
Replace with:
PHP Code:
<!-- test -->
<if 
condition="!in_array($bbuserinfo[userid],array(25,178,2))">
                    <
td class="vbmenu_option"><a href="misc.php?do=ccarc">$vbphrase[cybcb_go_archive]</a></td>
                </
tr>
<else />
                    <
td class="vbmenu_option"><a href="javascript:alert('Your not allowed to view the archive');"><span id="joejoe" style="color: red;">Denied</spanClick here</a></td>
                </
tr>
</if> <!-- 
test --> 
Find:
PHP Code:
<tr>
                <
td class="thead">$vbphrase[cybcb_search_chatbox]</td>
            </
tr>

            <
tr>
                <
td class="vbmenu_option"><a href="misc.php?ccbfind=unread">$vbphrase[cybcb_find_first_unread]</a></td>
            </
tr>
            <if 
condition="($bbuserinfo[userid])">
            <
tr>
                <
td class="vbmenu_option"><a href="misc.php?ccbfind=$bbuserinfo[userid]">$vbphrase[cybcb_find_your_last]</a></td>
            </
tr>
            </if>
            <if 
condition="($_REQUEST['do']!='ccarc')">
                <
tr>
                    <
td class="vbmenu_option" title="nohilite">
                        <
form id="cybcb_search" name="cybcb_search" action="misc.php?do=ccarc" method="post">
                            <
input type="hidden" name="securitytoken" value="$cybcb_sectok/>
                            <
input type="text" class="bginput" style="font-size:11px;" name="cbt" size="20" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;" value="$vbphrase[cybcb_search_chatbox]/> <input type="submit" class="button" value="$vbphrase[go]/>


                        </
form>
                    </
td>
                </
tr>

            </if> 
Replace with:
PHP Code:
<!-- test deny searching -->

<if 
condition="!in_array($bbuserinfo[userid],array(25,178,2))">
            <
tr>
                <
td class="thead">$vbphrase[cybcb_search_chatbox]</td>
            </
tr>

            <
tr>
                <
td class="vbmenu_option"><a href="misc.php?ccbfind=unread">$vbphrase[cybcb_find_first_unread]</a></td>
            </
tr>
            <if 
condition="($bbuserinfo[userid])">
            <
tr>
                <
td class="vbmenu_option"><a href="misc.php?ccbfind=$bbuserinfo[userid]">$vbphrase[cybcb_find_your_last]</a></td>
            </
tr>
            </if>
            <if 
condition="($_REQUEST['do']!='ccarc')">
                <
tr>
                    <
td class="vbmenu_option" title="nohilite">
                        <
form id="cybcb_search" name="cybcb_search" action="misc.php?do=ccarc" method="post">
                            <
input type="hidden" name="securitytoken" value="$cybcb_sectok/>
                            <
input type="text" class="bginput" style="font-size:11px;" name="cbt" size="20" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;" value="$vbphrase[cybcb_search_chatbox]/> <input type="submit" class="button" value="$vbphrase[go]/>


                        </
form>
                    </
td>
                </
tr>

            </if>
<else />

            <
tr>
                <
td class="thead"><a href="javascript:alert('Your not allowed to search the archive');">
    <
span id="joejoe" style="color: red;">Denied</spanClick here</a></td>
            </
tr>


            <
tr>
                <
td class="vbmenu_option"><a href="javascript:alert('Your not allowed to search the archive');">
    <
span id="joejoe" style="color: red;">Denied</spanClick here</a></td>
            </
tr>
            <if 
condition="($bbuserinfo[userid])">
            <
tr>
                <
td class="vbmenu_option"><a href="javascript:alert('Your not allowed to search the archive');">
    <
span id="joejoe" style="color: red;">Denied</spanClick here</a></td>
            </
tr>
            </if>
            <if 
condition="($_REQUEST['do']!='ccarc')">
                <
tr>
                    <
td class="vbmenu_option" title="nohilite">
                        <
form id="cybcb_search" name="cybcb_search" action="javascript:alert('Your not allowed to search the archive');" method="post">
                            <
input type="hidden" name="securitytoken" value="$cybcb_sectok/>
                            <
input type="text" class="bginput" style="font-size:11px;" name="cbt" size="20" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;" value="$vbphrase[cybcb_search_chatbox]/> <input type="submit" class="button" value="$vbphrase[go]/>


                        </
form>
                    </
td>
                </
tr>

            </if>

</if><!-- 
end deny search --> 
If it is too difficult to do the template edit, you can download the attached txt file and copy the entire content over the current content in the template.


Quote:
$urlname1 = "ccarc";
$urlname2 = "misc.php?do=cchatbox";
$vbuser = $vbulletin->userinfo['userid'];
$names = array("2","178","25");
if(in_array("$vbuser",$names));
$inarray = "yes";
$pos = strpos($_SERVER['REQUEST_URI'],"misc.php?do=cchatbox");
$self = substr($_SERVER['REQUEST_URI'],$pos);
if ($self == $urlname2 || $urlname1 && $inarray == "yes"){
echo "<script language=\"JavaScript\" type=\"text/javascript\">
history.go(-1) </script>";
}
$urlname1 and $urlname2 have certain strings declared to them, if any of these are present in the URL the user will be redirected. The ones already declared is enough for the script to work.

$names contain the array of the user id's. Simply add in a userid for this script to effect those people. seperate each value with a comma

$self == $urlname2 || $urlname1
If for some reason you declare a new $urlname you will need to add it to that OR conditional, and make sure to add an additional double pipe || for that new declared variable.

And in the end, if all is true, the user will be redirected to their previous history. If you decide to change this to Header("Location: ......."); make sure the Output buffering is set to on. And set to flush the output when it is finished.

------------
This is just a minor modification, as other modifications can include, A time period in which certain age groups can not view the chat box (this is used after watershed times, because of minors that maybe on that could view adult context within the chats.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01320 seconds
  • Memory Usage 1,934KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (8)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete