PATH:
root
/
quiz
<!doctype html> <html lang="pl"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>QUIZ - potwierdzenie wysłania wiadomości</title> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&&display=swap" rel="stylesheet"> <link rel="stylesheet" href="css/style.css"> </head> <body> <main id="content" role="main" class="content"> <div class="quiz-box"> <div class="bg bg-center"> <?php function formatMilliseconds($milliseconds) { $seconds = floor($milliseconds / 1000); $minutes = floor($seconds / 60); $hours = floor($minutes / 60); $milliseconds = $milliseconds % 1000; $seconds = $seconds % 60; $minutes = $minutes % 60; $format = '%02u:%02u'; $time = sprintf($format, $minutes, $seconds); return rtrim($time, '0'); } //Import PHPMailer classes into the global namespace //These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'src/Exception.php'; require 'src/PHPMailer.php'; require 'src/SMTP.php'; $conn = mysqli_connect("localhost", "quiz", "quiz", "quiz"); // Check connection if($conn === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } if (!empty($_POST)) { // Taking all 5 values from the form data(input) $name = $_POST['name']; $email = $_POST['email']; $totaltime = $_POST['totaltime']; $regulamin = $_POST['regulamin']; if( isset($_POST['newsletter']) ){ $newsletter = $_POST['newsletter']; }else{ $newsletter='off' ; } $currentDate = date("Y-m-d H:i:s"); $currentday = date("Y-m-d"); $salt = uniqid(mt_rand() , true); $token = sha1($currentDate . md5($salt)); $timestamp = $totaltime; $totaltime_s = formatMilliseconds((int)$timestamp); // sprawdzenie czy w bazie insnieje juz taki email i czy jest z datą dzisiejszą $sql = "SELECT * FROM zgloszenia WHERE email='$email' AND data_zgloszenia BETWEEN '$currentday 00:00:00' AND '$currentday 23:59:59'"; $result = $conn->query($sql); if($result->num_rows > 0) { echo '<h2>Dziś juz rozwiązywałeś quiz - spróbuj ponownie jutro</h2>'; echo '<a href="http://localhost/quiz/" class="btn btn2">Spróbuj ponownie</a>'; header( "refresh:3;url=http://localhost/quiz/" ); }else{ // nowe zgłoszenie $sql = "INSERT INTO zgloszenia VALUES ('id','$currentDate','$email','$name','$totaltime','$newsletter','$regulamin', '0' , '', '$token')"; //$result = $conn->query($sql); if(mysqli_query($conn, $sql)){ echo "<h2>Aby dokończyć zapisywanie wyniku,<br> kliknij w link potwierdzający, wysłany na Twój adres email.</h2>"; echo '<br><a target="_blank" href="https://wwfpolska.wixsite.com/olej-palmowy" class="btn btn2">Więcej o oleju palmowym</a>'; // wysyłka email: $from = $_POST['email']; // this is the sender's Email address $first_name = $_POST['name']; //Create an instance; passing `true` enables exceptions $mail = new PHPMailer(true); try { //Server settings // $mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output $mail->isSMTP(); //Send using SMTP $mail->Host = 'smtp.example.com'; //Set the SMTP server to send through $mail->SMTPAuth = true; //Enable SMTP authentication $mail->Username = 'user@example.com'; //SMTP username $mail->Password = 'secret'; //SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption $mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` //Recipients $mail->setFrom('from@example.com', 'Mailer'); $mail->addAddress('joe@example.net', 'Joe User'); //Add a recipient $mail->addAddress('ellen@example.com'); //Name is optional $mail->addReplyTo('info@example.com', 'Information'); $mail->addCC('cc@example.com'); $mail->addBCC('bcc@example.com'); //Content $mail->isHTML(true); //Set email format to HTML $mail->Subject = 'Potwierdzenie zgłoszenia na QUIZ'; $mail->Body = 'To jest potwierdzenie zgłoszenia na qiuz <br>' . $first_name .'Twój czas wypełniania quizu: '. $totaltime_s. '<br><br><h2>Aby dokończyć zapisywanie wyniku, kliknij w link potwierdzający:</h2> <br><br> https://quiz.olejpalmowy.com/verifyemail.php?token=' . $token; $mail->AltBody = 'To jest potwierdzenie zgłoszenia na qiuz <br>' . $first_name .'Twój czas wypełniania quizu: '. $totaltime_s. '<br><br><h2>Aby dokończyć zapisywanie wyniku, kliknij w link potwierdzający:</h2> <br><br> https://quiz.olejpalmowy.com/verifyemail.php?token=' . $token; $mail->send(); echo 'Dziękujemy - wiadomość została wysłana na emaila'; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } } else{ echo "Niestety wsytapił jakiś bląd SQL: $sql. " . mysqli_error($conn); } } // Close connection mysqli_close($conn); }else{ echo '<h2>wypełnij ponownie quiz</h2>'; echo '<a href="http://localhost/quiz/" class="btn btn2">Spróbuj ponownie</a>'; } ?> </div> </div> </main> </body>
[-] form.js
[edit]
[+]
..
[-] COMMITMENT
[edit]
[+]
language
[+]
src
[-] form.php
[edit]
[+]
vendor
[-] show.php
[edit]
[-] verifyemail.php
[edit]
[-] composer
[edit]
[-] HackTimer.js
[edit]
[+]
css
[-] get_oauth_token.php
[edit]
[-] composer.bat
[edit]
[-] composer.json
[edit]
[-] composer.phar
[edit]
[-] index.php
[edit]
[+]
edit