1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
// LOGIN USER'50'
if (isset($_POST['login_user'])) {
$username = $_POST['username'];;
$password = $_POST['password'];;
if (empty($username)) {
array_push($errors, "Username is required");
}
if (empty($password)) {
array_push($errors, "Password is required");
}
if (count($errors) == 0) {
//hash passwd
$checkpass = $bdd_challenges->query("SELECT * FROM users WHERE name='$username'");
$checkpassdata = $checkpass->fetch();
$mysqlpassword = $checkpassdata["password"];
$checkpass->closeCursor();
if ($password == $mysqlpassword) {
//Recupération des données de profile depuis la base de données du forum
$bdd_forum = new PDO('mysql:host=localhost;dbname=forum;charset=utf8', '*****', '****');
$userinfo = $bdd_forum->query("SELECT * FROM core_members WHERE name='$username'");
$userinfodata = $userinfo->fetch();
$email = $userinfodata["email"];
$joined = $userinfodata["joined"];
$bday = $userinfodata["bday_day"];
$bmonth = $userinfodata["bday_month"];
$byear = $userinfodata["bday_year"];
$pp_view = $userinfodata["members_profile_views"];
$pp_main = $userinfodata["pp_main_photo"];
$pp_reputation = $userinfodata["pp_reputation_points"];
$user_shop_points = $userinfodata["shop_points"];
$user_post = $userinfodata["msg_count_total"];
$userinfo->closeCursor();
//check challenges
$bdd_challenges = new PDO('mysql:host=localhost;dbname=challenges;charset=utf8', '*****', '*****');
$userchall = $bdd_challenges->query("SELECT * FROM users WHERE name='$username'");
$userchalldata = $userchall->fetch();
$webch1 = $userchalldata["web1"];
$webch2 = $userchalldata["web2"];
$webch3 = $userchalldata["web3"];
$webch4 = $userchalldata["web4"];
$webch5 = $userchalldata["web5"];
$webch6 = $userchalldata["web6"];
$webch7 = $userchalldata["web7"];
$crypt1 = $userchalldata["crypto1"];
$crypt2 = $userchalldata["crypto2"];
$crypt3 = $userchalldata["crypto3"];
$crypt4 = $userchalldata["crypto4"];
$crypt5 = $userchalldata["crypto5"];
$points_max = $userchalldata["points"];
$u_ctfdone = $userchalldata["ctfwin"];
$u_chdone = $userchalldata["chdone"];
$u_score = $userchalldata["score"];
$userchall->closeCursor();
$_SESSION['username'] = $username;
$_SESSION['email'] = $email;
$_SESSION['points'] = $user_shop_points;
$_SESSION['clan'] = $clan;
$_SESSION['score'] = $pp_reputation;
$_SESSION['avatar'] = $pp_main;
$_SESSION['msg_count'] = $user_post;
$_SESSION['view'] = $pp_view;
$_SESSION['profile_maxpoints'] = $profile_maxpoints;
$_SESSION['webch1'] = $webch1;
$_SESSION['webch2'] = $webch2;
$_SESSION['webch3'] = $webch3;
$_SESSION['webch4'] = $webch4;
$_SESSION['webch5'] = $webch5;
$_SESSION['webch6'] = $webch6;
$_SESSION['webch7'] = $webch7;
$_SESSION['crypt1'] = $crypt1;
$_SESSION['crypt2'] = $crypt2;
$_SESSION['crypt3'] = $crypt3;
$_SESSION['crypt4'] = $crypt4;
$_SESSION['crypt5'] = $crypt5;
$_SESSION['ctfdone'] = $u_ctfdone;
$_SESSION['u_score'] = $u_score;
$_SESSION['u_chdone'] = $u_chdone;
$_SESSION['max_points'] = $points_max;
$_SESSION['success'] = "You are now logged in";
header('location: index.php');
}else {
array_push($errors, "Wrong username/password combination");
}
}
} |
Partager