forked from blondak/php_zklib
-
Notifications
You must be signed in to change notification settings - Fork 3
/
zktest.php
190 lines (181 loc) · 4.83 KB
/
zktest.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
require __DIR__ . '/vendor/autoload.php';
use \ZKLib\ZKLib;
use \ZKLib\User;
?>
<html>
<head>
<title>ZK Test</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container">
<?php
$zk = new ZKLib('192.168.1.201');
$ret = $zk->connect();
if ( $ret ):
$zk->disable();
$capacity = $zk->getFreeSize();
/*
$zk->testVoice();
$zk->setUser(new User(
99,
User::PRIVILEGE_COMMON_USER,
'1234',
'User99',
'Card99',
'1',
-3,
99
));
*/
?>
<h1>PHP ZK Library</h1>
<h2>Clock info</h2>
<div class="row">
<div class="col col-md-12">
<table class="table table-bordered table-hover">
<tr>
<td><b>Status</b></td>
<td>Connected</td>
<td><b>Version</b></td>
<td><?php echo $zk->getVersion() ?></td>
<td><b>OS Version</b></td>
<td><?php echo $zk->getOs() ?></td>
<td><b>Platform</b></td>
<td><?php echo $zk->getPlatform() ?></td>
</tr>
<tr>
<td><b>Firmware Version</b></td>
<td><?php echo $zk->getPlatformVersion() ?></td>
<td><b>WorkCode</b></td>
<td><?php echo $zk->getWorkCode() ?></td>
<td><b>SSR</b></td>
<td><?php echo $zk->getSsr() ?></td>
<td><b>Pin Width</b></td>
<td><?php echo $zk->getPinWidth() ?></td>
</tr>
<tr>
<td><b>Face Function On</b></td>
<td><?php echo $zk->getFaceOn() ?></td>
<td><b>Serial Number</b></td>
<td><?php echo $zk->getSerialNumber() ?></td>
<td><b>Device Name</b></td>
<td><?php echo $zk->getDeviceName(); ?></td>
<td><b>Get Time</b></td>
<td><?php echo $zk->getTime()->format('r') ?></td>
</tr>
</table>
</div>
</div>
<h2>Capacity</h2>
<div class="row">
<div class="col col-md-12">
<table class="table table-bordered table-hover">
<tr>
<td><b>Attendance logs available</b></td>
<td><?php echo $capacity->getAttLogsAvailable(); ?></td>
<td><b>Attendance log capacity</b></td>
<td><?php echo $capacity->getAttLogsCapacity(); ?></td>
<td><b>Attendance logs stored</b></td>
<td><?php echo $capacity->getAttLogsStored(); ?></td>
</tr>
<tr>
<td><b>Templates available</b></td>
<td><?php echo $capacity->getTemplatesAvailable(); ?></td>
<td><b>Templates capacity</b></td>
<td><?php echo $capacity->getTemplatesCapacity(); ?></td>
<td><b>Templates stored</b></td>
<td><?php echo $capacity->getTemplatesStored(); ?></td>
</tr>
<tr>
<td><b>Users available</b></td>
<td><?php echo $capacity->getUsersAvailable(); ?></td>
<td><b>Users capacity</b></td>
<td><?php echo $capacity->getUsersCapacity(); ?></td>
<td><b>Users stored</b></td>
<td><?php echo $capacity->getUsersStored(); ?></td>
</tr>
<tr>
<td><b>Admins stored</b></td>
<td><?php echo $capacity->getAdminsStored(); ?></td>
<td><b>Passwords stored</b></td>
<td><?php echo $capacity->getPasswordsStored(); ?></td>
</tr>
</table>
</div>
</div>
<h2>Users</h2>
<div class="row">
<div class="col col-md-12">
<table class="table table-bordered table-hover">
<tr>
<th>UID</th>
<th>ID</th>
<th>Name</th>
<th>Role</th>
<th>Password</th>
<th>Group</th>
<th>TimeZone</th>
<th>Card number</th>
</tr>
<?php
try {
// $zk->clearUsers();
// $zk->setUser(new User(1, User::PRIVILEGE_SUPERADMIN, '1', 'Admin', '', '', -3, 1));
foreach($zk->getUsers() as $user): ?>
<tr>
<td><?php echo $user->getRecordId(); ?></td>
<td><?php echo $user->getUserId(); ?></td>
<td><?php echo $user->getName(); ?></td>
<td><?php echo $user->decodeRole(); ?></td>
<td><?php echo $user->getPassword(); ?></td>
<td><?php echo $user->getGroupId(); ?></td>
<td><?php echo $user->getTimeZone(); ?></td>
<td><?php echo $user->getCardNo(); ?></td>
</tr>
<?php
endforeach;
} catch (Exception $e) {
header("HTTP/1.0 404 Not Found");
header('HTTP', true, 500); // 500 internal server error
}
// $zk->clearAdmins();
?>
</table>
</div>
</div>
<h2>Attendance data</h2>
<div class="row">
<div class="col col-md-12">
<table class="table table-bordered table-hover">
<tr>
<th>UID</th>
<th>In / Out</th>
<th>Validated By</th>
<th>Status</th>
<th>DateTime</th>
</tr>
<?php
foreach($zk->getAttendances() as $attendance):
?>
<tr>
<td><?php echo $attendance->getUserId(); ?></td>
<td><?php echo $attendance->isOut() ? 'Out' : 'In'; ?></td>
<td><?php echo $attendance->validatedBy(); ?></td>
<td><?php echo $attendance->getStatus(); ?></td>
<td><?php echo $attendance->getDateTime()->format('r'); ?></td>
</tr>
<?php
endforeach;
?>
</table>
</div>
<?php
$zk->enable();
$zk->disconnect();
endif
?>
</div>
</body>
</html>