Anyway, if you wish to modify your system, this will allow you to input tags into message subject and \ or body that look like this
- Code: Select all
[PHP:return "Hello World";]
[PHP:\$me = 52; return Date("l", \$me);]
and PHP List will replace them with the value that is returned by your PHP snippet. NB you must use return and not echo. Also, remember all expressions must end with a semi-colon. If you get anything wrong in your PHP, you should see a message in the event log to let you know which statement was bad.
In /lists/admin/sendemaillib.php, search for
- Code: Select all
# remove any existing placeholders
and just before that line, add this
- Code: Select all
$htmlmessage = parsePHPTags($htmlmessage);
$textmessage = parsePHPTags($textmessage);
Before the line
- Code: Select all
if (!$mail->send("", $destinationemail, $fromname, $fromemail, $custom_subject)) {
add the line
- Code: Select all
$custom_subject = parsePHPTags($subject);
and before the function
- Code: Select all
addAttachments($msgid,&$mail,$type) {
add this function in its entirety
- Code: Select all
function parsePHPTags($instring) {
$instring = htmlspecialchars_decode($instring, ENT_QUOTES);
$startpos = 0;
// find all locations of [PHP: in whatever has just been passed to us, then take out the string to be executed
while ($startpos = strpos($instring, "[PHP:", $startpos)) {
$endpos = strpos($instring, "]", $startpos);
$commands[] = substr($instring, $startpos+5, $endpos-$startpos-5);
$startpos++;
}
$outstring = $instring;
foreach ($commands as $command) {
$replacement = eval($command);
if ($replacement) {
$outstring = str_replace("[PHP:".$command."]",$replacement,$outstring);
} else {
logEvent('Executing command '.$command.' failed in function parsePHPTags');
}
}
return $outstring;
}