Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_SERVER["HTTP_ORIGIN"])){
  4. header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
  5. }
  6.  
  7. if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
  8. header('Access-Control-Allow-Methods: POST, GET, DELETE, PUT, PATCH, OPTIONS');
  9. header('Access-Control-Allow-Headers: token, Content-Type');
  10. header("Access-Control-Max-Age: 600");
  11. header('Content-Length: 0');
  12. header('Content-Type: text/plain');
  13. die();
  14. }
  15.  
  16. header('Content-Type: application/json');
  17.  
  18. include('common.php');
  19. if(isset($_POST['action']) && $_POST['action']=='partner_application'){
  20. //captcha validation
  21. if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])){
  22. $secret = '6LfHdygTAAAAACwxNmCDPR8YB76GTuScqKJCLU2q';
  23. $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']);
  24. $responseData = json_decode($verifyResponse);
  25.  
  26. if($responseData->success==1){
  27. //email blank chk
  28. if(empty($_POST['email'])){
  29. $ret=array('success'=>0,'msg'=>'Not a valid email. lease try later.');
  30. } else{
  31. $to='service@zamenhof.net';
  32. $from='service@zamenhof.net';
  33. $subject='Contact form';
  34. $attachment=array();
  35. $body = 'Contact form from: '.$_POST['email'].'<br />';
  36. $body .= 'IP: '.$_SERVER['REMOTE_ADDR'].'<br />';
  37. $body .= 'Name: '.$_POST['first_name'].' '.$_POST['last_name'].'<br />';
  38. $body .= 'Website: '.$_POST['website'].'<br />';
  39. $body .= 'Country: '.$_POST['country'].'<br />';
  40. $body .= 'Volume: '.$_POST['volume'].'<br />';
  41. $body .= 'Other: '.$_POST['remarks'].'<br />';
  42. sl_mail($subject,$to,$from,$body,$attachment);
  43.  
  44. $ret=array('success'=>1,'msg'=>'Your application was</br>successfully submitted.</br></br>We will contact you shortly.');
  45. }
  46. } else {
  47. $ret=array('success'=>0,'msg'=>'Captcha is not validated. Please try later.');
  48. }
  49. } else {
  50. $ret=array('success'=>0,'msg'=>'Captcha is not clicked');
  51. }
  52. echo json_encode($ret);
  53. exit;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement