Coder Social home page Coder Social logo

kamshory / zklibrary Goto Github PK

View Code? Open in Web Editor NEW
190.0 21.0 173.0 80 KB

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.

License: GNU General Public License v2.0

PHP 100.00%
attendance-device attendance zk zk-technology fingerprint fingerprint-sensor fingerprint-authentication fingerprint-scanner fingerprint-validation facerecognition

zklibrary's Introduction

ZKLibrary

ZKLibrary is PHP Library for ZK Time & Attendance Devices. This library is design to reading and writing data to attendance device (fingerprint, face recognition or RFID) using UDP protocol. This library is useful to comunicate between web server and attendance device directly without any addition program. This library is implemented in the form of class. So that you can create an object and use it functions.

Web server must be connected to the attendance device via Local Area Network (LAN). The UDP port that is used in this communication is 4370. You can not change this port without changing firmware of the attendance device. So, you just use it.

The format of the data are: binary, string, and number. The length of the parameter and return value must be vary.

paypal

Example

<?php

require 'zklibrary.php';

$zk = new ZKLibrary('192.168.1.102', 4370);
$zk->connect();
$zk->disableDevice();

// $zk->setTime(date('Y-m-d H:i:s'));
$zk->testVoice();

$zk->enableDevice();
$zk->disconnect();

?>

Data Structrure

Class ZKLibrary {
    String ip;
    Unsigned Short port;
    Unsigned Long socket;
    Unigned Long session_id;
    String received_data;
    String user_data[][];
    String attendance_data[][];
    Unsigned Long timeout_sec;
    Unsigned Long timeout_usec;
}

Functions

__construct([$ip[, $port]])

Object constructor.

Parameters

$ip

IP address of device.

$port

UDP port of device.


__destruct()

Object destructor.


connect([$ip[, $port]])

Function to make a connection to the device. If IP address and port is not defined yet, this function must take it. Else, this function return FALSE and does not make any connection.

Parameters

$ip

IP address of the device.

$port

UDP port of the device.


disconnect()

Function to disconnect from the device. If ip address and port is not defined yet, this function must take it. Else, this function return FALSE and does not make any changes.


setTimeout([$sec[, $usec]])

Set timeout for socket connection.

Parameters

$sec

Timeout in second.

$usec

Timeout in micro second.


reverseHex($input)

Reverse hexadecimal digits.


encodeTime($time)

Encode time to binary data.

Paramaters

$time

String time in format YYYY-MM-DD HH:II:SS

Return Value

Encoded time in binary format.


decodeTime($data)

Decode binary data to time.

Parameters

$data

Binary data from device.

Return Value

Dedoded time in string format.


checkSum($p)

This function calculates the chksum of the packet to be sent to the time clock.

Parameters

$p

Packet to be checked.


createHeader($command, $chksum, $session_id, $reply_id, $command_string)

Create data header to be sent to the device.

Parameters

$command

Command to the device in integer.

Return Value

Data header in binary format.


$checksum

Checksum of packet.

$session_id

Session ID of the connection.

$command_string

Data to be sent to the device.

Return Value

Sum of data to be checked.


checkValid($reply)

Check wether reply is valid or not.

Parameters

$reply

Reply data to be checked.


execCommand($command, $command_string = '', $offset_data = 8)

Send command and data packet to the device and receive some data if any.

Parameters

$command

Command to the device in integer.

$command_string

Data to be sent to the device.

$offset_data

Offset data to be returned. The default offset is 8.


getSizeUser()

Get number of user.

Return Value

Number of registered user in the device.


getSizeAttendance()

Get number of attendance log.

Return Value

Number of attendance recorded in the device.


restartDevice()

Restart the device.


shutdownDevice()

Shutdown the device.


sleepDevice()

Sleep the device.


resumeDevice()

Resume the device.


changeSpeed($speed = 0)

Change transfer speed of the device. 0 = slower. 1 = faster.

Parameters

$speed

Transfer speed of packet when the device comunicate to other device, i.e server.

Note: some device may be not supported fast speed.


writeLCD($rank, $text)

Write text on LCD. This order transmit character to demonstrate on LCD, the data part 1, 2 bytes of the packet transmit the rank value which start to demonstrate, the 3rd byte setting is 0 , follows close the filling character which want to be transmit. May work in CMD_CLEAR_LCD when use this function.

Parameters

$rank

Line number.

$text

Text to be demonstrated to LCD of the device.


clearLCD()

Clear text from LCD.


testVoice()

Test voice of the device.


getVersion()

Get device version.

Return Value

Version of the device in string format.


getOSVersion($net = true)

Get OS version.

Parameters

$net

If net set to true, function will return netto data without parameter name.


setOSVersion($osVersion)

Set OS version

Parameters

$osVersion

Version of operating version.


getPlatform($net = true)

Get OS version.

Parameters

$net If net set to true, function will return netto data without parameter name.


setPlatform($patform)

Set platform.

Parameters

$platform

Platform name.


getFirmwareVersion($net = true)

Get firmware version.

Parameters

$net

If net set to true, function will return netto data without parameter name.


setFirmwareVersion ($firmwareVersion)

Set firmware version.

Parameters

$firmwareVersion

The version of firmware.


getWorkCode($net = true)

Get work code.

Parameters

$net If net set to true, function will return netto data without parameter name.


setWorkCode($workCode)

Set work code.

Parameters

$workCode

Work code.


getSSR($net = true)

Get SSR

Parameters

$net

If net set to true, function will return netto data without parameter name.


setSSR($ssr)

Set SSR.

Parameters

$ssr

SSR.


getPinWidth($net = true)

Get pin width.

Parameters

$net

If net set to true, function will return netto data without parameter name.


setPinWidth($pinWidth)

Set pin width.

Parameters

$pinWidth

Pin width


getFaceFunctionOn($net = true)

Check wether face detection function is available or not.

Parameters

$net

If net set to true, function will return netto data without parameter name.


setFaceFunctionOn ($faceFunction)

Set wether face detection function is available or not.

Parameters

$faceFunction

Face function. 1 = available; 2 = not available.


getSerialNumber($net = true)

get serial number of the device.

Parameters

$net

If net set to true, function will return netto data without parameter name.


setSerialNumber($serialNumber)

Set serial number of the device.

Parameters

$serialNumber

Serial number of the device.


getDeviceName($net = true)

Get device name.

Parameters

$net

If net set to true, function will return netto data without parameter name.


setDeviceName($deviceName)

Set device name.

Parameters

$deviceName

The device name.


getTime()

Get time of device from real time clock (RTC). The time resolution is one minute.

Return Value

getTime return time as string with format YYYY-MM-DD HH:II:SS.


setTime($t)

Set time of the device.

Parameters

Time to be set with format YYYY-MM-DD HH:II:SS.


enableDevice()

Ensure the machine to be at in the normal work condition, generally when data communication shields the machine auxiliary equipment (keyboard, LCD, sensor), this order restores the auxiliary equipment to be at the normal work condition.


disableDevice()

Shield machine periphery keyboard, LCD, sensor, if perform successfully, there are showing โ€œworkingโ€ on LCD.


enableClock()

Set the LCD dot (to glitter โ€˜:โ€™) the packet data part transmit 0 to stop glittering, 1 start to glitter. After this order carries out successfully, the firmware will refresh LCD.


getUser()

Retrive the user list from the device.

Return Value

getUser return array 2 dimension. The key of array is serial number of user. The value of array is array containing:

  • serial number of the user
  • user name
  • user role
  • user password

setUser($uid, $userid, $name, $password, $role)

Write user to the device.

Parameters

$uid

Serial number of the user. This is the unsigned short number (2 bytes).

$userid

User ID of the application. The maximum length of $userid is 8 characters containing numeric whithout zero on the beginning.

$name

User name. The maximum length of $name is 28 characters containing alpha numeic and some (not all) punctuation.

$role

The role of user. The length of $role is 1 byte. Possible value of $role are:

0 = LEVEL_USER
2 = LEVEL_ENROLLER
12 = LEVEL_MANAGER
14 = LEVEL_SUPERMANAGER

setUserTemplate($template)

Upload finger print template to the device. The precondition to successfully upload the fingerprint template which is, the user must exist, the user, whose the fingerprint will be uploaded, must be empty.

Parameter

$template

$template is binary data which the structure is shown bellow:

typedef struct _Template_{ 
    U16 Size;       // the length of fingerprint template 
    U16 PIN;        // corresponds with the user data structure PIN
    char FingerID;  // fingerprint 
    char Valid;     // fingerprint is valid or invalid
    char *Template; // fingerprint template 
} TTemplate, *PTemplate; 

getUserTemplate($uid, $finger)

Get finger print data from the device.

Parametes

$uid

Serial number of the user (2 bytes)

$finger

The finger on which the template will be taken (0-9).

Return Value

getUserTemplate will return an array contains:

  • length of template (2 bytes)
  • serial number of the user (2 bytes)
  • finger (1 byte, 0 to 9)
  • valid (1 byte)
  • template

Template is binary data which the structure is shown bellow:

typedef struct _Template_{ 
    U16 Size;       // the length of fingerprint template 
    U16 PIN;        // corresponds with the user data structure PIN
    char FingerID;  // fingerprint 
    char Valid;     // fingerprint is valid or invalid
    char *Template; // fingerprint template 
} TTemplate, *PTemplate; 

clearData()

Clear some kind of data, if do not assign the data type, then deletes all data, otherwise depending on the assigned type to delete data.


clearUser()

Same with clearData.


deleteUser($uid)

Delete some user from the device.

Parameters

$uid

Serial number of the user (2 bytes).


deleteUserTemp($uid, $finger)

Delete finger template of the user from the device.

Parameters

$uid

Serial number of the user (2 bytes).

$finger

The number of finger (0-9).


clearAdmin()

Delete all admin from the device.


getAttendance()

Retrieve the attendance log.

Return Value

getAttendance return array 2 dimension. The value of array is array containing.

  • serial number of the user
  • user id of the application
  • state
  • time of attendance in format YYYY-MM-DD HH:II:SS

clearAttendance()

Delete all attendance log from the device.

zklibrary's People

Contributors

erlangparasu avatar kamshory avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zklibrary's Issues

Connect function return false

I have my zk-k14 fingerprint device accessible via local network and when i tried to connect using this library i get false connection
things i checked and still getting false connection :-
-the fingerprint device is accessible throw this ip : 192.168.1.201 AND port : 4370.
-i make sure that the device is accessible without any pin code or passwords.
when i try to connect to the device using the official SDK it connect successfully so using wireshark i compared the packet sent from the official sdk with the one using this library and i noticed.
-the packet sent using this library is an empty UDP packet.
-the one sent from the official sdk is a TCP packet with this content

PP.}............PP.}.......vw...PP.}....L.;zw...PP.}......3#w...Ver 6.60 Jun 16 2015.PP.}........w...~OS.PP.}........w...~OS=1.PP.}......L.w...~ExtendFmt.PP.}......Jcw...~ExtendFmt=0.PP.}......N|w...ExtendOPLog.PP.}.......vw...PP.}.......tw...ExtendOPLog.PP.}.......~w...PP.}......W|w...ExtendOPLog.PP.}.......~w...PP.}......V|w...ExtendOPLog.PP.}.......~w...PP.}......U|w...ExtendOPLog.PP.}.......~w...PP.}......8.w.	.~Platform.PP.}.......?w.	.~Platform=JZ4725_TFT.PP.}.......=w.
.~ZKFPVersion.PP.}........w.
.~ZKFPVersion=10.PP.}
...E.`Uw....(PP.}	......vw...	PP.}........w...WorkCode.PP.}........w...WorkCode=1.PP.}
.......w.
.~SSR.PP.}........w.
.~SSR=1.PP.}........w...~PIN2Width.PP.}.......zw...~PIN2Width=9.PP.}........w...FaceFunOn.PP.}.......vw...PP.}........w...~UserExtFmt.PP.}.......Vw...~UserExtFmt=0.PP.}....L.+zw...PP.}......##w...Ver 6.60 Jun 16 2015.PP.}......	=w...~ZKFPVersion.PP.}........w...~ZKFPVersion=10.PP.}........w...~IsOnlyRFMachine.PP.}.......ow...~IsOnlyRFMachine=0.PP.}........w...~OS.PP.}........w...~OS=1.PP.}.......|w.......PP.}.......vw...PP.}......[yw...,...PP.}.......vw...PP.}....2.?~w...PP.}X.......w...........................&.......................................P...............PP.}....2.>~w...PP.}X.......w...........................&.......................................P...............PP.}....2.=~w...PP.}X.......w...........................&.......................................P...............PP.}....2.<~w...PP.}X.......w...........................&.......................................P...............PP.}....2.;~w...PP.}X.......w...........................&.......................................P...............PP.}........w...~UserExtFmt.PP.}.......Vw...~UserExtFmt=0.PP.}.......zw...PP.}.......vw...PP.}......\5w...~SerialNumber.PP.}*.....m.w...~SerialNumber=OEG6060486051400346.PP.}........w...~DeviceName.PP.}.......-w...~DeviceName=K14.

Set user state

Hello!

I want to disable or change his state to invalid for preventing the access to one zone, how can I do this? Is possible with this library? Thanks.

can't connect to DW6(zkteco)

I'm sure the protocol TCP:4370,
but why are all zklib library connected using UDP?

I have to track code (function connect),
socket_recvfrom($this->socket, $this->received_data, 1024, 0, $this->ip, $this->port);
always return empty ,
But use zktime for win can connect

Which ZKTecho model works smoothly with this ZKLibray

Hello @kamshory,

I'm try to use your library with ZKTeco K40 attendance time terminal but it not giving me any response. I use this code,

<?php
include "zklibrary.php";
$zk = new ZKLibrary('192.168.1.102', 4370);
$zk->connect();
$zk->disableDevice();
$zk->testVoice();
$zk->enableDevice();
$zk->disconnect();
?>

Could you please help me that which ZKTecho model works smoothly with this library.

Thanks in advance.

Codeigniter

How to connect this library to codeigniter?

getting face template

Hi there, thanks for this awesome library.

I was wondering if there is any way to get the face template. I've read the communication protocol but it's pretty old (2006).

I'm aware that this library doesn't have this option, but I just want to know if any of you was able to achieve this.

Thank you in advance.

No results are showed

There is no results in when i run the test.php file. There is another thing that I need to do?

getAttendance not get all Att

i used $zk->getAttendance();
but it get 1671 record of +4700

another issuse on date it out wrong date like "2000-01-01 00:00:00"
to fix it in sdk dll lib
new device use function (SSR_GetGeneralLogData) if is (IsTFTMachine)
and old device use function (GetGeneralExtLogData)

connection problem

@kamshory I am unable to connect my biometric device using this library. I am using zkteco K14 . I successfully connect it with desktop app but on web it is not working. Could you please help me out. Do your library support zkteco k14 biometric device?

Could the library support Ronald Jack?

Dear Sir,

Could the library support Ronald Jack? I can connect RJ device with Zkeeper (C# library) but couldn't connect with ZKlibrary.

Could you help!

retrieve att data too slow

I found that when use this library connect through port 4370 to network it really slow. example I ping to device 1ms it spended 10sec when connect to device. if ping to device 20ms more than 200sec to connect.

note: only connection not yet retrieved data from device.

do you have any idea to solve this issue?

I think we could not make device ping 1ms or <1ms all the time.

thanks for your idea.

Best Regards,
NOV Piseth

Blank page

getting blank page when i try to connect . i'm already using desktop software to get attendence but using these codes i'm getting a blank page , my device also has a communication key and a device id . i don't see any function to call that . what shall i do

setUserTemplate($data)

what is $data i have all values like size,pin,finger,id,pin and template ... how to place all these values in $data and in which format ... i have read the documentation but i did't get .. please help me to solve this issue

cannot get data through public ip

I use your's package through call public ip( after that, it redirect to ip of fingerprint machine) but i cannot get anything ( when i connect fingerprint in LAN, i can get everthing), can you help me?

The library can't connect to the device

I have a biometric device (Granding T9 model) that I want to use this library but I connection failed and this is the error :
object(ZKLibrary)#841 (9) { ["ip"]=> string(13) "192.168.1.201" ["port"]=> int(4370) ["socket"]=> resource(193) of type (Socket) ["session_id"]=> int(0) ["received_data"]=> string(0) "" ["user_data"]=> array(0) { } ["attendance_data"]=> array(0) { } ["timeout_sec"]=> int(5) ["timeout_usec"]=> int(5000000) }

This is the code I used
$zk = new ZKLibrary('192.168.1.201');
$zk->connect();
var_dump($zk);

P.S The T9 device don't have webserver builtin feature... is it needed for this library to work?... The previous I worked on which is "Granding gt100" have webserver in it and it worked.

ZKLibrary with Online application

This library works only with localhost. When I host the code with it. It can no longer read the ip address/port or even access data!

Get The Punch State

I always getting Check In as an output for the status and never change even I choose check out in the biometrics.

What is the possible problem?
And how to get the output the following (Check-In, Check-Out, Overtime-In, Overtime-Out) in my page?

It just always display Check In and never change.
The code I use is the following:

<html>
    <head>
        <title>ZK Test</title>
    </head>
    
    <body>
<?php
    include("zklib/zklib.php");
    
    $zk = new ZKLib("192.168.5.150", 4370);
    
    $ret = $zk->connect();
    sleep(1);
    if ( $ret ): 
        $zk->disableDevice();
        sleep(1);
    ?>
        
        <table border="1" cellpadding="5" cellspacing="2">
            <tr>
                <td><b>Status</b></td>
                <td>Connected</td>
                <td><b>Version</b></td>
                <td><?php echo $zk->version() ?></td>
                <td><b>OS Version</b></td>
                <td><?php echo $zk->osversion() ?></td>
                <td><b>Platform</b></td>
                <td><?php echo $zk->platform() ?></td>
            </tr>
            <tr>
                <td><b>Firmware Version</b></td>
                <td><?php echo $zk->fmVersion() ?></td>
                <td><b>WorkCode</b></td>
                <td><?php echo $zk->workCode() ?></td>
                <td><b>SSR</b></td>
                <td><?php echo $zk->ssr() ?></td>
                <td><b>Pin Width</b></td>
                <td><?php echo $zk->pinWidth() ?></td>
            </tr>
            <tr>
                <td><b>Face Function On</b></td>
                <td><?php echo $zk->faceFunctionOn() ?></td>
                <td><b>Serial Number</b></td>
                <td><?php echo $zk->serialNumber() ?></td>
                <td><b>Device Name</b></td>
                <td><?php echo $zk->deviceName(); ?></td>
                <td><b>Get Time</b></td>
                <td><?php echo $zk->getTime() ?></td>
            </tr>
        </table>
        <hr />
        <table border="1" cellpadding="5" cellspacing="2" style="float: left; margin-right: 10px;">
            <tr>
                <th colspan="5">Data User</th>
            </tr>
            <tr>
                <th>UID</th>
                <th>ID</th>
                <th>Name</th>
                <th>Role</th>
                <th>Password</th>
            </tr>
            <?php
            try {
                
               // $zk->setUser(999, '999', 'John Doe', '999', LEVEL_USER);
                $user = $zk->getUser();
                sleep(1);
                while(list($uid, $userdata) = each($user)):
                    if ($userdata[2] == LEVEL_ADMIN)
                        $role = 'ADMIN';
                    elseif ($userdata[2] == LEVEL_USER)
                        $role = 'USER';
                    else
                        $role = 'Unknown';
                ?>
                <tr>
                    <td><?php echo $uid ?></td>
                    <td><?php echo $userdata[0] ?></td>
                    <td><?php echo $userdata[1] ?></td>
                    <td><?php echo $role ?></td>
                    <td><?php echo $userdata[3] ?>&nbsp;</td>
                </tr>
                <?php
                endwhile;
            } catch (Exception $e) {
                header("HTTP/1.0 404 Not Found");
                header('HTTP', true, 500); // 500 internal server error                
            }
            //$zk->clearAdmin();
            ?>
        </table>
        
        <table border="1" cellpadding="5" cellspacing="2">
            <tr>
                <th colspan="6">Data Attendance</th>
            </tr>
            <tr>
                <th>Index</th>
                <th>UID</th>
                <th>ID</th>
                <th>Status</th>
                <th>Date</th>
                <th>Time</th>
            </tr>
            <?php
            $attendance = $zk->getAttendance();
            sleep(1);
            while(list($idx, $attendancedata) = each($attendance)):
                if ( $attendancedata[2] == 14 )
                    $status = 'Check Out';
                else
                    $status = 'Check In';
            ?>
            <tr>
                <td><?php echo $idx ?></td>
                <td><?php echo $attendancedata[0] ?></td>
                <td><?php echo $attendancedata[1] ?></td>
                <td><?php echo $attendancedata[2] ?></td>
               <!-- <td><?php echo $status ?></td>-->
                <td><?php echo date( "d-m-Y", strtotime( $attendancedata[3] ) ) ?></td>
                <td><?php echo date( "H:i:s", strtotime( $attendancedata[3] ) ) ?></td>
            </tr>
            <?php
            endwhile
            ?>
        </table>
        
        <fieldset>
            <legend><b>Example Using: </b></legend>
            
<pre style='color:#000000;background:#ffffff;'><pre>
<span style='color:#5f5035;'>&lt;?php</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>include</span><span style='color:#808030;'>(</span><span style='color:#0000e6;'>"zklib/zklib.php"</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#800000;font-weight:bold; '>new</span><span> ZKLib</span><span style='color:#808030;'>(</span><span style='color:#0000e6;'>"192.168.1.201"</span><span style='color:#808030;'>,</span><span> </span><span style='color:#008c00;'>4370</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$ret</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>connect</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>disableDevice</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>version</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>osversion</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>platform</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>fmVersion</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>workCode</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>ssr</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>pinWidth</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>faceFunctionOn</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>serialNumber</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>deviceName</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$user</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>getUser</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>while</span><span style='color:#808030;'>(</span><span> </span><span style='color:#800000;font-weight:bold; '>list</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$uid</span><span style='color:#808030;'>,</span><span> </span><span style='color:#797997;'>$userdata</span><span style='color:#808030;'>)</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#400000;'>each</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$user</span><span style='color:#808030;'>)</span><span> </span><span style='color:#808030;'>)</span><span> </span><span style='color:#800080;'>{</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>if</span><span> </span><span style='color:#808030;'>(</span><span style='color:#797997;'>$userdata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>2</span><span style='color:#808030;'>]</span><span> </span><span style='color:#808030;'>=</span><span style='color:#808030;'>=</span><span> LEVEL_ADMIN</span><span style='color:#808030;'>)</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$role</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#0000e6;'>'ADMIN'</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>elseif</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$userdata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>2</span><span style='color:#808030;'>]</span><span> </span><span style='color:#808030;'>=</span><span style='color:#808030;'>=</span><span> LEVEL_USER</span><span style='color:#808030;'>)</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$role</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#0000e6;'>'USER'</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>else</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$role</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#0000e6;'>'Unknown'</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'UID: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$uid</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'ID: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$userdata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>0</span><span style='color:#808030;'>]</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Name: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$userdata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>1</span><span style='color:#808030;'>]</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Role: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$role</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Password: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$userdata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>3</span><span style='color:#808030;'>]</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800080;'>}</span><span></span>
<span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$attendance</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>getAttendance</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>while</span><span style='color:#808030;'>(</span><span> </span><span style='color:#800000;font-weight:bold; '>list</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$idx</span><span style='color:#808030;'>,</span><span> </span><span style='color:#797997;'>$attendancedata</span><span style='color:#808030;'>)</span><span> </span><span style='color:#808030;'>=</span><span> </span><span style='color:#400000;'>each</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$attendance</span><span style='color:#808030;'>)</span><span> </span><span style='color:#808030;'>)</span><span> </span><span style='color:#800080;'>{</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Index: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$idx</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'ID: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$attendancedata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>0</span><span style='color:#808030;'>]</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Status: '</span><span style='color:#808030;'>.</span><span style='color:#797997;'>$attendancedata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>1</span><span style='color:#808030;'>]</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Date: '</span><span style='color:#808030;'>.</span><span style='color:#400000;'>date</span><span style='color:#808030;'>(</span><span style='color:#0000e6;'>"d-m-Y"</span><span style='color:#808030;'>,</span><span> </span><span style='color:#400000;'>strtotime</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$attendancedata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>2</span><span style='color:#808030;'>]</span><span style='color:#808030;'>)</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800000;font-weight:bold; '>echo</span><span> </span><span style='color:#0000e6;'>'Time: '</span><span style='color:#808030;'>.</span><span style='color:#400000;'>date</span><span style='color:#808030;'>(</span><span style='color:#0000e6;'>"H:i:s"</span><span style='color:#808030;'>,</span><span> </span><span style='color:#400000;'>strtotime</span><span style='color:#808030;'>(</span><span style='color:#797997;'>$attendancedata</span><span style='color:#808030;'>[</span><span style='color:#008c00;'>2</span><span style='color:#808030;'>]</span><span style='color:#808030;'>)</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#800080;'>}</span><span></span>
<span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>getTime</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>enableDevice</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style='color:#797997;'>$zk</span><span style='color:#808030;'>-</span><span style='color:#808030;'>></span><span>disconnect</span><span style='color:#808030;'>(</span><span style='color:#808030;'>)</span><span style='color:#800080;'>;</span><span></span>
<span style='color:#5f5035;'>?></span>
</pre>
        
        </fieldset>
    <?php
       /* $zk->enrollUser('123');
        $zk->setUser(123, '123', 'Shubhamoy Chakrabarty', '', LEVEL_USER);
        $zk->enableDevice();
        sleep(1);
        $zk->disconnect();*/
    endif
?>
    </body>
</html>

I cannot connect to ZKTeco Iface 950

the test.php page goes blank and nothing shows as if there is an error in creating the object //$zk = new ZKLibrary('192.168.1.202', 4370);
P.S. I changed the IP to the correct IP

Get Big Amount of Attendance Data

We have a very big amount of data which take much time, some time connection has timeout, but I want to get the data of a specific date or limit data per request. How it would be possible. Please guide me to solve this issue. Thank you so much.

Return an empty Array No result

I tried a lot but i have always get an empty array and an empty table i have a zkteco mb160 and i get all data from the software they provide with the device but this library return an empty array can someone solve my issue
array (size=0)
empty

getSizeAttendance Not working

I have data in many machine but getSizeAttendance not working and i have try to many different way and your given way but its not working data are coming empty. So please guide me how can i get data from my EL-Dorado machine.

not able to use this library on 32-bit windows

Hi thr,
this is my first post in Github, I may not know 'post' culture here.
so plz let me know if I missed anything..

first thing first: thank you very much for this library.
Issue:
I am not able to use zklibrary in 32-bit windows, though i m using it on 64-bit window n its working properly.

thanks in advance

Disabling method before PHP processing

Hello! Thank you very much for so helpful library!
I have a question connecting with methods calling. I get the attendances and user data for variables. Can I enable and disconnect the device after this and then make the PHP array processing? For example, I have this code now:

       //connection here
        $data = $zk->getAttendance();
	$users = $zk->getUser();

	foreach($data as $key=>$value){
                 //processing        
         }

        $zk->enableDevice();
	$zk->disconnect();

I want to do like this:

        //connection here
        $data = $zk->getAttendance();
	$users = $zk->getUser();
        $zk->enableDevice();
	$zk->disconnect();

	foreach($data as $key=>$value){
                 //processing        
         }

Is it real? I would test this idea, but I work with frequently used gadget and don't want to interrupt its process :)

Attendance state not working

Attendance state always give one(1). Another issue is the clearAttendance() method not working. Device Version is ZK 10.

Attendance data format

@kamshory I have the array of all attendances.My array structure is like this.
[0] => 1
[1] => 1
[2] => 8 //it is state.What does this means for???
[3] => 2016-12-27 11:51:33

And one more thing that I have all the attendances of users,Please guide me that how I differentiate the check in and check out of user.

Add user card while setting user

Hello,

I would like to know if it is possible to add user with card number?
Function setUser takes $uid, $userid, $name, $password, $role) parameters, so is there any solution to add $cardNumber parameter?.

Add/Update functionality

Dear @kamshory first all thank you very much for guidance.Dear @kamshory is it possible to add/update the attendance of any user.Means If I want to add the attendance for userABC or want to update the attendance of userXYZ. Please guide.

Get image of a user

@kamshory , first of all I am very thankful to you for being there for guidelines.Dear @kamshory I want to get the image of a user from my bio metric device.Please guide me regarding this.

Sending Data to library

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

attendance

how get getAttendance()

getAttendance()
Retrieve the attendance log.

Return Value

getAttendance return array 2 dimension. The value of array is array containing.

serial number of the user
user id of the application
state
time of attendance in format YYYY-MM-DD HH:II:SS

update 2017

getting attendance data

untitled
my device is connected i can get user data and attendance data but problem is i am not able to get attendance of last whole month its like if i am accessing getattendance() it returns data from last months 31st uptill now while i want it to get all the data.

Very Long Time Getting Data From Device

I used this library but it was very long time to get data from device (60-90 seconds), I think all many resource in web services would be taken, so All Aplication in same web services waiting for getting data finish.

Could you give me solution ? Thanks u very much

how it works $zk ->getUserTemplate()

hi, could you explain how it works, for example:

Uid = 2, Finger_id = 0

$template = $zk -> getUserTemplate(2, 0);

No Works,

Thks in advanced.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.