开发者

PHP script unable to find a file when called by a flash program

I'm working on a program right now that calls the script mail.php located in 开发者_StackOverflow中文版/var/www/vhosts/company/httpdocs. mail.php is trying to execute require_once dirname(__FILE__).'/../pear/Mail.php' to do an smtp send and the require_once is failing. My PEAR directory's located in /var/www/vhosts/company/pear. I then tried to add /var/www/vhosts/company/pear to the include_path but require_once is still failing.

I decided to take a step back and replace mail.php as a simple script that does file_exists(dirname(__FILE__).'/../pear/Mail.php') and prints the result to a logfile. When I run the script independently, it works fine and returns 1. When the flash program runs it, it's returning nothing. Printing out dirname(__FILE__).'/../pear/Mail.php' returns the same regardless if I run the script independently or if the flash file runs it. I've also tried chmod 777 on the Mail.php PEAR file but that didn't do anything.

Any ideas on what's going on?


I would bet anything it has to do with two things:

1) Flash/Actionscript normally does not access local file paths.

In other words, it probably isn't even executing the file.

As a compiled client-side module it needs an actual web-accessible URL. Part of the problem here is the design itself. Try it with an HTTP request within the actionscript and you will have better results. If you don't have access to the flash file.. well tough beans there.

Now if you are running a mail routine through actionscript? I would say that is a security risk. You are better off having the actionscript pass the routine to an AJAX receiver routine that checks session credentials and then sends mail.

2) CWDUP restrictions on the server.

Depending on certain server configurations, excecutables normally do not have access to filepaths outside their own root. (i.e. an executible cannot call ....\another directory\other file.) Some servers will allow this, but many wont.

You may want to make sure your PEAR directory is in your php.ini path variable. This way you don't need to use CWDUPs in your directory name at all, it will find it in the includes directory. (which is normally how pear modules work.)

So rather than using a buncha dot-dots.. try working down from the top.

$mailpath=$_SERVER['DOCUMENT_ROOT'].'\include\mail.php';

As a last resort, you can try copying the mail.php routine into the same directory and see if that works. If that still fails, then its your include path to PEAR. (as the mail.php is probably calling PEAR functions.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜