• Stars
    star
    197
  • Rank 197,722 (Top 4 %)
  • Language
    PHP
  • License
    GNU General Publi...
  • Created over 8 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

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.

More Repositories

1

ISO8583-JSON-XML

This library is used to convert messages from one format to another. The supported formats are ISO 8583, JSON, and XML
Java
34
star
2

BMKG

Library to get weather forecast and earthquake data history from BMKG
PHP
26
star
3

PlanetbiruPhotoEditor

Planetbiru Photo Editor is a web-based photo editor using HTML5 Canvas and JavaScript
JavaScript
15
star
4

MIDICreator

MIDI Creator is a web-based application that can convert sound into MIDI, both sound from files and sound from a microphone directly. MIDI Creator periodically samples the sound, analyzes the frequency, then creates a MIDI notation according to the frequency, volume and duration for that note.
JavaScript
15
star
5

OTP-Pi

OTP-Pi is a server for sending SMS via HTTP, WebSocket and Message Broker protocols. Users can install OTP-Pi on the server with a static IP address that can be accessed by clients who will send SMS. In addition, users can also install OTP-Pi on servers with dynamic IP addresses. This server then accesses a websocket server, a Redis server, an MQTT server or a RabbitMQ server. OTP-Pi acts as a consumer that will send all SMS it receives.
Java
13
star
6

Al-Quran

Al Quran adalah aplikasi Al Quran berbasis web dengan bahasa pemrograman PHP dan database MariaDB.
PHP
13
star
7

MusicPlayer

Music player using HTML5 Canvas and Audio
PHP
5
star
8

ESP32DrumPad

ESP32DrumPad
C++
4
star
9

OTP-Broker

OTP Broker adalah server untuk mengirimkan SMS melalui protokol HTTP, WebSocket dan Message Broker. Pengguna dapat memasang OTP Broker pada server dengan IP address statis yang diapat diakses oleh klien yang akan mengirimkan SMS. Selain itu, pengguna juga dapat memasang OTP Broker pada server dengan IP address dinamis. Server ini kemudian mengakses sebuah server websocket atau server RabbitMQ. OTP Broker bertindak sebagai consumer yang akan mengirimkan semua SMS yang diterimanya.
HTML
4
star
10

MusicProductionManager

Music Production Manager
JavaScript
3
star
11

ISO-8583-Parser-and-Builder-With-TLV

ISO 8583 parser and builder with Tag Length Value (TLV)
Java
3
star
12

Number64

number64 is script to encode and decode decimal to 64-based number. The 64-based number represented by 0-9, A-Z, a-z, -, and _. 64-based number is used to shortening decimal number i.e to generate QR code.
JavaScript
3
star
13

OTP-Mini

OTP Broker using ESP32 and SIM800l
C++
3
star
14

PlanetbiruCompareDB

PlanetbiruCompareDB is tool to compare 2 database
Hack
3
star
15

PHPMusicXML

Create and convert MusicXML with PHP
HTML
3
star
16

ISO8583Parser

ISO 8583 Message Parser using JavaScript
JavaScript
3
star
17

ParseSQL

This library parse multiple query of MySQLDump output file. ParseSQL designed to parse multiple query and ready to be executed using mysql_query. This library is usefull to create database structure or restore database from sql file.
PHP
3
star
18

Koperasi-Simpan-Pinjam-Syariah

PlanetCoops Syariah adalah aplikasi koperasi simpan pinjam syariah berbasis web yang dapat dijalankan di hampir semua browser modern.
3
star
19

PlanetbiruFileManager

Planetbiru File Manager is a web-based file manager using the PHP language that can be integrated with a variety of programs for managing files on the server. Planetbiru File Manager has a lot of very useful functions to create a new file, upload, edit, delete, move, rename, compress, extract, and so on. You can also drag and drop files from local storage to file area to upload them.
JavaScript
3
star
20

Universal-REST-Simulator

Universal REST Simulator is a universal simulator for REST APIs. This simulator can be configured by adding some configuration files into the config directory. Universal REST Simulator can read all files with the extension .
JavaScript
3
star
21

AudioToImage

This program will create image of audio file.
PHP
2
star
22

TreeView

TreeView list using only CSS
HTML
2
star
23

ISO8583-JSON-JavaScript

Building and parsing ISO8583 on JavaScript
JavaScript
2
star
24

Lyric-Editor

JavaScript
2
star
25

KSP-Syariah-Planetbiru

JavaScript
2
star
26

JavaAudioRecorder

Web-Based Java Audio Recorder for Raspberry Pi 3 Model B
Java
2
star
27

OpenCartTranslator

OpenCartTranslator is program to translate OpenCart Language Package from any language to another language. This program does not require any database server.
PHP
2
star
28

Oflline-CentOS-Server-Raspberry-Pi-4

CentOS 7.7 Minimal Installation as Offline Standalone Server on Raspberry Pi 4
2
star
29

PHPMessageBroker

Simple message brocker using native PHP
PHP
2
star
30

WebRTC-WebSocket-Chat

JavaScript
2
star
31

PHPPushClient

This program must be run with a console and cannot be accessed with a browser. This program will run in the background continuously. If the connection is lost, the program will try to establish a new connection.
PHP
2
star
32

RTCRaspberryPi3BCentOS7

C
2
star
33

VocalToMusic

Convert vocal to MIDI and MusicXML
JavaScript
2
star
34

DynamicForm

HTML
2
star
35

PushNotificationClient

Push Notification is a notification that is forcibly sent by the server to the client so that the notification sent to the client without waiting for the client to request it. In order for the notification to be accepted by the client, the client and server must always be connected through socket communication.
HTML
2
star
36

PHPProxyServer

PHP Proxy Server
PHP
2
star
37

ISO8583

PHP
1
star
38

PlanetEncryption

PlanetEncryption is library to encrypt your data.
PHP
1
star
39

WSMessageBrocker

PHP message broker using WebSocket
PHP
1
star
40

PHPDBASE

PHPDBASE is library to read and write data to DBASE File incase it is not available on your website hosting.
PHP
1
star
41

WSClient

PHP
1
star
42

JavaMessageBroker

1
star
43

Old-Nokia-Ringtone

HTML
1
star
44

FeedingTime

HTML
1
star
45

Feeding-Time

HTML
1
star
46

Smart-Switch

C++
1
star
47

Base64-Image-On-Paste

Create base64 encoded image URL on Paste
HTML
1
star
48

WSClientESP32

C++
1
star
49

otp-esp32

OTP Broker with ESP-32
C
1
star
50

PasteRTF

This script will paste data from clipboard containing image, HTML or plain text.
HTML
1
star
51

jQueryUNAND

HTML
1
star
52

PushNotificationSender

Push notification sender
PHP
1
star
53

LanguageDirection

HTML
1
star
54

CSSAnimationWave

CSS Animation
HTML
1
star
55

Analog-Clock

JavaScript
1
star
56

Access-Point-Raspberry-Pi

1
star
57

OTP-Publisher

OTP-Publisher
PHP
1
star
58

PlanetEdu

This is test question creator for Planet Edu
HTML
1
star
59

CSSAnimationPressure

CSS Animation
HTML
1
star
60

ESP32WebServer

C++
1
star
61

DigitalCompass

HTML
1
star
62

PlanetbiruContextMenu

PlanetbiruContextMenu
PHP
1
star
63

Wave-Recording-Simulator

JavaScript
1
star
64

Tag-and-Mention-Editor

This editor is useful to create text containing hashtag and mention user.
PHP
1
star
65

MyBBTranslator

MyBBTranslator is program to translate MyBB Language Package from any language to another language. This program does not require any database server.
PHP
1
star
66

AndroidGame

Java
1
star
67

ObjectStringify

Java
1
star
68

PlanetbiruCaptureImage

PlanetbiruCaptureImage is JavaScript library to capture image from camera using HTML5.
JavaScript
1
star
69

EBIPPMessageSpecification

1
star
70

InstallCentos7OnRaspberryPi3

1
star
71

ScriptGenerator

This program generate JSP script automaticaly. The script containing controller and UI (HTML element)
JavaScript
1
star
72

PushNotificationServer

Push notification server
Java
1
star
73

MusicXML

PHP
1
star
74

PseudoClassStyle

Sometime yo need to change pseudo class ::before and ::after dynamicaly from script but it is not simple way to do it. Now you can use this script to change pseudo class ::before and ::after style using jQuery. It is work in Firefox 50.
HTML
1
star
75

InstallApacheAndMariaDBOnRaspberryPi3

1
star