Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]file_get_contents wyłączone :/
robos85
post
Post #1





Grupa: Zarejestrowani
Postów: 466
Pomógł: 11
Dołączył: 21.09.2006
Skąd: Szczecin

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


Otóż na serwerze mam wyłączone file_get_contents.
Jak mogę pobrać inaczej treść pliku - jest on malutki całe 6 linijek ale ważne:/
Ew. czy można jakoś to z poziomu htaccess włączyć;p
Go to the top of the page
+Quote Post
2 Stron V   1 2 >  
Start new topic
Odpowiedzi (1 - 19)
mike
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

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


fopen() + fread() + fclose()
lub kilka innych sposóbów, które masz w dokumentacji Funkcje Systemu plików

Nie, nie można tego włączyć skoro admin wyłączył.
Go to the top of the page
+Quote Post
wookieb
post
Post #3





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Sprawdz w phpinfo czy napewno ta funkcja jest zablokowana. Bo moze probujesz pobrac zawartosc z innego serwera np
Kod
file_get_contents('http://wp.pl');

a wtedy za takie cos moze byc odpowiedzialne injne ustawienie fopen wrappers
Go to the top of the page
+Quote Post
robos85
post
Post #4





Grupa: Zarejestrowani
Postów: 466
Pomógł: 11
Dołączył: 21.09.2006
Skąd: Szczecin

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


Tak, plik chcę z innego serwera pobrać
robię tak:
  1. <?php
  2. $nazwa_pliku = "http://em.bankier.pl/provider/mci/index.php";
  3. $uchwyt = fopen($nazwa_pliku, "r");
  4. $tresc = fread($uchwyt, filesize($nazwa_pliku));
  5. fclose($uchwyt);
  6. $smarty->assign('notowania',$tresc);
  7. ?>


a błąd mam taki:
Kod
Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in /public_html/index.php on line 17

Warning: fopen(http://em.bankier.pl/provider/mci/index.php) [function.fopen]: failed to open stream: no suitable wrapper could be found in /public_html/index.php on line 17

Warning: filesize() [function.filesize]: stat failed for http://em.bankier.pl/provider/mci/index.php in /public_html/index.php on line 18

Warning: fread(): supplied argument is not a valid stream resource in /public_html/index.php on line 18

Warning: fclose(): supplied argument is not a valid stream resource in /public_html/index.php on line 19


i co mam w takim wypadku zrobić?
Go to the top of the page
+Quote Post
wookieb
post
Post #5





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Wiec zrob to za pomoca curl
http://php.net/curl
Go to the top of the page
+Quote Post
robos85
post
Post #6





Grupa: Zarejestrowani
Postów: 466
Pomógł: 11
Dołączył: 21.09.2006
Skąd: Szczecin

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


  1. <?php
  2. function wczytaj($url)
  3. {
  4.    $curl = curl_init();
  5.  
  6.    $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
  7.    $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
  8.    $header[] = "Cache-Control: max-age=0";
  9.    $header[] = "Connection: keep-alive";
  10.    $header[] = "Keep-Alive: 300";
  11.    $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
  12.    $header[] = "Accept-Language: en-us,en;q=0.5";
  13.    $header[] = "Pragma: ";
  14.    $gacookie='cookie.txt';
  15.    curl_setopt($curl, CURLOPT_URL, $url);
  16.    curl_setopt($curl, CURLOPT_USERAGENT, 'Googlebot/2.1 (+http://www.google.com/bot.html)');
  17.    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
  18.    curl_setopt($curl, CURLOPT_REFERER, 'http://www.google.com');
  19.    curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
  20.    curl_setopt($curl, CURLOPT_AUTOREFERER, true);
  21.    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  22.    curl_setopt($curl, CURLOPT_TIMEOUT, 10);
  23.  
  24.    $html = curl_exec($curl);
  25.    curl_close($curl);
  26.    
  27.    return $html;
  28. }
  29.  
  30. $s = wczytaj('http://em.bankier.pl/provider/mci/index.php');
  31. $smarty->assign('notowania',$s);
  32. ?>


W curl za dobry nie jestem, ale czy takie coś może być, czy coś skopałem?

chcę pobrać tą stronę : http://em.bankier.pl/provider/mci/index.php
Go to the top of the page
+Quote Post
wookieb
post
Post #7





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Wystarczy
  1. <?php
  2. function wczytaj($url)
  3. {
  4.    $curl = curl_init();
  5.    curl_setopt($curl, CURLOPT_URL, $url);
  6.    $html = curl_exec($curl);
  7.    curl_close($curl);
  8.    return $html;
  9. }
  10.  
  11. $s = wczytaj('http://em.bankier.pl/provider/mci/index.php');
  12. $smarty->assign('notowania',$s);
  13. ?>
Go to the top of the page
+Quote Post
Spirit86
post
Post #8





Grupa: Zarejestrowani
Postów: 607
Pomógł: 23
Dołączył: 8.09.2004
Skąd: Wrocław

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


jak nie masz włączonych bibliotek cURL a ustawioną dyrektywę do file, możesz zrobić:

  1. <?php
  2. function pobierz($url){
  3.  return join(file($url));
  4. }
  5.  
  6. pobierz('http://onet.pl');
  7. ?>
Go to the top of the page
+Quote Post
wookieb
post
Post #9





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




No przeciez pokazal ze nie moze tego zrobic za pomoca file...
Go to the top of the page
+Quote Post
pyro
post
Post #10





Grupa: Zarejestrowani
Postów: 2 148
Pomógł: 230
Dołączył: 26.03.2008

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


Cytat(wookieb @ 8.10.2008, 15:48:54 ) *
Wystarczy
  1. <?php
  2. function wczytaj($url)
  3. {
  4.    $curl = curl_init();
  5.    curl_setopt($curl, CURLOPT_URL, $url);
  6.    $html = curl_exec($curl);
  7.    curl_close($curl);
  8.    return $html;
  9. }
  10. ?>


popraw swoj kod bo zes bzdury napisal
Go to the top of the page
+Quote Post
Pilsener
post
Post #11





Grupa: Zarejestrowani
Postów: 1 590
Pomógł: 185
Dołączył: 19.04.2006
Skąd: Gdańsk

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


Nie zapominajmy też o socketach:
fsockopen" title="Zobacz w manualu PHP" target="_manual - na forum są na pewno przykłady pobrania pliku przy wykorzystaniu fsockopen.
Go to the top of the page
+Quote Post
wookieb
post
Post #12





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Cytat(pyro @ 8.10.2008, 20:07:42 ) *
popraw swoj kod bo zes bzdury napisal


Wiec najpierw sprawdz a nie herezje szerzysz.
Go to the top of the page
+Quote Post
Spirit86
post
Post #13





Grupa: Zarejestrowani
Postów: 607
Pomógł: 23
Dołączył: 8.09.2004
Skąd: Wrocław

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


Cytat(wookieb @ 8.10.2008, 18:02:23 ) *
No przeciez pokazal ze nie moze tego zrobic za pomoca file...


Cytat(robos85 @ 8.10.2008, 13:16:08 ) *
Otóż na serwerze mam wyłączone file_get_contents.
Go to the top of the page
+Quote Post
wookieb
post
Post #14





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Czytaj dokładnie. Chodzi o fopen_wrappers. wiec za pomoca fopen tez tego nie otworzysz, ani za pomoca file.
Go to the top of the page
+Quote Post
pyro
post
Post #15





Grupa: Zarejestrowani
Postów: 2 148
Pomógł: 230
Dołączył: 26.03.2008

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


Cytat(wookieb @ 9.10.2008, 09:15:15 ) *
Wiec najpierw sprawdz a nie herezje szerzysz.


Wiec moze SAM TO SPRAWDZ ZANIM DASZ, zanim znowu napiszesz bzdety to sie zastanow wookieb, dam ci stowe jak ci cos zwroci do zmiennej $html kod html otwieranej strony.
Go to the top of the page
+Quote Post
wookieb
post
Post #16





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




http://wookieb.pl/curl.php


  1. <?php
  2. function wczytaj($url)
  3. {
  4.   $curl = curl_init();
  5.   curl_setopt($curl, CURLOPT_URL, $url);
  6.   $html = curl_exec($curl);
  7.   curl_close($curl);
  8.   return $html;
  9. }
  10.  
  11. echo wczytaj('http://www.google.pl/');
  12. ?>


Podac ci juz numer konta?
Go to the top of the page
+Quote Post
pyro
post
Post #17





Grupa: Zarejestrowani
Postów: 2 148
Pomógł: 230
Dołączył: 26.03.2008

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


Cytat(wookieb @ 9.10.2008, 20:00:21 ) *
http://wookieb.pl/curl.php


  1. <?php
  2. function wczytaj($url)
  3. {
  4.   $curl = curl_init();
  5.   curl_setopt($curl, CURLOPT_URL, $url);
  6.   $html = curl_exec($curl);
  7.   curl_close($curl);
  8.   return $html;
  9. }
  10.  
  11. echo wczytaj('http://www.google.pl/');
  12. ?>


Podac ci juz numer konta?


niech zgadne, wstawiles wkoncu
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
wookieb
post
Post #18





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Nie. Ten kod działą i nie gadaj. Podawac numer konta?
Go to the top of the page
+Quote Post
pyro
post
Post #19





Grupa: Zarejestrowani
Postów: 2 148
Pomógł: 230
Dołączył: 26.03.2008

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


nie trzeba, bo u mnie nie dziala

$html trzyma tylko bool
Go to the top of the page
+Quote Post
wookieb
post
Post #20





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




BO returntransfer jest domyslnie true od curl 7.10 masz starsza wersje. Gdzie moja stowa?!??!?! (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) :D

Ten post edytował wookieb 9.10.2008, 19:10:57
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 24.08.2025 - 01:00