mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-19 19:29:15 +12:00
Update web
This commit is contained in:
parent
852b5f33ec
commit
6e32fc9aca
18 changed files with 480 additions and 158 deletions
|
@ -26,23 +26,37 @@ function is_logged_in()
|
|||
|
||||
function user_exists(string $username)
|
||||
{
|
||||
include('dbconfig.php');
|
||||
include('config.php');
|
||||
$usernameUppercase = strtoupper($username);
|
||||
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||
$stmt = $connect->prepare("SELECT COUNT(1) FROM Users WHERE UPPER(Username)=?");
|
||||
$stmt->bind_param("s", strtoupper($username));
|
||||
$stmt->bind_param("s", $usernameUppercase);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$count = intval($result->fetch_row()[0]);
|
||||
return $count>0;
|
||||
}
|
||||
|
||||
function get_username(string $id)
|
||||
{
|
||||
include('config.php');
|
||||
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||
$stmt = $connect->prepare("SELECT Username FROM Users WHERE Id=?");
|
||||
$stmt->bind_param("i", $id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$usetname = intval($result->fetch_row()[0]);
|
||||
return $usetname;
|
||||
}
|
||||
|
||||
|
||||
function get_userid(string $username)
|
||||
{
|
||||
include('dbconfig.php');
|
||||
include('config.php');
|
||||
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||
|
||||
$usernameUppercase = strtoupper($username);
|
||||
$stmt = $connect->prepare("SELECT Id FROM Users WHERE UPPER(Username)=?");
|
||||
$stmt->bind_param("s", strtoupper($username));
|
||||
$stmt->bind_param("s", $usernameUppercase);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$id = intval($result->fetch_row()[0]);
|
||||
|
@ -51,7 +65,7 @@ function get_userid(string $username)
|
|||
|
||||
function get_sex(int $userid)
|
||||
{
|
||||
include('dbconfig.php');
|
||||
include('config.php');
|
||||
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||
|
||||
$stmt = $connect->prepare("SELECT Gender FROM Users WHERE Id=?");
|
||||
|
@ -64,7 +78,7 @@ function get_sex(int $userid)
|
|||
|
||||
function get_admin(int $userid)
|
||||
{
|
||||
include('dbconfig.php');
|
||||
include('config.php');
|
||||
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||
|
||||
$stmt = $connect->prepare("SELECT Admin FROM Users WHERE Id=?");
|
||||
|
@ -77,7 +91,7 @@ function get_admin(int $userid)
|
|||
|
||||
function get_mod(int $userid)
|
||||
{
|
||||
include('dbconfig.php');
|
||||
include('config.php');
|
||||
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||
|
||||
$stmt = $connect->prepare("SELECT Moderator FROM Users WHERE Id=?");
|
||||
|
@ -90,7 +104,7 @@ function get_mod(int $userid)
|
|||
|
||||
function get_password_hash(int $userid)
|
||||
{
|
||||
include('dbconfig.php');
|
||||
include('config.php');
|
||||
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||
$stmt = $connect->prepare("SELECT PassHash FROM Users WHERE Id=?");
|
||||
$stmt->bind_param("i", $userid);
|
||||
|
@ -102,7 +116,7 @@ function get_password_hash(int $userid)
|
|||
|
||||
function get_salt(int $userid)
|
||||
{
|
||||
include('dbconfig.php');
|
||||
include('config.php');
|
||||
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||
$stmt = $connect->prepare("SELECT Salt FROM Users WHERE Id=?");
|
||||
$stmt->bind_param("i", $userid);
|
||||
|
@ -125,7 +139,7 @@ function check_password(int $userId, string $password)
|
|||
|
||||
function populate_db()
|
||||
{
|
||||
include('dbconfig.php');
|
||||
include('config.php');
|
||||
$connect = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Unable to connect to '$dbhost'");
|
||||
mysqli_query($connect, "CREATE TABLE IF NOT EXISTS Users(Id INT, Username TEXT(16),Email TEXT(128),Country TEXT(128),SecurityQuestion Text(128),SecurityAnswerHash TEXT(128),Age INT,PassHash TEXT(128), Salt TEXT(128),Gender TEXT(16), Admin TEXT(3), Moderator TEXT(3))");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue