Guest User

Untitled

a guest
Jun 17th, 2018
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. <?php
  2. /*
  3. This first bit sets the email address that you want the form to be submitted to.
  4. You will need to change this value to a valid email address that you can access.
  5. */
  6. $webmaster_email = "im.muslim1@gmail.com";
  7.  
  8. /*
  9. This bit sets the URLs of the supporting pages.
  10. If you change the names of any of the pages, you will need to change the values here.
  11. */
  12. $feedback_page = "feedback_form.html";
  13. $error_page = "error_message.html";
  14. $thankyou_page = "thank_you.html";
  15.  
  16. /*
  17. This next bit loads the form field data into variables.
  18. If you add a form field, you will need to add it here.
  19. */
  20. $your_name = $_REQUEST['your_name'];
  21. $email_address = $_REQUEST['email_address'] ;
  22. $comments = $_REQUEST['comments'] ;
  23.  
  24. /*
  25. The following function checks for email injection.
  26. Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
  27. */
  28. function isInjected($str) {
  29. $injections = array('(\n+)',
  30. '(\r+)',
  31. '(\t+)',
  32. '(%0A+)',
  33. '(%0D+)',
  34. '(%08+)',
  35. '(%09+)'
  36. );
  37. $inject = join('|', $injections);
  38. $inject = "/$inject/i";
  39. if(preg_match($inject,$str)) {
  40. return true;
  41. }
  42. else {
  43. return false;
  44. }
  45. }
  46.  
  47. // If the user tries to access this script directly, redirect them to the feedback form,
  48. if (!isset($_REQUEST['email_address'])) {
  49. header( "Location: $feedback_page" );
  50. }
  51.  
  52. // If the form fields are empty, redirect to the error page.
  53. elseif (empty($email_address) || empty($comments)) {
  54. header( "Location: $error_page" );
  55. }
  56.  
  57. // If email injection is detected, redirect to the error page.
  58. elseif ( isInjected($email_address) ) {
  59. header( "Location: $error_page" );
  60. }
  61.  
  62. // If we passed all previous tests, send the email then redirect to the thank you page.
  63. else {
  64. mail( "$webmaster_email", "Feedback Form Results",
  65. $comments, "From: $email_address" );
  66. header( "Location: $thankyou_page" );
  67. }
  68. ?>
Add Comment
Please, Sign In to add comment