ftp_get on 4.2.3
| From: | Jaime Kikpole | Date: | Fri, 18 Oct 2002 05:51:28 +0000 |
| Subject: | ftp_get on 4.2.3 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-120464@lists.php.net to get a copy of this message | ||
I have PHP 4.2.3 installed on Apache 1.x and FreeBSD 4.7. PHP and
Apache are installed from the FreeBSD ports collection. I've also
installed SquirrelMail from the ports collection and a few SquirrelMail
plugins by hand. One of those plugins is attempting to use FTP functions
in PHP to get and put the .procmailrc and .spamassassin/* files for the
user, providing a GUI for simple editing of these configuration files.
Using some syslogd magic, I've learned:
- The ftp_connect and ftp_login commands seem to work fine.
- The ftp_get command seems to complete, judging from the ftpd process's
output to syslogd.
- The file never seems to actually get written to disk, even though the
ftpd process has handed off the entire file.
- The syslogd files some the retrieve (i.e. "get") command working, which
it doesn't list until the command is completed. Then the web application
"hangs" for a little more than 90 seconds. (e.g. 96 seconds in one case,
108 seconds in another) When it "un-hangs" it behaves as if there was no
file to retrieve.
- The ftp_get() function has a return value of "", which I assume to mean
false.
- The above remains exactly the same when ftp_connect() references
127.0.0.1 or localhost.
- A "apachectl restart" command appears to clear this problem for exactly
one access. In other words, the script will work, then not work until an
apachectl restart, then it will begin to occur again.
The code in question is:
function proc_get($localfile) {
global $username, $key, $onetimepad, $imapServerAddress;
$password = OneTimePadDecrypt($key, $onetimepad);
print "proc_get<BR>";
$conn = @ftp_connect($imapServerAddress);
@ftp_login($conn, $username, $password);
@ftp_get($conn, $localfile, ".procmailrc", FTP_ASCII) or touch($localfile);
$tmp= @ftp_close($conn);
}
function proc_put($localfile) {
global $username, $key, $onetimepad, $imapServerAddress;
$password = OneTimePadDecrypt($key, $onetimepad);
$conn = ftp_connect($imapServerAddress);
ftp_login($conn, $username, $password);
ftp_put($conn, ".procmailrc", $localfile, FTP_ASCII);
ftp_close($conn);
}
Note that $localfile is set to /tmp/pmrc.$username. The www user
(which runs the apache processes) can read from and write to /tmp. As I
said, however, the /tmp/pmrc.* files do not appear.
Any thoughts?
Jaime Kikpole
--
Network Administrator
Cairo-Durham Central School District