public function __construct($file) { parent::__construct(); $this->id = Guid::create(); $this->filename = basename($file); $this->path = dirname($file); if (is_file($file)) { $this->type = mime_content_type($file); $this->bytes = filesize($file); } }
public static function get($id, $defaultValue = null) { if (static::exists($id)) { $value = $_SESSION[$id]; if (trim($value) !== '') { $value = Guid::decrypt(static::getSecret(), $value); $data = explode('|', $value); if (is_array($data) && trim(end($data)) === static::getSecret()) { return unserialize($data[0]); } } } return $defaultValue; }
public function invalidateToken() { $this->api_token = Guid::create(); $this->update(); }
public static function getTicket() { if (Cookie::exists(static::COOKIE_NAME) === false) { return null; } $ticket = Guid::decrypt(static::getSalt(), Cookie::get(static::COOKIE_NAME)); if ($ticket !== false) { $ticket = explode('|', $ticket); return count($ticket) > 0 ? $ticket : null; } return null; }
exit(0); break; case 'password:create': $argv = array_slice($argv, 2); if (!isset($argv[0])) { die('Error: missing required parameter [input password]'); } echo sprintf('New password: %s', password_hash($argv[0], PASSWORD_DEFAULT)) . chr(10); echo chr(10); exit(0); break; case 'password:reset': $argv = array_slice($argv, 2); if (!isset($argv[0])) { die('Error: missing required parameter [user id]'); } $user = \Pecee\Model\ModelUser::findOrfail($argv[0]); if ($user === null) { echo sprintf('User with id %s not found', $argv[0]) . chr(10); } else { $password = \Pecee\Guid::createRandomPassword(8); $user->setPassword($password); $user->save(); echo sprintf('Password changed for %s to: %s', $user->username, $password) . chr(10); } echo chr(10); exit(0); break; } echo 'No input specified'; exit(1);
public static function getNextClosure() { self::$closureCount++; $basis = self::$closureCount . Guid::create(); return "closure" . md5($basis); }