date.chapril.org-framadate/app/classes/Framadate/Security/Token.php
2015-01-10 16:35:21 +01:00

35 lines
597 B
PHP

<?php
namespace Framadate\Security;
class Token {
private $time;
private $value;
function __construct() {
$this->time = time() + TOKEN_TIME;
$this->value = $this->generate();
}
private function generate() {
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;
}
}