Guest User

autoresp

a guest
Sep 10th, 2014
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.99 KB | None | 0 0
  1.    
  2.  
  3.     <?php
  4.     if(isset($_GET['u'])){
  5.             $conn = mysqli_connect("localhost","oi199521_amailer","zxcdsa123","oi199521_mailer") or die("Error " . mysqli_error($conn));
  6.             $hasz = $conn->real_escape_string($_GET['u']);
  7.             $conn->query("UPDATE users SET u_active = 1 WHERE u_activation_key = '$hasz'");
  8.     }
  9.     require_once('class.phpmailer.php');
  10.     $baseRel = 'http://moja-strona.com/mailer/mail/'; // odnosnik na którym znajduje sie strona z skryptem, zkaonczone ukosnikie "/"
  11.     $errMsg = "";
  12.     $succMsg = "";
  13.     $msgAlt = 'To participate in the contest you need to confirm your email. '; // wiadomosc poakzywna uzytkownikowi, gdy ma zablokowane przegladarnie wiadomsoci html
  14.      
  15.     if(@$_POST['regEnd'] == "true"){
  16.             $mail = $_POST['mail'];
  17.             $name = filter_var($_POST['uname'], FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^[A-z]+$/")));
  18.             $hasz = sha1($mail);
  19.            
  20.             if(filter_var($mail,FILTER_VALIDATE_EMAIL) && $name != "") {
  21.            
  22.                     $conn = mysqli_connect("localhost","oi199521_amailer","zxcdsa123","oi199521_mailer") or die("Error " . mysqli_error($conn));
  23.                    
  24.                     if(mysqli_fetch_assoc($conn->query("SELECT u_id FROM users WHERE u_email = '$mail'")) != ""){
  25.      
  26.                                     $errMsg .= "This email address already exists<br />"; // wiadomosc o tym , ze email jzu istnieje
  27.                             } else {
  28.                            
  29.                                     $query = "INSERT INTO `users` (`u_id`,`u_name`,`u_email`,`u_activation_key`,`u_active`) VALUES (NULL,'$name','$mail','$hasz','0')";
  30.                                     $conn->query($query);
  31.                                     $mail = new PHPMailer();
  32.                                     $mail->Host = "mail.safe-side.com"; // adrsz logowania
  33.                                     $mail->Port = 25; // port do logowania
  34.                                     $mail->SMTPAuth = true;
  35.                                     $mail->Username = "[email protected]"; // login do konta smtp poczta
  36.                                     $mail->Password = "zxcdsa123"; // haslo do konta SMTP poczta
  37.                                     $mail->setFrom('[email protected]', 'Youtube Contest'); // od kogo wiadomość, czyli dane nadawcy
  38.                                     $mail->addReplyTo('[email protected]', 'Youtube Contest'); // DO kogo ma odpowiadać nadawca
  39.                                     $mail->Subject = 'Please confirm your email address in the contest'; // temat wiadomosci
  40.                                     $msgAlt .= .$baseRel.'index.php?u='.$hasz;
  41.                                     $mail->IsHTML(true);
  42.                                     /*
  43.                                             Niżej masz wiadomsoc do uzytkownia jaką wysylasz. Uzywasz zaniczików html itd
  44.                                             linijka: <A href="http://mojastrona.com/mailer/mail/index.php?u='.$hasz.'">click here </a> - odpowaida za link do aktywacji
  45.                                             Jeżeli ktos sie boji kliknąć w link to dajemu mu możliwość skopiowania linku do przeglądakri
  46.                                             odpowiada za to ta linijka: or copy this link into your browser:<br /><em>http://mojastrona.com/mailer/mail/index.php?u='.$hasz.'</em>';
  47.                                             Jezeli nie chcesz potwierdzania adres emaila to porpstu wysylasz wiadomosc, ze dziekuesz za rejestracje
  48.                                      */
  49.                                     $mail->Body = 'Hello'.$name.'<br />To participate in the contest you need to confirm your email. <br />
  50.                                                            To confirm, <A href="'.$baseRel.'index.php?u='.$hasz.'">click here </a><br />
  51.                                                            or copy this link into your browser:<br /><em>'.$baseRel.'index.php?u='.$hasz.'</em>'; /
  52.                                     $mail->AltBody = $msgAlt;
  53.                                     //$mail->MsgHTML(file_get_contents('msg.html'));
  54.                                     $mail->AddAddress($_POST['mail'],$name);
  55.                                    
  56.                                     if(!$mail->Send())
  57.                                             {
  58.                                                     $errMsg .= 'An error occurred while trying to send e-mail :'. $mail->ErrorInfo;
  59.                                             } else {
  60.                                                     $succMsg = 'Mail has been sent. Read the email and confirm your email address'; // informacja o tym, ze email zostal wyslany
  61.                                             }
  62.                            
  63.                             }
  64.            
  65.             } else {
  66.              $errMsg .= "Name or email is not valid!<br />"; // wiadomosc o blednej nazwei albo emailu
  67.             }
  68.            
  69.     }
Advertisement
Add Comment
Please, Sign In to add comment