Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [CURL][PHPBB] logowanie do panelu admina
Forum PHP.pl > Forum > Gotowe rozwiązania > Skrypty forum
blexth
witam, mam klasę do logowania się przez curl do phpbb na usera, żeby można po prostu napisać temat itp, a w jaki sposób można zalogować się do panelu admina (znając oczywiście dane?), próbowałem po prostu zmienić ścieżkę z login.php na admin/index.php, ale nie działa any idea?
Cysiaczek
To nie ma nic wspólnego z OOP.

Przenoszę na Gotowe rozwiązania -> Skrypty forum


Wydaje mi się, że musisz podać więcej szczegółów.

Pozdrawiam.
blexth
no to podaję funkcję logującą

  1. <?php
  2. function login($username, $password)
  3. {
  4. global $_SERVER;
  5.  
  6. // Generate post string
  7. $post_fields = $this->array_to_http(array(
  8. 'username' => $username,
  9. 'password' => $password,
  10. 'autologin' => 1,
  11. 'redirect' => 'admin/index.php',
  12. 'login' => 'Log In',
  13. ));
  14. // Init curl
  15. $this->curl = curl_init();
  16. // Set options
  17. curl_setopt ( $this->curl, CURLOPT_URL, $this->phpbb_url . 'login.php?redirect=admin/index.php' );
  18. curl_setopt ( $this->curl, CURLOPT_POST, true );
  19. curl_setopt ($ch, CURLOPT_REFERER, "http://adresforum.pl/admin/index.php"); 
  20. curl_setopt ( $this->curl, CURLOPT_POSTFIELDS, $post_fields );
  21. curl_setopt ( $this->curl, CURLOPT_RETURNTRANSFER, true );
  22. curl_setopt ( $this->curl, CURLOPT_HEADER, false );
  23. curl_setopt ( $this->curl, CURLOPT_COOKIE, $this->cookie_name );
  24. curl_setopt ( $this->curl, CURLOPT_COOKIEJAR, $this->cookie_name );
  25. curl_setopt ( $this->curl, CURLOPT_COOKIEFILE, $this->cookie_name );
  26. curl_setopt ( $this->curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
  27. // Execute request
  28. $result = curl_exec ( $this->curl );
  29. // Error handling
  30. if ( curl_errno ( $this->curl ) )
  31. {
  32. $this->error = array(
  33. curl_errno($this->curl),
  34. curl_error($this->curl),
  35. );
  36. curl_close ( $this->curl );
  37. return false;
  38. }
  39. // Close connection
  40. curl_close ( $this->curl );
  41. // Return result
  42. return true;
  43. }
  44. ?>


ten sposób po prostu nie działa, nie wychodzi logowanie na admina
nowotny
Ja bym podsniffował jak przebiega logowanie do admina... jak wygląda POST i wtedy odpowiednio zmodyfikował $post_fields...
blexth
przejrzalem, jedyna roznica to zamiast Log in jest 'zaloguj', ale ciagle nie dziala.

czyli nie da sie?
nowotny
Skąd wiesz że nie działa...? jak to sprawdzasz...?

Pokaż no to co wysniffowałeś... cały nagłówek...
blexth
bo odpalam file_get_contents (index.php) i w indeksie jest spoko zalogowany a jak odpalam na admin/index.php to nie jest ];

wysniffowane:
Kod
POST /forum/login.php HTTP/1.1

Host: adres.pl

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20060629 Firefox/1.0.4 (Debian package 1.0.4-2sarge9)

Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

Accept-Language: en-us,en;q=0.7,pl;q=0.3

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Connection: keep-alive

Referer: http://adres/forum/login.php?redirect=admin/index.php&admin=1&sid=6fd93ab3829593e52eb47b3262c64f52

Cookie: phpbb3_gs1bp_k=; style_cookie=printonly; phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22userid%22%3Bs%3A1%3A%222%22%3B%7D; phpbb3_gs1bp_sid=230ee99d52e0fb0e9d3e9824523b74fd; phpbb3_gs1bp_u=2; __utmz=38071927.1200687138.104.8.utmccn=(referral)|utmcsr=shou.pl:2082|utmcct=/frontend/x3/stats/lastvisit.html|utmcmd=referral; __utma=38071927.229132273.1195373403.1202232064.1202243595.122; PHPSESSID=0283166399260e2f6690582bf7b0cf18; __utmb=38071927; __utmc=38071927; phpbb2mysql_sid=6fd93ab3829593e52eb47b3262c64f52

Content-Type: application/x-www-form-urlencoded

Content-Length: 94

username=login&password=pass&redirect=admin%2Findex.php%3Fadmin%3D1&admin=1&login=Zaloguj
nowotny
Tak to wg. mnie powinno wyglądać:
  1. <?php
  2. function login($username, $password)
  3. {
  4. global $_SERVER;
  5.  
  6. // Generate post string
  7. $post_fields = $this->array_to_http(array(
  8. 'username' => $username,
  9. 'password' => $password,
  10. 'autologin' => 1,
  11. 'redirect' => 'admin/index.php?admin=1',
  12. 'admin' => 1
  13. 'login' => 'Zaloguj',
  14. ));
  15. // Init curl
  16. $this->curl = curl_init();
  17. // Set options
  18. curl_setopt ( $this->curl, CURLOPT_URL, $this->phpbb_url . 'login.php' );
  19. curl_setopt ($this->curl, CURLOPT_FOLLOWLOCATION,1);
  20.  curl_setopt ( $this->curl, CURLOPT_POST, true );
  21. curl_setopt ($this->curl, CURLOPT_REFERER, $this->phpbb_url.'login.php?redirect=admin/index.php&admin=1'); 
  22.  curl_setopt ( $this->curl, CURLOPT_POSTFIELDS, $post_fields );
  23. curl_setopt ( $this->curl, CURLOPT_RETURNTRANSFER, true );
  24. curl_setopt ( $this->curl, CURLOPT_HEADER, false );
  25. curl_setopt ( $this->curl, CURLOPT_COOKIE, $this->cookie_name );
  26. curl_setopt ( $this->curl, CURLOPT_COOKIEJAR, $this->cookie_name );
  27. curl_setopt ( $this->curl, CURLOPT_COOKIEFILE, $this->cookie_name );
  28. curl_setopt ( $this->curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
  29. // Execute request
  30. $result = curl_exec ( $this->curl );
  31. // Error handling
  32. if ( curl_errno ( $this->curl ) )
  33. {
  34. $this->error = array(
  35. curl_errno($this->curl),
  36. curl_error($this->curl),
  37. );
  38. curl_close ( $this->curl );
  39. return false;
  40. }
  41. // Close connection
  42. curl_close ( $this->curl );
  43. // Return result
  44. return true;
  45. }
  46. ?>
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.