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
194 stars 176 forks source link

getAttendance not get all Att #16

Open MrAhmedSayedAli opened 6 years ago

MrAhmedSayedAli commented 6 years ago

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)

kamshory commented 6 years ago

My best practice is clear all attendance log after move it into the database. For invalid date, you can fix it at

$timestamp = $this->decodeTime(hexdec($this->reverseHex(substr($u[1], 58, 8)))); 
li-on commented 6 years ago

One of my machine (very old - ver 6.40-09 Jan 26 2010) returning att data in 16 bytes instead of 40 and with different header length. So i had to change code:

                $attendance_data = substr($attendance_data, 12);
                while(strlen($attendance_data) > 16) 
                {
                    $u = unpack('H30', substr($attendance_data, 0, 15));
                    $u1 = hexdec(substr($u[1], 0, 2));
                    $u2 = hexdec(substr($u[1], 2, 2));
                    $id = $u1+($u2*256);
                    $state = hexdec(substr( $u[1], 18, 2 ) );
                    $timestamp = $this->decodeTime(hexdec($this->reverseHex(substr($u[1], 8, 8)))); 
                    array_push($attendance, array(0, $id, $state, $timestamp));
                    $attendance_data = substr($attendance_data, 16 );
                }
kamshory commented 6 years ago

@li-on Thank you brother.