|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* KNUT7 K7F (https://marciozebedeu.com/) |
|
4
|
|
|
* KNUT7 K7F (tm) : Rapid Development Framework (https://marciozebedeu.com/) |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under The MIT License |
|
7
|
|
|
* For full copyright and license information, please see the LICENSE.txt |
|
8
|
|
|
* Redistributions of files must retain the above copyright notice. |
|
9
|
|
|
* |
|
10
|
|
|
* @link https://github.com/knut7/framework/ for the canonical source repository |
|
11
|
|
|
* @copyright (c) 2015. KNUT7 Software Technologies AO Inc. (https://marciozebedeu.com/) |
|
12
|
|
|
* @license https://marciozebedeu.com/license/new-bsd New BSD License |
|
13
|
|
|
* @author Marcio Zebedeu - [email protected] |
|
14
|
|
|
* @version 1.0.2 |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace Ballybran\Helpers\Security; |
|
18
|
|
|
|
|
19
|
|
|
use Ballybran\Helpers\Hook; |
|
|
|
|
|
|
20
|
|
|
use http\Url; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class Session |
|
24
|
|
|
* @package Ballybran\Helpers\Security |
|
25
|
|
|
*/ |
|
26
|
|
|
class Session |
|
27
|
|
|
{ |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* init Sessin our Session Start |
|
37
|
|
|
* É usado para ativar o incio de sassão do usuário. |
|
38
|
|
|
*/ |
|
39
|
|
|
public static function init() |
|
40
|
|
|
{ |
|
41
|
|
|
if (headers_sent()) { |
|
42
|
|
|
return; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
$id = session_id(); |
|
46
|
|
|
if (empty( $id )) { |
|
47
|
|
|
@session_start( |
|
|
|
|
|
|
48
|
|
|
[ |
|
49
|
|
|
'cookie_lifetime' => 86400 , |
|
50
|
|
|
// 'read_and_close' => true, |
|
51
|
|
|
] |
|
52
|
|
|
); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param $key |
|
58
|
|
|
* @param $value |
|
59
|
|
|
* @return mixed |
|
60
|
|
|
*/ |
|
61
|
|
|
public static function set($key, $value) |
|
62
|
|
|
{ |
|
63
|
|
|
return $_SESSION[$key] = $value; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param $key |
|
68
|
|
|
* @return mixed |
|
69
|
|
|
*/ |
|
70
|
|
|
public static function get($key) |
|
71
|
|
|
{ |
|
72
|
|
|
if(isset($_SESSION[$key])) { |
|
73
|
|
|
return $_SESSION[$key]; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* funtion usado para destruir a sessao |
|
79
|
|
|
* exxemplo de uso:: public function DestruirSessao(){ Session::Destroy() } |
|
80
|
|
|
*/ |
|
81
|
|
|
public static function Destroy() |
|
82
|
|
|
{ |
|
83
|
|
|
@session_destroy(); |
|
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param $key |
|
89
|
|
|
*/ |
|
90
|
|
|
public static function unsetValue($key) |
|
91
|
|
|
{ |
|
92
|
|
|
if (isset($_SESSION[$key])) { |
|
93
|
|
|
unset($_SESSION[$key]); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Usa-se como condicao. Se o usuario existe ou se for maior que zero ( > 0 ) |
|
99
|
|
|
* entao, isso significa que o usuario existe |
|
100
|
|
|
* mais se for menor q zero ( < 0 ) sigifica que o usuario nao existe. |
|
101
|
|
|
* exemplo de uso: Session::exist(){ |
|
102
|
|
|
* .. .. .. .. your code .. .. .. . |
|
103
|
|
|
* } |
|
104
|
|
|
* @return bool |
|
105
|
|
|
*/ |
|
106
|
|
|
public static function exist() |
|
107
|
|
|
{ |
|
108
|
|
|
if (sizeof($_SESSION) > 0) { |
|
109
|
|
|
session_regenerate_id(); |
|
110
|
|
|
return true; |
|
111
|
|
|
} else { |
|
112
|
|
|
return false; |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
} |
|
118
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths