Escape(Tools_Http::Post('name')); $email = $DB->Escape(Tools_Http::Post('email')); $contacts = new Contacts; $message = $DB->Escape(Tools_Http::Post('msg')); $err = ''; $fields = array(); $array['product_id'] = 0; $array['product_name'] = ''; $array['name'] = $name; $array['email'] = $email; $array['text'] = $message; $array['type'] = 4; if (!$name) { $err = $L->Str('Please enter your name!'); $fields[] = 'name'; } if (!$email) { $err = $L->Str('Please enter your email!'); $fields[] = 'email'; } if (!$message) { $err = $L->Str('Please enter your message!'); $fields[] = 'msg'; } $url = 'https://www.google.com/recaptcha/api/siteverify'; $data = array('secret' => '6LfeGW0eAAAAAFmEL3bBbaCnK2k79o4m8LFPAu93', 'response' => $_POST['g-recaptcha-response'] , 'remoteip'=>$_SERVER['REMOTE_ADDR']); // use key 'http' even if you send the request to https://... $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data), ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); $resultArr = json_decode($result); if(!$resultArr->success) { $err = $L->Str('Bot check failed!'); $fields[] = 'captcha'; } if (!$err) { $msg = "Pieprasījums no kontaktu formas.\n\n"; $msg .= "Datums: ".date("d.m.Y H:i")."\n"; $msg .= "IP adrese: ".Tools_Http::getIP()."\n"; $msg .= "
\n"; $msg .= "

Lietotāja dati

\n"; $msg .= "Vārds: ".Tools_Text::htmlEscape($name)."\n"; $msg .= "E-pasts: ".Tools_Text::htmlEscape($email)."\n\n"; $msg .= "Ziņojums: ".Tools_Text::htmlEscape($message).""; //$to = $Config -> Get('EMAIL_FROM_ADDR'); $to = 'info@euroled.lv'; //$to = 'anton@promo.lv'; $result = Tools_Email::sendMail($to,'Pieprasījums no mājaslapas '.$Config -> Get('DEFAULT_PAGE_TITLE'),$msg); $contacts->insertItem($array); ?>