Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- declare(strict_types=1);
- include '../../vendor/autoload.php';
- // Init Cache System
- use Phpfastcache\CacheManager;
- use Phpfastcache\Config\ConfigurationOption;
- // Setup File Path on your config files
- // Please note that as of the V6.1 the "path" config
- // can also be used for Unix sockets (Redis, Memcache, etc)
- CacheManager::setDefaultConfig(new ConfigurationOption([
- 'path' => '/cache', // or in windows "C:/tmp/"
- ]));
- // In your class, function, you can call the Cache
- $cache = CacheManager::getInstance('files');
- class User
- {
- /**
- * Variables
- */
- public $UserID = -1;
- public $Login = "false";
- public $UserName = "undefined";
- public $UserUUID = "undefined";
- public $UserPassword = "undefined";
- public $Group;
- public $Info = array();
- /**
- * Constructor
- */
- public function __construct(string $username, string $password = "")
- {
- $client = new MongoDB\Client("mongodb://localhost:27017");
- $collection = $client->VaroxWeb->users;
- $user = $collection->findOne(['Name' => $username]);
- $this->UserName = $user['Name'];
- $this->UserUUID = $user['UUID'];
- $this->UserPassword = $user['Password'];
- if (password_verify($password, $this->UserPassword)) {
- $this->Login = "true";
- } else {
- $this->Login = "false";
- }
- $CachedString = $cache->getItem($this->UserUUID);
- if (!$CachedString->isHit($this->UserUUID)) {
- $CachedString->set($user)->expiresAfter(60);
- $cache->save($CachedString);
- }
- foreach ($CachedString->get() as $k => $v) {
- $this->Info += array($k => $v);
- }
- if (isset($this->Info['group'])) {
- // $this->Group = new Group(intval($this->Info['rank']));
- } else {
- // $this->Group = Group::getGroupByName(Group::$DEFAULT_GROUP);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement