Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'db.php';
- error_reporting(E_ALL);
- $hash = $_POST['wachtwoord'];
- $salt = 'hello_1m_@_SaLT';
- $password = hash('sha256', $hash . $salt);
- $email=$_POST['email'];
- $email = stripslashes($email);
- $email = mysql_real_escape_string($email);
- $password = stripslashes($password);
- $password = mysql_real_escape_string($password);
- $sql = "SELECT * FROM users WHERE email='$email' AND wachtwoord='$password' OR ign='$email' AND password='$password' AND display=1";
- $result = mysql_query($sql);
- $count = mysql_num_rows($result);
- if($count == 1){
- if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- $query = mysql_query("SELECT email FROM users WHERE ign='$email'");
- $result_mail = mysql_fetch_assoc($query);
- $email = $result_mail['email'];
- }
- $stay = $_POST["stay"];
- $sql_user = mysql_query("SELECT id, active, block FROM users WHERE email='$email' OR ign='$email' AND password='$password' AND display=1");
- $user = mysql_fetch_assoc($sql_user);
- if($user['active'] == 1) {
- if($user['block'] == 1) {
- header("Location: /blocked/login");
- }
- else {
- function randomstring($length) {
- $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $charactersLength = strlen($characters);
- $randomString = '';
- for ($i = 0; $i < $length; $i++) {
- $randomString .= $characters[rand(0, $charactersLength - 1)];
- }
- return $randomString;
- }
- $code = randomstring(60);
- $id = $user['id'];
- if($stay == "on") {
- $expire = "never";
- }
- else {
- $current_timestamp = time();
- $expire = strtotime('+1 day', $current_timestamp);
- }
- $upload_code = "INSERT INTO sessions (session_id, user_id, expire) VALUES ('$code', '$id', '$expire')";
- if ($conn->query($upload_code) === TRUE) {
- setcookie (
- "session",
- $code,
- time()+2000000000,
- "/",
- "your.url.net"
- );
- $goback = $_GET['goback_url'];
- if($goback) {
- $goback_url = str_replace("!", "/", $goback);
- echo $goback_url;
- header("Location: ".$goback_url);
- }
- else {
- echo $goback;
- header("Location: /");
- }
- }
- else {
- echo "Error: " . $upload_code . "<br>" . $conn->error;
- }
- }
- }
- else {
- header("location:/noaccount/login");
- }
- }
- else {
- header("location:/error/login");
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement