You are not logged in.

#1 2005-04-04 20:51:06

chane
Member
Registered: 2003-12-02
Posts: 93

PHP script can't find import

I'm trying to run a php script I downloaded for web log file analysis.  When I run it I am getting the following error:

[root@bacchus http]# ./statviz.php --config example.conf

Warning: main(Config.php): failed to open stream: No such file or directory in /home/chane/http/statviz.php on line 28

Fatal error: main(): Failed opening required 'Config.php' (include_path='.:/usr/share/pear') in /home/chane/http/statviz.php on line 28

I am running this as root and just to be sure have set all paths in /home... to be chmod 777.

Line 28 is:

require_once 'Config.php';

When I look in the /usr/share/pear directory there is not a file named Config.php.  This file is located in .../pear/PEAR/Config.php.

I have tried to change the require to be PEAR/Config.php but that did not load it either.

My php install is vanilla via pacman.  I am not a php expert so any suggestions as to how to fix this are much appreciated.

BTW: here is the script I am trying to run:
http://statviz.sourceforge.net/

Thanks in advance,
Chris....

Offline

#2 2005-04-04 20:59:48

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: PHP script can't find import

it looks like you executed it from within your user public_html folder (although your folder is renamed).
Be aware that apache uses su_exec for php files executed in this folder. It will modify the permission structure for includes and file writing..

Try looking at the log file in /var/log/httpd/suexec_log

The file you try to include would have to have the same user (or group, depending on how you setup su_exec). It is similar to php safe mode, I believe..


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#3 2005-04-04 21:23:41

chane
Member
Registered: 2003-12-02
Posts: 93

Re: PHP script can't find import

forgot to mention I am running this from the command line and not via a web server.  In essence this program takes a file in and generates a file out.  I just happened to have named the subdirectory http since the script is analyzing web log files.

Could I have the path setup incorrectly for php to be used from the command prompt?

Just reread your post and I will look further into php safe mode?  Maybe that's it....

EDIT: safe mode is off in the php.ini file....

Chris....

Offline

#4 2005-04-04 21:31:35

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: PHP script can't find import

maybe the PHP include paths need to be modified? just thinking outloud....

Offline

#5 2005-04-04 21:50:15

chane
Member
Registered: 2003-12-02
Posts: 93

Re: PHP script can't find import

simple question - how do I change the php include path?

I'm willing to try anything....

Chris....

Offline

#6 2005-04-04 22:03:35

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: PHP script can't find import

edit php.ini

; UNIX: "/path1:/path2"
include_path = ".:/php/includes:/usr/share/pear:/usr/share/pear/PEAR"
;

I am not sure why the pear in arch is layout as as it is..Maybe the pear packager knows..

EDIT: For some reason, it seems you need to include both the base pear dir, and PEAR dir in includes..
/usr/share/pear/Console
/usr/share/pear/Console/Getopt.php

These are not in the PEAR dir, but they are required by your script..
I altered the include accordingly.

EDIT2: Another solution. Just add this to the top of the php script..

<?php
ini_set("include_path",ini_get("include_path").":/usr/share/pear:/usr/share/pear/PEAR");
?>

"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#7 2005-04-04 22:30:24

chane
Member
Registered: 2003-12-02
Posts: 93

Re: PHP script can't find import

I edited the php.ini file.  Two interesting things:

First, the include_path was commented out.  I found the interesting since the error message had a path in it (.:/usr/share/pear).

Second, I uncommented and made the path look like:
include_path=".:/usr/share/pear:/usr/share/pear/PEAR"

and I got this error:
FATAL: Config module required. Please install the PEAR module: Config

Offline

#8 2005-04-04 22:40:00

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: PHP script can't find import

see my edits above. I later noticed that the base pear dir also had to be included..
as for the include path being commented out and still having a value. the initial string listed is the default value, meaning that is what it is set to if it is commented out. If you oncomment and CHANGE it, then it gets modified..


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#9 2005-04-04 22:52:25

chane
Member
Registered: 2003-12-02
Posts: 93

Re: PHP script can't find import

Catcus - thanks for your help.

Sometimes I dislike technology....

I tried both of your sugestions for modifying the import path and ended up with the following code:

#!/usr/bin/php -d output_buffering=0
<?php
ini_set("include_path",ini_get("include_path").":/usr/share/pear:/usr/share/pear/PEAR");

// constants
define('STATVIZ_CONF_TYPE', 'inifile');

// includes
require_once 'Console/Getopt.php';
require_once 'Config.php';

// check dependencies
if (!class_exists('Console_Getopt')) die('FATAL: Console_GetOpt module required. Please install the PEAR module: Console_GetOpt' . "n");
if (!class_exists('Config')) die('FATAL: Config module required. Please install the PEAR module: Config' . "n");
</snip>

When I run this I am hitting the second error message !class_exists('Config')....

Did you download this script and get it working on your box by chance?

Thanks for you help,  I appreciate you taking the time to walk me through something that should be simple...
Chris....

Offline

#10 2005-04-04 23:09:11

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: PHP script can't find import

I added:

ini_set("include_path",ini_get("include_path").":/usr/share/pear/PEAR");

to the script right before the
define('STATVIZ_CONF_TYPE', 'inifile');
section

Then I had to install Config for PEAR...

prompt$ sudo pear install Config

then running the script worked fine.
I think the files in /usr/share/pear are just for using pear itself (ie installing pear elements). Whereas the files in /usr/share/pear/PEAR are the files used by php scripts, hence, that dir should be the one in the include, and not the base pear dir..


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#11 2005-04-04 23:12:20

chane
Member
Registered: 2003-12-02
Posts: 93

Re: PHP script can't find import

Catcus -

A big thank you.

The last trick of installing Config was what I was missing.

Thanks again!

Chris....

Offline

#12 2005-04-04 23:14:02

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: PHP script can't find import

np.
glad to get you working..


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

Board footer

Powered by FluxBB