Skip to content

Instantly share code, notes, and snippets.

@aice09
Last active February 27, 2022 16:37
Show Gist options
  • Save aice09/d6082544dd1064dfd0bae06b15dbd337 to your computer and use it in GitHub Desktop.
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
<?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();
}
}
@aice09
Copy link
Author

aice09 commented Feb 27, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment