I am soo greatful for this tutorial here:
http://www.howtoforge.com/how-to-log...tect-form-spam
But, is there anyway of making the function itself in /usr/local/bin to make the log file run as root and not apache?
This would allow me to put it into the /var/log folder.
Quote:
#!/usr/bin/php
<?php
/**
This script is a sendmail wrapper for php to log calls of the php mail() function.
Author: Till Brehm, www.ispconfig.org
(Hopefully) secured by David Goodwin <david @ _palepurple_.co.uk>
*/
$sendmail_bin = '/usr/sbin/sendmail';
$logfile = '/tmp/mail_php.log';
//* Get the email content
$logline = '';
$pointer = fopen('php://stdin', 'r');
while ($line = fgets($pointer)) {
if(preg_match('/^to:/i', $line) || preg_match('/^from:/i', $line)) {
$logline .= trim($line).' ';
}
$mail .= $line;
}
//* compose the sendmail command
$command = 'echo ' . escapeshellarg($mail) . ' | '.$sendmail_bin.' -t -i';
for ($i = 1; $i < $_SERVER['argc']; $i++) {
$command .= escapeshellarg($_SERVER['argv'][$i]).' ';
}
//* Write the log
file_put_contents($logfile, date('Y-m-d H:i:s') . ' ' . $_ENV['PWD'] . ' ' . $logline, FILE_APPEND);
//* Execute the command
return shell_exec($command);
?>
|
Thats the shell script for it anyways.
Thanks in advance,
Jeremy
Recent comments
7 hours 27 min ago
12 hours 26 min ago
13 hours 52 min ago
14 hours 45 min ago
16 hours 28 min ago
20 hours 52 min ago
21 hours 44 min ago
23 hours 57 min ago
1 day 13 hours ago
1 day 14 hours ago