mirror of
https://github.com/pikami/palm-paste.git
synced 2025-12-19 08:49:49 +00:00
Added users system! (They can login and logout)
This commit is contained in:
33
includes/user.php
Normal file
33
includes/user.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
function GetUsersIDBySession($sid,$skey){
|
||||
include "config/config.php";
|
||||
//SELECT * FROM pastes WHERE uid=
|
||||
$stmt = $conn->prepare("SELECT uid FROM sessions WHERE id=:sid AND skey=:skey");
|
||||
$stmt->bindParam(':skey', $skey);
|
||||
$stmt->bindParam(':sid', $sid);
|
||||
$stmt->execute();
|
||||
if($result = $stmt->fetch()){
|
||||
$conn = null;
|
||||
return $result[0];
|
||||
} else {
|
||||
$conn = null;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
function LogOutUserBySession($sid,$skey){
|
||||
include "config/config.php";
|
||||
$stmt = $conn->prepare("DELETE FROM sessions WHERE id=:sid AND skey=:skey");
|
||||
$stmt->bindParam(':skey', $skey);
|
||||
$stmt->bindParam(':sid', $sid);
|
||||
$stmt->execute();
|
||||
$conn = null;
|
||||
}
|
||||
function UnsetBrowserCookies(){
|
||||
//These cookies expired an hour ago! What are you doind browser? :D
|
||||
setcookie("pp_sid", '', time() - 3600);
|
||||
setcookie("pp_skey", '', time() - 3600);
|
||||
}
|
||||
function GetUsernameByID(){
|
||||
//Placeholder
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user