-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
117 lines (90 loc) · 2.61 KB
/
test.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
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* Created by PhpStorm.
* User: sokolskih
* Date: 23.06.2017
* Time: 17:59
*/
$arr = [1, 2, 3];
var_dump($arr);
require_once 'vendor/autoload.php';
use Illuminate\Database\Capsule\Manager as Capsule;
class DataBase
{
function __construct()
{
$host = '127.0.0.1';
$db = 'loftschool';
$user = 'root';
$pass = '';
$charset = 'utf8';
$dbdriver = 'mysql';
$capsule = new Capsule;
$capsule->addConnection([
'driver' => $dbdriver,
'host' => $host,
'database' => $db,
'username' => $user,
'password' => $pass,
'charset' => $charset,
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
// Setup the Eloquent ORM…
$capsule->setAsGlobal();
$capsule->bootEloquent();
}
public function getUsersList()
{
$userslist = User::all(); // $this->pdo->query('SELECT * FROM table_name');
while ($row = $userslist) {
$users[] = $row;
}
return $users;
}
public function is_userInDataBase($login)
{
$user = User::where('login', '=', $login)->get()->toArray();
if (is_array($user[0])) {
return true;
} else {
return false;
}
}
public function userAndPasswordConformity($login = '', $password = '')
{
$passwordInBase = User::where('login', '=', $login)->first()->password;//->toArray(); //$this->pdo->prepare('SELECT * FROM table_name WHERE login= :login');
echo '<br>' . $login . '<br>' . $password . '<br>';
var_dump($passwordInBase);
if ($passwordInBase != '') {
if ($password == $passwordInBase) {
return true;
} else {
return false;
}
} else {
return false;
}
}
public function saveNewUser($login, $password)
{
try {
$user = new User;
$user->login = $login;
$user->password = $password;
$user->save();
return true;
} catch (Exception $e) {
echo '<br><br><br>asdasdas<br>';
var_dump($e);
return false;
}
}
}
class User extends \Illuminate\Database\Eloquent\Model
{
}
$dataBase = new DataBase();
//var_dump($dataBase -> userAndPasswordConformity('q2','$6$naborSimvolovFor$s7j6Oyieq2YQ/O/vd52VtEQ.XuY1YQymDFZIC6TcsuJ0NQ0D34I30UayGAztBezxxsSZpV0vJPbHRUqRIE5AQ'));
//var_dump($dataBase->is_userInDataBase('q34'));
$dataBase->saveNewUser('g5', 'q5');