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

setUser function not working. #2

Open bryant24 opened 10 years ago

bryant24 commented 10 years ago

function zksetuser($self, $uid, $userid, $name, $password, $role) { $command = CMD_SET_USER; $command_string = pack('sxs8s28ss7sx8s16s', chr( $uid ), chr($role), $password, $name, $chr(1), '', $userid, '' ); ...... }


A parameter $chr(1) in the pack function,,I thought it's a little mistake, and this function is not working when update/add the user's information,the variable $command_string always return false,but when I use python_zklib,everything goes all right,so,please give me a help,thx!

dnaextrim commented 10 years ago

Sorry for the long wait, for a problem I have to fix this bug, you can download and try it again, I forgot to turn on the "pack SetUser" to the version of PHP, so "pack" still in versions of Python.

Thanks for this bug report.

kamshory commented 8 years ago

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);

ipdigital commented 7 years ago

Is there a way to set the RFID of the card, related to this user? Above the 25th character of $name, it gets the card id, but it converts it to another number! Has anyone solved this?