Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.94 KB | None | 0 0
  1. <?php
  2. declare(strict_types=1);
  3. include '../../vendor/autoload.php';
  4. // Init Cache System
  5. use Phpfastcache\CacheManager;
  6. use Phpfastcache\Config\ConfigurationOption;
  7.  
  8. // Setup File Path on your config files
  9. // Please note that as of the V6.1 the "path" config
  10. // can also be used for Unix sockets (Redis, Memcache, etc)
  11. CacheManager::setDefaultConfig(new ConfigurationOption([
  12.     'path' => '/cache', // or in windows "C:/tmp/"
  13. ]));
  14.  
  15. // In your class, function, you can call the Cache
  16. $cache = CacheManager::getInstance('files');
  17. class User
  18. {
  19.     /**
  20.      * Variables
  21.      */
  22.     public $UserID = -1;
  23.     public $Login = "false";
  24.     public $UserName = "undefined";
  25.     public $UserUUID = "undefined";
  26.     public $UserPassword = "undefined";
  27.     public $Group;
  28.     public $Info = array();
  29.  
  30.     /**
  31.      * Constructor
  32.      */
  33.     public function __construct(string $username, string $password = "")
  34.     {
  35.         $client = new MongoDB\Client("mongodb://localhost:27017");
  36.         $collection = $client->VaroxWeb->users;
  37.         $user = $collection->findOne(['Name' => $username]);
  38.  
  39.         $this->UserName = $user['Name'];
  40.         $this->UserUUID = $user['UUID'];
  41.         $this->UserPassword = $user['Password'];
  42.  
  43.         if (password_verify($password, $this->UserPassword)) {
  44.             $this->Login = "true";
  45.         } else {
  46.             $this->Login = "false";
  47.         }
  48.  
  49.         $CachedString = $cache->getItem($this->UserUUID);
  50.         if (!$CachedString->isHit($this->UserUUID)) {
  51.             $CachedString->set($user)->expiresAfter(60);
  52.             $cache->save($CachedString);
  53.         }
  54.  
  55.         foreach ($CachedString->get() as $k => $v) {
  56.             $this->Info += array($k => $v);
  57.         }
  58.  
  59.         if (isset($this->Info['group'])) {
  60.         //    $this->Group = new Group(intval($this->Info['rank']));
  61.         } else {
  62.         //    $this->Group = Group::getGroupByName(Group::$DEFAULT_GROUP);
  63.         }
  64.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement