27 protected static string $SALT =
'';
30 protected string $ip =
'';
34 protected string $id =
'';
50 $session_id = session_id();
52 if (isset(
$_SERVER[
'REMOTE_ADDR'])) {
55 $this->
setTimestamp($timestamp !== 0 ? $timestamp : time());
66 $token = implode(
'-', array(
73 $token = sha1($token);
80 if (self::getSALT() !==
'' && self::getSALT() !==
'0') {
84 if (is_file(self::SALT_FILE_PATH)) {
86 require self::SALT_FILE_PATH;
90 if (strcmp($salt,
'') === 0) {
102 if (is_file(self::SALT_FILE_PATH)) {
103 unlink(self::SALT_FILE_PATH);
105 $template = file_get_contents(
'./Services/WebAccessChecker/wacsalt.php.template');
106 $random = new \ilRandom();
107 $salt = md5(time() * $random->int(1000, 9999) . self::SALT_FILE_PATH);
108 self::setSALT($salt);
109 $template = str_replace(
'INSERT_SALT', $salt, $template);
110 if (is_writable(dirname(self::SALT_FILE_PATH))) {
111 file_put_contents(self::SALT_FILE_PATH, $template);
148 public function setIp(
string $ip): void
186 return md5($this->
id);
190 public function setId(
string $id): void
202 public static function setSALT(
string $salt): void
setRawToken(string $raw_token)
static setSALT(string $salt)
setSessionId(string $session_id)
setTimestamp(int $timestamp)
__construct(string $path, string $client, int $timestamp=0, int $ttl=0)
ilWACToken constructor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const DATA_DIR_NON_WRITEABLE
setClient(string $client)
static getTokenMaxLifetimeInSeconds()