><<||', $string); $table = '
'; foreach ($values as $v) { list($a, $b) = explode(',', $v); $table .= ' '; } $table .= '
Agent Codename
' . ucfirst($a) . ' ' . ucwords($b) . '
'; return $table; } function salt_and_hash($pw) { $salt = 'fdiojhlkjasdfjh'; $o_salt = 'qwelnbfnvaslkfj'; $pw = $salt . $pw . $o_salt; return hash('sha512', $pw); } function increment_login_count($id) { p_query('UPDATE users SET login_count = login_count + 1 WHERE id = ?', 'i', $id); } function auth_user($username, $password) { $results = p_query('SELECT id, password FROM users WHERE username = ?', 's', $_POST['username'])->fetch_assoc(); if (!$results) { return '

Username or Password is incorrect!

'; } else { if ($results['password'] == salt_and_hash($password)) { $_SESSION['hashbrown_access'] = true; $_SESSION['username'] = $username; increment_login_count($results['id']); return true; } else { if (isset($_SESSION['login_attempts'])) $_SESSION['login_attempts']++; else $_SESSION['login_attempts'] = 1; if ($_SESSION['login_attempts'] >= 3) { return '

Reached 3+ failed login attempts!

'; } else { return '

Username or Password is incorrect!

'; } } } } function create_user($username, $password, $v_password) { if ($password != $v_password) { return '

Passwords do not match!

'; } $exists = p_query('SELECT username FROM users WHERE username = ?', 's', $username)->fetch_assoc(); if ($exists) { return '

Username is taken!

'; } $user = p_query('INSERT INTO users (username, password) VALUES (?, ?)', 'ss', $username, salt_and_hash($password)); if (!$user) { return '

Unable to create user!

'; } return true; } function logout() { foreach (array_keys($_SESSION) as $key) unset($_SESSION[$key]); header('Location: .'); } function get_user_image() { $result = p_query('SELECT image_path FROM users WHERE username = ?', 's', $_SESSION['username'])->fetch_assoc(); return 'img/' . $result['image_path']; } function update_user_pw($password, $v_password) { if ($password != $v_password) { return '

Passwords do not match!

'; } $result = p_query('UPDATE users SET password = ? WHERE username = ?', 'ss', salt_and_hash($password), $_SESSION['username']); if ($result) { return true; } else { return false; } } function query($stmt) { $conn = new mysqli(HOST, USER, PASS, DB); $result = $conn->query($stmt); if ($result) return $result; else return mysqli_insert_id($conn); } function p_query($stmt, $types, ...$args) { $conn = new mysqli(HOST, USER, PASS, DB); $stmt = $conn->prepare($stmt); $stmt->bind_param($types, ...$args); $stmt->execute(); $result = $stmt->get_result(); if ($result) return $result; else return mysqli_insert_id($conn); } function pretty_dump($arg) { echo '
';
    print_r($arg);
    echo '
'; }