This is GPL, only it seems odd to include a license in a programm that has twice the size of the license. */ /* Set a variable if it does'nt have a value already */ function set(&$variable, $value) { if (!isset($variable)) $variable = $value; } /* Initialize hooks for action and markup */ $HandleActions['mailform'] = 'HandleMailForm'; $LinkPatterns[125]["\\bmailform:(\w+)"] = 'CreateMailForm'; /* Initialize default values */ set($MailFormMsg['success'],"Message has been sent successfully!"); set($MailFormMsg['failure'],"Message could not be sent!"); set($MailFormMsg['error'],"An error occured!"); set($MailFormString['Your Address'],'Your address:'); set($MailFormString['Subject'],'Subject:'); set($MailFormString['Message'],'Message:'); set($MailFormString['Send'],'Send'); set($MailFormHeader,""); set($MailFormFooter,"\n-------------------------------------------\n" ."This message was sent by the PmWiki MailForm at " ."$ScriptUrl"); set($MailFormDefaultSender,""); set($MailFormFmt, "
$[ackString]
$[Your Address]
$[Subject]
$[Message]
"); function CreateMailForm($pattern, $ref, $txt) { global $MailFormMsg, $MailFormFmt,$MailFormText, $MailFormString; $MailFormString['ackString'] = $MailFormMsg[$_REQUEST['mailform']]; $MailForm = $MailFormFmt; foreach ($MailFormString as $key => $value) { $MailForm = str_replace('$['.$key.']', $value, $MailForm); } $MailForm = preg_replace('/'.$pattern.'/',$MailForm, $ref); return $MailForm; return $MailFormFmt; } function HandleMailForm() { global $pagename, $MailFormAddresses, $MailFormHeader, $MailFormFooter, $MailFormDefaultSender; $to = $MailFormAddresses[$_REQUEST['address']]; $from = $_REQUEST['sender']; $subject = $_REQUEST['subject']; $text = $MailFormHeader.$_REQUEST['text'].$MailFormFooter; if ($from=="") $from=$MailFormDefaultSender; if ($to=="") { $msg = 'error'; } else if (mail($to, $subject, $text, "From: $from")) { $msg = 'success'; } else { $msg = 'failure'; } Header("Location: $ScriptUrl?pagename=$pagename&mailform=$msg"); } ?>