-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauth.php
More file actions
51 lines (44 loc) · 933 Bytes
/
Copy pathauth.php
File metadata and controls
51 lines (44 loc) · 933 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
require 'config.php';
require 'totp.php';
if (!isset($_SESSION)) {
session_start();
}
function checkLoginOTP($code)
{
global $config;
$totp = new TOTP();
$validCode = $totp->getOTP(
$config['totp_secret'],
$config['totp_digits'],
$config['totp_period'],
$config['totp_offset'],
$config['totp_algo']
)['otp'];
if ($code === $validCode) {
return true;
} else {
return false;
}
}
function setLoggedIn($value)
{
$_SESSION['logged_in'] = $value;
}
function isLoggedIn()
{
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true) {
return true;
} else {
return false;
}
}
function requireLogin()
{
if (!isLoggedIn()) {
flashNextURL($_SERVER['REQUEST_URI']);
redirect(getLoginURL());
exit();
}
}