diff --git a/plugins/cas_auth_unl/migration.php b/plugins/cas_auth_unl/migration.php index ab9b8ae390ab298c9f7c6e395b5db44da8461128..541e58b21ad748463650a01aa8b13c1748b26946 100644 --- a/plugins/cas_auth_unl/migration.php +++ b/plugins/cas_auth_unl/migration.php @@ -6,11 +6,17 @@ require_once __DIR__ . '/../../elgg/vendor/autoload.php'; $lock_file = __DIR__ . '/migration.lock'; $lock = @file_get_contents($lock_file); + +$lock_data = json_decode($lock, true); + if (!$lock) { - $lock = 0; + $lock_data = array( + 'last_guid' => 0, + 'icontime' => 0 + ); } -if (!$users = @file_get_contents('http://planetred.unl.edu/sync.php?start='.$lock)) { +if (!$users = @file_get_contents('https://planetred.unl.edu/sync.php?start='.$lock_data['last_guid'] . '&icontime='.$lock_data['icontime'])) { echo 'FAILED TO CONNECT' . PHP_EOL; exit(); } @@ -86,5 +92,10 @@ foreach ($users as $source_user) { $target_user->icontime = time(); //Update the lock file - file_put_contents($lock_file, $source_user['guid']); + $lock_data = array( + 'last_guid' => $source_user['guid'], + 'icontime' => time() + ); + + file_put_contents($lock_file, json_encode($lock_data)); }