<?php
defined('DOIT') or die('Restricted access');
require_once(PATH.'/modules/phpmailer/phpmailer.class.php');
$modsettings = explode(",",$modsettings);
$showsubject = $modsettings[0];
$subjectname = $modsettings[1];
$mustsubject = (bool)$modsettings[2];
$mustmail = (bool)$modsettings[3];
$errormsg = $nameerr = $namehint = $emailerr = $emailhint = $messageerr = $messagehint = $contactname = $email = $subject = $message = $sent = false;
//build form
$f = new Form('','post',$this->name,false,false,$mod_contact['lbl_compulsory'],false);
$f->addInput('text','contactname',$mod_contact['lbl_yourname'],false,true,false,false,false,false,false,'contact_name','contactinput',false,array($mod_contact['msg_name'],'below'));
$f->addInput('text','email',$mod_contact['lbl_email'],false,$mustmail,false,false,false,false,false,'contact_email','contactinput',false,array($mod_contact['msg_email'],'below'));
if ($showsubject=="1") {
$f->addInput('text','subject',$subjectname,false,$mustsubject,false,false,false,false,false,'contact_subject','contactinput',false,array($mod_contact['lbl_nosubject'],'below'));
}
$f->addInput('textarea','message',$mod_contact['lbl_msg'],false,true,false,false,false,20,5,'contact_message','contactinput',false,array($mod_contact['msg_msg'],'below'));
$f->addButton('submit','submit',false,$mod_contact['lbl_submit'],false,false,'contactbutton');
// Handling
$f->getErrors();
$msg = $f->getMsg();
$myvalues = $f->getCleanValues('html');
//check values that depend on each other
//if there were no errors proceed with whatever
if (is_array($f->errors) && sizeof($f->errors)<1 && $f->sent) { $doit = true; } else { $doit = false; }
//do it :)
if ($doit) {
$to = $this->siteemail;
$mailtext =
'<p><strong>'.$myvalues['contactname'].'</strong> ('.$myvalues['email'].') '.$mod_contact['lbl_wrote'].' <strong>'.date('d.m.Y').'</strong> '.
$mod_contact['lbl_wroteat'].' <strong>'.date('H:i:s').'</strong>:</p><p>'.str_replace("\n",'<br />',$myvalues['message']).'</p>';
//header for html mails
$header = 'MIME-Version: 1.0'."\r\n";
$header .= 'Content-type: text/html; charset=utf-8'."\r\n";
$header .= 'From: '.$this->pagetitle.": $mod_contact[lbl_contact] <$settings[siteemail]>\r\n";
//prevent multiple mails
if (!$sent) {
$mail = new PHPMailer();
$mail->From = $settings['siteemail'];
$mail->AddAddress($this->siteemail);
$mail->Subject = $mod_contact['lbl_contact'];
$mail->IsHTML(true);
$mail->Body = $mailtext;
if (isset($myvalues['email']) && $myvalues['email'] && !empty($myvalues['email'])) {
$mail->AddReplyTo($myvalues['email']);
}
if ($mail->Send()) {
$errormsg = "<p class='contactinfomsg'>".$mod_contact["msg_send_ok"]."</p>";
$sent=true;
} else {
$errormsg = "<p class='contacterrormsg'>".$mod_contact["msg_send_err"]."</p>";
}
}
}
//render form
$contactform = $f->render('fieldset');
echo '<div class="contactform">'.$errormsg.$contactform.'</div>';
?>