I am currently working on a project with attendance management system using attendance devices connected on LAN and i own the model SC700 of ZKTeco company. Unfortunately, the device isn't implemented with a web server, so the only way to interact is using the UDP Port 4370. That also means that i can't use this wonderful library https://github.com/cobisja/tad-php
The project is custom, written in PHP(Codeigniter 3) and i have used the dnaextrim's library from github (https://github.com/dnaextrim/php_zklib) to interact with the devices. So far so good, everything works great, except the SetUser functionality. I can set a new user with id,name,password,role from my app to the device but i can't set the RFID of the card he is going to use.
The function builds a 74 character long string and sends it to the device like below
function zksetuser($self, $uid, $userid, $name, $password, $role, $card) {
$command = CMD_SET_USER;
//$command_string = str_pad(chr( $uid ), 2, chr(0)).chr($role).str_pad($password, 8, chr(0)).str_pad($name, 28, chr(0)).str_pad(chr(1), 9, chr(0)).str_pad($userid, 8, chr(0)).str_repeat(chr(0),16);
$byte1 = chr((int) ($uid % 256));
$byte2 = chr((int) ($uid >> 8));
$command_string = $byte1 . $byte2 . chr($role) . str_pad($password, 8, chr(0)) . str_pad($name, 24, chr(0)) . str_pad($card, 13, chr(0)) . str_pad($userid, 8, chr(0)) . str_repeat(chr(0), 16);
$chksum = 0;
$session_id = $self->session_id;
$u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6/H2h7/H2h8', substr($self->data_recv, 0, 8));
$reply_id = hexdec($u['h8'] . $u['h7']);
$buf = $self->createHeader($command, $chksum, $session_id, $reply_id, $command_string);
socket_sendto($self->zkclient, $buf, strlen($buf), 0, $self->ip, $self->port);
try {
@socket_recvfrom($self->zkclient, $self->data_recv, 1024, 0, $self->ip, $self->port);
$u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6', substr($self->data_recv, 0, 8));
$self->session_id = hexdec($u['h6'] . $u['h5']);
return substr($self->data_recv, 8);
} catch (ErrorException $e) {
return FALSE;
} catch (exception $e) {
return False;
}
}
The parameter $card is implemented by me, so i can pass the RFID number of the card, but the problem is that the device "converts" the RFID i send, to another number! I can't figure out what manipulations it does for this conversion or what should i do to map a user with his RFID card.
Has anyone solved this before with ZKTeco SC700 using PHP?