dnaextrim / php_zklib

Attendance Machine Library for PHP with a connection to the network using the UDP protocol and port 4370
http://dnaextrim.github.io/php_zklib/
GNU General Public License v2.0
162 stars 135 forks source link

Showing a maximum of 256 users #7

Open smaaroufi opened 9 years ago

smaaroufi commented 9 years ago

Hi, Thank you for this amazing library, great work ;) I tested it and it works almost very fine, however there's a bug, i have 431 users on my zk attendance machine, but the script shows only 256 users. Is there any advice to fix this ? Thanks

MostafaNaguib commented 9 years ago

this might be because of the request time out i haven't tested the lib yet, i'm just assuming that ------------- ^^ this have nothing to do with the request time has to do with the code in zklib/zkuser.php it does loop over the whole users, but then doesn't get all of em

anyways what you could do is change the way array loop on them here

$users[$uid] = array($userid, $name, intval( $role ), $password);

to

$users[$userid] = array($userid, $name, intval( $role ), $password);

or even an empty [] which will do the same

dnaextrim commented 9 years ago

sorry I could not develop this library again because I already resigned from where I work and I do not have attendance machine to develop this library

MostafaNaguib commented 9 years ago

Thank you very much @dnaextrim you already made wonderful work with the lib, and whenever any question will come up i'll try helping as much as i can ;)

dnaextrim commented 9 years ago

Thanks @MostafaNaguib

omarouhari commented 8 years ago

Hello @MostafaNaguib I use python_zklib and I got several limitations :

  1. The last attendance can't be downloaded.
  2. Can't set cardnumber of a user.
  3. Can't set a user with uid > 255. I realy need your help. Thanks to help me to fixe this issues. Regards.
kamshory commented 8 years ago

file zkuser.php To read user, replace $uid = hexdec( substr($u[1], 0, 4) ).' '; with $u1 = hexdec( substr($u[1], 2, 2) ); $u2 = hexdec( substr($u[1], 4, 2) ); $uid = $u1+($u2*256);

To write user, replace $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); with $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, 28, chr(0)).str_pad(chr(1), 9, chr(0)).str_pad($userid, 8, chr(0)).str_repeat(chr(0),16);

file zkattendance.php To read log, replace $uid = hexdec( substr( $u[1], 0, 6 ) ); $uid = explode(chr(0), $uid); $uid = intval( $uid[0] ); with $u1 = hexdec( substr($u[1], 4, 2) ); $u2 = hexdec( substr($u[1], 6, 2) ); $uid = $u1+($u2*256);

dannwolf commented 8 years ago

hello i can´t see the information of the device, What can i do?

ipdigital commented 6 years ago

@kamshory hello I use your solution but still cannot add more than 256 users to the device, or read the attendances of them. And from user 256 and on the role is set to administrator instead of user.

kamshory commented 6 years ago

You can try this one https://github.com/kamshory/ZKLibrary