Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Zdalne logowanie go phpbb nie działa
Forum PHP.pl > Forum > PHP
radmistrz2
Mam taki skrypt:

  1. <?php
  2.  
  3. function login($username, $password)
  4. {
  5. global $_SERVER;
  6.  
  7. // Generate post string
  8. $post_fields = $this->array_to_http(array(
  9. 'username' => $username,
  10. 'password' => $password,
  11. 'autologin' => 1,
  12. 'redirect' => 'index.php',
  13. 'login' => 'Zaloguj'
  14. ));
  15. // Definiowanie cURL'a
  16. $this->curl = curl_init();
  17. // Set options
  18. curl_setopt ( $this->curl, CURLOPT_URL, $this->phpbb_url . 'login.php?redirect=index.php' );
  19. curl_setopt ( $this->curl, CURLOPT_POST, true );
  20. curl_setopt ($ch, CURLOPT_REFERER, "http://www.przykładowastrona.pl/forum/index.php"); 
  21.  curl_setopt ( $this->curl, CURLOPT_POSTFIELDS, $post_fields );
  22. curl_setopt ( $this->curl, CURLOPT_RETURNTRANSFER, true );
  23. curl_setopt ( $this->curl, CURLOPT_HEADER, false );
  24. curl_setopt ( $this->curl, CURLOPT_COOKIE, $this->cookie_name );
  25. curl_setopt ( $this->curl, CURLOPT_COOKIEJAR, $this->cookie_name );
  26. curl_setopt ( $this->curl, CURLOPT_COOKIEFILE, $this->cookie_name );
  27. curl_setopt ( $this->curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4');
  28. // Logowanie
  29. $result = curl_exec ( $this->curl );
  30. // Diagnoza błędu
  31. if ( curl_errno ( $this->curl ) )
  32. {
  33. $this->error = array(
  34. curl_errno($this->curl),
  35. curl_error($this->curl),
  36. );
  37. curl_close ( $this->curl );
  38. return false;
  39. }
  40. // Rozłączanie
  41. curl_close ( $this->curl );
  42. // Prawidłowy wynik
  43. return true;
  44. }
  45.  
  46. ?>

No i gdy wywołam stworzonąfunkcję nie loguje mnie. Co jest nie tak? Wywala mi błąd w 8 linijce kodu
Crozin
1) $_SERVER jest tablicą superglobalną - nie trzeba jej globalem traktować
2) Na lini #20 masz: curl_setopt($ch, ...); a chyba powinno być curl_setopt($this->curl, ...);
radmistrz2
niestety to nie pomogło
Sabistik
To może przedstawienie nam treści błędu lekko ułatwi sprawę?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.