Last active
February 27, 2022 16:37
-
-
Save aice09/d6082544dd1064dfd0bae06b15dbd337 to your computer and use it in GitHub Desktop.
How to Sync User Data From Biometrics A to B,C, and others | vodvud/php_zklib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('zklib/ZKLib.php'); | |
$users = []; | |
//Main device | |
$zk = new ZKLib('192.168.1.100'); | |
$ret = $zk->connect(); | |
if ($ret) { | |
$zk->disableDevice(); | |
//Get users | |
$users = $zk->getUser(); | |
$zk->enableDevice(); | |
} | |
$zk->disconnect(); | |
if (count($users) > 0) { | |
//Sync devices list | |
$devices = [ | |
'192.168.1.101', | |
'192.168.1.102', | |
'192.168.1.103', | |
'192.168.1.104', | |
'192.168.1.105' | |
]; | |
foreach ($devices as $ip) { | |
$zk = new ZKLib($ip); | |
$ret = $zk->connect(); | |
if ($ret) { | |
$zk->disableDevice(); | |
//Remove old users | |
$zk->clearUsers(); | |
foreach ($users as $user) { | |
//Add user | |
$zk->setUser( | |
$user['uid'], | |
$user['userid'], | |
$user['name'], | |
$user['password'], | |
$user['role'] | |
); | |
} | |
$zk->enableDevice(); | |
} | |
$zk->disconnect(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In order to execute your code properly I adjust the Resources Limit in my php.ini.
I adjust the max_execution_time=30 to max_execution_time=120 .
And the max_input_time=30 to max_input_time=240.
So I get the same data from biometrics A.