Skip to content
WJunction - Webmaster Forum

[PHP] Login to vBulletin

Status
Not open for further replies.

skinner

Experienced Member
741
2010
59
Hi,

I'm trying to login with my php page to 1 forum vbulletin 4.2.

I use that code:

PHP:
function vBulletinLogin($user, $pass) { 

    $md5Pass = md5($pass); 
    $data = "?do=login&url=%2Findex.php&securitytoken=guest&vb_login_md5password=$md5Pass&vb_login_md5password_utf=$md5Pass&vb_login_username=$user&cookieuser=1"; 

    $ch = curl_init(); 

    curl_setopt($ch, CURLOPT_URL, "http://www.domain.com/forums/login.php"); 
    curl_setopt($ch, CURLOPT_REFERER, 'http://www.domain.comt/forums/index.php');
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
    curl_setopt($ch, CURLOPT_TIMEOUT, '40'); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
    curl_setopt($ch, CURLOPT_COOKIEJAR, "temp/codecall_$user.txt"); 
    curl_setopt($ch, CURLOPT_COOKIEFILE, "temp/codecall_$user.txt"); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    $store = curl_exec ($ch); 
    curl_close($ch); 
    //echo $store;

    $pos = strpos($store, "Thank you for Logging in"); 
    if ($pos === FALSE) { 
      return 0; 
    } else { 
      return 1; 
    } 

  } 

  if (vBulletinLogin("username","password")) { 
    echo "Logged In"; 
  } else { 

    echo "Failed to Login check User / Pass"; 
  }

But it won't work. What do I write wrong?

Thanks
 

11 comments

Is this your own code?
What I do when faceing such task is to go to the site, and do a login while logging everything sent and received by the browser with Firebug or Chrome's developer tools, then I recreate that stuff with curl.
 
if that forum host enable php curl then you can't login
the php curl must be disable then you can use your curl script
 
hi, i just found this post and your code is interesting as i am trying to do something similar. My guess is that its not working because you don't provide salted password. VB stores password in md5 with salt.
 
hi, i just found this post and your code is interesting as i am trying to do something similar. My guess is that its not working because you don't provide salted password. VB stores password in md5 with salt.

My problem was that forum was not in english so I had to change some variables..
 
maybe missing the GET do=login?

curl_setopt($ch, CURLOPT_URL, "http://www.domain.com/forums/login.php?do=login");
 
Status
Not open for further replies.

About the author

S
Experienced Member · Joined
741
Messages
59
Reactions
28
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom