Need PHP help

Discussion in 'Web Programming' started by Govind, Sep 2, 2007.

Need PHP help
  1. Unread #1 - Sep 2, 2007 at 6:14 PM
  2. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Need PHP help

    Trying to code a vBulletin hack that lets you ban several users at once:
    Code:
    if($_POST['do'] == 'ban')
    {
        $vbulletin->input->clean_array_gpc('p', array(
            'username'    => TYPE_STR,
            'reason'    => TYPE_STR
        ));
        $usernames = $_POST['userlist'];
        $namearray = explode(" ",$usernames);
        $liftdate = 0;
        $reason = $_POST['reason'];
        if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['ismoderator']))
        {
            if(!$canmassban)
            {
                print_stop_message('mbnopermission');
            }
        }
        $namearray[i] = $db->query_first("
            SELECT user.*,
                IF(moderator.moderatorid IS NULL, 0, 1) AS ismoderator
            FROM " . TABLE_PREFIX . "user AS user
            LEFT JOIN " . TABLE_PREFIX . "moderator AS moderator USING(userid)
            WHERE user.username = '" . $db->escape_string($vbulletin->GPC['username']) . "'
        ");
        $listlength = count($namearray);
        
        //$user = $db->query_first("SELECT user.*, IF (moderator.moderatorid IS NULL, 0, 1) AS ismoderator FROM " . TABLE_PREFIX . "user AS user LEFT JOIN " . TABLE_PREFIX . "moderator AS moderator USING(userid) WHERE user.username = '" . $db->escape_string($vbulletin->GPC['username']) . "'");
            
        //Gotta make  sure they exist/arent admin
        /*if (!$user OR $user['userid'] == $vbulletin->userinfo['userid'] OR is_member_of($user, 6))
        {
            print_stop_message('invalid_user_specified');
        }*/
        //Cant let mods ban each other    
        if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']))
        {
            if ($user['usergroupid'] == 5 OR $user['ismoderator'])
            {
                print_stop_message('no_permission_ban_non_registered_users');
            }
        }
        for($i = 0; $i < $listlength; $i++)
        {
            //The moment we've all been waiting for...
            $db->query_write("
                INSERT INTO " . TABLE_PREFIX . "userban
                (userid, usergroupid, displaygroupid, customtitle, usertitle, adminid, bandate, liftdate, reason)
                VALUES
                ($namearray[i][userid], 2, 0, 0, 1, '" . $vbulletin->userinfo['userid'] . ", TIMENOW, $liftdate, $reason)
            ");
    
    
        }
    }
    The error I get is:
    Code:
    Database error in vBulletin 3.6.7:
    
    Invalid SQL:
    
                INSERT INTO userban
                (userid, usergroupid, displaygroupid, customtitle, usertitle, adminid, bandate, liftdate, reason)
                VALUES
                (->userid, 2, 0, 0, 1, '1, TIMENOW, 0, test);
    
    MySQL Error  : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '>userid, 2, 0, 0, 1, '1, TIMENOW, 0, test)' at line 4
    Error Number : 1064
    Date         : Sunday, September 2nd 2007 @ 04:06:52 PM
    Script       : http://localhost/modcp/massban.php?do=ban
    Referrer     : http://localhost/modcp/massban.php?do=prepare
    IP Address   : 0.0.0.0
    Username     : Admin
    Classname    : vB_Database
    Any idea how to fix it :S
     
  3. Unread #2 - Sep 3, 2007 at 8:55 AM
  4. pur3 st4k3r
    Joined:
    Jul 9, 2007
    Posts:
    550
    Referrals:
    0
    Sythe Gold:
    0

    pur3 st4k3r Forum Addict
    Do Not Trade

    Need PHP help

    smr sorry for spamming but would you help me out with my security settings or could you reccomend a mod that could??
     
  5. Unread #3 - Sep 3, 2007 at 11:15 PM
  6. timk777
    Joined:
    Feb 19, 2007
    Posts:
    156
    Referrals:
    0
    Sythe Gold:
    0

    timk777 Active Member

    Need PHP help

    Code:
                INSERT INTO userban
                (user.userid, user.usergroupid, user.displaygroupid, user.customtitle, user.usertitle, user.adminid, user.bandate, user.liftdate, user.reason)
    
    Replace that one line with that. I think that should work. If it doesn't it might be something else.
     
  7. Unread #4 - Sep 3, 2007 at 11:50 PM
  8. Annex
    Joined:
    Aug 28, 2005
    Posts:
    2,324
    Referrals:
    3
    Sythe Gold:
    0
    UWotM8?

    Annex Ballin'
    Veteran (Ex-Admin)
    PHP Programmers Retired Administrator

    Need PHP help

    You forgot the $ in TABLE_PREFIX.
     
  9. Unread #5 - Sep 5, 2007 at 8:43 PM
  10. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Need PHP help

    Thanks guys, and I just realized that I put the namearray thing OUTSIDE the for loop...

    Gosh I'm an idiot lol.
     
< My phpbb forum - RATE! | Faster Than Imageshack... >

Users viewing this thread
1 guest


 
 
Adblock breaks this site