php WapCraft Users plugin author Alex Priadko version 01 package WapCr

 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
<?php
/**
* WapCraft Users plugin
* @author Alex Priadko
* @version 0,01
* @package WapCraft
*/
class User
{
private $tocken;
public function __construct ($tocken)
{
$this->tocken = $tocken;
}
/**
* Проверка пользователя на авторизацию крч аутентификация
* @return int
* @param md5 hash
*/
public function checkAuth ()
{
global $db;
$parseDbTocken = $db->prepare("SELECT * FROM `users` WHERE `session_key`=? and `session_life`>?");
$parseDbTocken->execute(array($this->tocken,$_SERVER['REQUEST_TIME']));
$numr = $parseDbTocken->fetch();
if (isset($numr))
{
return 1;
}
else
{
return 0;
}
}
public function __get($col)
{
global $db;
if ($this->checkAuth() == 1)
{
$_data = $db->prepare("SELECT * FROM `users` WHERE `session_key`=?");
$_data->execute(array($this->tocken));
if (!is_null($_data))
{
$_data = $_data->fetch();
}
//$_data = $_data->fetch("SELECT * FROM `users` WHERE `tocken`=?",array ($this->tocken));
return $_data[$col];
}
}
}