Guest User

Untitled

a guest
Nov 23rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2. /**
  3. * Generate uuids for clients and admins that don't have uuids set.
  4. *
  5. * The WHMCS 7.4.1 update process automatically inserts uuids, but if your
  6. * installation bypasses WHMCS update routines then this will generate uuids for
  7. * the client and admin users that don't have one yet.
  8. *
  9. * Warning! Please back up at least your tblclient and tbladmin tables before
  10. * running this!
  11. */
  12.  
  13. use Ramsey\Uuid\Uuid;
  14. use WHMCS\User\Admin;
  15. use WHMCS\User\Client;
  16.  
  17. require_once dirname(__FILE__)."/../init.php";
  18.  
  19. // Look for client and admin users with empty uuids.
  20. $clients = Client::where('uuid', '')->get();
  21. $admins = Admin::where('uuid', '')->get();
  22.  
  23. var_dump('Found ' . $clients->count() . ' client(s) with no uuid.');
  24. var_dump('Found ' . $admins->count() . ' admin(s) with no uuid.');
  25.  
  26. // Generate uuids for clients.
  27. $clients->each(function (Client $client) {
  28. $client->uuid = Uuid::uuid4();
  29. $client->save();
  30. var_dump('Generated uuid ' . $client->uuid . ' for client id ' . $client->id);
  31. });
  32.  
  33. // Generate uuids for admins.
  34. $admins->each(function (Admin $admin) {
  35. $admin->uuid = Uuid::uuid4();
  36. $admin->save();
  37. var_dump('Generated uuid ' . $admin->uuid . ' for admin id ' . $admin->id);
  38. });
Add Comment
Please, Sign In to add comment