Module->ClassAction; if (method_exists($this,$action)) $this->{$action}(); } private function httpPost($url, $data) { $curl = curl_init($url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curl); curl_close($curl); return $response; } public function Run() { // init vars $FieldTexts = array(); // get form id $form_id = 0; if ($this->Module->Parameters->exists('form_id')) $form_id = $this->Module->Parameters->get('form_id'); if ($form_id == 0) return; // load form //$result = mysql_query('SELECT * FROM mod_contactform_form WHERE id = '. $form_id); $result = $this->Database->doQuery('SELECT * FROM mod_contactform_form WHERE id = '. $form_id); if ($result->num_rows == 0) return; $this->Form = $result->fetch_object(); //mysql_fetch_object($result); // get language from session $session = Session::getInstance(); $this->CurrentLanguageId = $session->getSectionValue('user','language'); // get all text for the current language $result = $this->Database->doQuery('SELECT contactform_field,text FROM mod_contactform_language WHERE contactform_form_id = ' . $this->Form->id . ' AND language_id = ' . $this->CurrentLanguageId); while($row = $result->fetch_object()) $this->FieldTexts[$row->contactform_field] = $row->text; if (empty($action)) $action = "Main"; // redirect after post if (isset($_SESSION['mContactForm'])) { $this->Main_Success(); return; } // handle postback if (isset($_POST['mContactformSend'])) $action = $action . '_PostBack'; // default action : Main (display form) if (method_exists($this,$action)) $this->$action(); } protected function renderField($fieldname,$mandatory,$type,$value) { $htmlString = ""; $mandatorySign = $mandatory==1||$mandatory==true?'*':''; $htmlString .= ''; switch ($type) { case 'input': case 'number': $htmlString .= '

'; break; case 'email': $htmlString .= '

'; break; case 'textarea': $htmlString .= '

'; break; case 'select': $htmlString .= '

'; break; case 'check': $htmlString .= '
FieldTexts[$fieldName])) return $this->FieldTexts[$fieldName]; $result = mysql_query('SELECT text FROM mod_contactform_language WHERE mod_contactform_form_id = ' . $this->Form->id . ' AND contactform_field') $fieldLanguage = new dbModContactformLanguage(); $fieldLanguage->ContactformFormId = $this->Settings->Id; $fieldLanguage->ContactformField = strtolower($fieldName); $fieldLanguage->LanguageId = $this->CurrentLanguageId; if ($fieldLanguage->exists()) { $this->FieldTexts[$fieldName] = $fieldLanguage->Text; return $fieldLanguage->Text; } else { $this->FieldTexts[$fieldName] = $fieldName; return $fieldName; } }*/ public function Main() { echo '
'; $header_message = str_replace("\n",'
', $this->FieldTexts['header_message']); if (strlen($header_message) > 0) echo ''. $header_message . '

'; //if ($this->Settings->Field1Mandatory||$this->Settings->Field2Mandatory||$this->Settings->Field3Mandatory||$this->Settings->Field4Mandatory||$this->Settings->Field5Mandatory) // echo 'Velden met een * zijn verplicht

'; //echo $this->renderField('Email','E-mail adres',true,'input',''); // generate fields for ($i = 1; $i <= 10; $i++) { $fieldActive = 'field'.$i.'_active'; $fieldMandatory = 'field'.$i.'_mandatory'; $fieldType = 'field'.$i.'_type'; $fieldDefaultValue = 'field'.$i.'_value'; $fieldName = 'field' . $i; if ($this->Form->$fieldActive == 1) echo $this->renderField($fieldName,$this->Form->$fieldMandatory,$this->Form->$fieldType,$this->Form->$fieldDefaultValue); } $button_message = $this->FieldTexts['button_message']; if (strlen($button_message) == 0) $button_message = 'Verzenden'; if ($this->GoogleCaptchaEnabled) echo '
'; echo '
'; $footer_message = $this->FieldTexts['footer_message']; if (strlen($footer_message) > 0) echo '
'. $footer_message . ''; //if ($this->Settings->EnableEmailVisitor) // echo '

Na het verzenden ontvangt u van ons per e-mail een bevestiging van de gestelde vraag of opmerking. Uw gegevens worden strikt vertrouwelijk behandeld en niet aan derden verstrekt.'; echo '
'; $invalid_message = $this->FieldTexts['invalid_message']; if (strlen($invalid_message) == 0) $invalid_message = 'De volgende verplichte velden zijn niet correct ingevuld:'; //$invalid_message = 'The following required fields are not correct:'; $invalid_message = str_replace("\n",'\n\\',$invalid_message); echo '
'; } protected function getPostedValue($fieldNumber) { $fieldType = 'field'.$fieldNumber.'_type'; $field = 'field'.$fieldNumber; if ($this->Form->$fieldType == 'check') { if (isset($_POST[$field])) { return "X (ja / yes)"; } else { return ""; } } else if (isset($_POST[$field])) { return $this->Database->escape(htmlspecialchars(utf8_decode(trim($_POST[$field])))); //return mysql_escape_string(htmlspecialchars(trim(str_replace("\r","",$_POST[$field])))); } return ""; } public function Main_PostBack() { if ($this->GoogleCaptchaEnabled) { if (isset($_POST['g-recaptcha-response'])) { $result = $this->httpPost('https://www.google.com/recaptcha/api/siteverify', array('secret' => '6LdPG5MUAAAAAFPmVeyR4B2pYAKyL7xj86mGPFGT', 'response' => $_POST['g-recaptcha-response'])); if (empty($result)) $myError = $invalidCaptcha; $resultObj = json_decode($result); if (!$resultObj->success) { //$myError = $invalidCaptcha; echo '
De controle of u geen robot bent is mislukt. Mogelijk is er iets misgegaan. Probeert u het a.u.b. opnieuw
'; return $this->Main(); //exit(); } } else { //$myError = $invalidCaptcha; echo '
De controle of u geen robot bent is mislukt. Mogelijk is er iets misgegaan. Probeert u het a.u.b. opnieuw
'; return $this->Main(); } } // opslaan in database $timestamp = date("Y-m-d H:i:s"); // mysql date format $sql = "INSERT INTO mod_contactform_data (mod_contactform_form_id,timestamp,field1,field2,field3,field4,field5,field6,field7,field8,field9,field10) VALUES (".$this->Form->id.",'".$timestamp."','".$this->getPostedValue(1)."','". $this->getPostedValue(2)."','". $this->getPostedValue(3) ."','". $this->getPostedValue(4) ."','".$this->getPostedValue(5)."','" . $this->getPostedValue(6) ."','". $this->getPostedValue(7)."','" . $this->getPostedValue(8)."','". $this->getPostedValue(9)."','". $this->getPostedValue(10)."')"; //print_r ($sql); //exit(); $this->Database->doQuery($sql); /* $formdata = new dbModContactformData(); $formdata->Timestamp = date("Y-m-d H:i:s"); //date("d-m-Y H:i:s"); $formdata->Field1 = $this->getPostedValue(1); $formdata->Field2 = $this->getPostedValue(2); $formdata->Field3 = $this->getPostedValue(3); $formdata->Field4 = $this->getPostedValue(4); $formdata->Field5 = $this->getPostedValue(5); $formdata->Field6 = $this->getPostedValue(6); $formdata->Field7 = $this->getPostedValue(7); $formdata->Field8 = $this->getPostedValue(8); $formdata->Field9 = $this->getPostedValue(9); $formdata->Field10 = $this->getPostedValue(10); $formdata->save(); */ $session = Session::getInstance(); // verzenden email $headers = 'MIME-Version: 1.0' . "\r\n"; $header = 'MIME-Version: 1.0' . "\n" . 'Content-type: text/plain; charset=UTF-8'; //$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; //$headers .= 'To:' .$formdata->Email . "\r\n"; //$headers .= 'From: "'. $session->getSectionValue('user','SITE_NAME') . '" <'.$session->getSectionValue('user','SITE_OWNEREMAIL'). ">\r\n"; $replyAdresses = explode(',',$this->Form->email_replyaddress); if (!is_array($replyAdresses)) header('location:' .$_SERVER['HTTP_REFERER']); $headers .= 'From: "'. $session->getSectionValue('user','SITE_NAME') . '" <'.$replyAdresses[0]. ">\r\n"; ///$headers .= 'Reply-To: "'. $session->getSectionValue('user','SITE_NAME') . '" <'.$session->getSectionValue('user','SITE_OWNEREMAIL'). ">\r\n"; $headers .= 'Reply-To: "'. $session->getSectionValue('user','SITE_NAME') . '" <'.$replyAdresses[0]. ">\r\n"; $headers .= 'Return-Path:'. $session->getSectionValue('user','SITE_NAME') . '" <'.$replyAdresses[0]. ">\r\n"; $headers .= 'X-Mailer: '.$session->getSectionValue('user','SITE_NAME').' - Powered by Mybo Sites'; //$headers .= "From: info@brinkpiano.nl\r\n"; //echo $headers; //$t = mail('b.hageman@gmail.com', 'Testbericht', 'Dit is een testbericht', $headers); //print_r ( error_get_last()); //echo 'test'; //exit(); // Email to visitor if ($this->Form->enable_email_visitor == 1) { $subject_message = $this->FieldTexts['email_visitor_subject']; // $this->getFieldText('subject_message'); $body_message = $this->FieldTexts['email_visitor_body']; //$this->getFieldText('body_message'); $emailVisitor = null; // get $this->Settings adres user who posted form if ($this->Form->field1_type == 'email') $emailVisitor = $this->getPostedValue(1); elseif ($this->Form->field2_type == 'email') $emailVisitor = $this->getPostedValue(2); elseif ($this->Form->field3_type == 'email') $emailVisitor = $this->getPostedValue(3); elseif ($this->Form->field4_type == 'email') $emailVisitor = $this->getPostedValue(4); elseif ($this->Form->field5_type == 'email') $emailVisitor = $this->getPostedValue(5); elseif ($this->Form->field6_type == 'email') $emailVisitor = $this->getPostedValue(6); elseif ($this->Form->field7_type == 'email') $emailVisitor = $this->getPostedValue(7); elseif ($this->Form->field8_type == 'email') $emailVisitor = $this->getPostedValue(8); elseif ($this->Form->field9_type == 'email') $emailVisitor = $this->getPostedValue(9); elseif ($this->Form->field10_type == 'email') $emailVisitor = $this->getPostedValue(10); //echo 'e:'.$emailVisitor; // exit(); //send email to user who posted the form if ($emailVisitor != null) mail($emailVisitor,$subject_message,$this->composeMailBody($body_message),$headers); } // send email to site owner if ($this->Form->enable_email_owner == 1) { $subject_message = $this->Form->email_owner_subject; //$this->getFieldText('admin_subjectmessage'); $body_message = $this->Form->email_owner_body; //$this->getFieldText('admin_bodymessage'); //mail($session->getSectionValue('user','SITE_OWNEREMAIL'),$subject_message,$this->composeMailBody($body_message),$headers); foreach ($replyAdresses AS $addr) mail($addr,$subject_message,$this->composeMailBody($body_message),$headers); } // redirect $_SESSION['mContactForm'] = 'posted'; header('location:' .$_SERVER['HTTP_REFERER']); } protected function composeMailBody($message) { // field names $message = str_replace('{veld1_naam}',$this->FieldTexts['field1'],$message); $message = str_replace('{veld2_naam}',$this->FieldTexts['field2'],$message); $message = str_replace('{veld3_naam}',$this->FieldTexts['field3'],$message); $message = str_replace('{veld4_naam}',$this->FieldTexts['field4'],$message); $message = str_replace('{veld5_naam}',$this->FieldTexts['field5'],$message); $message = str_replace('{veld6_naam}',$this->FieldTexts['field6'],$message); $message = str_replace('{veld7_naam}',$this->FieldTexts['field7'],$message); $message = str_replace('{veld8_naam}',$this->FieldTexts['field8'],$message); $message = str_replace('{veld9_naam}',$this->FieldTexts['field9'],$message); $message = str_replace('{veld10_naam}',$this->FieldTexts['field10'],$message); // field values $message = str_replace('{veld1_waarde}',$this->getPostedValue(1),$message); $message = str_replace('{veld2_waarde}',$this->getPostedValue(2),$message); $message = str_replace('{veld3_waarde}',$this->getPostedValue(3),$message); $message = str_replace('{veld4_waarde}',$this->getPostedValue(4),$message); $message = str_replace('{veld5_waarde}',$this->getPostedValue(5),$message); $message = str_replace('{veld6_waarde}',$this->getPostedValue(6),$message); $message = str_replace('{veld7_waarde}',$this->getPostedValue(7),$message); $message = str_replace('{veld8_waarde}',$this->getPostedValue(8),$message); $message = str_replace('{veld9_waarde}',$this->getPostedValue(9),$message); $message = str_replace('{veld10_waarde}',$this->getPostedValue(10),$message); return $message; } public function Main_Success() { echo '
'; unset($_SESSION['mContactForm']); echo str_replace("\r\n","
",$this->FieldTexts['success_message']); echo '
'; } } ?>