@@ -13,9 +13,10 @@ class User
1313 * @param string $name (max length = 24)
1414 * @param int|string $password (max length = 8, only numbers - depends device setting)
1515 * @param int $role Default Util::LEVEL_USER
16+ * @param int $cardno Default 0 (max length = 10, only numbers)
1617 * @return bool|mixed
1718 */
18- public function set (ZKLib $ self , $ uid , $ userid , $ name , $ password , $ role = Util::LEVEL_USER )
19+ public function set (ZKLib $ self , $ uid , $ userid , $ name , $ password , $ role = Util::LEVEL_USER , $ cardno = 0 )
1920 {
2021 $ self ->_section = __METHOD__ ;
2122
@@ -24,20 +25,24 @@ public function set(ZKLib $self, $uid, $userid, $name, $password, $role = Util::
2425 (int )$ uid > Util::USHRT_MAX ||
2526 strlen ($ userid ) > 9 ||
2627 strlen ($ name ) > 24 ||
27- strlen ($ password ) > 8
28+ strlen ($ password ) > 8 ||
29+ strlen ($ cardno ) > 10
2830 ) {
2931 return false ;
3032 }
3133
3234 $ command = Util::CMD_SET_USER ;
3335 $ byte1 = chr ((int )($ uid % 256 ));
3436 $ byte2 = chr ((int )($ uid >> 8 ));
37+ $ cardno = hex2bin (Util::reverseHex (dechex ($ cardno )));
38+
3539 $ command_string = implode ('' , [
3640 $ byte1 ,
3741 $ byte2 ,
3842 chr ($ role ),
3943 str_pad ($ password , 8 , chr (0 )),
40- str_pad ($ name , 28 , chr (0 )),
44+ str_pad ($ name , 24 , chr (0 )),
45+ str_pad ($ cardno , 4 , chr (0 )),
4146 str_pad (chr (1 ), 9 , chr (0 )),
4247 str_pad ($ userid , 9 , chr (0 )),
4348 str_repeat (chr (0 ), 15 )
0 commit comments