|  | Posted by Hilarion on 07/01/05 12:38 
>> in my script i wanna download a gz file, decompress it and compare its>> content to a string from my php-script. how would I do it? I tried:
 >> $relayblacklist =
 >> gzread("http://wget-mirrors.uceprotect.net/uce-pfsm-1/access.gz",
 >>        10000); if(stristr($relayblacklist,$relay)==false)
 >>          echo "no such entry!<br>\n";
 >> but I got: Warning: gzread(): supplied argument is not a valid stream
 >> resource in /srv/www/htdocs/web2/html/php/nospam/pop.php on line 190
 >>
 >> I think I first have download the file to a local one and then
 >> decompress it. Is that right? How to download a binary file? I' just
 >> found file() but how to handle this with binary?
 
 You need to pass stream resource from "gzopen" as first parameter
 of "gzread", not path to the file.
 
 
 > Also tried this:
 > [Code]
 > $fp = fopen("http://wget-mirrors.uceprotect.net/uce-pfsm-1/access.gz",
 > "rb");
 > $relayblacklist = gzread(fread ($fp,10000),10000);
 > fclose ($fp);
 
 Same again. (This time you tried to pass zipped data to gzread instead
 of handle given by "gzopen".)
 
 
 > echo $relayblacklist;
 > unlink("http://wget-mirrors.uceprotect.net/uce-pfsm-1/access.gz");
 
 You can't remove remote file. "Unlink" works only on local files.
 
 
 It could be something like:
 
 $gz = gzopen( "http://wget-mirrors.uceprotect.net/uce-pfsm-1/access.gz", "r" );
 $relayblacklist = gzread( $gz, 10000 );
 
 
 but "gzopen" does not support HTTP (or FTP). It works only on local files.
 
 There is a way to solve the problem (found in "gzopen" user notes on PHP
 manual pages) using "fopen" and URL wrappers:
 
 $fp = fopen( "compress.zlib://http://wget-mirrors.uceprotect.net/uce-pfsm-1/access.gz", "r" );
 $relayblacklist = gzread( $fp, 10000 );
 
 
 Hilarion
 
 PS.: Read manuals. It's all there.
  Navigation: [Reply to this message] |