php-general Digest 14 Dec 2006 04:21:47 -0000 Issue 4513
Topics (messages 245804 through 245819):
Re: problem with ob_start() and header() in osCommerce cart
245804 by: Jochem Maas
245805 by: afan.afan.net
Re: (SOLVED) Varying session behavior between 2 nearly identical Apache/PHP
setups
245806 by: Matthew North
245807 by: Jochem Maas
Exchange vs IMAP
245808 by: Richard Lynch
Re: php redirection..
245809 by: tedd
245819 by: Casey Chu
Re: How php works?
245810 by: tedd
245815 by: Kai Xiang
245816 by: Kai Xiang
Re: utf8 encoding £ to £ problem
245811 by: Nisse Engström
Re: Error Display
245812 by: Jochem Maas
Re: file uploads Q?
245813 by: tedd
[so O T that it hurts :-)] Re: [PHP] file uploads Q?
245814 by: Jochem Maas
Re: Havn't been on the list in a while
245817 by: Chuck Anderson
245818 by: Chuck Anderson
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
[EMAIL PROTECTED] wrote:
> Hi,
> even it's problem with osCommerce cart I think it's still php question:
>
> there is a code in application_top.php file (this file is includeed in
> login.php page, all the way on the top of the login.php file wich means is
> "the first one")
>
> // Check if the browser supports gzip encoding, HTTP_ACCEPT_ENCODING
> if (strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip'))
> {
> // Start output buffering, and register compress_output() (see
> // below)
> ob_start("compress_output");
>
> // Tell the browser the content is compressed with gzip
> header("Content-Encoding: gzip");
> }
>
> and I'm getting login.php as blank page.
> But, when I hide ob_start() and header() lines I will get login page but
> with Warning says "The Encryption key file is missing."?!?!?
>
> Any idea?
I think asking in a/the OSCommerce forum will get you quicker result
(don't forget to tell them what OS,php version, OSC version, etc you are
running)
bloomin' weird error about the 'Encryption key' though... assuming it's a
php error... chances are it's specific to OSC.
ps - don't know anything about OSC myself, sorry
>
> -afan
>
--- End Message ---
--- Begin Message ---
> [EMAIL PROTECTED] wrote:
>> Hi,
>> even it's problem with osCommerce cart I think it's still php question:
>>
>> there is a code in application_top.php file (this file is includeed in
>> login.php page, all the way on the top of the login.php file wich means
>> is
>> "the first one")
>>
>> // Check if the browser supports gzip encoding, HTTP_ACCEPT_ENCODING
>> if (strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip'))
>> {
>> // Start output buffering, and register compress_output() (see
>> // below)
>> ob_start("compress_output");
>>
>> // Tell the browser the content is compressed with gzip
>> header("Content-Encoding: gzip");
>> }
>>
>> and I'm getting login.php as blank page.
>> But, when I hide ob_start() and header() lines I will get login page but
>> with Warning says "The Encryption key file is missing."?!?!?
>>
>> Any idea?
>
> I think asking in a/the OSCommerce forum will get you quicker result
> (don't forget to tell them what OS,php version, OSC version, etc you are
> running)
>
> bloomin' weird error about the 'Encryption key' though... assuming it's a
> php error... chances are it's specific to OSC.
>
> ps - don't know anything about OSC myself, sorry
>
I alerady posted on osCommerce forum but soemtimes I have to wait for 2
days to get an answer :)
Could it be something in php.ini has to be changed? Or Apache?
I use php 5.2 and Apache 2.2
Thanks
-afan
>>
>> -afan
>>
>
>
--- End Message ---
--- Begin Message ---
Thanks to all who responded. Your responses reconfirmed that there
must be some configuration difference between the two so I grudgingly
re-examined everything, and esp. phpinfo() output.
Turns out the test machine had a default (at build time) of
'output_buffering = 0'. Although the two machines shared exact
php.ini, the test machine was effectively doing no output buffering
while the development system was. Explicitly changing this setting to
4096 'solved' the problem.
However, this wasn't the whole story. Turning on output buffering
could only solve the problem if we were doing some out-of-band output
before the session headers were sent that was now being buffered.
Sure enough I found some code that was outputting some response text
before session_start() was called. On the test machine this output
was being buffered until after session_start(), so no apparent problem
existed.
I think the lesson here is, if you're missing headers in your output,
assume first that it's because you've started body output before the
headers in question were sent. If I'd made that assumption earlier I
probably would have saved hours on this bug! (otoh, doesn't that
situation normally result in a PHP warning? where'd that go? oh
well...).
- Matt
On 12/12/06, Matthew North <[EMAIL PROTECTED]> wrote:
Hello All,
I have an odd situation that I wonder if someone might have some
insight on. The scenario is this:
- Two FreeBSD systems running Apache+mod_php+others. We use one for
development and the other for testing.
- Each system is running PHP 5.2.0 with identical php.ini files.
- On each system we have identical PHP code (confirmed to be identical
by comparing cksum output) that looks essentially like this:
=== snip ===
<?php
.
. [page setup code]
.
trigger_error('['.session_id().']');
if (needSession && !session_id())
session_start();
trigger_error('['.session_id().']');
.
. [page output code]
.
?>
=== snip ===
Errors are logged to file rather than the page, so the trigger_error()
calls above result in entries similar to:
[08-Dec-2006 16:59:23] PHP Notice: [] in /path/to/file.php on line 178
[08-Dec-2006 16:59:23] PHP Notice: [GmQidWwShpRpHCGDiQrBr-Lk4ib] in
/path/to/file.php on line 181
So it appears a session is started.
However, on the test system a session cookie is never sent back to the
browser so the session cannot be restored, while on the development
system everything works as it should (session cookie is set and
session is therefore restored on each page load).
Using 'wget -S', here are the response headers sent by the development system:
$ wget -S http://dev/ajax/shopping_list.php\?action=add\&SKU=ABC
--15:48:41-- http://dev/ajax/shopping_list.php?action=add&SKU=ABC
=> `shopping_list.php?action=add&SKU=ABC.1'
Resolving dev... 192.168.0.30
Connecting to dev|192.168.0.30|:80... connected.
HTTP/1.1 200 OK
Date: Mon, 11 Dec 2006 23:48:41 GMT
Server: Apache/2.2.3 (FreeBSD) mod_ssl/2.2.3 OpenSSL/0.9.7e-p1 DAV/2
PHP/5.2.0 with Suhosin-Patch mod_ruby/1.2.5 Ruby/1.8.5(2006-08-25) SVN/1.4.2
mod_jk/1.2.15
X-Powered-By: PHP/5.2.0
Set-Cookie: PHPSESSID=WJ33PpO,nphiPAVxrbrWrQEnO5a; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Content-Length: 103
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: application/xml
Length: 103 [application/xml]
And on the live server:
$ wget -S http://test/ajax/shopping_list.php\?action=add\&SKU=ABC
--15:48:26-- http://test/ajax/shopping_list.php?action=add&SKU=ABC
=> `shopping_list.php?action=add&SKU=ABC'
Resolving test... 192.168.0.31
Connecting to test|192.168.0.31|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Date: Mon, 11 Dec 2006 23:48:26 GMT
Server: Apache/2.0.59 (Unix) mod_ssl/2.0.59 OpenSSL/0.9.7e-p1 SVN/1.3.2
PHP/5.2.0 DAV/2
X-Powered-By: PHP/5.2.0
Content-Length: 103
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: application/xml
Length: 103 [application/xml]
No session cookie! Note that the bodies of these two responses are
identical as determined using diff. Also note that we have other sets
of code on the test system which call session_start(), and a session
cookie _is_ set, as it should be, and everything works fine. So it's
not simply that the session module is broken or mis-configured on the
test machine. Under most circumstances sessions work fine on both
systems. This implies that there is something specific about the code
that is running in the [page setup code] and/or [page output code]
(refer to snippet above) that is causing session_start() to behave
unusually. But again, the PHP code is identical, so it must be the
code *in combination with* some other external difference between the
two systems.
The only differences between the two systems that could conceivably
make sense (to my mind) in terms of this differing behavior are:
Apache 2.0.59 and no Suhosin patch on the test machine, vs Apache
2.2.3 _with_ Suhosin patch on the development system (and I mention
Suhosin only because it makes some cookie-related changes). There are
other differences, but none that would appear that they should have
this effect. Here are the configure commands used for each system:
test system:
=======
'./configure' '--with-mysql=/usr/local/mysql' '--with-pgsql=/usr/local/pgsql'
'--with-gettext' '--with-xml' '--with-imap' '--with-imap-ssl' '--with-pspell'
'--with-zlib' '--with-zlib-dir=/usr' '--with-bz2' '--with-ndbm' '--enable-dba'
'--with-gd' '--enable-gd-native-ttf' '--with-freetype-dir=/usr/local'
'--with-jpeg-dir=/usr/local' '--with-tiff-dir=/usr/local'
'--with-png-dir=/usr/local' '--with-tidy' '--with-openssl' '--enable-sysvsem'
'--enable-sysvshm' '--enable-dbase' '--enable-ftp' '--enable-memory-limit'
'--enable-inline-optimization' '--disable-debug'
'--with-apxs2=/usr/local/apache2/bin/apxs' '--prefix=/usr/local/php'
'--with-config-file-path=/usr/local/php'
development system:
============
'./configure' '--enable-versioning' '--enable-memory-limit' '--with-layout=GNU'
'--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all'
'--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection'
'--enable-spl' '--program-prefix=' '--disable-path-info-check'
'--with-apxs2=/usr/local/sbin/apxs' '--with-regex=php' '--with-zend-vm=CALL'
'--prefix=/usr/local'
I acknowledge that these aren't particularly similar, but they do not
differ in any way that should cause this difference in behavior (do
they?).
The PHP modules loaded match between the two systems, with the
exception of tidy which is enabled on the test machine and not enabled
on the development system.
And again, php.ini are identical between the systems.
What could explain this difference in behavior?
Thanks,
Matthew H. North
--- End Message ---
--- Begin Message ---
nice of you to write up the solution...
Matthew North wrote:
> Thanks to all who responded. Your responses reconfirmed that there
> must be some configuration difference between the two so I grudgingly
> re-examined everything, and esp. phpinfo() output.
>
> Turns out the test machine had a default (at build time) of
> 'output_buffering = 0'. Although the two machines shared exact
> php.ini, the test machine was effectively doing no output buffering
> while the development system was. Explicitly changing this setting to
> 4096 'solved' the problem.
>
> However, this wasn't the whole story. Turning on output buffering
> could only solve the problem if we were doing some out-of-band output
> before the session headers were sent that was now being buffered.
> Sure enough I found some code that was outputting some response text
> before session_start() was called. On the test machine this output
> was being buffered until after session_start(), so no apparent problem
> existed.
>
> I think the lesson here is, if you're missing headers in your output,
> assume first that it's because you've started body output before the
> headers in question were sent. If I'd made that assumption earlier I
> probably would have saved hours on this bug! (otoh, doesn't that
> situation normally result in a PHP warning? where'd that go? oh
> well...).
most likely ini setting display_errors is OFF - chances
are the PHP errors/warnings/etc are being logged to the apache error log.
>
> - Matt
>
--- End Message ---
--- Begin Message ---
I have a specific email Inbox in MS Exchange that I need to get to and
read with PHP.
I'm not certain, but I think it's using what MS Exchange calls
"multi-user", based on my Googling...
There is one real NT Login User (Administrator) and in MS Outlook,
that user is presented with a popup of multiple email addresses during
the startup process, so they can choose which mailbox to read.
Using PHP + IMAP, I can do:
imap_open('{a.b.c.d}Inbox', 'Administrator', '********');
This gets me into the Administrator Inbox.
Unfortunately, I need to get into the [EMAIL PROTECTED] Inbox.
Peeking around in MS Exchange, 'user' is NOT an actual NT Logon.
That email address is tied to the Administrator NT Logon.
So how does one switch to another mutli-user mailbox?
I've tried every reasonable combination of inputs to imap_open() and
imap_list() that I can think of.
I've also tried more than a few very UN-reasonable combinations, since
this IS Microsoft. :-)
I have been Googling and reading a ton of documentation, most of which
tells me how to do what I already know how to do, which is to get to
Administrator's Inbox.
I'm also very open to another Open Source solution, maybe even a
commercial solution, to be able to read this multi-user's Inbox with
PHP.
TIA!
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
--- End Message ---
--- Begin Message ---
At 9:02 PM +0100 12/12/06, Tim wrote:
Just a quick question regarding this issue.
Considering bruce wants to be able to display the data and then change
location after a given time, and as stut said you can't do this with a
header() as it redirects before output, I would have imagined a dynamic meta
tag in the header with a time variable and a location variable.
Why not use the standard meta refresh tag? It's worked for me before.
tedd
PS:
I have lots of comments. Thoughts are less common but they do
occasionally happen.
-Stut
LOL
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Search Engines don't like the META tag.
Use
<script>location.href='foobar.php';</script><a href='foobar.php'>Foo Bar</a>
On 12/13/06, tedd <[EMAIL PROTECTED]> wrote:
At 9:02 PM +0100 12/12/06, Tim wrote:
>Just a quick question regarding this issue.
>
>Considering bruce wants to be able to display the data and then change
>location after a given time, and as stut said you can't do this with a
>header() as it redirects before output, I would have imagined a dynamic meta
>tag in the header with a time variable and a location variable.
>
Why not use the standard meta refresh tag? It's worked for me before.
tedd
PS:
>I have lots of comments. Thoughts are less common but they do
>occasionally happen.
>
>-Stut
LOL
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
At 2:15 PM +0800 12/13/06, Kai Xiang wrote:
Hello all:
I'm new here and looking PHP these days, howerver , I'm confused by how it
works, and here is some questions I have.
Is there any old bird wanna help me out?
Sure, which way did you come in?
You might want to ask one of the younger birds, they remember most of
what we forgot.
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Thanks Jochem, Roman :)
On 12/13/06, Jochem Maas <[EMAIL PROTECTED]> wrote:
Kai Xiang wrote:
> On 12/13/06, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
>
>> # [EMAIL PROTECTED] / 2006-12-13 14:15:26 +0800:
>> > I'm new here and looking PHP these days, howerver , I'm confused by
how
>> it
>> > works, and here is some questions I have.
>> > Is there any old bird wanna help me out?
>> >
>> > 1. I heard there is a zend engine inside PHP playing the role as a
>> virtual
>> > machine, and PHP excution have 2 step, first compile to opcode and
then
>> > excute the opcode,
>> > so is that means the php are compiled only once per file? or still
need
>> to
>> > recompile when another request issued to the server? also I heard
about
>> the
>> > caching extention about php, is it talking about caching the opcode?
>> is't
>> > caching the opcode or excute results? how it shares between the
>> requests?
>>
>> Both kinds of things exist, with different sharing strategies.
>
>
> Can you tell it more detail, opcode caching cache the compiled opcode,
so
> not any compile needed anymore if no source changed? what about results,
> what kind of methdology it's taking?
you can get a good idea of APC from the changelog:
http://pecl.php.net/package-changelog.php?package=APC
Zend als offers opcode caching as part of their suite of products ... Im
not all to familiar with Zend's stuff but no doubt their website has
plenty
of info.
>
>
>
>> > 3. Take linux apache for example, if compiled as a apache module, and
>> using
>> > prefork threading model, for example, if I have 100 process, is that
>> means I
>> > have 100 copy of PHP library local data(I assume only one reentrant
>> > excutable image) in each process? compare to a worker model, like 10
>> process
>> > and 10 threads in each one process, should it make a difference that
we
>> only
>> > have 10 copy of PHP library local data ?
>>
>> Practical concerns make your question moot: even if the basic
>> distribution was all threadsafe, you're bound to hit a library that
uses
>> strtok(3) or strerror(3), or static variables. How much of the code you
>> rely on is labelled by its authors as threadsafe?
>
>
> So it is not a good idea to use worker and php module at the same time,
but
correct - stick with the prefork module with apache, I believe *think* it
is possible
to safely use a threaded module if you decide to go the FastCGI route but
I maybe
thinking this because I completely misunderstood what someone was saying
about FastCGI
(I remember reading quite abit about FastCGI in posts made to
[email protected]
by core-dev/Zend-Founder Andi Gutmans - although I can't say I understood
everything I read!)
> if no threadsafe problem , maybe my thinking is right?
> Btw, I thought strerror in libc were thread-safe.
>
>
--- End Message ---
--- Begin Message ---
On 12/14/06, tedd <[EMAIL PROTECTED]> wrote:
At 2:15 PM +0800 12/13/06, Kai Xiang wrote:
>Hello all:
>
>I'm new here and looking PHP these days, howerver , I'm confused by how
it
>works, and here is some questions I have.
>Is there any old bird wanna help me out?
Sure, which way did you come in?
You might want to ask one of the younger birds, they remember most of
what we forgot.
Ha, that sounds interesting :)
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On Tue, 5 Dec 2006 12:37:48 -0000, "Chris Dean" wrote:
> I was just wondering if anyone knows why php's utf8_encode
> function converts the £ symbol into £
Yes. The '£' character is a two-octet sequence
in UTF-8. The problem is that you are viewing it
as if it were encoded in ISO-8859-1 (or similar).
These are the octet sequences for the characters
involved:
Character ISO-8859-1 UTF-8
----------- ---------- -------
£ (pound) <a3> <c2 a3>
 (A-circ.) <c2> <c3 82>
In other words, you are seeing the two characters
<c2><a3> instead of the one character <c2 a3>.
The fact that <a3> appears in both encodings is
nothing more than an interesting coincidence.
Example (right):
<?php
header ('Content-Type: text/plain; charset=utf-8');
echo utf8_encode ("\xa3");
?>
Example (wrong):
<?php
header ('Content-Type: text/plain; charset=iso-8859-1');
echo utf8_encode ("\xa3");
?>
--nfe
--- End Message ---
--- Begin Message ---
Craige Leeder wrote:
> I have been working with PHP5 since it's release, and until a few
> months ago, have never experienced the problem I am about to describe
> to you. I am not sure weather it has been discovered previously or
> not, nor do I know exactly how to replicate it, but I would like to
> know if you have encountered the problem as well. The problem is this:
>
> I have noticed that there appears to be (fatal) errors that do not
> show when they occur in an included file. The script simply halts
> execution, and returns headers to the browser. I do not have a list of
> the errors that do not display, but I do not believe it applies to all
> fatal errors.
>
> The errors show perfectly fine when the file is called directly from
> the php parser (/through the browser), just not when included. This is
> an extreme annoyance, and would like to know if it has been
> discovered. As far as I can tell, the errors seem to apply mostly to
> Objects and classes, but I cannot be certain. I have not run too many
> tests on the problem.
I have run into this issue since almost the beginning of php5 - never
really have got a handle on it.
what I do know is that it's, in my case, always/only occurs in cases
where syntax error causes an included file to fail to parse. I also
know that it's only occurs when the complexity of an application
rises above a certain level - I've never been able to reproduce
using a debugger to step through code that is giving the blank page
always makes the fatal error 'appear' (i.e. the debugger returns
the error) - at least that is what I found when I last test ZDE.
whenever I get the blank screen of death (PBSOD?) I run the following
cmdline in the root directory of the project in question (you
may need to change it a bit to suit your needs), it quickly tells you
what is not parsing (it assumes your code is running on a real OS ;-):
find . -name \*.php \! -exec php -l {} \;
>
> Although it should not need to be stated, I do have error reporting
> set to E_ALL.
are you sure there is nothing changing the error_reporting or display_errors
somewhere in the code (maybe some third party code) - I vaguely remember being
caught out by Smarty's error handling code with respect to this problem.
anyway no real answers from me, but at least you know your not alone ;-)
>
> - Craige
>
--- End Message ---
--- Begin Message ---
At 5:14 PM +0100 12/12/06, Børge Holen wrote:
On Tuesday 12 December 2006 15:02, Jochem Maas wrote:
> Børge Holen wrote:
> > It is sad to see that you got an amazing tool like this list and still
> manages to read and understand it the way you FEEL like at any moment.
what makes this list 'amazing' is the handful of people who regularly
answer (even the most banal) questions.
the interpretation is the perogative of the reader - if you feel you are
being misunderstood your only recourse is to write more clearly, moaning
about how other people 'feel like reading & understanding' what you write
is futile and childish.
AFAIC rather than hiding your derision behind some politically correct
'sadness' (which you either imply to be some kind of fact and/or an opinion
shared by some unnamed group - whereas I hazard to guess that neither is
even close to the truth) just come out and say what *you* mean.
LOL, Yes yes, I agree with a lot of what you are saying, more or less bs.
but then again; you are a complete moron. go relieve yerself, that would
probably help.
Well... if Jochem is a moron, then I must be
dunce because I've learn a lot from him, and
continue to do so. If you take the time to
listen, even you might learn something.
tedd
As Funkadelic once said:
"Free your mind... and your ass will follow."
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
tedd wrote:
> At 5:14 PM +0100 12/12/06, Børge Holen wrote:
>> On Tuesday 12 December 2006 15:02, Jochem Maas wrote:
>> > Børge Holen wrote:
>>>
...
>
> Well... if Jochem is a moron, then I must be dunce because I've learn a
> lot from him, and continue to do so. If you take the time to listen,
> even you might learn something.
:-) very kind of you - note that the knowledge flows boths ways, I might be
rather far down the php road but from what I gather you were programming rocks
when I was still wearing nappies, many times I find myself learning something
new
about IT/programming in general from the old skool brigage - something Im very
grateful
for... let's hope Eight-of-Nine comes around and joins the 'clan'**.
fancy a change? I'll swap my moron badge for your dunce cap and a packet of
peanuts. :-P
also there's a rather nice chap on this list claiming to be the village idiot,
maybe we can convince into a 3 way swap - a change of scene for every kind of
fool? :-)
** replace 'clan' with whatever word synonymous with the concept of 'group'
doesn't offend you (in reference to a post ages ago where someone complained
about
tedd's use of the word 'gang'.
>
> tedd
>
> As Funkadelic once said:
> "Free your mind... and your ass will follow."
>
--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
Seems like this list has slowed down alot.
Anybody else notice this, or am I just missing something?
jl
If you're referring to what I think you are .... yes ..... I get almost
nothing but timeouts when trying to do anything in this newsgroup.
--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
*****************************
--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
Seems like this list has slowed down alot.
Anybody else notice this, or am I just missing something?
jl
If you're referring to what I think you are .... yes ..... I get almost
nothing but timeouts when trying to do anything in this newsgroup.
--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
*****************************
--- End Message ---