forked from martinloren/Youtube-dl-WebUI-QNAP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsessions.php
37 lines (31 loc) · 799 Bytes
/
sessions.php
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
<?php
// Start session
session_start();
// Include config.php
require_once("config.php");
function startSession($pass)
{
$pass = htmlentities($pass);
if((isset($GLOBALS['settings']['security']) && $GLOBALS['settings']['security'] == "yes"))
{
if(password_verify($pass, $GLOBALS['settings']['password'])) $_SESSION['logged'] = 1;
else $_SESSION['logged'] = 0;
} else {
$_SESSION['logged'] = 1;
}
}
function endSession()
{
if(!session_id()) session_start();
session_destroy();
}
function secured(){
return (isset($GLOBALS['settings']['security']) && $GLOBALS['settings']['security'] === "yes");
}
function loggedIn(){
return (isset($_SESSION['logged']) && $_SESSION['logged'] == 1);
}
function authorized(){
return (!secured() || loggedIn());
}
?>