forked from exodus4d/pathfinder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccesscontroller.php
More file actions
62 lines (47 loc) · 1.25 KB
/
Copy pathaccesscontroller.php
File metadata and controls
62 lines (47 loc) · 1.25 KB
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
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Created by PhpStorm.
* User: exodus4d
* Date: 09.02.15
* Time: 23:30
*/
namespace Controller;
use Model;
class AccessController extends Controller {
function __construct() {
parent::__construct();
}
/**
* event handler
* @param $f3
*/
function beforeroute($f3) {
$loginCheck = $this->_checkLogIn();
if( !$loginCheck ){
// no user found or LogIn timer expired
$this->logOut($f3);
}
parent::beforeroute($f3);
}
/**
* checks weather a user is currently logged in
* @return bool
*/
private function _checkLogIn(){
$loginCheck = false;
if($this->f3->get('SESSION.user.time') > 0){
// check logIn time
$logInTime = new \DateTime();
$logInTime->setTimestamp($this->f3->get('SESSION.user.time'));
$now = new \DateTime();
$timeDiff = $now->diff($logInTime);
$minutes = $timeDiff->days * 60 * 24 * 60;
$minutes += $timeDiff->h * 60;
$minutes += $timeDiff->i;
if($minutes <= $this->f3->get('PATHFINDER.TIMER.LOGGED')){
$loginCheck = true;
}
}
return $loginCheck;
}
}