date.chapril.org-framadate/app/classes/Framadate/Security/Token.php

35 lines
597 B
PHP
Raw Normal View History

2015-01-09 09:22:31 +01:00
<?php
namespace Framadate\Security;
class Token {
private $time;
private $value;
2015-01-10 16:35:21 +01:00
function __construct() {
$this->time = time() + TOKEN_TIME;
$this->value = $this->generate();
2015-01-09 09:22:31 +01:00
}
private function generate() {
2015-01-10 16:35:21 +01:00
return sha1(uniqid(mt_rand(), true));
}
public function getTime() {
return $this->time;
}
public function getValue() {
return $this->value;
}
public function isGone() {
return $this->time < time();
}
public function check($value) {
return $value === $this->value;
2015-01-09 09:22:31 +01:00
}
}