Crecket

Untitled

Mar 23rd, 2015
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.18 KB | None | 0 0
  1.  <?php
  2. date_default_timezone_set('Europe/Amsterdam');
  3. include('../../db_connect.php');
  4. include('../includes/page_load.php');
  5. include('../php/check_locked.php');
  6. session_start();
  7. $conn = mysqli_connect($servername, $username, $password, $dbname);
  8. $options = array('cost' => 11);
  9. $addrip = $_SERVER['REMOTE_ADDR'];
  10. $agent = $_SERVER['HTTP_USER_AGENT'];
  11. $currenttime = time();
  12. $locktime = time() + 3600;
  13. $errormessage = $errorcaptchamsg = "";
  14. $toggletype = $message2 = "";
  15. $cls = array('','','','','','');
  16. $error = array();
  17.  
  18. if(isset($_POST['login'])){
  19.     if(isset($_POST['g-recaptcha-response'])){
  20.         $captcha=$_POST['g-recaptcha-response'];
  21.     }
  22.    
  23.     $testtype = mysqli_real_escape_string($conn, $_POST['selecttype']);
  24.     $testtype = test_input($testtype);
  25.     $testmail = mysqli_real_escape_string($conn, $_POST['email']);
  26.     $testmail = test_input($testmail);
  27.    
  28.     if (!filter_var($testmail, FILTER_VALIDATE_EMAIL)) {
  29.       $errormessage = "Invalid email format";
  30.       $cls[0]  = 'class="errorclass"';
  31.       $error[] = '1';
  32.     }
  33.    
  34.     if(count($error)<1){
  35.         $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=SECRETKEY&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
  36.         if($response.success==false) {
  37.             $errorcaptchamsg = "SPAMMER.";
  38.         }else{
  39.             $sql= "SELECT * FROM users WHERE Email = '$testmail'";
  40.             $result = $con->query($sql);
  41.             $resultcount = mysqli_num_rows($result);
  42.             if ($resultcount == 0) {
  43.                 $errormessage = "No account with this email address has been found";
  44.             }else{                 
  45.                 $row = mysqli_fetch_array($result, MYSQLI_BOTH);
  46.                 if($testtype == "nameinput"){
  47.                     $message2 = "Someone has requested to receive the username for this email address: " . $row['Email'] . ". If you didn't request this please ignore this message. <br><br>" ;
  48.                     $message2 .= "Your username is: " . $row['Username'] . "<br>";
  49.                     $subject = "Username request - Crecketgaming";
  50.                 }else{
  51.                     $message2 = "Someone has requested to receive the password for: " . $row['Username'] . ". If you didn't request this please ignore this message. <br><br>" ;
  52.                     $message2 .= "Click <a href='http://crecketgaming.com/restorepassword.php?token=". $randomsalt . "&user=" . $row['Username'] . "''>here</a> or follow this url to enter a new password:<br>";
  53.                     $message2 .= "<a>http://crecketgaming.com/restorepassword.php?token=". $randomsalt . "&user=" . $row['Username'] . "'</a>";
  54.                     $subject = "Password request - Crecketgaming";
  55.                 }
  56.  
  57.                 $headers .= 'From: <[email protected]>' . "\r\n";
  58.                 $headers .= "MIME-Version: 1.0\r\n";
  59.                 $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
  60.                
  61.                 $message = "<html><body>";
  62.                 $message .= $message2;
  63.                 $message .= "<strong>Name: </strong>"  . $row['Username'] . "<br>";
  64.                 $message .= "<a href='http://crecketgaming.com/login'><p>Click here to return to the login page</p></a>";
  65.                 $message .= "</body></html>";
  66.  
  67.                 mail($testmail, $subject, $message, $headers);
  68.                 $successmessage = "Mail sent.";
  69.  
  70.             }
  71.         }
  72.     }  
  73. }
  74.    
  75. function test_input($data) {
  76.    $data = trim($data);
  77.    $data = stripslashes($data);
  78.    $data = htmlspecialchars($data);
  79.    return $data;
  80. }
  81.  
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment