Witam na forum smile.gif

Próbuję zrobić automatyczne logowanie z mojej strony na forum. Z phpBB i vBulletin dałem sobie radę, ale mam problem z Invision Power Board. Mam taki skrypt:

index.php:
  1. <?php
  2.  
  3. // Init class
  4. include('curl_phpbb.class.php');
  5. include('curl_vbull.class.php');
  6. include('curl_ipb.class.php');
  7.  
  8. // The ending backslash is required.
  9. $ipb = new curl_ipb('urlforum');
  10.  
  11. // Log in
  12. $ipb->login('logindoforum', 'hasło');
  13.  
  14. // Read index
  15. echo $ipb->read('index.php');
  16.  
  17. ?>


curl_ipb.class.php:
  1. <?php
  2. class curl_ipb
  3. {
  4.  var $curl = null;
  5.  var $cookie_name = array();
  6.  var $ipb_url = null;
  7.  var $error = array();
  8.  function curl_ipb($ipb_url, $cookie_name = 'tmpfile.tmp')
  9.  {
  10.  // Check CURL is present
  11.  if ( ! function_exists ( 'curl_init') )
  12.  {
  13.  // Output an error message
  14.  trigger_error('curl_ipb::error, Sorry but it appears that CURL is not loaded, Please install it
     to continue.'
    );
  15.  return false;
  16.  }
  17.  if ( empty($ipb_url) )
  18.  {
  19.  // Output an error message
  20.  trigger_error('curl_ipb::error, The ipb location is required to continue, Please edit your scri
    pt.'
    );
  21.  return false;
  22.  }
  23.  // Set base location
  24.  $this->ipb_url = $ipb_url;
  25.  // Create temp file
  26.  $this->cookie_name = $cookie_name;
  27.  }
  28.  
  29.  /*
  30.  @ Function : login() - Log In
  31.  @ About : Does a remote login to the target ipb and stores in cookie
  32.  @ Type : Public
  33.  */
  34.  function login($username, $password)
  35.  {
  36.  global $_SERVER;
  37.  
  38.  // Generate post string
  39.  $post_fields = $this->array_to_http(array(
  40.  'referer' => $this->ipb_url,
  41.  'CookieDate' => 1,
  42.  'UserName' => $username,
  43.  'PassWord' => $password,
  44.  ));
  45.  // Init curl
  46.  $this->curl = curl_init();
  47.  // Set options
  48.  curl_setopt ( $this->curl, CURLOPT_URL, $this->ipb_url . 'index.php?act=login&CODE=00' );
  49.  curl_setopt ( $this->curl, CURLOPT_POST, true );
  50.  curl_setopt ( $this->curl, CURLOPT_POSTFIELDS, $post_fields );
  51.  curl_setopt ( $this->curl, CURLOPT_RETURNTRANSFER, true );
  52.  curl_setopt ( $this->curl, CURLOPT_HEADER, false );
  53.  curl_setopt ( $this->curl, CURLOPT_COOKIE, $this->cookie_name );
  54.  curl_setopt ( $this->curl, CURLOPT_COOKIEJAR, $this->cookie_name );
  55.  curl_setopt ( $this->curl, CURLOPT_COOKIEFILE, $this->cookie_name );
  56.  curl_setopt ( $this->curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
  57.  // Execute request
  58.  $result = curl_exec ( $this->curl );
  59.  // Error handling
  60.  if ( curl_errno ( $this->curl ) )
  61.  {
  62.  $this->error = array(
  63.  curl_errno($this->curl),
  64.  curl_error($this->curl),
  65.  );
  66.  curl_close ( $this->curl );
  67.  return false;
  68.  }
  69.  // Close connection
  70.  curl_close ( $this->curl );
  71.  // Return result
  72.  return true;
  73.  }
  74.  
  75.  /*
  76.  @ Function : read() - Read a pages contents
  77.  @ About : Returns the contents of a url
  78.  @ Type : Public
  79.  */
  80.  function read($page_url)
  81.  {
  82.  global $_SERVER;
  83.  
  84.  // Init curl
  85.  $this->curl = curl_init();
  86.  // Set options
  87.  curl_setopt ( $this->curl, CURLOPT_URL, $this->ipb_url . $page_url );
  88.  curl_setopt ( $this->curl, CURLOPT_POST, false );
  89.  curl_setopt ( $this->curl, CURLOPT_RETURNTRANSFER, true );
  90.  curl_setopt ( $this->curl, CURLOPT_HEADER, false );
  91.  curl_setopt ( $this->curl, CURLOPT_COOKIE, $this->cookie_name );
  92.  curl_setopt ( $this->curl, CURLOPT_COOKIEJAR, $this->cookie_name );
  93.  curl_setopt ( $this->curl, CURLOPT_COOKIEFILE, $this->cookie_name );
  94.  curl_setopt ( $this->curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
  95.  // Execute request
  96.  $result = curl_exec ( $this->curl );
  97.  // Error handling
  98.  if ( curl_errno ( $this->curl ) )
  99.  {
  100.  $this->error = array(
  101.  curl_errno($this->curl),
  102.  curl_error($this->curl),
  103.  );
  104.  curl_close ( $this->curl );
  105.  return false;
  106.  }
  107.  // Close connection
  108.  curl_close ( $this->curl );
  109.  // Return result
  110.  return $result;
  111.  }
  112.  
  113. ...kolejne funkcje, niewa&#380;ne bo nie są używane do logowania
  114. ?>


Używając skryptu do logowania na vB i phpBB zmieniałem nazwy i zawartość $post_fields. Z iPB próbowałem z różnymi kombinacjami, ale nic to nie dało. Po otworzeniu index.php otrzymuję białą, pustą stronę.