Forum Moderators: coopster

Message Too Old, No Replies

Faxing From My PHP App.

PHP Faxing

         

NWGuy

8:56 pm on May 18, 2006 (gmt 0)

10+ Year Member



All,
Iam writing an application in PHP that needs to fax a simple text file. Iam running Fedora Core 4. I have a conexant chipset fax/modem class 1 using a Linuxant modem driver. I have a /dev/modem link pointing to the linuxant device /dev/ttySHCF0. I want to keep this faxing environment simple. So after looking at Hylafax and all the other faxing options, I found that only efax on my system will work. I successfully sent a fax from the command line using efax. Here is the command:

efax -o1 -d/dev/modem -t5035884445 /var/www/inventory/html/BackOfcOps/faxfiles/testfile

As stated previously, this worked perfectly. Next I transferred this command to the passthru, and the other related functions in PHP. Also created two other passthru lines using the "whoami" and "pwd" commands. When I executed the command, I got an error. The error in the error_log stated that permission to access device file was denied. The "whoami" and "pwd" commands worked perfectly. I checked the file permissions and that are good. I checked the ownership and even changed the ownership and those settings are good. I checked the php.ini file and i'm not in safe mode. What am I missing? Any help would be greatly appreciated. I did try to install hylafax and it had install problems that hylafax has yet to respond to with a solution.

Thanks in advance for your help....Bob

eelixduppy

10:48 pm on May 18, 2006 (gmt 0)



Welcome to WebmasterWorld!

There are two things i would recommend trying. The first is, that you can get rid of the -d argument because what you have it set to is the default. The second, and more important, is this:


When using Class 1 modems the program must respond to certain events within 55 milliseconds. Longer delays may cause the fax protocol to fail in certain places (between DCS and TCF or between RTC and MPS). Class 1 modems should therefore not be used on systems that cannot guarantee that the program will respond to incoming data in less than 55 milliseconds.

With this said, i would recommend not forcing efax to use class 1 fax modem commands.

So in the end, you are left with this:

passthru("efax -t5035884445 /var/www/inventory/html/BackOfcOps/faxfiles/testfile");

If this doesn't work, which im not sure if it will, obviously reply with another post

NWGuy

9:14 pm on May 19, 2006 (gmt 0)

10+ Year Member



Thanks for the warm welcome to webmasterworld. I was pleasantly surprised to find it and hopefully will be a regular visitor.

I tried your suggestion and still got the same message.

efax: Fri May 19 14:07:54 2006 efax v 0.9 Copyright 1999 Ed Casas
efax: 07:54 Error: can't open serial port /dev/modem: Permission denied
efax: 07:54 failed -> /var/www/inventory/html/BackOfcOps/faxfiles/testfile
efax: 07:54 done, returning 2 (unrecoverable error)

that was the error message in the /var/log/httpd/error_log file. The following is the revised passthru command that generated the message above:

$faxcommandstring ="efax -t5035884445 /var/www/inventory/html/BackOfcOps/faxfiles/testfile";
$status = 0;
passthru($faxcommandstring,$status);

I strongly believe its a system protection thing somewhere cause I can get this to work from the command line as user apache and other usernames. I've looked at all sorts of things at the system level and am just not seeing it. I have a whoami command that works just fine and a pwd command that works just fine both from within PHP. Don't know if you agree or not, but I think it has something to do with trying to access a device file from PHP. I'm at a loss. I'm thinking of writing a program that runs in the background and looks for files and then executes the fax command from within that program which can run as a different user than apache. Dont know if that makes sense. Any thoughts?
Bob

bcolflesh

9:22 pm on May 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does root (or a user privileged to access ports) own the file with the passthru command?

NWGuy

3:19 am on May 20, 2006 (gmt 0)

10+ Year Member



When I installed the Linuxant modem drivers, I was required to install it as root and then set a symbolic link from /dev/modem to /dev/ttySHCF0 (which is the resultant driver from the install). The symbolic link is owned by root but the file priviledges are 777. The system would not allow me to change the owner:group from root to anything else. I did change the owner:group of ttySHCF0 to apache and set the file permissions to 777. This problem doesnt occur when I execute from a command line as apache, or any other user after making the file owner and permission changes. This problem only seems to occur when executed from within the PHP script. I went thru the PHP.ini file and ensured that safe mode was not on and couldn't see any other parameter that would be of issue. However, I'm not claiming to know all the parameters..lol. Hope that answers your question? Oh, I've also talked with the Linuxant tech support and they dont know an answer. Their position is since it works from the command line its gotta be a problem elsewhere.
Thanks Bob

bcolflesh

3:57 am on May 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check this guy's solution:

[redhat.com...]

NWGuy

2:25 pm on May 20, 2006 (gmt 0)

10+ Year Member



I did that also. The /dev/modem device file is a symlink ln -s to the /dev/ttySHCF0 device file which is a device file generated by the Linuxant modem driver installation software. The /dev/modem symlink has 777 priviledges. /dev/ttySHCF0 has 777 privileges. The owner:group for both have been changed. However, only the ttySHCF0 device will actually let me change the owner:group. The symlink wont let me change it. However, I would have thought with permissions set to 777 that owner:group settings would be overridden. It works from the command line but not from the PHP app. That is the real clue but I just cant seem to trace the source of the problem.

NWGuy

4:43 am on May 23, 2006 (gmt 0)

10+ Year Member



All,
Wanted to update you on my particular situation. I still have not found a solution to the PHP faxing problem. So I went another route. I wrote a 'C' routine that runs and acts as a faxserver. It invokes efax successfully and manages the faxfiles. I have set it up as a scheduled task so that it runs and checks for new fax requests. I'm still curious about the previous problem though. If you happen to find something else to try, I'm still interested as to why it didnt work the way I was trying it. Thanks for your help.....Bob