Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Zdalne logowanie go phpbb nie działa
radmistrz2
post 3.04.2008, 09:03:39
Post #1





Grupa: Zarejestrowani
Postów: 143
Pomógł: 4
Dołączył: 2.03.2008

Ostrzeżenie: (10%)
X----


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

Ten post edytował radmistrz2 3.04.2008, 09:04:38
Go to the top of the page
+Quote Post
Crozin
post 3.04.2008, 09:25:29
Post #2





Grupa: Zarejestrowani
Postów: 6 476
Pomógł: 1306
Dołączył: 6.08.2006
Skąd: Kraków

Ostrzeżenie: (0%)
-----


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, ...);
Go to the top of the page
+Quote Post
radmistrz2
post 3.04.2008, 10:04:09
Post #3





Grupa: Zarejestrowani
Postów: 143
Pomógł: 4
Dołączył: 2.03.2008

Ostrzeżenie: (10%)
X----


niestety to nie pomogło
Go to the top of the page
+Quote Post
Sabistik
post 3.04.2008, 17:05:32
Post #4


Administrator wortalu


Grupa: Przyjaciele php.pl
Postów: 960
Pomógł: 39
Dołączył: 21.10.2003
Skąd: Kraków

Ostrzeżenie: (0%)
-----


To może przedstawienie nam treści błędu lekko ułatwi sprawę?
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 6.07.2025 - 15:52