Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wyjaśnienie kilka spraw dot. skryptu.
Krisu
post 4.05.2008, 13:46:36
Post #1





Grupa: Zarejestrowani
Postów: 211
Pomógł: 0
Dołączył: 30.03.2006
Skąd: Żary

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


Otóż korzystam, ze skryptu, który uploaduje zdjęcia na imageshack.

Mam teraz prośbę, gdyż planuję rozszerzyć skrypt o nowe serwery np. fotosik.pl, ale nie wiem dokładnie jak to zrobić.
Proszę o wskazówki a postaram się sam to zrobić.

Mam problemy ze zrozumieniem zmiennej $AaB03x. Ktoś pomoże?

Skrypt:
  1. <?php
  2.  
  3. function imageshackUpload($filename){
  4. $sock = @fsockopen("www.imageshack.us", 80, $errno, $errstr, 30);
  5.  
  6. $handle = fopen($filename, "r");
  7. $binarydata = fread($handle, filesize($filename));
  8. fclose($handle);
  9.  
  10. $mimetype = 'image/png';
  11.  
  12. $AaB03x = "--AaB03xr\n";
  13. $AaB03x .="content-disposition: form-data; name=\"uploadtype\"r\nr\n";
  14.  
  15. $AaB03x .= "onr\n";
  16. $AaB03x .= "--AaB03xr\n";
  17. $AaB03x .= "content-disposition: form-data; name=\"fileupload\"; filename=\"".basename($filename)."\"r\n";
  18. $AaB03x .= "Content-Type: $mimetyper\n";
  19. $AaB03x .= "Content-Transfer-Encoding: binaryr\nr\n";
  20.  
  21. $AaB03x .= "$binarydatar\n";
  22. $AaB03x .= "--AaB03x--r\n";
  23.  
  24. $header = "POST / HTTP/1.1r\n";
  25. $header .= "Host: www.imageshack.usr\n";
  26. $header .= "Content-type: multipart/form-data, boundary=AaB03xr\n";
  27. $header .= "Content-Length: ".strlen($AaB03x)."r\nr\n";
  28.  
  29. $header .= $AaB03x;
  30.  
  31. fwrite($sock, $header);
  32.  
  33. while (!feof($sock)){
  34. $response .= fgets($sock, 128);
  35. }
  36.  
  37. fclose($sock);
  38.  
  39. preg_match_all("#<input type=\"text\" onclick=\"highlight(this)\" style=\"width: 500px\" size=\"70\" value=\"[img](.*)[/img]\"/>#", $response, $matches);
  40.  
  41. return $matches[1][0];
  42. }
  43.  
  44. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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: 14.08.2025 - 03:13