PHP library to interacts with ZK Time and Attendance Devices.
Library for connecting under the network using the UDP protocol and port 4370
See ZK communication protocol manual here
License: GNU General Public License v2.0
PHP library to interacts with ZK Time and Attendance Devices.
Library for connecting under the network using the UDP protocol and port 4370
See ZK communication protocol manual here
we have around 20 devices, for some of the I can fetch all punches in few seconds while some are taking too longer to fetch punches.
I also tried to increate max_memery and max_timeout but still it is not returning and server gets hanged.
any idea how to deal with such situation?
1- avoid server getting hanged.
2-read punches in optimized manner when there are many (eg 20k or 40k punches)
How to shutdown the machine and restart it remotely?
Hi, you're doing a great job.
When I test this code with my machine it can get device info and people's name correctly, but it can't get the attendance log.
I tried var_dump($attendance); after $attendance = $zk->getAttendance();
it returned empty value.
I can still download attendance log with other win form program.
Please help.
Thank you very much
Hello,
I want to ask will this library work only on the localhost or on the public internet as well?
Mostly php applications are hosted in different servers so will it connect to a biometric attendance connected in local computer?
As per my understanding, a website cannot communicate with a device connected via usb.
Please clarify.
I was try to download and receive all record and its work when its code are echo, but not to insert into database.. can you help me ?
Hi there!
How would you update the set method in user model to set the user RFID also?
Thanks.
after enabling socket and soap extenssion its working fine on local server but same code not working on server
Given:
A-192.168.5.166
B-192.168.5.164
C-192.168.5.165
D-192.168.5.168
E-192.168.5.169
I would like to ask if the user data from biometrics A can be copied or duplicated to other biometrics machine (B,C,D,and E).
Right now we are using the same biometrics but different system (created in C#,VB and .NET) to get the data from the machine to put to database and sync user data from biometrics A to B,C,D and E.
Reference: https://www.codeproject.com/Articles/1104538/Csharp-ZKTeco-Biometric-Device-Getting-Started
It can be possible to do it?
The following image below is the system we use today to get data to our ZKTeco biometrics machine.
Hi, Util Class is very helpful to get check in and check out status all things are working good. but i want to access attendance by date how to filter it by date wise please help me out to solve this problem thanks.
Sir i want to read RFID and also write it to the device.
How can I connect a devices with communication key (password protected devices)
Hello, i know that this has nothing to do with the library, but how to send zk9500 data to the php api ? i thought it would be like barcode scanner but..
It is working on local server but same code not working on live server after enabling socket and soap extenssion
No display of anything
Fatal error: Uncaught Error: Call to undefined function socket_create() in ....\zklib\ZKLib.php:26 Stack trace: #0 ....\test.php(15): ZKLib->__construct('172.16.69.230') #1 {main} thrown in .....\zklib\ZKLib.php on line 26
I am getting userid 0 after 2000 Attendance log from my local machine.
how can increase the size? Please help
Hi
i have problem with arabic characters when i read or write from device.
character sample that show to me:
ãåÑÇä ÒãÇäí
Well, I know that there are no proper solution to get or set the fingerprint template from the device.
But from what I understand from this library, is that it uses an algorithm to store it on the device.
Here is the catch, the algorithm is an encoded string. The machine does that.
So, using "unpack" to get the vx10 algorithm template string is the proper way to restore it later.
Are there any ideas or anyone who can think of a solution? I'm sure it can be done.
The packet response from the machine is binary, afaik.
`
public function getUserTemplate($uid, $finger)
{
$template_data = '';
$this->user_data = array();
$command = CMD_USERTEMP_RRQ;
$byte1 = chr((int)($uid % 256));
$byte2 = chr((int)($uid >> 8));
$command_string = $byte1.$byte2.chr($finger);
$chksum = 0;
$session_id = $this->session_id;
$u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6/H2h7/H2h8', substr( $this->received_data, $this->start_data, 8) );
$reply_id = hexdec( $u['h8'].$u['h7'] );
$buf = $this->createHeader($command, $chksum, $session_id, $reply_id, $command_string);
$this->send($buf);
try
{
$this->received_data = $this->recv();
$u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6', substr( $this->received_data, $this->start_data, 8 ) );
$bytes = $this->getSizeTemplate();
if($bytes)
{
while($bytes > 0)
{
$received_data = $this->recv(1032);
array_push( $this->user_data, $received_data);
$bytes -= 1024;
}
$this->session_id = hexdec( $u['h6'].$u['h5'] );
$received_data = $this->recv();
}
$template_data = array();
if(count($this->user_data) > 0)
{
for($x=0; $x<count($this->user_data); $x++)
{
if ($x == 0)
{
$this->user_data[$x] = substr($this->user_data[$x], 8);
}
else
{
$this->user_data[$x] = substr($this->user_data[$x], 8);
}
}
$user_data = implode('', $this->user_data);
$template_size = strlen($user_data)+6;
$prefix = chr($template_size%256).chr(round($template_size/256)).$byte1.$byte2.chr($finger).chr(1);
$user_data = $prefix.$user_data;
if(strlen($user_data) > 6)
{
$valid = 1;
$template_data = array($template_size, $uid, $finger, $valid, $user_data);
}
}
return $template_data;
}
catch(ErrorException $e)
{
return FALSE;
}
catch(exception $e)
{
return FALSE;
}
}
`
I'm sure there is a way to get that algorithm string.
And restore it in the following function
`
public function setUserTemplate($data)
{
$command = CMD_USERTEMP_WRQ;
$command_string = $data;
//$length = ord(substr($command_string, 0, 1)) + ord(substr($command_string, 1, 1))256;
return $this->execCommand($command, $command_string);
/
$chksum = 0;
$session_id = $this->session_id;
$u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6/H2h7/H2h8', substr( $this->received_data, $this->start_data, 8) );
$reply_id = hexdec( $u['h8'].$u['h7'] );
$buf = $this->createHeader($command, $chksum, $session_id, $reply_id, $command_string);
$this->send($buf);
try
{
$u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6', substr( $this->received_data, $this->start_data, 8 ) );
$this->session_id = hexdec( $u['h6'].$u['h5'] );
return substr( $this->received_data, 8 );
}
catch(ErrorException $e)
{
return FALSE;
}
catch(exception $e)
{
return FALSE;
}
*/
}
`
Any ideas might make it work.
SpeedFace_-V5L[TD]_[P]
Hello. Data Attendance
Only the first Attendance is correct the rest is different from what is on the device can you help me?
Status | Connected | Version | Ver 6.60 Jul 1 2020 | OS Version | ~OS=1 | Platform | ~Platform=ZAM170_TFT |
---|---|---|---|---|---|---|---|
Firmware Version | ~ZKFPVersion=10 | WorkCode | WorkCode=0 | SSR | ~SSR=1 | Pin Width | ~PIN2Width=14 |
Face Function On | FaceFunOn=1 | Serial Number | ~SerialNumber= | Device Name | ~DeviceName=Smart Terminal | Get Time | 2023-05-08 23:23:56 |
UID | ID | Name | State | Date Time | Type |
---|---|---|---|---|---|
0 | Unknown | 2000-01-01 00:00:00 | Check-in | ||
0 | Password | 2000-01-01 00:04:15 | Check-in | ||
0 | �@߽, | �@߽, | Password | 2000-02-08 16:26:03 | Check-in |
0 | � | � | Password | 2000-01-01 00:00:00 | Check-in |
255 | � | � | Password | 2000-01-01 00:00:00 | Check-in |
24 | 3 | ggcsdhhj | Fingerprint | 2023-05-08 23:18:53 | Check-in |
PC Connection User_Manual
Menu Name Description
Comm Key Comm Key: The default password is 0, which can be changed. The Comm Key
may contain 1 to 6 digits.
Device ID
The identity number of the device, which ranges between 1 and 254. If the
communication method is RS232/RS485, you need to input this device ID in the
software communication interface.
fingerprint should register manually, then copy to another machines . still working ?
Hi there!
I use a setUser function but I can not add user, could you please tell me how to add user.
I am using the following code to check if the fingerprint data.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<?php
$enableGetDeviceInfo = true;
$enableGetUsers = true;
$enableGetData = true;
include('zklib/ZKLib.php');
$zk = new ZKLib(
'192.168.5.166' //your device IP
);
$ret = $zk->connect();
if ($ret) {
$zk->disableDevice();
$zk->setTime(date('Y-m-d H:i:s')); /
?>
<?php if($enableGetUsers === true) {
$getFingerprint = $zk->getFingerprint(237);
if (count($getFingerprint) > 0) {
foreach ($getFingerprint as $key => $value) {
echo $value.'<br><br><br>';
}
}
}
$zk->enableDevice();
$zk->disconnect();
}
?>
</body>
</html>
Then the following characters display:
0���MiSS21�*)���� ���+i���$�*'����%�K��oH*���~���*����W2$��&�P�*=�v����*�)��l+$��;�u�*2�A����*�/�P�;%��6�I�+��������*��������%�$����(+M�i-���}*5�-�����$�?����C+9��G�i��*R������;$�U����S+2�XY�p��*^�����b��U��2��~� 7G~��}��n|b�����j|J�SYe���y 1�y֔���- ��Q/?�7 ��8���= �� �����O ��! �e,.�7���2 �+��#�/�����������&���~�oe$�*��ab����X����ŖP�Y"������K�z���1� ����W,������ �&�� �L{��#�{څ����Ҩ�@� ���Wˆ����d��KS� ���}���}��i*u�t� Y����M�p�a� ���%�Q:��� �����\2GË �<������<�Y����f���?CU����PW�i*�G�e�G����n���ŦI��Ë�҈�0��|�q����V������;w�*���TK�����������:�����U�F���!��r�q�C�'�c�O~~�e *�����>�m�*����C�Ŗ�������D�J�*��-��D����a��w����� +���O������nq�������tb{� Œ�jw�U��]�9]���7��� *��'��� *y�@pZ���*s�C{�������������������O�����+�E�C�����?�Vľ]�*F�@X�P:(���=j�������������;���������8�@�C�����l��s���|4�%���0����B���1�I�����Cs�i �������Y������Zt�������R M�C�������R��VwՉ���:���*��4E��Ŷ���G7��&4�f���G���ޣt����Z����Q�����:������h0��:l01�����1e[��x81��� M)�RB�C�*��ER
(����MaSS21�"#���� ���#i���!�"=����q-_Oc�"U"���R���"Y����-������"W�����y"�R��sN-��E���"O�����9"�P�� 3,��B�~�"<������"����)�,��>���"��S� �^"��G�E��T-M��N�++#B�L:����"H�������-�X���d��)��)��y�~#L�g���6��5��Yw������P���M��������m���G.m�]��?4��'3 ��d�����`�������M�������w�b���m���l%��5 ����5)������m�1�|��|��h�������Ѓt�ݥ͊!�1��z�۔�Ѓ�����"� ����.���������������U�n�H-K ����.���A��s����?��~�q Ż _����f��� �w���w����� �=�i�z���?��:%��F}�x����F>���w�}���R���"\S`�������T�� ��p��s�Y �����?��p}W��@�S�q��.����G��rZ����[s�Y�:�~�u��n���~�������������y���*�U����=�"�����>������i��~�po0������9���EBa�xgZz� }�V��s�2���d�����\z ���;��� ����������s���TG���}��b�VnD�^��<��������:��dT ��F�j_���F��U_���Ʒ������W�O� ���P�Vji�����O[��������Yb�����/�z�LY���nq�9�L��;�M���~�IVI�U�����w6D �҆�w{� ��@���{<��F��^M ��=��[�"��C�2[���6W���������i���T�x���xZ���DqK ��=��+&�<�S����R%Hi��A��J�2]�F�[��G�mU��H�L���o�I8���)3G�����H<��2[AC���տP�SV�����������������������R��a�ER
0����MiSS21�*)���� ���+i���$�*'����%�K��oH*���~���*����W2$��&�P�*=�v����*�)��l+$��;�u�*2�A����*�/�P�;%��6�I�+��������*��������%�$����(+M�i-���}*5�-�����$�?����C+9��G�i��*R������;$�U����S+2�XY�p��*^�����b��U��2��~� 7G~��}��n|b�����j|J�SYe���y 1�y֔���- ��Q/?�7 ��8���= �� �����O ��! �e,.�7���2 �+��#�/�����������&���~�oe$�*��ab����X����ŖP�Y"������K�z���1� ����W,������ �&�� �L{��#�{څ����Ҩ�@� ���Wˆ����d��KS� ���}���}��i*u�t� Y����M�p�a� ���%�Q:��� �����\2GË �<������<�Y����f���?CU����PW�i*�G�e�G����n���ŦI��Ë�҈�0��|�q����V������;w�*���TK�����������:�����U�F���!��r�q�C�'�c�O~~�e *�����>�m�*����C�Ŗ�������D�J�*��-��D����a��w����� +���O������nq�������tb{� Œ�jw�U��]�9]���7��� *��'��� *y�@pZ���*s�C{�������������������O�����+�E�C�����?�Vľ]�*F�@X�P:(���=j�������������;���������8�@�C�����l��s���|4�%���0����B���1�I�����Cs�i �������Y������Zt�������R M�C�������R��VwՉ���:���*��4E��Ŷ���G7��&4�f���G���ޣt����Z����Q�����:������h0��:l01�����1e[��x81��� M)�RB�C�*��ER
What is this?
I am not able to display username of my zkteco mb200. but its working another zkteco device.
How can i retrive username? where to change in get user info function?
right now it displays only id please help me to findout this problem
[1] => Array
(
[0] => 1
[1] => 1
[2] => 0000000000
[3] => 1
[4] => 0
[5] =>
)
[2] => Array
(
[0] => 2
[1] => 2
[2] => 0000000000
[3] => 2
[4] => 0
[5] =>
)
[3] => Array
(
[0] => 3
[1] => 3
[2] => 0000000000
[3] => 3
[4] => 0
[5] =>
)
Hi, Shall I submit a pull request for the composer support?
Sir, the system work great, it works with card, fingerprint, and password.
But sir when i use overtime-in and overtime-out the data display was Undefined.
How to work it sir?
The code in the example.php is working after update:
$zk->setUser(1, '211', 'Carl', '5555', ZK\Util::LEVEL_USER, '0007909321');
$zk->setUser(2, '2', 'Admin', '0927', ZK\Util::LEVEL_ADMIN,'0008209349');
But when I update the following code in https://github.com/aice09/php_zklib-1/blob/master/sync.php
Not Working
$zk->setUser(
$user['uid'],
$user['userid'],
$user['name'],
$user['cardno'],
$user['role'],
$user['password']
);
Working but shuffled
$zk->setUser(
$user['userid'],
$user['name'],
$user['cardno'],
$user['uid'],
$user['role'],
$user['password']
);
Not Working base from zklib/src/User.php public function set and example
$zk->setUser(
$user['uid'],
$user['userid'],
$user['name'],
$user['password'],
$user['role'],
$user['cardno']
);
What is the best way to setusers?
Hi,
I want to detect the user login and prevent the door from opening if the user is not authorized.
how can I do it?
I can't retrieve attendance data using example.php. Please help
After getting user attendance data form the machine, the date and time of the biometrics machine change. How to fix the issue?
I was testing in local, it is woking fine and also can get data but when move project to cloud ( In hosting) it not work.
anyone have any solutions?
How to get and set finger, please!
first i wana to thank you for your work, god job.
can you help me how can i use getFingerprint() and setFingerprint().
thanks
Hi,
I had read some documents https://github.com/vodvud/php_zklib/blob/master/zklib/docs/ZK_Communication_protocol_manual_CMD.pdf on the repo.
It mentions something like a real-time event, where it triggers a function and has something in return.
see CMD_REG_EVENT and EF_VERIFY.
Because I want to have the attendance collected every time there is an activity on the biometric device.
Example.
When a person check-in, that data will automatically be retrieved and then be stored in the database without using cron jobs.
thanks.
Hi.
Thanks for the library.
I just want to know what models of ZKTeco devices does the library support?
And can the library be used to get the attendance data from the zkteco device at a regular interval to provide a bit of a real-time data on my web app.
Hi.
I change Scripts for set Card Number for user:
ZKlib.php
public function setUser($uid, $userid, $name, $password, $role = Util::LEVEL_USER,$card) { return (new ZK\User())->set($this, $uid, $userid, $name , $password, $role,$card); }
User.php
` public function set(ZKLib $self, $uid, $userid, $name, $password, $role = Util::LEVEL_USER ,$card)
{
$self->_section = __METHOD__;
if (
(int)$uid === 0 ||
(int)$uid > Util::USHRT_MAX ||
strlen($userid) > 9 ||
strlen($name) > 24 ||
strlen($password) > 8
) {
return false;
}
$command = Util::CMD_SET_USER;
//echo $command;
$byte1 = chr((int)($uid % 256));
$byte2 = chr((int)($uid >> 8));
$command_string = implode('', [
$byte1,
$byte2,
chr($role),
str_pad($password, 8, chr(0)),
str_pad($name, 24, chr(0)),
str_pad($card, 13, chr(0)),
//str_pad(chr(1), 9, chr(0)),
str_pad($userid, 8, chr(0)),
str_repeat(chr(0), 16)
]);
print_r($command_string);
return $self->_command($command, $command_string);
}`
example.php:
$zk->setUser(60, '60', 'name', '12345', ZK\Util::LEVEL_ADMIN,12345678);
But set another number after set
card number:123456
card number after set :0875770417
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.