>I'm still trying to compress an entire directory on a linux server to be
decompressed >probably in windows client. I'm trying to use exec command and
tar (compressor for linux), >but I don't know how to do it. Can anybody
pleeeaase help me?

So, like, do they download it later, or is your PHP program supposed to
return the compressed archive?...

Let's assume the latter, cuz that's more fun :-)

Use a URL like this:
http://yourserver.com/whatever.php/whatever.tgz

Your PHP file is whatever.php
That bogus-looking whatever.tgz on the end is because [BLEEP]ing IE 3.mumble
ignores MIME-Type and goes by the URL ending to decide what kind of file you
are returning.  MS sucks.  Or is it Netscape that does that?  Netscape sucks
too.

<?php
    $path = "/path/you/want/to/compress/*";
    exec("tar -cz $path", $results, $errorcode);
    if ($errorcode){
        echo "<HTML><BODY>\n";
        echo "OS Error: $errorcode.  Usually path/permissions.  Use 'man
errno' to look up this number if it makes you feel good.<BR>\n";
        # Hmmmmmm.  You might need a " 2S|" or similar after the $path above
        # to get stderr to redirect to stdout so PHP can get error messages
from tar...
        # Any gurus want to comment on how that works, and if " 2S| " is the
right mojo?
        # I hate Un*x some days. :-)
        echo "Here's what tar had to say, if anything:<BR>\n";
        while (list(,$line) = each($results)){
            echo $line, "<BR>\n";
        }
    }
    else{
        header("Content-type: application/octet-stream"); # Force download
        header("Content-disposition: filename=whatever.tgz");
        # Is strlen() binary safe?...  If not, this next line will mess you
up...
        # But without it, the browser can't do that nifty progress meter
during download.
        header("Content-length: " . strlen($results));
        # There's probably more headers you want...
        echo $results;
    }
?>

>I know I should test these, but sending a message is easier. :)
>If a connect the server using ftp_connect and ftp_login, when I try to
create a directory >using mkdir or ftp_mkdir or a file using fopen, will
they belong to me or to nobody???

They will belong to whomever you connected to the FTP server as, assuming
that user can even create files in the first place...

mkdir() and fopen() in your local server will belong to whomever PHP
(Apache) runs as, which is usually "nobody", but could have been configred
in httpd.conf to be "www" or any valid user, including "root" if you were
incredibly stupid, or, if you run PHP as a CGI and wrap it in suExec, it
would be whatever user suExec is configured to run PHP as, which might be
your real login, or might not.  Didja follow all that? :-)
http://php.net/chown et al may or may not be of use...

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to