Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [inne][PHP]Krzaki w curlu.., Krzaki w wysyłanym poście.
RaitoPL
post 27.08.2012, 23:39:12
Post #1





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 17.07.2012

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


Witam. Mam problem. Napisałem prostego bota dodającego posty do mojego forum za pomocą CURL'a. Ale problem jest taki, że wysyła krzaki.. Jak to zmienić? Kodowanie pliku = utf-8, nie mam pojęcia, co jest nie tak. Jeśli ktoś byłby mi w stanie pomóc - będę wdzięczny. Dodam, że nie mogę używać żadnych osobnych bibliotek, ponieważ skrypt musi działać na każdym serwerze (nie - nie spam-bot).
Pozdrawiam.
Go to the top of the page
+Quote Post
Aqu
post 28.08.2012, 00:14:08
Post #2





Grupa: Zarejestrowani
Postów: 279
Pomógł: 58
Dołączył: 14.07.2012

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


Sprawdź:
  1. curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
Go to the top of the page
+Quote Post
RaitoPL
post 28.08.2012, 00:32:51
Post #3





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 17.07.2012

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


Nadal krzaki ;/
Go to the top of the page
+Quote Post
untorched
post 28.08.2012, 01:01:48
Post #4





Grupa: Zarejestrowani
Postów: 318
Pomógł: 76
Dołączył: 27.12.2011
Skąd: Dąbrowa Górnicza

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


Może pokaż trochę kodu
Go to the top of the page
+Quote Post
RaitoPL
post 28.08.2012, 21:26:25
Post #5





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 17.07.2012

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


  1. <?php
  2. $f['username'] = 'x';
  3. $f['password'] = 'x';
  4. $f['redirect'] = '';
  5. $f['login'] = 'Zaloguj';
  6. $tytul = mysql_real_escape_string(htmlspecialchars($_POST['tytul']));
  7. $message = mysql_real_escape_string(htmlspecialchars($_POST['opis']));
  8. $l = $link . '/login.php';
  9.  
  10. $ch = curl_init();
  11. curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  13. curl_setopt($ch, CURLOPT_URL, $l);
  14. curl_setopt($ch, CURLOPT_POST, 1);
  15. curl_setopt($ch, CURLOPT_POSTFIELDS, $f);
  16. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  17. curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
  18. curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookies.txt');
  19. curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookies.txt');
  20. curl_setopt($ch, CURLOPT_HEADER, 1);
  21. $headers = array('Accept-Language: pl,en-us;q=0.7,en;q=0.3',
  22. 'Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7');
  23. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  24. curl_exec($ch);
  25.  
  26. curl_setopt($ch, CURLOPT_URL, "$temat");
  27. curl_setopt($ch, CURLOPT_POSTFIELDS, "&subject=$tytul&t=$message&mode=newtopic&message=".urlencode($message)."&post=Submit");
  28. $result = curl_exec($ch);
  29. $pattern = '#<a href="(.*?)">Tutaj</a>#';
  30. $ile = preg_match_all($pattern, $result, $matches, PREG_PATTERN_ORDER);
  31. //print_r($matches);
  32. //echo $matches[1][0];
  33. $zwrot = $link . '/' . $matches[1][0];
  34. echo "$i. $zwrot <br>";
  35.  
  36. curl_close($ch);
  37.  
  38. //preg_match('#<a href="(.*?)">Tutaj</a>#', $adres, $link);
  39. //echo $link[1];
  40. //print_r($link);
  41. //echo $result;
  42.  
  43.  
  44. ?>
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: 27.04.2024 - 08:13