php-general Digest 10 Feb 2010 11:49:15 -0000 Issue 6583

Topics (messages 301913 through 301924):

Re: SOAP connect error
        301913 by: Shawn McKenzie
        301914 by: Eric Lommatsch

Re: howto do informative error handling without the  fatalities
        301915 by: clancy_1.cybec.com.au
        301916 by: Rene Veerman
        301917 by: Paul M Foster
        301922 by: Rene Veerman

Re: PHP Manual problems
        301918 by: clancy_1.cybec.com.au
        301920 by: James McLean
        301923 by: Lester Caine

Owner or other; permissions for webpage users
        301919 by: clancy_1.cybec.com.au
        301921 by: James McLean

Re: create archive file in memory with zipArchive class
        301924 by: Richard Quadling

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Eric Lommatsch wrote:
> Hello,
>  
> I am working with the SOAP package of PHP and I am trying make a connection
> from a hosted website to a server in our office. 
>  
> I can get to the server perfectly fine from within our office, but I cannot
> connect from the eternal site.
>  
> I have checked and I am certain that the firewall for the server is open.
> When I attempt to use the login page that I have created for the website I am
> getting the following error message:
>  
> Connect Error to XX.XX.XX.XXX:8080
>  
> Where XX.XX.XX.XXX mask the actual ip address of the server. I have tried to
> interogate all the values that soap_fault documents that it can return and
> the only information I have been able to find beside the above message, which
> is the $errorstring, is that my $faultcode = "HTTP".
>  
> The information that I am getting is very cryptic. if I include our ip
> address when I search I get no results. If I put in connect error :8080 I get
> millions of meaningless results.
>  
> Can someone please help to figure out how to get more meaningful information
> from soap_fault for this problem so that I can figure out how to fix it.
>  
> Thank you
>  
> Eric H. Lommatsch
> Programmer
> 360 Business 
> 2087 South Grant Street
> Denver, CO 80210
> Tel 303-777-8939 Ext 23
> Fax 888-282-9927
>  
> er...@360b.com
>  
> 

If you go home or to Starbucks can you get to http://XX.XX.XX.XXX:8080 ?
 If not, then the external server can't either.  It could be a network
firewall/proxy sever in your office, or any number of things.

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
>-----Original Message-----
>From: Shawn McKenzie [mailto:nos...@mckenzies.net] 
>Sent: Tuesday, February 09, 2010 3:07 PM
>To: Eric Lommatsch
>Cc: php-gene...@lists.php.net
>Subject: Re: SOAP connect error
>
>Eric Lommatsch wrote:
>> Hello,
>>  
>> I am working with the SOAP package of PHP and I am trying make a 
>> connection from a hosted website to a server in our office.
>>  
>> I can get to the server perfectly fine from within our office, but I 
>> cannot connect from the eternal site.
>>  
>> I have checked and I am certain that the firewall for the server is open.
>> When I attempt to use the login page that I have created for the 
>> website I am getting the following error message:
>>  
>> Connect Error to XX.XX.XX.XXX:8080
>>  
>> Where XX.XX.XX.XXX mask the actual ip address of the server. I have 
>> tried to interogate all the values that soap_fault documents that it 
>> can return and the only information I have been able to find beside 
>> the above message, which is the $errorstring, is that my $faultcode =
"HTTP".
>>  
>> The information that I am getting is very cryptic. if I include our ip 
>> address when I search I get no results. If I put in connect error 
>> :8080 I get millions of meaningless results.
>>  
>> Can someone please help to figure out how to get more meaningful 
>> information from soap_fault for this problem so that I can figure out how
to fix it.
>>  
>> Thank you
>>  
>> Eric H. Lommatsch
>> Programmer
>> 360 Business
>> 2087 South Grant Street
>> Denver, CO 80210
>> Tel 303-777-8939 Ext 23
>> Fax 888-282-9927
>>  
>> er...@360b.com
>>  
>> 
>
>If you go home or to Starbucks can you get to http://XX.XX.XX.XXX:8080 ?
> If not, then the external server can't either.  It could be a network
firewall/proxy sever in your office, or any number of things.
>
>--
>Thanks!
>-Shawn
>http://www.spidean.com


I have connected to a clients computer that is remote from our office and I
am able to get to http://XX.XX.XX.XXX:8080. I probably should have mentioned
that when I try to get the webservice outside of the PHP site I am developing
I can get into that just fine. It is just when I try to use the PHP SOAP
client to access the webservice that I am getting the issue.


Thank you
 
Eric H. Lommatsch
Programmer
360 Business 
2087 South Grant Street
Denver, CO 80210
Tel 303-777-8939 Ext 23
Fax 888-282-9927
 
er...@360b.com

--- End Message ---
--- Begin Message ---
On Tue, 9 Feb 2010 16:09:05 +0000, rquadl...@googlemail.com (Richard Quadling) 
wrote:

>On 9 February 2010 14:20, Ashley Sheridan <a...@ashleysheridan.co.uk> wrote:
>>
>> On Tue, 2010-02-09 at 09:19 -0500, Robert Cummings wrote:
>>
>> Richard wrote:
>> > Hi,
>> >
>> >> I have extended the standard exception class to send me an email
>> >> whenever an exception occurs.
>> >
>> > I did that once. Once being the operative word... :-) Ended up with
>> > tens of thousands of emails one morning. At first I thought... "Wow,
>> > maybe my popularity has grown somewhat". But it hadn't.
>>
>> I have something similar... a cron job that checks the error_log file
>> every 10 minutes and sends me the contents if any exist. I also set a
>> special header so I can be sure it's not spam and appropriately route it
>> into my mail folder maze, Much less spammy :)
>>
>> Cheers,
>> Rob.
>> --
>> http://www.interjinn.com
>> Application and Templating Framework for PHP
>>
>>
>> Real developers don't have errors in their code; they're undocumented 
>> features ;)
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>
>So, no documentation AND bugs!!! Gee. I really wouldn't want to rely
>on that code base!

So you don't use (or work with) any Microsoft product?


--- End Message ---
--- Begin Message ---
Well, i've thought of a few ways to allow localized overriding of
values returned by functions in case of an error.

I have yet to figure out what the exact advantages are of this
code-standard, but the overhead seems acceptable and i recon this,
when done, will beat the "trigger_error()-try-catch" paradigm.
I'd like to hear your comments.

// imo unsafe & prone to fatalities:
$r = funcA ( funcB ( funcC ($p) ), funcD ($q) );

// "safe"; make all notices, warnings and errors from any level
// in the call-chain fully visible, identifiable, and "survivable/fudgeable"
// by code at (all) higher levels in the call-chain.
// [disclaimer] the code below here doesn't pass 3rd-level (funcC())
// (meta-)results back to the first level (funcA()) yet, but this code
// is a start towards that;
$r = funcA (defaults(array(0=>'[funcB failed]',1=>'funcD failed'))),
        funcB (defaults($onError_cCallvalue),
                funcC (defaults($onError_pValue), $p)
        ),
        funcD (defaults($onError_qValue), $q)
);

function funcA ($defaults, $returnedByFuncB, $returnedByFuncD) {
        $returnedByFuncB = workWith ($defaults, $returnedByFuncB, 0);
        $returnedByFuncD = workWith ($defaults, $returnedByFuncD, 1);
        //all parameters (with idx>0) are meta-arrays containing the
"parameter-value" and all meta-info.
        // workWith() always returns the actual parameter-value in 
$p['workValue'];

        //if any parameter $p (with idx>0) is not a meta-array,
        //      workWith($d, $r, $n) turns it into a meta array(
        //              'workValue' => $p
        //      );

        //if a param is a meta-array $p, and it contains an ['errors'] subarray,
        //      workWith() sets by-reference $p['workValue'] to one of these
(order of trying):
        //              $defaults['onError'][$n] (localized override)
        //              $p['onErrorDefault'], (functions own default value for 
when an
error occurs)

        //first call to workWith(,,0) will call beginErrorContext()

        //beginErrorContext() will increase a global idx $callID (int),
        //  used to list all notices, warnings and errors, and their details in
        //      the global variable $callsErrors[$callID][$errorIdx++] = array(
        //              'errorMsg' => 'for coders'
        //              (optional:)'userErrorMsg' => 'for laymen'
        //              'backtrace' => array(....)
        //      )

        // the never-fatal error handler specified with set_error_handler() will
        //      call getDebugInfo() and append full error info into
        //      $callsErrors[$callID][$errorIdx++]





        //forwardDefaults() clones all meta-details for
        //      re-used parameters into a new $defaults array to be used
        //      by funcE().
        //the 2nd parameter for forwardDefaults lists which parameter
        //      passed deeper refers to which parameter received by this here 
function.
        //the 3rd parameter for forwardDefaults is used to specify new defaults.
        $returnedByFuncF = funcF('blablasetting');
        $x = funcE (
                forwardDefaults($defaults, array(0=>0,2=>1), array(1 => 
'defaultblabla')),
                $returnedByFuncB, $returnedByFuncF, $returnedByFuncD
        );
        return goodResult($x);
}

function funcE ($defaults, $returnedByFuncB, $returnedByFuncF,
$returnedByFuncD) {
        $returnedByFuncB = workWith ($defaults, $returnedByFuncB, 0);
        $returnedByFuncF = workWith ($defaults, $returnedByFuncF, 2);
        $returnedByFuncD = workWith ($defaults, $returnedByFuncD, 2);

        // do a call that might raise E_WARNINGS or other crap;
        // safeCall() is only a try-except struct to call in this case
        // str_replace('xx','yy', ...) and if it fails,
        // return the default instead of the actual result.
        $x = safeCall (
                defaults('returnedByFuncB not a string'),
                'str_replace', 'xx','yy',$returnedByFuncB
        );


        if (is_string($returnedByFuncB) && is_string($returnedByFuncD)) {
                return goodResult (
                        $returnedByFuncB . $returnedByFuncD . $x
                );
                // goodResult() and badResult() will both call
                //      endErrorContext(), and copy the errors in
                //      $callsErrors[$callID]
                // to the array returned to the calling function.

                // goodResult() and badResult() will call processErrors(),
                //      which is repsonsible for mailing / db-storage of any
                //      notices, warnings, errors, etc.

        } else {
                //      badResult() will call getDebugInfo() to include
                //              a full trace, superglobals, lotsa details.
                return badResult (array(
                'errorMsg' => 'params 1 and 2 must be strings'
                'onErrorDefault' => ''
                ));
                //shorthand of the above:
                return badResult ('params 1 and 2 must be strings', '');
        }
}


function defaults () {
        $r = array (
        'isMetaForFuncs' => true
        );

        if (func_num_args()==1) {
                return array_merge_recursive ($r,
array('onError'=>array(0=>func_get_arg(0))));
        } else {
                switch (func_get_arg(0)) {
                case 'onError':
                        $p = func_get_arg(1);
                        if (is_array($p)) {
                                return array_merge_recursive ($r, 
array('onError'=>$p));
                        } else {
                                return array_merge_recursive ($r, 
array('onError'=>array(0=>$p)));
                        }
                        break;
                }
        }
}


I also considered the following constructs but rejected them for
clumsiness (first) or sheer uselessness (2nd).

  $r = funcA ($bcalldef, funcB($ccalldef, funcC ($pdef, $p)),
$dcalldef, funcD($qdef, $q));

  $r = funcA ( funcB ( funcC ( $p ) ), funcD ($q), array (
    'isMetaForFuncs' => true,
    0 => array (
      'onError' => $bCallDefaultOnError,
      0 => array (
        'onError' => $cCallDefaultOnError,
        0 => array (
          'onError' => $pDefaultOnError,
        )
      )
    ),
    1 => array (
      'onError' => $qDefaultOnError
    )
  );

--- End Message ---
--- Begin Message ---
On Tue, Feb 09, 2010 at 11:38:42PM +0100, Rene Veerman wrote:

> Well, i've thought of a few ways to allow localized overriding of
> values returned by functions in case of an error.
> 
> I have yet to figure out what the exact advantages are of this
> code-standard, but the overhead seems acceptable and i recon this,
> when done, will beat the "trigger_error()-try-catch" paradigm.
> I'd like to hear your comments.
> 
> // imo unsafe & prone to fatalities:
> $r = funcA ( funcB ( funcC ($p) ), funcD ($q) );

I wasn't going to comment, but seriously, Rene, I would not make it a
habit of calling functions within the parameters of other functions.
Among other things, it obviously creates a whole host of the problems
you're talking about, and it makes your code hard to debug and read. The
only way I'd normally do something like this is if I were using native
PHP functions and the possible failure of the functions wouldn't matter.
Rather, I'd do something like this:

$d = funcD($q);
// tests if necessary
$c = funcC($p);
// tests if necessary
$b = funcB($c);
// tests if necessary
$r = funcA($b, $d);

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Wed, Feb 10, 2010 at 3:04 AM, Paul M Foster <pa...@quillandmouse.com> wrote:
> $d = funcD($q);
> // tests if necessary
> $c = funcC($p);
> // tests if necessary
> $b = funcB($c);
> // tests if necessary
> $r = funcA($b, $d);
>

You're right.
I knew when i was posting my last reply yesterday that i had made
things probably too complicated.

But after sleeping and a look at real code which is to work with my
improved-err-handling, i've come up with a new construct, that i think
will fit the bill for now.

I'm going to use the "result meta-array" instead of "plain result
values", because that
- completely equalizes the syntax for detecting bad results, and
prevents doing a lookup with a function to a value that is also the
"bad-result" return value for the lookup function.
- is much easier to read, than checking what the "bad-result" value is
for a lookup function.
- allows me to redirect the error info from a called function inside
the calling function
- allows infinite expansion of (meta-)communication between calling
and called functions.

So while i'm dumping the funcA (defaults($onError_pValue), $p) crap,
i'm retaining most of the other ideas in my previous post to this
thread.

the calling function does this, inside 3x foreach:
........
                                        // if not done yet, resolve the fields 
for this table=>hit that
require looking-up
                                        if 
(!$sqls[$tableName]['hasPreInserts']) {
                                                foreach 
($tableCmd['preInsertFields'] as $fieldName=>$fieldLookupCmd) {
                                                        $r = 
maintenance__lookupPreInserts ($wm, $fieldLookupCmd);
                                                        if (!good($r)) {
                                                                
$tableCmd['invalidPreInserts'] = true;
                                                        } else {
                                                                
$sqls[$tableName]['preInserts'][$fieldName] = result($r);
                                                        }
                                                }
                                        }
                                        
                                        if 
(!array_key_exists('invalidPreInserts', $tableCmd)) {
                                        // add the fields for this table for 
this hit:
.........


and the helper functions:

function maintenance__lookupPreInserts (&$wm, $fieldLookupCmd) {
  startErrorContext(); // to catch php E_NOTICE, E_WARNING, etc
        $flcp = explode ('::', $fieldLookupCmd);
        if (count($flcp)!=3) {
                return badResult(E_USER_ERROR, array(
                        'msg' => 'Need 3 counts of \'::\'',
                        'vars' => array (0=>array('$fieldLookupCmd', 
$fieldLookupCmd))
                ));
  }     
        
        $section = $flcp[0];

        $searchInSection = array();
        $criteria = explode (',,', $flcp[1]);
        foreach ($criteria as $idx1 => $criterium) {
                $cs = explode('===',$flcp[1]);
                if (count($cs)!=2) return badResult (E_USER_ERROR, array(
                                'msg' =>
                                        'Any criterium (after first "::", 
between ",,") needs to be like
this:'."\n".
                                        'fieldName===searchValue',
                                'vars' => array (0=>array('$fieldLookupCmd', 
$fieldLookupCmd))
                ));
                $searchInSection = array_merge ($searchInSection, array(
                        $cs[0] => $cs[1]
                ));
        }
        
        $pathInSection = explode(',,', $flcp[2]);
        
  foreach ($wm[$section] as $idx => $fields) {
    $gotIt = true;
    foreach ($searchInSection as $fn => $fv) {
      if ($fields[$fn]!=$fv) {
                                $gotIt = false;
                                break;
      }
    }
    if ($gotIt) {
      return chase ($wm[$section], $pathInSection);
    }
  }
}


function chase ($arr, $indexes) {
  startErrorContext();
  $r = $arr;
  foreach ($indexes as $idx) {
    if (is_array($r)) {
      $r = $r[$idx];
    } else {
                        return badResult (E_USER_ERROR, array(
                                'msg' => 'Could not walk the full tree',
                                'vars' => array(
                                        0=>array('$arr', $arr),
                                        1=>array('$indexes', $indexes)
                                )
                        ));
    }
  }
  return goodResult($r);
}

--- End Message ---
--- Begin Message ---
On Thu, 04 Feb 2010 02:39:03 +0100, joc...@iamjochem.com (Jochem Maas) wrote:

>Op 2/4/10 1:32 AM, clanc...@cybec.com.au schreef:
>> Recently I have frequently found, especially in the morning (GMT 2200 - 
>> 0200), that I can
>> open a bookmark in the manual, for example 
>> http://www.php.net/manual/en/ref.image.php.
>> But if I then do a search of any type I get 'The page cannot be displayed'.  
>> I then cannot
>> reach any page, including the one I originally opened.
>> 
>> This morning, after some fiddling, I found that if I closed the browser, and 
>> re-opened it
>> I could then see the original bookmark again, and link to some pages, but 
>> others would
>> again crash the browser, as would all searches.
>> 
>> I am using IE6, and have seen a message that I should update my browser, but 
>> only when the
>> page is displaying properly.  Firefox 3.5.5 immediately converted the above 
>> to
>> http://au2.php.net/manual/en/ref.image.php. and then told me "The manual 
>> page you are
>> looking for (http://au2.php.net/manual/en/ref.image.php.) is not available 
>> on this server
>> right now."
>
>there are stacks of mirrors. try one of:
>
>au.php.net
>tw.php.net
>tw2.php.net
>tn.php.net
>tn2.php.net
>sg.php.net
>sg2.php.net
>
>... guessing those are closest to you.

Thanks. I was under the misapprehension that the providers server would 
automatically hunt
for a valid mirror, but I find that my various bookmarks are scattered on 
mirrors all over
the place. Also that if I do a search from what appears to be the logical 
starting
bookmark it doesn't work, but if I do it from most of the others it does. Very 
strange.

>as for using IE6 ... WTF ... you do realise this is essentially a web 
>developers mailing list right?

The interesting things in my websites go on behind-the-scenes, in the PHP, and 
produce
relatively straightforward HTML. I have avoided the well-known bugs in IE6, and 
think my
webpages display correctly on any of the modern browsers, but as Microsoft 
delights in
rearranging everything in every update, and making the features you need ever 
harder to
find, I stick to IE6 for my everyday work.


--- End Message ---
--- Begin Message ---
On Wed, Feb 10, 2010 at 2:26 PM,  <clanc...@cybec.com.au> wrote:
> On Thu, 04 Feb 2010 02:39:03 +0100, joc...@iamjochem.com (Jochem Maas) wrote:
>>as for using IE6 ... WTF ... you do realise this is essentially a web 
>>developers mailing list right?
>
> The interesting things in my websites go on behind-the-scenes, in the PHP, 
> and produce
> relatively straightforward HTML. I have avoided the well-known bugs in IE6, 
> and think my
> webpages display correctly on any of the modern browsers, but as Microsoft 
> delights in
> rearranging everything in every update, and making the features you need ever 
> harder to
> find, I stick to IE6 for my everyday work.

Wow. Ignoring the issue that IE6 will soon be EOL (finally), and
ignoring how bad it is at handling anything even remotely modern, your
workstation must be a haven for virii, spyware and malware... IE6 has
just about the worst security track record out there, at least on the
desktop anyway.

If you must have IE6 for whatever reason, stick it on Windows
installed on a VM and upgrade your main workstation browser to
something more recent. At least a VM can be backed up at a known-good
point and if^H^Hwhen it gets compromised it can be deleted easily and
replaced with your backup.

I'll make it easy for you: http://www.getfirefox.com :)

Cheers

--- End Message ---
--- Begin Message ---
James McLean wrote:
On Wed, Feb 10, 2010 at 2:26 PM,  <clanc...@cybec.com.au> wrote:
On Thu, 04 Feb 2010 02:39:03 +0100, joc...@iamjochem.com (Jochem Maas) wrote:
as for using IE6 ... WTF ... you do realise this is essentially a web 
developers mailing list right?
The interesting things in my websites go on behind-the-scenes, in the PHP, and 
produce
relatively straightforward HTML. I have avoided the well-known bugs in IE6, and 
think my
webpages display correctly on any of the modern browsers, but as Microsoft 
delights in
rearranging everything in every update, and making the features you need ever 
harder to
find, I stick to IE6 for my everyday work.

Wow. Ignoring the issue that IE6 will soon be EOL (finally), and
ignoring how bad it is at handling anything even remotely modern, your
workstation must be a haven for virii, spyware and malware... IE6 has
just about the worst security track record out there, at least on the
desktop anyway.

If you must have IE6 for whatever reason, stick it on Windows
installed on a VM and upgrade your main workstation browser to
something more recent. At least a VM can be backed up at a known-good
point and if^H^Hwhen it gets compromised it can be deleted easily and
replaced with your backup.

I'll make it easy for you: http://www.getfirefox.com :)

Since a large section of our USER base is still tied to W2k and does not have access to install other software, the call for IE6 to die is STILL somewhat premature! What is needed is someone to kick M$ to sort the mess out by at least allowing IE8 to install on W2k machines, rather than telling hundreds of councils they have to replace ALL their computers :(

The alternative is to convince M$ controlled councils that Firefox is OK and that using it will not invalidate their contracts - but then all the work currently being done to convert legacy setups to work with *IE7* would have to be scrapped and reworked on Firefox. Many of my customers have only just got funds to start an *IE7* roll out! Redoing all that work for IE8 is yet another problem for which money is not available.

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
I'm basically familiar with the UNIX permissions - 'owner', 'group', or 
'other', but I
have no real idea how these apply to webpage users under PHP. I know that if I 
FTP to the
server I am the owner, and I think that if I, or anyone else, opens one of my 
webpages I
am 'other'.

However what I would like to do is assign certain users, who have logged in 
through a
security portal, to 'group', so that they (but not 'others') have permission to 
write to
data files on the site.

Can this be done with PHP?

--- End Message ---
--- Begin Message ---
On Wed, Feb 10, 2010 at 2:51 PM,  <clanc...@cybec.com.au> wrote:
> I'm basically familiar with the UNIX permissions - 'owner', 'group', or 
> 'other', but I
> have no real idea how these apply to webpage users under PHP. I know that if 
> I FTP to the
> server I am the owner, and I think that if I, or anyone else, opens one of my 
> webpages I
> am 'other'.

Almost right. It's UGO, User Group and Other.

When you view a PHP page, it's (usually) served by Apache, the process
will be owned by a user, usually 'apache'; who is also a member of a
group, usually 'apache'. On some systems these users/groups can be
'httpd', 'www-data' etc. When you or I look at a PHP file served from
Apache, there is no concept of users/groups/others outside those that
apply to the Apache process that served the data.

> However what I would like to do is assign certain users, who have logged in 
> through a
> security portal, to 'group', so that they (but not 'others') have permission 
> to write to
> data files on the site.

It's a seperate thing, because once again inside PHP there is no
concept of users/groups outside the Apache process itself. It would be
up to your PHP code to manage who has access to what, the files will
all be read from and written to disk by the Apache process.

HTH.

Cheers

--- End Message ---
--- Begin Message ---
On 9 February 2010 16:47, Ryan Sun <ryansu...@gmail.com> wrote:
> thanks, Richard, maybe you are right, the actual file name is not my job
> I changed it to 'php://temp' but its still the same, nothing has been 
> changed...
>
> On Tue, Feb 9, 2010 at 11:13 AM, Richard Quadling
> <rquadl...@googlemail.com> wrote:
>> On 9 February 2010 15:42, Ryan Sun <ryansu...@gmail.com> wrote:
>>> I want to generate credential zip file for user on the fly with
>>> zipArchive and render it for download, so I created following code
>>> ---------------------------------------------------------
>>> $zip = new ZipArchive();
>>> $filename = '/tmp/xxx.zip';
>>> if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
>>>      throw new Exception();
>>> }
>>> if($zip)
>>> {
>>>     $zip->addFromString('xxx.xx', $fileString);
>>> }
>>> $zip->close();
>>> $fileString = file_get_contents($filename);
>>> unlink($filename);
>>>
>>> $this->getResponse()->setHeader('Content-Type', 'application/zip');
>>> $this->getResponse()->setHeader('Content-Disposition','attachment;filename=xxx.zip');
>>> $this->getResponse()->setBody($fileString);
>>> -----------------------------------------------------
>>> it works, but I think creating the file in memory is a better
>>> approach, so I changed the 2nd lineI(using php 5.2.0) to
>>> $filename = 'php://temp/xxx.zip';
>>> then the php just won't archive the file and the file downloaded is
>>> just a plain text file.
>>>
>>> so
>>> question 1, how to create zip Archive file in memory on the fly and
>>> download it (I don't have to save it on disk)?
>>> question 2, if there is no way to create in memory, is it safe to just
>>> unlink() the file?
>>>
>>> thanks in advance.
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> According to http://docs.php.net/manual/en/wrappers.php.php, it looks
>> like you should be using ...
>>
>> $filename = 'php://temp';
>>
>> That's it.
>>
>> The actual file name is not your job.
>>
>>
>>
>> --
>> -----
>> Richard Quadling
>> "Standing on the shoulders of some very clever giants!"
>> EE : http://www.experts-exchange.com/M_248814.html
>> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
>> ZOPA : http://uk.zopa.com/member/RQuadling
>>
>

It looks like this isn't possible.





-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---

Reply via email to