Advertisement
Guest User

Untitled

a guest
May 3rd, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.70 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Verify.php
  5.  * Aktivoi käyttäjätilin rekisteröitymisen jälkeen.
  6.  *
  7.  * @pedro gonzales
  8.  *
  9.  */
  10.  
  11. require_once ('DBBase.php');
  12.  
  13. /**
  14.  * Tarkistaa että $code merkkijono löytyy linkistä, ja ottaa sen talteen.
  15.  *
  16.  */
  17.  
  18. if(!isset($_GET["code"])) {
  19.     echo("error");
  20.     die("Ei koodia.");
  21. } else {
  22.     $code = $_GET["code"];
  23.     echo $code;
  24. }
  25.  
  26. /**
  27.  * Input kentistä otettu salsana ja username
  28.  * ** DEMO **
  29.  */
  30.  
  31. $inputusername = "pietu";
  32. $inputpassword = "jepjep";
  33.  
  34. /**
  35.  * Päivittää käyttäjän tilan tietokannassa aktiiviseksi ( => 1)
  36.  *
  37.  */
  38.  
  39. function updateCode($u) {
  40.     $DB = new DBBase();
  41.     $DB->update("users", array('userstate'), array('1'), "username = '" . $u . "'");
  42.     echo "koodi vaihdettu";
  43. }
  44.  
  45. /**
  46.  * Lähettää käyttäjälle tiedon tilin aktivoinnista
  47.  *
  48.  */
  49.  
  50. function sendNotice($e) {
  51.     $subject = "Palveluun aktivointi onnistui";
  52.     $message = "Tervetuloa käyttämään palvelua, tilisi on nyt aktivoitu";
  53.     $from = "testi@testi.com";
  54.     $headers = "From: $from";
  55.     mail($e,$subject,$message,$headers);
  56. }
  57.  
  58. /**
  59.  * Pääfunktio joka suorittaa yllä olevat funktiot jos username ja password täsmää.
  60.  *
  61.  */
  62.  
  63. function checkVerification($c="", $iu="", $ip="") {
  64.    
  65.     $asd = new DBBase();
  66.     $result = $asd->select("username, password, email", "users", "userstate = '" . $c . "'");
  67.     while ($row = mysqli_fetch_object($result)) {
  68.         $username = $row->username;
  69.         $password = $row->password;
  70.         $email = $row->email;
  71.         echo $username;
  72.         echo $password;
  73.     }
  74.  
  75.     if ($ip == $password && $iu == $username) {
  76.         updateCode($username);
  77.         sendNotice($email);
  78.     }
  79.  
  80.     else {
  81.  
  82.         echo "Väärä käyttäjätunnus ja/tai salasana";
  83.  
  84.     }
  85.  
  86. }
  87.  
  88. checkVerification($code, $inputusername, $inputpassword);
  89.  
  90. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement