-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodel.php
58 lines (49 loc) · 926 Bytes
/
model.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
<?php
/**
* <model.php>
*/
/**
* @param int $count
* @return array
*/
function database($count)
{
$dataStorage = array(
'userid1' => array('username' => 'username1', 'password'=>'password1'),
'userid2' => array('username' => 'username2', 'password'=>'password2'),
'userid3' => array('username' => 'username3', 'password'=>'password3'),
);
return ($count < count($dataStorage) + 1 )? $dataStorage['userid'.$count]: [];
}
/**
* @param array $userinfo
* @return boolean
*/
function getResponse($userinfo)
{
$response = false;
$count = 1;
while($data = database($count++))
{
if ($data == $userinfo)
{
$response = true;
break;
}
}
return $response;
}
/**
* @param string $username $password
* @return string
*/
function retreatResponse($uname, $pw)
{
$user_info = array('username' => $uname, 'password'=> $pw);
if(getResponse($user_info))
{
return 'granted';
}
return 'denied';
}
?>