Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Na localhost (XAMPP) działa na serwerze nie.
Forum PHP.pl > Forum > Przedszkole
desavil
Witam, mam taki skrypt:
  1. <?php
  2. $file_id = $_GET[file_id];
  3. $file = $_GET[file];
  4. $link = "http://xxx:xxx@hotfile.com/dl/$file_id/$file/";
  5.  
  6. $genlink = file_get_contents("http://hotfile.com/dl/$file_id/$file/");
  7. $genlink_zmien = explode('<div class="arrow_down"><strong>Pobieranie:</strong> ', $genlink);
  8. $genlink_zmien2 = explode(' <span>|</span> <strong>', $genlink_zmien[1]);
  9. $genlink_zmien3 = explode(' MB</strong></div>', $genlink_zmien2[1]);
  10. $size = 1024*1024*$genlink_zmien3[0];
  11.  
  12. $nazwa_pliku = $genlink_zmien2[0];
  13. $nazwa_pliku_bezspacji = str_replace(" ","_",$nazwa_pliku);
  14. $file_extension = strtolower(substr(strrchr($nazwa_pliku,"."),1));
  15. switch($file_extension){
  16. case "exe": $ctype="application/octet-stream"; break;
  17. case "zip": $ctype="application/zip"; break;
  18. case "mp3": $ctype="audio/mpeg"; break;
  19. case "mpg": $ctype="video/mpeg"; break;
  20. case "flv": $ctype="video/flv"; break;
  21. default: $ctype="application/force-download";
  22. }
  23.  
  24. $size2=$size-1;
  25. header("Pragma: public"); // required
  26. header("Expires: 0");
  27. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  28. header("Cache-Control: private",false);
  29. header("Content-Type: $ctype");
  30. header("Content-Disposition: attachment; filename=$nazwa_pliku_bezspacji");
  31. header("Content-transfer-encoding: binary");
  32. header("Content-Length: $size");
  33. header("Content-Range: bytes $size2/$size");
  34. @readfile($link);
  35. ?>

Na XAMMPie w localhost działa skrypt poprawnie, bez problemów się ściąga pliki, a na serwerze nie. Co jest nie tak?

Wywala taki błąd na serwerze www:
Cytat
Warning: file_get_contents(http://hotfile.com/dl/39878927//) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in /home/xxxx/domains/domena.pl/public_html/hf.php on line 6

Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/domains/domena.pl/public_html/hf.php:6) in /home/xxxx/domains/domena.pl/public_html/hf.php on line 25

Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/domains/domena.pl/public_html/hf.php:6) in /home/xxxx/domains/domena.pl/public_html/hf.php on line 26

Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/domains/domena.pl/public_html/hf.php:6) in /home/xxxx/domains/domena.pl/public_html/hf.php on line 27

Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/domains/domena.pl/public_html/hf.php:6) in /home/xxxx/domains/domena.pl/public_html/hf.php on line 28

Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/domains/domena.pl/public_html/hf.php:6) in /home/xxxx/domains/domena.pl/public_html/hf.php on line 29

Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/domains/domena.pl/public_html/hf.php:6) in /home/xxxx/domains/domena.pl/public_html/hf.php on line 30

Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/domains/domena.pl/public_html/hf.php:6) in /home/xxxx/domains/domena.pl/public_html/hf.php on line 31

Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/domains/domena.pl/public_html/hf.php:6) in /home/xxxx/domains/domena.pl/public_html/hf.php on line 32

Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/domains/domena.pl/public_html/hf.php:6) in /home/xxxx/domains/domena.pl/public_html/hf.php on line 33


Pozdrawiam i proszę o pomoc.
desavil
H4eX, bardzo mądre rozwiązanie, da mi to tylko to iż błąd
Cytat
Warning: file_get_contents(http://hotfile.com/dl/39878927//) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in /home/xxxx/domains/domena.pl/public_html/hf.php on line 6

będzie można zapisać do pliku i w pliku pojawi się ten błąd...
H4eX
Przeczytałeś w ogóle wszystko!?

metoda 2.
Dodaj do pliku .htaccess znajdującego się w katalogu głównym:
  1. PHP_FLAG output_buffering on


lub jeśli masz dostęp do pliku php.ini to dopisz w nim/zmień:
  1. output_buffering=on;
desavil
Coś pomogło, ale pobiera plik z rozmiarem 0baitów i o nazwie takiej samej jak nazwa pliku php :/

Nierozumnie tylko tego, że u mnie na komputerze działa, a na serwerze nie :/

Może zmienić jakąś funkcje w php.ini trzeba??
H4eX
Na serwerze było zablokowane i dlatego nie działało.

Co do błędu pierwszego:
http://forum.php.pl/index.php?showtopic=27886
Cytat
Blad jest dla tego ze nie mozesz otwierac plikow http:// (ustanione w php.ini w celach bezpieczenstwa)

desavil
http://
jest dostępne na serwerze
H4eX
Czytaj ze zrozumieniem.
desavil
Mam zamienić file_get_contents na fopen questionmark.gif

@Edit
nie pomogło
H4eX
Spróbuj dodać do .htaccess
  1. PHP_FLAG allow_url_fopen = On


Masz dostęp do php.ini?
desavil
Tak mam dostęp do PHP ini i w php ini jest: allow_url_fopen = On
Teraz jak się pobiera to nazwa pliku jest taka sama jak nazwa pliku w którym jest skrypt i plik jest pusty po ściągnięciu.

I co o tym sądzicie?

Na innym dedyku od znajomego na którym też jest directadmin to skrypt działa. Ale nie mam tam dostępu do php.ini więc jaka funkcja może to blokowaćquestionmark.gif
H4eX
Na dedyku nie ma dostępu do php.ini, niemożliwe. Najlepiej by było jakbyś porównał od siebie i od znajomego te dwa pliki. Możesz jeszcze spróbować włączyć:

  1. allow_url_fopen
w php.ini
desavil
Chodziło mi, że na dedyku kolegi nie mam dostępu do php.ini bo on ma resellera ;p
Zaraz sprawdzę i napiszę

@edit
W php.ini mam takie coś:
Cytat
; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = On

; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
allow_url_include = Off
H4eX
Ustaw:
  1. allow_url_include = On


We wcześniejszym poście machnąłem się i zamiast include dałem fopen tongue.gif
desavil
Też nie działa :/
H4eX
Porównaj php.ini z twojego komputera a serwera. Proponuję użyć: WinMerge
http://www.idg.pl/ftp/pc_13996/WinMerge.2.6.6.pl.html
desavil
Ale pisałem już wcześniej, że nie mam dostępu do php.ini od serwera kolegi gdyż on ma konto reseller...
H4eX
Ale nie serwera znajomego tylko twojego, na którym nie działa ten kod.
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.