vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   vbshout ban command (https://vborg.vbsupport.ru/showthread.php?t=230204)

DJ29Joesph 12-14-2009 06:41 PM

vbshout ban command
 
trying to add a ban and unban command to vbshout. I'm hoping I can use the database for this. I created a column in vbuser called Shoutban. The two commands will be /ban and /unban.

This is what I have so far. These are just snips of the code I changed.

PHP Code:

function isBanned($user)
{
    global 
$vbulletin;
    
$banneduserid $vbulletin->db->query('SELECT userid FROM '.TABLE_PREFIX.'user WHERE ShoutBan > 0')
    return (
isBanned_Check($user['userid'], $banneduserid) || isBanned_Check($user['usergroupid'], 'shout_banned_usergroups'));    
}

function 
isBanned_Check($bash$against)
{
    global 
$vbulletin;
    return 
in_array($bashiif($vbulletin->options[$against], explode(','$vbulletin->options[$against]), array()));
}

function 
execCommand($Command)
{
    global 
$meShout;

    if (
preg_match_all("#^/pruneshout(.*)$#"$Command$MatchesPREG_SET_ORDER) && canCommand())
    {
        return 
execCommand_pruneshout($Matches);
    }
    else if (
preg_match_all("#^/prune(.*)$#"$Command$MatchesPREG_SET_ORDER) && canCommand())
    {
        return 
execCommand_prune($Matches);
    }
    else if (
preg_match_all("#^/ban(.*)$#"$Command$MatchesPREG_SET_ORDER) && canCommand())
    {
        return 
execCommand_ban($Matches);
    }
    else if (
preg_match_all("#^/unban(.*)$#"$Command$MatchesPREG_SET_ORDER) && canCommand())
    {
        return 
execCommand_unban($Matches);
    }
    else if (
preg_match_all("#^/me(.*)$#"$Command$MatchesPREG_SET_ORDER))
    {
        
$meShout 1;
        return 
trim($Matches[0][1]);
    }

    return 
$Command;
}

function 
execCommand_ban($Data)
{
    global 
$vbulletin;

    
$Data trim($Data[0][1]);

    if (!empty(
$Data))
    {
        
$u $vbulletin->db->query_first('select userid from '.TABLE_PREFIX.'user where username = \''.addslashes(htmlspecialchars_uni($Data)).'\''))
        {
            
$vbulletin->db->query('UPDATE '.TABLE_PREFIX.'user SET ShoutBan=1 WHERE userid = \''.intval($u['userid']).'\'');
        }    
    }

    return 
true;
}

function 
execCommand_unban($Data)
{
    global 
$vbulletin;

    
$Data trim($Data[0][1]);

    if (!empty(
$Data))
    {
        
$u $vbulletin->db->query_first('select userid from '.TABLE_PREFIX.'user where username = \''.addslashes(htmlspecialchars_uni($Data)).'\''))
        {
            
$vbulletin->db->query('UPDATE '.TABLE_PREFIX.'user SET ShoutBan=0 WHERE userid = \''.intval($u['userid']).'\'');
        }
        
    }

    return 
true;


Im not all that great with php but thought I give it a try. Thanks

kh99 12-14-2009 06:56 PM

I'm not sure I follow all your logic, but a couple things I noticed: In the isBanned function , I think you want "query_first" for the query. Also, it looks to me like isBanned_Check will always fail if you're not passing something for $against because you're calling in_array with an empty array. I think that will mean that isBanned is really only checking the banned groups. (Or I've missed something...)

DJ29Joesph 12-17-2009 06:48 AM

ah yes, you are correct, thanks


All times are GMT. The time now is 10:20 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01190 seconds
  • Memory Usage 1,740KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete