vBulletin 3.6 / vNews Bad Function

Discussion in 'Web Design & Coding' started by Electronic Punk, Jun 8, 2006.

  1. Electronic Punk

    Electronic Punk Administrator Staff Member Political User Folding Team

    Messages:
    18,590
    Location:
    Copenhagen, Denmark
    Here is the function that I think is causing all the problems:

    PHP:
    function validateuser($userid,$userpassword) {

      global 
    $inadmin,$vb_prefix,$vb_license,$HTTP_POST_VARS;

      if (
    $userid 0) {

        
    $userinfo query_first("SELECT
          "
    .$vb_prefix."user.usergroupid,
          "
    .$vb_prefix."user.username,
          "
    .$vb_prefix."user.salt,
          "
    .$vb_prefix."user.userid,
          "
    .$vb_prefix."user.password,
          "
    .$vb_prefix."user.email,
          "
    .$vb_prefix."user.options,
          "
    .$vb_prefix."user.pmunread,
          "
    .$vb_prefix."usergroup.genericoptions,
          news_staff.*
          FROM "
    .$vb_prefix."user
          INNER JOIN "
    .$vb_prefix."usergroup ON ".$vb_prefix."user.usergroupid = ".$vb_prefix."usergroup.usergroupid
          LEFT JOIN news_staff ON "
    .$vb_prefix."user.userid = news_staff.userid
          WHERE "
    .$vb_prefix."user.userid = $userid");

        if (
    $userinfo) {

          if (
    $inadmin & !empty($HTTP_POST_VARS[username])) {
            
    $userpassword md5(md5($userpassword.$userinfo[salt]).$vb_license);
          }

          if ((
    md5($userinfo[password] . $vb_license)) == $userpassword) {
            if ((
    $userinfo[usergroupid] != 3) & ($userinfo[usergroupid] != 4)) {
              if (
    $userinfo[genericoptions] & 32) {
                unset(
    $userinfo);
                if (
    $inadmin) {
                  return 
    false;
                } else {
                  
    standarderror("user_banned");
                }
              }

              if (
    $GLOBALS[getpmmsg] & !$inadmin) {
                
    $GLOBALS[num_private_msgs] = $userinfo[pmunread];
              }

              
    $userinfo[viewsigs] = iif($userinfo[options] & 1,1,0);
              
    $userinfo[activated] = 1;
              
    $userinfo[moderated] = 1;
              
    $userinfo[showemail] = iif($userinfo[options] & 256,1,0);
              
    $userinfo[emailnotification] = iif($userinfo[options] & 16384,1,0);
              
    $userinfo[commentdefault] = $GLOBALS[commentreplydefault];

              return 
    $userinfo;
            } else { 
    // Account not activated
              
    unset($userinfo);
              return 
    false;
            }
          } else { 
    // Password wrong
            
    unset($userinfo);
            return 
    false;
          }
        } else { 
    // Userid wrong
          
    unset($userinfo);
          return 
    false;
        }
      } else { 
    // No userid
        
    unset($userinfo);
        return 
    false;
      }
    }
    Late last night I had to remove both

    Code:
          } elseif ($userinfo[bandate] & (($userinfo[liftdate] == 0) | (time() < $userinfo[liftdate]))) {
            $error = "user_banned";
    and

    Code:
                } else {
                  standarderror("user_banned");
    To trick the frontpage into working correctly.
    Really needed Tingle's help with this but he is offline at the moment.

    the issue comes from vBulletin switching the flag on whether a user is banned. ie what once was 0 is now 1, so Virtuanews thinks the user is banned. Quite annoying. I am pretty sure all the other Virtuanews functions are working fine.

    Anyone that can make head or tail of this?
     
    Last edited: Jun 8, 2006
  2. Electronic Punk

    Electronic Punk Administrator Staff Member Political User Folding Team

    Messages:
    18,590
    Location:
    Copenhagen, Denmark
    Looks like just the second bit of code needed to be removed.
    Might just even be this line here:

    if ($userinfo[genericoptions] & 32) {

    Before if that field contained a 32 the user was banned, now if it doesn't they are banned. Not sure how to reverse it !& did not work
     
  3. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    thats a logial AND operation. its bitmasking :)
     
  4. Electronic Punk

    Electronic Punk Administrator Staff Member Political User Folding Team

    Messages:
    18,590
    Location:
    Copenhagen, Denmark
    Dunno what it is....

    Code:
              if ($userinfo[genericoptions] & 32) {
                unset($userinfo);
                if ($inadmin) {
                  return false;
                } else {
                  standarderror("user_banned");
                }
    Snipped all that out anyway and the frontpage is temp. working.
    Which is ****ing great news.

    Dunno what the implications of what I have done might be tho, will have to test that now.
     
  5. Electronic Punk

    Electronic Punk Administrator Staff Member Political User Folding Team

    Messages:
    18,590
    Location:
    Copenhagen, Denmark
    If I can figure out why vBulletin doesn't like its own damn Javascript I will be laughing :)
     
  6. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    Could try using invision instead :p
     
  7. Electronic Punk

    Electronic Punk Administrator Staff Member Political User Folding Team

    Messages:
    18,590
    Location:
    Copenhagen, Denmark
    Why the hell would I even consider that? :p
     
  8. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    Because invision is the way of the future :p

    Might be a good idea to find a replacement for vNews.
     
  9. Electronic Punk

    Electronic Punk Administrator Staff Member Political User Folding Team

    Messages:
    18,590
    Location:
    Copenhagen, Denmark
    Nah no need now, is sorted. Will ask Tingle to fix the function if I see him.
     
  10. kcnychief

    kcnychief █▄█ ▀█▄ █ Political User Folding Team

    Messages:
    16,948
    Location:
    Massachusetts
    Oooor we could just code our own front page news portal?