[PHP] include_once behaves differently in mod_php4 vs php5-cgi

2005-11-30 Thread Toomas Aas

Hello!

There's a website with a following structure

index.php in the site's DocumentRoot directory (for this thread, let's 
call it /www)


functions.php, init.php and db_connect.php in /www/library

index.php includes line:

include_once('library/functions.php');

functions.php includes lines:

include_once('db_connect.php');
include_once('init.php');

The website was running fine under PHP 4.4.0 installed as Apache module.

Then we tried it with PHP 5.0.5 installed as CGI. We got the following 
errors:


PHP Warning:  main() : open_basedir restriction in effect. 
File(/db_connect.php) is not within the allowed path(s): 
(/www:/usr/local/www/phpMyAdmin:/var/tmp/php) in 
/www/library/functions.php on line 2
PHP Warning:  main(db_connect.php) : failed to open stream: Operation 
not permitted in /www/library/functions.php on line 2
PHP Warning:  main() : Failed opening 'db_connect.php' for inclusion 
(include_path='.:') in /www/library/functions.php on line 2


...and similar 3 messages about init.php.

Note that first warning is about '/db_connect.php', not 'db_connect.php' 
or './db_connect.php'. /www/library should be inside the open_basedir, 
since it is under /www, which is listed in open_basedir in php.ini. It 
looks like something is changed in PHP's behaviour between versions 4 
and 5 or is differently handled in CGI vs Apache SAPI, but I find it 
unlikely since I can find no documentation regarding this. It's more 
likely that I am overlooking something trivial, but I can't figure out 
what it is.


I tried to change the include lines to

include_once('./db_connect.php');
include_once('./init.php');

but this made no difference.

However, when I specify the full path:

include_once('/www/library/db_connect.php');
include_once('/www/library/init.php');

then the errors disappear and 'everything' seems to work.

Also, I never get any errors about the

include_once('library/funcions.php');

line in index.php

I'm puzzled...


--
... ASCII stupid question, get a stupid ANSI!

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



[PHP] iconv() in PHP returns 'Unknown error 0'

2005-09-07 Thread Toomas Aas

Hello!

I am managing a FreeBSD 4.11 server which is currently running PHP 
4.3.11.  The server was originally installed in 2003 with an older 
version of PHP and libiconv 1.8. All software has been installed from 
FreeBSD ports. Over the time PHP has been upgraded several times, but 
libiconv has remained untouched:


mail# pkg_info | grep iconv
libiconv-1.8_2  A character set conversion library
php4-iconv-4.3.11   The iconv shared extension for php

There was a time when PHP's iconv() function definitely worked on this 
server, but now it seems to have a problem. I copied and pasted this 
simple test script from www.php.net:


-
?php
echo iconv(ISO-8859-1, UTF-8, This is a test.);
?
-

When I load this script via the browser, PHP outputs nothing. I have 
error logging set to file only, and in the log file there is this error:


[07-Sep-2005 12:10:07] PHP Notice:  iconv(): Unknown error (0) in 
/storage/www/iconvtest.php on line 2


This is the only error I see in PHP's error log or any other logfile 
with similar timestamp.


The iconv extension is loaded and can be seen in output of phpinfo().

I read that sometimes on FreeBSD you need to use libiconv() instead of 
iconv(), but this is not the case here - when I replace iconv() with 
libiconv() I get PHP Fatal error:  Call to undefined function: 
libiconv().


I can successfully run iconv from command line:
$ echo This is a test.  iconvtest
$ iconv -f ISO-8859-1 -t UTF-8 iconvtest
This is a test.

Is it possible that my problem is caused by anything *else* than iconv 
library being out of date compared to PHP's iconv extension? If I need 
to update libiconv, I also need to update lot of things that depend on 
it, and this takes some time. If there is some quicker way to get PHP's 
iconv extension functional, I'd prefer to use that for now.


--
Toomas Aas 
|arvutivõrgu peaspetsialist | head specialist on computer networks|
|Tartu Linnakantselei   | Tartu City Office   |
- +372 736 1274

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



Re: [PHP] iconv() in PHP returns 'Unknown error 0'

2005-09-07 Thread Toomas Aas

Toomas Aas wrote:


-
?php
echo iconv(ISO-8859-1, UTF-8, This is a test.);
?
-

When I load this script via the browser, PHP outputs nothing. I have 
error logging set to file only, and in the log file there is this error:


[07-Sep-2005 12:10:07] PHP Notice:  iconv(): Unknown error (0) in 
/storage/www/iconvtest.php on line 2


It looks like I found the solution myself. To my great surprise, the 
order of 'extension' lines in php.ini seems to be significant. As those 
of you who use FreeBSD might know, if you install PHP and a choice of 
extensions from ports, then extensions are described in separate file 
/usr/local/etc/php/extensions.ini. I moved the line describing 
'iconv.so' to the first line in this file, and the test script quoted 
above started working as expected.


--
Toomas Aas 
|arvutivõrgu peaspetsialist | head specialist on computer networks|
|Tartu Linnakantselei   | Tartu City Office   |
- +372 736 1274

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