nebukad

cek.php

Feb 14th, 2015
932
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <?php
  2. function ambil_ip() {
  3.     foreach (array('HTTP_CLIENT_IP', 'HTTP_X_REAL_IP', 'REMOTE_ADDR', 'HTTP_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED') as $key) {
  4.         if (array_key_exists($key, $_SERVER) === true) {
  5.           foreach (explode(',', $_SERVER[$key]) as $ip) {
  6.             if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
  7.               return $ip;
  8.             }
  9.           }
  10.         }
  11.     }
  12. }
  13.  
  14. session_start();
  15. require_once("auth.php");
  16. session_start();
  17.  
  18. $username = isset($_POST['email']) ? $_POST['email'] : "";
  19. $username = mysql_real_escape_string($username);
  20. $pass = isset($_POST['password']) ? $_POST['password'] : "";
  21. $pass = md5(md5(md5($pass)));
  22.  
  23. if($username != ""){
  24.     $cekuser = mysql_query("SELECT * FROM user WHERE email = '$username'");
  25.     $jumlah = mysql_num_rows($cekuser);
  26.     $hasil = mysql_fetch_array($cekuser);
  27.     $ip = ambil_ip($cekip);
  28.  
  29.     if($jumlah == 0) {
  30.         echo $username;
  31.         header('location: http://citels-team.net/account/?error=1');
  32.     } else {
  33.         if($pass <> $hasil['password']) {
  34.             header('location: http://citels-team.net/account/?error=2');
  35.         } else {
  36.             $_SESSION['email'] = $username;
  37.             $k = mysql_query("UPDATE `user` SET `ip`='$ip' WHERE email='$username'");
  38.             header('location: http://citels-team.net');
  39.         }
  40.     }
  41. }else{
  42.     echo "Username is empty";
  43. }
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment