Add ZK library classes for device interaction and user management
- Implemented Os class for retrieving OS information. - Added Pin class for getting PIN width. - Created Platform class for fetching platform details and version. - Developed SerialNumber class to retrieve device serial number. - Introduced Ssr class for SSR information retrieval. - Implemented Time class for setting and getting device time. - Added User class for user management including setting, getting, clearing, and removing users. - Created Util class with various utility functions for command handling and data processing. - Implemented Version class for fetching device version. - Added WorkCode class for retrieving work code information. - Set up Composer autoloading for the ZK library.
This commit is contained in:
43
zklib/src/Time.php
Normal file
43
zklib/src/Time.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace ZK;
|
||||
|
||||
use ZKLib;
|
||||
|
||||
class Time
|
||||
{
|
||||
/**
|
||||
* @param ZKLib $self
|
||||
* @param string $t Format: "Y-m-d H:i:s"
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function set(ZKLib $self, $t)
|
||||
{
|
||||
$self->_section = __METHOD__;
|
||||
|
||||
$command = Util::CMD_SET_TIME;
|
||||
$command_string = pack('I', Util::encodeTime($t));
|
||||
|
||||
return $self->_command($command, $command_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ZKLib $self
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function get(ZKLib $self)
|
||||
{
|
||||
$self->_section = __METHOD__;
|
||||
|
||||
$command = Util::CMD_GET_TIME;
|
||||
$command_string = '';
|
||||
|
||||
$ret = $self->_command($command, $command_string);
|
||||
|
||||
if ($ret) {
|
||||
return Util::decodeTime(hexdec(Util::reverseHex(bin2hex($ret))));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user