Escape(Tools_Http::Post('name')); $email = $DB->Escape(Tools_Http::Post('email')); $contacts = new Contacts; $message = $DB->Escape(Tools_Http::Post('msg')); $err = ''; $array['product_id'] = 0; $array['product_name'] = ''; $array['name'] = $name; $array['email'] = $email; $array['text'] = $message; $array['type'] = 3; $url = 'https://www.google.com/recaptcha/api/siteverify'; $data = array('secret' => '6LdwSwcTAAAAAGrF02Ad4-ZmDOna43wvsrmFb-L6', '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); $fields = array(); if (!$name) { $err = $L->Str('Please enter your name!'); $fields[] = 'name'; } if (!$email) { $err = $L->Str('Please enter your email!'); $fields[] = 'email'; } if(!$resultArr->success) { $err = $L->Str('Bot check failed!'); $fields[] = 'captcha'; } if (!$message) { $err = $L->Str('Please enter your message!'); $fields[] = 'msg'; } if (!$err) { $msg = "Sadarbības Pieprasījums.\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 = 'info@euroled.lv'; $result = Tools_Email::sendMail($to,'Zajavka na Sotrudnichestvo',$msg); $contacts->insertItem($array); ?>