Results 1 to 4 of 4

Thread: Any PHP/cURL/vBulletin experts out there?

  1. #1
    Only here for the free Wi-Fi Site Admin Spiderman's Avatar
    Join Date
    Aug 2000
    Location
    Wheat Ridge
    Posts
    8,471

    Any PHP/cURL/vBulletin experts out there?

    I'm trying to write a program that ties into the forum software to send a private message. The program will be called by an admin while they're logged in to the forum, so I have all the security & cookie info. Because it's a POST request, things are a little more complicated. I'm pretty sure I'm stuck trying to get the cookies set properly for the "new session". Documentation isn't the best, so I'm not even sure if I'm doing it right.

    I've tried php with fsockopen... (I'm sending $_COOKIE as the parameter value for $cookies):
    Code:
    ...
      $parts=parse_url($url);
     
      $fp = fsockopen($parts['host'], 
              isset($parts['port'])?$parts['port']:80, 
              $errno, $errstr, 30);
      if (!$fp) {
          return false;
      } else {
          $out = "POST ".$parts['path']." HTTP/1.1\r\n";
          $out.= "Host: ".$parts['host']."\r\n";
          $out.= "Content-Type: application/x-www-form-urlencoded\r\n";
          $out.= "Content-Length: ".strlen($parts['query'])."\r\n";
     
          foreach( $cookies as $name => $value )
          {
           if ($name == "cscvbsessionhash" 
           || $name == "cscvblastvisit" 
           || $name == "cscvblastactivity")
           { 
             $out .= 'Cookie: ' . $name . '=' . $value . "\r\n";
            }
          }
          $out.= "Connection: Close\r\n\r\n";
          if (isset($parts['query'])) $out.= $parts['query'];
     
          // for debugging
          echo "<p>";
          echo "out = " . $out;
          echo "<p>";
     
          fwrite($fp, $out);
     
          // for debugging
          while (!feof($fp)) {
            echo fgets($fp, 128);
          }
     
          fclose($fp);
          return true;
      }
    and cURL:

    Code:
    ...
    $ch = curl_init('http://www.cosportbikeclub.org/forums/private.php');
    curl_setopt ($ch, CURLOPT_POST, 1);
    foreach( $_COOKIE as $name => $value )
    {
     if ($name == "cscvbsessionhash" 
     || $name == "cscvblastvisit" 
     || $name == "cscvblastactivity")
     {
      // I even added domain & path, but to no avail
      curl_setopt ($ch, CURLOPT_COOKIE, $name . "=" . $value . "domain=.www.cosportbikeclub.org; path=/");
     }
    }
     
    curl_setopt
    (
     $ch, CURLOPT_POSTFIELDS, 
      urlencode
      (
       "&do=insertpm"
       . <other parameters go here>
         )
    );
    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_exec ($ch);
    curl_close ($ch);
    and even tho I was logged in to the forum when I clicked the link to call the page with the above code (both sets of code end with the same result), the (debugging) page I end up on indicates that I'm not logged in (User Name & Password box appear on top-right, along with Log In button), and there's an error message:
    Sorry. The administrator has banned your IP address. To contact the administrator click here

    I'm not really banned tho, or even entirely logged out - if I click on Today's Posts, the next page shows me as being logged in (Username, last visit date, & notifications take the place of the User Name & Password box & Log In button).

    I've already wasted 2 days getting to this point, and another day trying to get past it. Any help would be greatly appreciated.

    TIA
    Bob <------ Asshole Nazi devil moderator out to get each and every one of you
         - 2002 Yamaha R1 (92K+ miles... bought new) ---------------------------------------->
         - 2015 Yamaha Bolt C-Spec (Cafe Racer)
         - 2004 Yamaha R6 (racebike)
         - 2006 Yamaha R1 (racebike)
    R.I.P. 502
    ~ Everything works out in the end. If it hasn't worked out, it isn't the end.

  2. #2
    Senior Member mclarke's Avatar
    Join Date
    May 2006
    Location
    Denver, CO
    Posts
    1,840

    Re: Any PHP/cURL/vBulletin experts out there?

    Lemme look at it when I get home Bob. Please stand by...

    No matter our intentions, when we kill the innocent, we become the enemy.


  3. #3
    Only here for the free Wi-Fi Site Admin Spiderman's Avatar
    Join Date
    Aug 2000
    Location
    Wheat Ridge
    Posts
    8,471

    Re: Any PHP/cURL/vBulletin experts out there?

    Thanks Matt... FWIW, I found some help here, including what was supposed to be a solution to the problem I posted yesterday (see link in last comment/post near bottom of page), but that solution doesn't seem to be working.
    Bob <------ Asshole Nazi devil moderator out to get each and every one of you
         - 2002 Yamaha R1 (92K+ miles... bought new) ---------------------------------------->
         - 2015 Yamaha Bolt C-Spec (Cafe Racer)
         - 2004 Yamaha R6 (racebike)
         - 2006 Yamaha R1 (racebike)
    R.I.P. 502
    ~ Everything works out in the end. If it hasn't worked out, it isn't the end.

  4. #4
    Senior Member mclarke's Avatar
    Join Date
    May 2006
    Location
    Denver, CO
    Posts
    1,840

    Re: Any PHP/cURL/vBulletin experts out there?

    Now that is a funky error message... wow!

    I am still trying to figure out what is wrong with your php script. I am curious why it is not reading the cookie... Let me open my local one and see if I can find this.

    Excellent problem

    No matter our intentions, when we kill the innocent, we become the enemy.


Similar Threads

  1. Any MRA experts interested in my 2 digit number?
    By specialk_34 in forum The Pros
    Replies: 6
    Last Post: Fri May 20th, 2005, 11:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •