Re: [PHP] Help! Apache 2.2 gives segmentation fault errors with PHP.

2006-02-16 Thread Olaf Greve

Hi all,

Yesterday I had trouble when configuring Apache 2.2 with PHP 4.4.2, 
which caused Apache to crash (segmentation fault) when calling various 
PHP functions. Just before heading home I encountered the source of the 
issue, as well as the solution.


The hint to the answer resided in the /var/log/httpd-error.log file:

 And the /var/log/httpd-error.log file mentions the following (at the 
end):

 [...]
 PHP Warning:  Function registration failed - duplicate name - bzopen in
 Unknown on line 0
 PHP Warning:  Function registration failed - duplicate name - bzread in
 Unknown on line 0
 [...]
 ..many more similar messages...

This obviously hinted at these functions (i.e php4-extensions) somehow 
being doubly present and called.


Issuing a 'pkg_info | grep php' command was most illustrative, and 
showed over a screen full of output like this:


mod_php4-4.4.2_1,1  PHP Apache Module
php4-bcmath-4.4.2_1 The bcmath shared extension for php
php4-bz2-4.3.10 The bz2 shared extension for php
php4-bz2-4.4.2_1The bz2 shared extension for php
php4-calendar-4.4.2_1 The calendar shared extension for php
php4-crack-4.4.2_1  The crack shared extension for php
php4-ctype-4.4.2_1  The ctype shared extension for php
php4-dio-4.4.2_1The dio shared extension for php
php4-domxml-4.4.2_1 The domxml shared extension for php
php4-exif-4.4.2_1   The exif shared extension for php
php4-extensions-1.0 A meta-port to install PHP extensions
php4-gd-4.3.10  The gd shared extension for php
php4-gd-4.4.2_1 The gd shared extension for php
[...more lines where those came from...]

Tadh!! there we go: indeed several extensions were somehow not 
removed properly when a previous upgrade to PHP 4.4.2 (from v4.3.10) was 
performed!


As to the reason for this, go figure, I always install from the ports by 
doing a 'make' 'make deinstall' 'make reinstall' sequence when upgrading...


Anyway, manually removing all PHP extensions using the various 
individual 'make deinstall' sequences (and bluntly pkg_delete for pear). 
Then, I cleanly redid the process for installing mod_php4 and the 
extensions, and now all is working fine!


Tnx for thinking along with me, and beware of this potential pitfall! :)

Cheers!
Olafo

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] installing php 4.4.2 on windows system

2006-02-16 Thread Olaf Greve

Hi Paul,


I have been developing a php website.  I have been ftping my php web
pages to a webserver and that works hkowever I don't have an error log
on the webserver.  So I downloaded apache 2.0.55.   I am doing a
manual installation and I am at the point where it tells me where to
place the php.ini file.  The instructions tell me to put the file in a
number of places. The directions told me that if I were using apache
to use the PHPIniDir directive.  My question is where do I put the
php.ini file? Where do I put this Directive? In the Httpd.conf?


Under Windows it didn't use to be necessary to make Apache explicitly 
point to the ini file (at least: for all Apache 1.3.x versions). Rather, 
the trick used to be to simply place the php.ini file somewhere in the 
path that has been set for all Windows applications.


Normally, the 'windows' or 'winnt\system32' directories do the trick. If 
you're working under NT, 2000, or XP give the latter a go and restart 
Apache. Chances are it still picks it up swell. If it doesn't, then 
indeed perhaps as of Apache 2 you need to explicitly make Apache point 
to the right file.


Cheers!
Olafo

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Help! Apache 2.2 gives segmentation fault errors with PHP.

2006-02-15 Thread Olaf Greve

Hi guys,

Alright, after having been stuck with this for an hour or two now, I'm 
going to call upon your infinite wisdom regarding the following:


On a FreeBSD 5.2.1-RELEASE #0 (so says dmesg) machine, I'm trying to 
set-up Subversion, Trac and our regular PHP4 and MySQL stuff.


The main issue is that Apache 2.2 blows up (with a segmentation fault) 
when calling various PHP scripts, which I think is due to a dodgy way of 
having set-up PHP4 under Apache. This message works towards the issue, 
providing relevant(?) details, as I type along:


Here we go:
Previously the machine was running Apache 1.3.34 and that went just 
swell with PHP and all, but apparently for Subversion and/or Trac, 
Apache 2 is desired such that it can be used with WebDav.


No problem so far. I made sure the ports tree was up to date and then 
from the ports I built (always via a 'make' 'make install' sequence, and 
where necessary removing earlier versions as the process went along) 
Apache 2.2, and Subversion.


Upon configuring Apache 2.2 for PHP, however, I'm now running into 
trouble. In order to make PHP4 work under Apache 2.2 I built 
/usr/ports/www/mod_php4 and installed it.


Then I added the following to Apache's httpd.conf file:
[...]
LoadModule php4_modulelibexec/apache22/libphp4.so
[...]
IfModule mime_module
[...]
   AddType application/x-httpd-php .php
   AddType application/x-httpd-php-source .phps

Also, some other stuff was tweaked in httpd.conf (though very mildly), 
like enabling SSL etc.


Now, upon starting Apache, using 'apachectl start' the following warning 
is printed twice:
[Wed Feb 15 15:12:41 2006] [warn] (2)No such file or directory: Failed 
to enable the 'httpready' Accept Filter


And the /var/log/httpd-error.log file mentions the following (at the end):
[...]
[Wed Feb 15 15:12:38 2006] [notice] caught SIGTERM, shutting down
[Wed Feb 15 15:12:41 2006] [warn] RSA server certificate is a CA 
certificate (BasicConstraints: CA == TRUE !?)
[Wed Feb 15 15:12:41 2006] [warn] RSA server certificate CommonName (CN) 
`Olaf Greve' does NOT match server name!?
[Wed Feb 15 15:12:42 2006] [warn] RSA server certificate is a CA 
certificate (BasicConstraints: CA == TRUE !?)
[Wed Feb 15 15:12:42 2006] [warn] RSA server certificate CommonName (CN) 
`Olaf Greve' does NOT match server name!?
PHP Warning:  Function registration failed - duplicate name - bzopen in 
Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - bzread in 
Unknown on line 0

[...]
..many more similar messages...
[...]
PHP Warning:  Function registration failed - duplicate name - 
ob_gzhandler in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - 
zlib_get_coding_type in Unknown on line 0
PHP Warning:  zlib:  Unable to register functions, unable to load in 
Unknown on line 0
[Wed Feb 15 15:12:42 2006] [notice] Digest: generating secret for digest 
authentication ...

[Wed Feb 15 15:12:42 2006] [notice] Digest: done
[Wed Feb 15 15:12:43 2006] [notice] Apache/2.2.0 (FreeBSD) mod_ssl/2.2.0 
OpenSSL/0.9.7c DAV/2 PHP/4.4.2 configured -- resuming normal operations



So it starts, but it seems pretty much all PHP extensions are doubly 
declared!
When calling phpinfo, the modules do show up as expected, but as soon as 
one tries to use e.g. the 'header()' function in PHP (or quite a few 
other PHP functions for that matter), nothing seems to happen in the 
browser, and the /var/log/httpd-error.log file mentions the following:

[...]
[Wed Feb 15 15:19:29 2006] [notice] child pid 27728 exit signal 
Segmentation fault (11)


And a similar message is written to /var/log/messages, being:
[...]
Feb 15 15:19:28 aceshuttle kernel: pid 27728 (httpd), uid 80: exited on 
signal 11



I suspect something went wrong in the way I try to use PHP. Basically, I 
first removed the installed /usr/ports/lang/php4 port, then built and 
installed the /usr/ports/www/mod_php4 port, and then added various 
php4-extensions, using the /usr/ports/lang/php4-extensions port (I 
suspect the extensions to cause the problem).


Does anyone know what could be going on and/or how to properly set up 
PHP 4 under Apache 2.2?


Tnx a lot in advance, and cheers!
Olafo


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to output multiple tables nicely(!) from PHP in Excel format?

2006-02-08 Thread Olaf Greve

Hi,

One of our clients is a true Excel wizard and in order to enable his 
highly advanced sheets to become available for others as well (editable 
and all), I have created a PHP version of his Excel sheets which uses a 
MySQL DB for storage.


I shall spare you all the technical intricacies of the sheets in 
question, and shall in stead suffice by stating that the generated 
tables use a great amount of cells and rows, where several rows have 
been colspanned and use a varierty of colours and borders as well.
Good, so far no biggie, but of course the same client has now requested 
that the same complex HTML tables also be outputtable as Excel again. :)


Still, in itself no problem, just starting the script with the following:
?
Header (Content-type: application/vnd.ms-excel);
flush();
?

And then omitting all HTML tags, but for the ones generating the HTML 
table (i.e. no body tags, head tags, javascripts, etc.) and for the ones 
within the table that use spacer graphics to force specific column/row 
widths/heights nicely does the trick.


Again: so far so good.

But now for the issue:
The client's request is to create three different complex tables (with 
three different complex lay-outs) like these, preferrably in one Excel 
sheet. I have yet to figure out a way to do this nicely. Just creating 
three tables and sending them to the same output works, but the columns 
will then always force the widths to the biggest width, spun over the 
columns of the three tables. This is where the issue is: the three 
individual tables will then no longer have nicely formatted and sized cells.


Does anyone know of a way to achieve this nicely, preferrably creating a 
tab per table?


Thanks in advance, and cheers,
Olaf

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to output multiple tables nicely(!) from PHP in Excel format?

2006-02-08 Thread Olaf Greve

Hi all,

I've written a ArrayToExcel(XML) class, you're welcome to use if you 
wish. May need a bit of tweaking to get the colspan working (I haven't 
touched it in quite a while). But the process itself I think is rather 
nice :)


 http://projects.londonis.co.uk/arraytoexcel/

Thanks for your answer and the offer. I checked it, but I somehow do not 
see multiple tabs appear (neitehr in the direct .xls output, nor in the 
two XML versions)?!?


Meanwhile I've been playing around somewhat more with my own code (which 
in this case has the advantage that I have to do little rewrites in the 
code in order to use solely one script for both an HTML view as well as 
an Excel view), and most of it looks satifactorily enough. The only (?) 
nasty thing left is that the column widths are always set to that of the 
widest column, so I'll need to figure out a work around for that (e.g. 
by using different table headers for the .XLS version).


I would still be very interested in a way to get the 3 tables sent to 
different tabs though, but I'm not certain the way I do it can take care 
of that.


If anyone can tell me how to go about this, it would be greatly 
appreciated...


Cheers!
Olafo

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to destroy HTTP authentication (from PHP)?

2006-02-01 Thread Olaf Greve

Hi all,

Alright: here's a bit of a challenge (so as to avoid the word issue) 
;) my colleagues have run into previously: how to kill HTTP 
authentication...


I remember that they never did figure that one out, and I too will now 
have to get my hands dirty with trying to find a proper way to do so.


Simply unsetting the PHP_AUTH_USER and PHP_AUTH_PWD variables doesn't 
seem to do any magic, and using a forced 401 ('Unauthorized') HTTP 
header is also highly ideal (not to say blatantly dirty)...


S, has anyone found a proper way of achieving this (ideally from PHP)?

Also, in case this cannot be done from PHP, does anyone know of any 
Apache modules (or tricks/tweaks/settings) that will allow HTTP 
authentication to be neatly destroyed?


Thanks in advance, and cheers,
Olafo

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to destroy HTTP authentication (from PHP)?

2006-02-01 Thread Olaf Greve

Hi Jochem (and others),


save the 'authenticated' state in the session;
only send out the http auth headers when:

1. the user is not authenticated
2. the page is should be protected

logging out would then clear the 'authenticated'
state from the SESSION

now I probably didn't explain that very well - but I can say I
have that concept working - unfortunately the relevant classes
that I wrote to do that are heavily interdependent on other
stuff which makes it's useless for putting the point accross;
anyway hope the idea helps.


Actually, the idea does make a lot of sense. In fact, that very trick 
was what was previously used in the application. The reason it's not 
used anymore like that, is that the PHP sessions didn't seem to work 
reliably for several end users (a long story...), and that we're trying 
to revert back to the inherent authentication mechanism (i.e. HTTP 
authentication) of the CMS that's being used...


Anyway... I just encountered the following page:
http://httpd.apache.org/docs/1.3/howto/auth.html

If you scroll down to the section called: How do I log out?, you'll 
find a pretty definite answer regarding 'real' HTTP authentication 
destruction: it cannot be done. :(


Good, I'll ponder some more on a good 'plan B' to provide the client 
with the functionality they desire, without having to spend too many 
hours on it...


Tnx for the answers!

Cheers!
Olafo

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Problems with GZIPped content in some cases?!?

2006-01-31 Thread Olaf Greve


Hi all,

Firstly, I'm new to this list, so I'm hoping I'm not flogging a dead 
horse with this question, and I also hope I'm not inadvertently breaking 
any list etiquete in any way...

Should this be the case, I apologise in advance. :P

Alright, with that out of the way, I'll post my actual question:

I find myself with very limited time to fix a bug in my code regarding 
explicit GZIP compression. The server on which it runs (Debian Linux, 
PHP 4.1.2) does not have the output handler set to ob_gzhandler, nor 
does it have the zlib.compression directive set to on.


Now, when using the (shortened for brevity) below code I was given 
previously for this, I run into the following weird behaviour:

-It works for most people.
-For some people, their browser prompts them that it wants to download 
an application of type PHP.
-For yet some other people, the shown page seems to only contain a lot 
of garbled (GZIPped, I suppose...) data.


I have previously seen weird things like this happen with GZIP 
(particularly when enabling it via the php.ini directives AND then 
trying to do so explicitly with code like the code posted here), but in 
this case I'm not certain what the exact source of the problem is (I'm 
guessing something with the headers is off or so)...


Then: this sounds like something that other developers will previously 
have run into, so I'm hoping someone knows the definitive answer, or at 
least some good pointers for solving it...


So, if someone has any ideas, can they please let me know (off-list in 
case the reply is deemed off-topic for this list)?


Thank you all kindly in advance, and with kind regards,
Olaf Greve



?
ob_start();
ob_implicit_flush(0);

function CheckCanGzip(){
global $HTTP_ACCEPT_ENCODING;
global $HTTP_HOST;
if (headers_sent() || connection_aborted()) return 0;
if (strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false) return x-gzip;
if (strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false) return gzip;
return 0;
}

function gzdataout($level=1){ // level = compression level 0-9, 0=none, 
9=max


$Encoding = CheckCanGzip();

$Content = ob_get_contents();
ob_end_clean();

if($Encoding){
header(Content-Encoding: .$Encoding);
echo \x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xFF;
echo substr(gzcompress($Content,$level),2,-4);
} else {
echo $Content;
}
flush();
exit();
}
?
actual page content
?
gzdataout();
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Problems with GZIPped content in some cases?!?

2006-01-31 Thread Olaf Greve

Hi Barry (and others),

Thanks for your answer!


This is surely a browser problem.


I already feared as much...

The nasty thing is that due to this some of the end users of our client 
are losing confidence in the way the application works.
Disabling GZIP is not really what I want to do either, as some pages 
alone comprise about 1MB (!) of pure HTML...:D


However... I have of course also been RTFM-ing a good bit, and I'm now 
trying the far simpler per page override of the output buffer by using 
the following function call:


ob_start(ob_gzhandler);

This seems to enforce GZIP compression correctly (I've performed a 
socket call and analysed the headers and data, and it is GZIPped 
alright, and the header for GZIP compression is set as well), so I have 
just informed our client that I would like them to test it again.


I will keep the list posted as well to let you know if it works 
correctly now or not...


Cheers,
Olafo

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php