kamshory / ZKLibrary

ZKLibrary is PHP library for reading and writing data to attendance device using UDP protocol. This library useful to comunicate between web server and attendance device directly without addition program. This library is implemented in the form of class. So that you can create an object and use it functions.
GNU General Public License v2.0
198 stars 179 forks source link

Sending Data to library #6

Open test8git opened 6 years ago

test8git commented 6 years ago

Hi, could you please explain me, that how (and in which format) i will send data from device to test.php or zkLibrary? How to use the library? Please describe with an example. Thanks

rajucs commented 5 years ago

To get data from fingerprint and save it to the database, see code bellow:

<?php
include "zklibrary.php";
$zk = new ZKLibrary('192.168.1.102', 4370);
$zk->connect();
$zk->disableDevice();
$users = $zk->getUser();
foreach($users as $key=>$user)
{
   $sql = "insert into `person` (`uid`, `id`, `name`, `level`, `password`) values
   ('$key', '$user[0]', '".addslashes($user[1])."',  '$user[2]', '".addslashes($user[3])."');";
   mysql_query($sql); 
}
$zk->enableDevice();
?>

I Tried this to insert server data to my localhost database but failed.

saifurrahman1193 commented 4 years ago

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, 0, 8) ); $reply_id = hexdec( $u['h8'].$u['h7'] ); $buf = $this->createHeader($command, $chksum, $session_id, $reply_id, $command_string); socket_sendto($this->socket, $buf, strlen($buf), 0, $this->ip, $this->port); try { $u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6', substr( $this->received_data, 0, 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; } */ } please can anyone explain this code ? what exactly i have to pass here? i want to set user fingerprint data. Thanks in advance

rizkimuhammadfauzi commented 4 years ago

hi , how to push attendance to my machine ?

nurRachmanHS commented 4 years ago

I have a problem when I upload files to the server and run file it shows Request timeout but when I run on local it works fine can you please tell me how I solve the problem I have already increase my server timeout request ?

your localhost max_execution_time is set to default which mean the code stop itself after 30 seconds, you can change it from your localhost setting or add the following line in your php code : ini_set('max_execution_time', 0); 0 is for indefinite execution time.

Sarojb31 commented 4 years ago

Did you complete solving reading getUserTemplate($uid, $finger) and for writing setUserTemplate($data) .Can I get the image from the scanner?

Can I get the response value after placing a finger in scanner along with image to keep in my database?

rilwansha commented 2 years ago

anyone know hot getUserTemplate & SetUsertemplate please help me thank you

nitheeshtr1 commented 1 year ago

anyone help me how can update user group only without loss another datas?

CMD_USERGRP_WRQ Set user group. Fill the 1-4 byte of data part of the transmission packet with user serial number (2Bytes), 5-8 byte with the group serial number.

this is the command,any one help me please....

erkutcin commented 1 year ago

Hi, I am trying to retrieve the datas. I made all updates, but it's still not working. Did you find a solution for yours? Could you help me?

nitheeshtr commented 1 year ago

any one can help me to edit user group function cmd_usergrp_wrq-22 this is my code but its not working,any one can help me to create $commad_string

reference url : https://github.com/adrobinoga/zk-protocol/blob/master/sections/access.md for set user group

public function userGroup($uid,$gid) { $command = CMD_USERGRP_WRQ; $byte1 = chr((int) ($uid % 256)); $byte2 = chr((int) ($uid >> 8)); $byte3 = chr((int) ($gid)); $command_string = $byte1 . $byte2 . $byte3; return $this->execCommand($command, $command_string); }

erkutcin commented 1 year ago

herhangi biri kullanıcı grubu işlevini düzenlememe yardımcı olabilir cmd_usergrp_wrq-22 bu benim kodum ama çalışmıyor, herhangi biri $commad_string oluşturmama yardımcı olabilir

referans url'si: set kullanıcı grubu için https://github.com/adrobinoga/zk-protocol/blob/master/sections/access.md

public function userGroup($uid,$gid) { $command = CMD_USERGRP_WRQ; $byte1 = chr((int) ($uid % 256)); $byte2 = chr((int) ($uid >> 8)); $byte3 = chr((int) ($gid)); $command_string = $byte1 . $bayt2 . $bayt3; dönüş $bu->execCommand($komut, $command_string); }

I'm having trouble pulling data. Can you share the working sdk you are using? Names are coming from the zkteco k70 device, but the inputs and outputs are not.

nitheeshtr commented 1 year ago

herhangi biri kullanıcı grubu işlevini düzenlememe yardımcı olabilir cmd_usergrp_wrq-22 bu benim kodum ama çalışmıyor, herhangi biri $commad_string oluşturmama yardımcı olabilir referans url'si: set kullanıcı grubu için https://github.com/adrobinoga/zk-protocol/blob/master/sections/access.md public function userGroup($uid,$gid) { $command = CMD_USERGRP_WRQ; $byte1 = chr((int) ($uid % 256)); $byte2 = chr((int) ($uid >> 8)); $byte3 = chr((int) ($gid)); $command_string = $byte1 . $bayt2 . $bayt3; dönüş $bu->execCommand($komut, $command_string); }

I'm having trouble pulling data. Can you share the working sdk you are using? Names are coming from the zkteco k70 device, but the inputs and outputs are not.

use this function for change verification method for specified user $uid=> user id from device (PIN) $gid=>verification mode (find code bellow) FP+PW+RF = 128 FP = 129 PIN = 130 PW = 131 RF = 132 FP+PW = 133 FP+RF = 134 PW+RF = 135 PIN&FP = 136 FP&PW = 137 FP&RF = 138 PW&RF = 139 FP&PW&RF = 140

public function userVerify($uid,$gid) { $command = CMD_VERIFY_WRQ; $byte1 = chr((int) ($uid % 256)); $byte2 = chr((int) ($uid >> 8)); $byte3 = chr((int) ($gid));

    $command_string = $byte1 . $byte2 . $byte3 . str_repeat(chr(0),21);
    return $this->execCommand($command, $command_string);
}
madaniibrahim commented 1 year ago

i need to write a fingerprint on zkteco k40 machine .... setfingerprint() or setUsertemplate didn't work with me ... is there any one has solution .. i really need it as soon as possible

Amaan-n commented 4 months ago

i need to write a fingerprint on zkteco k40 machine .... setfingerprint() or setUsertemplate didn't work with me ... is there any one has solution .. i really need it as soon as possible

Did you get any solution

Amaan-n commented 4 months ago

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, $commandstring); / $chksum = 0; $session_id = $this->session_id; $u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6/H2h7/H2h8', substr( $this->received_data, 0, 8) ); $reply_id = hexdec( $u['h8'].$u['h7'] ); $buf = $this->createHeader($command, $chksum, $session_id, $reply_id, $command_string); socket_sendto($this->socket, $buf, strlen($buf), 0, $this->ip, $this->port); try { $u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6', substr( $this->received_data, 0, 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; } */ } please can anyone explain this code ? what exactly i have to pass here? i want to set user fingerprint data. Thanks in advance

Did you get the solution on how to set the fingerprint data, I want to transfer the fingerprints from device to another I am able to fetch it from the 1st device but not able to set it to the 2nd device?