Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.80 KB | None | 0 0
  1. <?php
  2.     // Import PHPMailer classes into the global namespace
  3.     // These must be at the top of your script, not inside a function
  4.     use PHPMailer\PHPMailer\PHPMailer;
  5.     use PHPMailer\PHPMailer\Exception;
  6.    
  7.     if((isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response']))) {
  8.         $secretKey = "TWOJ SECRET KEY Z GOOGLE RECAPTCHA";
  9.         $response = $_POST['g-recaptcha-response'];
  10.         $url = 'https://www.google.com/recaptcha/api/siteverify';
  11.         $data = array(
  12.             'secret' => $secretKey,
  13.             'response' => $response
  14.         );
  15.         $options = array(
  16.             'http' => array (
  17.                 'method' => 'POST',
  18.                 'content' => http_build_query($data)
  19.             )
  20.         );
  21.         $context  = stream_context_create($options);
  22.         $verify = file_get_contents($url, false, $context);
  23.         $captcha_success=json_decode($verify);
  24.        
  25.         if (true == $captcha_success->success) {
  26.            
  27.             if( (isset($_POST['name']) && !empty($_POST['name']))
  28.                 && (isset($_POST['email']) && !empty($_POST['email']))
  29.                 && (isset($_POST['subject']) && !empty($_POST['subject']))
  30.                 && (isset($_POST['message']) && !empty($_POST['message'])) ) {
  31.  
  32.                 $name = $_POST['name'];
  33.                 $email = $_POST['email'];
  34.                 $subject = $_POST['subject'];
  35.                 $message = $_POST['message'];
  36.                
  37.                
  38.                 //Load composer's autoloader
  39.                 require 'vendor/autoload.php';
  40.  
  41.                 $mail = new PHPMailer(true);                                // Passing `true` enables exceptions
  42.                 try {
  43.                     //Server settings
  44.                     $mail->SMTPDebug = 0;                                   // Enable verbose debug output
  45.                     $mail->isSMTP();                                        // Set mailer to use SMTP
  46.                     $mail->Host = 'smtp.gmail.com';                         // Specify main and backup SMTP servers
  47.                     $mail->SMTPAuth = true;                                 // Enable SMTP authentication
  48.                     $mail->Username = 'MAIL Z KTOREGO BEDZIESZ WYSYLAC NP ruf@ruf.com';         // SMTP username
  49.                     $mail->Password = 'TWOJE HASLO NP ruf';                           // SMTP password
  50.                     $mail->SMTPSecure = 'tls';                              // Enable TLS encryption, `ssl` also accepted
  51.                     $mail->Port = 587;                                      // TCP port to connect to
  52.  
  53.                     //Recipients
  54.                     $mail->setFrom($email, $name);
  55.                     $mail->addAddress('bartlomiej.pabisiak@gmail.com', 'Bartlomiej Pabisiak');     // Add a recipient
  56.                     $mail->addReplyTo($email, $name);
  57.                     //$mail->addCC('cc@example.com');
  58.                     //$mail->addBCC('bcc@example.com');
  59.  
  60.                     //email content
  61.                     $mail->isHTML(true);                                  // Set email format to HTML
  62.                     $mail->Subject = "[bpabisiak.pl - contact] ".$subject;
  63.                     $mail->Body    = $message;
  64.                     $mail->AltBody = $message;
  65.  
  66.                     $mail->send();
  67.                     //echo 'Message has been sent';
  68.                 } catch (Exception $e) {
  69.                     echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  70.                 }
  71.             } else {
  72.                 //echo "Missing value in the form";
  73.             }          
  74.            
  75.             //echo "<p>You are not not a bot!</p>";
  76.         } else if (false == $captcha_success->success) {
  77.             //echo "<p>You are a bot! Go away!</p>";
  78.         }      
  79.     }
  80. ?>
  81.  
  82. <!DOCTYPE HTML>
  83. <html>
  84.     <head>
  85.         <script src='https://www.google.com/recaptcha/api.js?hl=en'></script>
  86.        
  87.         <!-- Global site tag (gtag.js) - Google Analytics -->
  88.         <script async src="https://www.googletagmanager.com/gtag/js?id=UA-113899585-1"></script>
  89.         <script>
  90.           window.dataLayer = window.dataLayer || [];
  91.           function gtag(){dataLayer.push(arguments);}
  92.           gtag('js', new Date());
  93.  
  94.           gtag('config', 'UA-113899585-1');
  95.         </script>
  96.        
  97.        
  98.         <title>Bartlomiej Pabisiak | Software Developer</title>
  99.         <meta charset="utf-8" />
  100.         <meta name="viewport" content="width=device-width, initial-scale=1" />
  101.         <!--[if lte IE 8]><script src="assets/js/ie/html5shiv.js"></script><![endif]-->
  102.         <link rel="stylesheet" href="assets/css/main.css" />
  103.         <noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
  104.         <!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie8.css" /><![endif]-->
  105.     </head>
  106.     <body>
  107.  
  108.         <!-- Wrapper-->
  109.             <div id="wrapper">
  110.  
  111.                 <!-- Nav -->
  112.                     <nav id="nav">
  113.                         <a href="#me" class="icon fa-home active"><span>Home</span></a>
  114.                         <!--<a href="#work" class="icon fa-folder"><span>Work</span></a>-->
  115.                         <a href="#contact" class="icon fa-envelope"><span>Contact</span></a>
  116.                         <a target="_blank" href="https://www.linkedin.com/in/ibpabisiak/" class="icon fa-linkedin"><span>Linkedin</span></a>
  117.                         <!--<a href="https://www.facebook.com/bpabisiak" class="icon fa-facebook"><span>Facebook</span></a>-->
  118.                         <a target="_blank" href="https://github.com/ibpabisiak" class="icon fa-github"><span>GitHub</span></a>
  119.                     </nav>
  120.  
  121.                 <!-- Main -->
  122.                     <div id="main">
  123.  
  124.                         <!-- Me -->
  125.                             <article id="me" class="panel">
  126.                                 <header>
  127.                                     <h1>Bartłomiej Pabisiak</h1>
  128.                                     <p>Software Developer</p>
  129.                                 </header>
  130.                                 <!--<a href="#work" class="jumplink pic">
  131.                                     <span class="arrow icon fa-chevron-right"><span>See my work</span></span>
  132.                                     <img src="images/me.png" alt="Bartłomiej Pabisiak" />
  133.                                 </a>-->
  134.                             </article>
  135.  
  136.                         <!-- Work -->
  137.                        
  138.                         <!--
  139.                             <article id="work" class="panel">
  140.                                 <header>
  141.                                     <h2>Work</h2>
  142.                                 </header>
  143.                                 <p>
  144.                                     Phasellus enim sapien, blandit ullamcorper elementum eu, condimentum eu elit.
  145.                                     Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia
  146.                                     luctus elit eget interdum.
  147.                                 </p>
  148.                                 <section>
  149.                                     <div class="row">
  150.                                         <div class="4u 12u$(mobile)">
  151.                                             <a href="#" class="image fit"><img src="images/pic01.jpg" alt=""></a>
  152.                                         </div>
  153.                                         <div class="4u 12u$(mobile)">
  154.                                             <a href="#" class="image fit"><img src="images/pic02.jpg" alt=""></a>
  155.                                         </div>
  156.                                         <div class="4u$ 12u$(mobile)">
  157.                                             <a href="#" class="image fit"><img src="images/pic03.jpg" alt=""></a>
  158.                                         </div>
  159.                                         <div class="4u 12u$(mobile)">
  160.                                             <a href="#" class="image fit"><img src="images/pic04.jpg" alt=""></a>
  161.                                         </div>
  162.                                         <div class="4u 12u$(mobile)">
  163.                                             <a href="#" class="image fit"><img src="images/pic05.jpg" alt=""></a>
  164.                                         </div>
  165.                                         <div class="4u$ 12u$(mobile)">
  166.                                             <a href="#" class="image fit"><img src="images/pic06.jpg" alt=""></a>
  167.                                         </div>
  168.                                         <div class="4u 12u$(mobile)">
  169.                                             <a href="#" class="image fit"><img src="images/pic07.jpg" alt=""></a>
  170.                                         </div>
  171.                                         <div class="4u 12u$(mobile)">
  172.                                             <a href="#" class="image fit"><img src="images/pic08.jpg" alt=""></a>
  173.                                         </div>
  174.                                         <div class="4u$ 12u$(mobile)">
  175.                                             <a href="#" class="image fit"><img src="images/pic09.jpg" alt=""></a>
  176.                                         </div>
  177.                                         <div class="4u 12u$(mobile)">
  178.                                             <a href="#" class="image fit"><img src="images/pic10.jpg" alt=""></a>
  179.                                         </div>
  180.                                         <div class="4u 12u$(mobile)">
  181.                                             <a href="#" class="image fit"><img src="images/pic11.jpg" alt=""></a>
  182.                                         </div>
  183.                                         <div class="4u$ 12u$(mobile)">
  184.                                             <a href="#" class="image fit"><img src="images/pic12.jpg" alt=""></a>
  185.                                         </div>
  186.                                     </div>
  187.                                 </section>
  188.                             </article>
  189.                             -->
  190.                        
  191.                             <article id="contact" class="panel">
  192.                                 <header>
  193.                                     <h2>Contact Me</h2>
  194.                                 </header>
  195.                                 <form action="#contact" method="post">
  196.                                     <div>
  197.                                         <div class="row">
  198.                                             <div class="6u 12u$(mobile)">
  199.                                                 <input type="text" name="name" placeholder="Name" />
  200.                                             </div>
  201.                                             <div class="6u$ 12u$(mobile)">
  202.                                                 <input type="text" name="email" placeholder="Email" />
  203.                                             </div>
  204.                                             <div class="12u$">
  205.                                                 <input type="text" name="subject" placeholder="Subject" />
  206.                                             </div>
  207.                                             <div class="12u$">
  208.                                                 <textarea name="message" placeholder="Message" rows="8"></textarea>
  209.                                             </div>
  210.                                             <div class="g-recaptcha" data-sitekey="6Ldsl0UUAAAAAKSBWEbU_E1EHjn-N_Cn1tBze5TJ"></div>
  211.                                             <div class="12u$">
  212.                                                 <input type="submit" value="Send Message" />
  213.                                             </div>
  214.                                         </div>
  215.                                     </div>
  216.                                 </form>
  217.                             </article>
  218.                     </div>
  219.  
  220.                 <!-- Footer -->
  221.                     <div id="footer">
  222.                         <ul class="copyright">
  223.                             <li>&copy; BARTŁOMIEJ PABISIAK 2018</li><!--<li>Design: <a href="http://html5up.net">HTML5 UP</a></li>-->
  224.                         </ul>
  225.                     </div>
  226.  
  227.             </div>
  228.  
  229.         <!-- Scripts -->
  230.             <script src="assets/js/jquery.min.js"></script>
  231.             <script src="assets/js/skel.min.js"></script>
  232.             <script src="assets/js/skel-viewport.min.js"></script>
  233.             <script src="assets/js/util.js"></script>
  234.             <!--[if lte IE 8]><script src="assets/js/ie/respond.min.js"></script><![endif]-->
  235.             <script src="assets/js/main.js"></script>
  236.  
  237.     </body>
  238. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement