Professional Web Applications Themes

decompress remote file - PHP Development

Hi, 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? Than you! My server uses php 4.3.3...

  1. #1

    Default decompress remote file

    Hi,

    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?
    Than you!
    My server uses php 4.3.3


    roN Guest

  2. #2

    Default Re: decompress remote file

    roN work wrote: 

    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);
    echo $relayblacklist;
    unlink("http://wget-mirrors.uceprotect.net/uce-pfsm-1/access.gz");
    But:
    [Output]
    Warning: gzread(): supplied argument is not a valid stream resource in
    /srv/www/htdocs/web2/html/php/nospam/pop.php on line 136

    Warning: unlink(http://wget-mirrors.uceprotect.net/uce-pfsm-1/access.gz): No
    such file or directory in /srv/www/htdocs/web2/html/php/nospam/pop.php on
    line 139
    [/Output]


    roN Guest

  3. #3

    Default Re: decompress remote file

    >> in my script i wanna download a gz file, decompress it and compare its [/ref]

    You need to pass stream resource from "gzopen" as first parameter
    of "gzread", not path to the file.

     

    Same again. (This time you tried to pass zipped data to gzread instead
    of handle given by "gzopen".)

     

    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.
    Hilarion Guest

Similar Threads

  1. Replies: 0
    Last Post: November 27th, 09:13 AM
  2. Replies: 5
    Last Post: October 11th, 09:54 PM
  3. #40437 [NEW]: decompress.bzip2 is broken
    By phpbugger dot 5 dot n1 at spamgourmet dot com in forum PHP Bugs
    Replies: 2
    Last Post: February 11th, 09:50 PM
  4. Remote.pm (File::Remote) error handling question
    By terminlman@yahoo.com in forum PERL Modules
    Replies: 3
    Last Post: January 31st, 07:26 PM
  5. perl decompress
    By Anish in forum PERL Beginners
    Replies: 2
    Last Post: June 2nd, 01:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139