Seite 1 von 1

Verfasst: 03.04.2009, 11:36
von rz@r23.de

Verfasst: 03.04.2009, 11:43
von rz@r23.de
require_once( '../include/configuration.cfg.php');
require_once( DIR_WS_INCLUDES . '_DB_Structure.class.php' );

require_once( DIR_CFG_CLASSES . 'Smarty.cfg.class.php' );

require_once 'HTML/Common.php';
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';


require_once ( 'HTMLPurifier/HTMLPurifier.auto.php');
$config = HTMLPurifier_Config::createDefault();
$config->set('Core', 'Encoding', 'ISO-8859-1');
$purifier = new HTMLPurifier($config);





$form =& new HTML_QuickForm('contact_form', 'post');
$form->applyFilter('__ALL__', array($purifier, 'purify') );

$de_sender_email = utf8_decode($_REQUEST['email]);
$de_sender = utf8_decode($_REQUEST['sender]);
$de_company = utf8_decode($_REQUEST['company]);
$de_subject = utf8_decode($_REQUEST['subject]);
$de_messagebody = utf8_decode($_REQUEST['messagebody]);

$form->setDefaults( array(
'sender_email' => $purifier->purify( $de_sender_email ),
'sender' => $purifier->purify( $de_sender ),
'company' => $purifier->purify( $de_company ),
'subject' => $purifier->purify( $de_subject ),
'messagebody' => $purifier->purify( $de_messagebody )
));



$form->addElement('text', 'sender_email', 'sender_email', array('size' => 50, 'maxlength' => 32));
$form->applyFilter('sender_email', 'trim');
$form->addRule('sender_email', 'Geben Sie eine valide E-Mail-Adresse an.', 'email', null, 'server');

$form->addElement('text', 'sender', 'sender', array('size' => 50, 'maxlength' => 64));
$form->applyFilter('sender', 'trim');
//$form->addRule('sender', 'Geben Sie einen Namen an.', 'required', null, 'server');

$form->addElement('text', 'company', 'company', array('size' => 50, 'maxlength' => 64));
$form->applyFilter('company', 'trim');

$form->addElement('text', 'subject', 'subject', array('size' => 50, 'maxlength' => 64));
$form->applyFilter('subject', 'trim');
//$form->addRule('subject', 'Geben Sie ein Betreff an.', 'required', null, 'server');

$attrs = array( "rows"=>"10",
"cols"=>"70");
$form->addElement('textarea', 'messagebody', 'messagebody', $attrs);
$form->applyFilter('messagebody', 'trim');
//$form->addRule('messagebody', 'Der Inhalt der Nachricht ist leer.', 'required', null, 'server');

$form->addElement('submit', 'submit', 'übernehmen');








if ( $form->validate() ) {


$t_subject = $form->exportValue('subject');
$t_sender = $form->exportValue('sender');
$t_company = $form->exportValue('company');
$t_email = $form->exportValue('sender_email');
$t_messagebody = $form->exportValue('messagebody');



include('Mail.php');
include('Mail/mime.php');

$smarty_txt = new SmartyConfig();
$smarty_html = new SmartyConfig();

// txt
$smarty_txt->assign('NOW_DAY', date("d.m.Y"));
$smarty_txt->assign('NOW_CLOCK', date("H:i:s"));

$smarty_txt->assign('SUBJECT', $t_subject);
$smarty_txt->assign('FIRSTNAME', $t_sender);
$smarty_txt->assign('ENTERPRICE', $t_company);
$smarty_txt->assign('MAIL_BODY', $t_messagebody);
$smarty_txt->assign('MAIL_FROM', $t_email);


// html
$smarty_html->assign('META_TITLE', META_TITLE );
$smarty_html->assign('META_COPYRIGHT', META_COPYRIGHT );
$smarty_html->assign('HTTP_SERVER', HTTP_SERVER );

$smarty_html->assign('NOW_DAY', date("d.m.Y"));
$smarty_html->assign('NOW_CLOCK', date("H:i:s"));

$smarty_html->assign('SUBJECT', $t_subject);
$smarty_html->assign('FIRSTNAME', $t_sender);
$smarty_html->assign('ENTERPRICE', $t_company);
$smarty_html->assign('MAIL_BODY', nl2br($t_messagebody));
$smarty_html->assign('MAIL_FROM', $t_email);


$smarty_txt->template_dir = '../templates/';
$smarty_html->template_dir = '../templates/';

$text = $smarty_txt->fetch( 'mails/contact.send.txt.htm' );
$html = $smarty_html->fetch( 'mails/contact.send.html.htm' );




$crlf = "\n";
$hdrs = array(
'MIME-Version' => '1.0',
'Content-Type' => 'text/plain; charset="iso-8859-1"',
'Content-Transfer-Encoding' => '8bit',
'From' => $t_email,
'Subject' => $t_subject
);

$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);

$body = $mime->get();
$hdrs = $mime->headers($hdrs);

$mail =& Mail::factory('mail');



$mail->send( SITE_CONTACT_MAIL, $hdrs, $body);

// --------------------------------------------------------------------

$smarty_reply_txt = new SmartyConfig();
$smarty_reply_html = new SmartyConfig();

// txt ...

// html
$smarty_reply_html->assign('META_TITLE', META_TITLE );
$smarty_reply_html->assign('META_COPYRIGHT', META_COPYRIGHT );
$smarty_reply_html->assign('HTTP_SERVER', HTTP_SERVER );


$smarty_reply_txt->template_dir = '../templates/';
$smarty_reply_html->template_dir = '../templates/';

$text = $smarty_reply_txt->fetch( 'mails/contact.reply.txt.htm' );
$html = $smarty_reply_html->fetch( 'mails/contact.reply.html.htm' );

$crlf = "\n";
$hdrs = array(
'MIME-Version' => '1.0',
'Content-Type' => 'text/plain; charset="iso-8859-1"',
'Content-Transfer-Encoding' => '8bit',
'From' => $t_email,
'Subject' => $t_subject
);

$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);

$body = $mime->get();
$hdrs = $mime->headers($hdrs);

$mail =& Mail::factory('mail');
$mail->send( $t_email, $hdrs, $body);


$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= '<contact>';
$xml .= "<success><msg>Nachricht versendet</msg></success>";
$xml .= '</contact>';
echo $xml;
exit();

}


$smarty = new SmartyConfig();
$smarty->template_dir = '../templates/';
// assign smarty
require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
$renderer =& new HTML_QuickForm_Renderer_ArraySmarty($smarty, true);
$form->accept($renderer);
$smarty->assign('form', $renderer->toArray());
$smarty->display('form.htm');
exit();