19 declare(strict_types=1);
32 return hash(
'sha256', self::class);
37 return "Ensures 'session_max_idle' is set properly";
47 $http_config = $environment->getConfigFor(
'http');
60 $client_ini = $environment->getResource(
Setup\Environment::RESOURCE_CLIENT_INI);
62 $ini = $environment->getResource(
Setup\Environment::RESOURCE_ILIAS_INI);
64 $io = $environment->getResource(
Setup\Environment::RESOURCE_ADMIN_INTERACTION);
65 $factory = $environment->getResource(
Setup\Environment::RESOURCE_SETTINGS_FACTORY);
67 $settings = $factory->settingsFor(
'common');
69 $session_max_idle = $this->config->getSessionMaxIdle();
71 $url =
$ini->readVariable(
'server',
'http_path');
72 $filename = uniqid((
string) mt_rand(),
true) .
'.php';
74 $token = bin2hex(random_bytes(32));
81 $result = $curl->exec();
87 "An error occurred while trying to determine the values for 'session.cookie_lifetime' and" . PHP_EOL .
88 "'session.gc_maxlifetime' in your php.ini: {$e->getMessage()}" . PHP_EOL .
89 'You can IGNORE the the error if you are sure these settings comply with our expection to' . PHP_EOL .
90 'ensure a proper session handling.' 93 $client_ini->setVariable(
'session',
'expire', (
string) $session_max_idle);
98 unlink(
"public/$filename");
101 if ($result ===
'') {
103 "ILIAS could not determine the value for 'session.cookie_lifetime' and 'session.gc_maxlifetime'" . PHP_EOL .
104 'in your php.ini to check whether it complies with our expection to ensure a proper session handling.' . PHP_EOL .
105 'Do you like to continue, anyway?';
107 if (!$io->confirmOrDeny(
$message)) {
108 throw new Setup\NoConfirmationException(
$message);
112 [$cookie_lifetime, $gc_maxlifetime] = explode(
'&', $result);
114 if ($cookie_lifetime != 0) {
116 "The value 'session.cookie_lifetime' in your php.ini does not correspond" . PHP_EOL .
117 "to the value '0' recommended by ILIAS. Do you want to continue anyway?";
119 if (!$io->confirmOrDeny(
$message)) {
120 throw new Setup\NoConfirmationException(
$message);
124 if ($gc_maxlifetime <= $session_max_idle) {
126 "The value 'session.gc_maxlifetime' in your php.ini is smaller or equal than" . PHP_EOL .
127 "'session_max_idle' in your ILIAS-Config. ILIAS recommends a bigger value." . PHP_EOL .
128 'Do you want to continue anyway?';
130 if (!$io->confirmOrDeny(
$message)) {
131 throw new Setup\NoConfirmationException(
$message);
135 $client_ini->setVariable(
'session',
'expire', (
string) $session_max_idle);
142 $factory = $environment->getResource(
Setup\Environment::RESOURCE_SETTINGS_FACTORY);
144 $settings = $factory->settingsFor(
'common');
146 $ini = $environment->getResource(
Setup\Environment::RESOURCE_ILIAS_INI);
148 $io = $environment->getResource(
Setup\Environment::RESOURCE_ADMIN_INTERACTION);
150 $url =
$ini->readVariable(
'server',
'http_path');
157 $result = $curl->getInfo(CURLINFO_HTTP_CODE);
158 if ($result !== 200) {
183 if (!isset(\
$_GET[
'token'])) {
187 if (\
$_GET[
'token'] !==
"$token") {
191 \$scl = ini_get(
'session.cookie_lifetime');
192 \$smlt = ini_get(
'session.gc_maxlifetime');
194 echo \$scl .
"&" . \$smlt;
197 file_put_contents(
"public/$filename", $content);
206 $url .=
'?token=' .
$token;
214 $curl->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
215 $curl->setOpt(CURLOPT_SSL_VERIFYHOST, 0);
216 $curl->setOpt(CURLOPT_RETURNTRANSFER, 1);
217 $curl->setOpt(CURLOPT_FOLLOWLOCATION, 1);
218 $curl->setOpt(CURLOPT_MAXREDIRS, 1);
228 set_error_handler(
static function (
int $severity,
string $message,
string $file,
int $line): never {
229 throw new ErrorException($message, $severity, $severity, $file, $line);
233 $url .=
'?token=' .
$token;
237 return file_get_contents($url);
239 restore_error_handler();
247 "ilSessionMaxIdleIsSetObjective:\n" .
248 "Cannot establish proper connection to webserver.\n" .
249 "In the event of an installation the value for session expire\n" .
250 "will be the default value.\n" .
251 "In the event of an update, the current value for session expire\n" .
getPHPIniValuesByFileGetContents(string $url, ?string $token=null)
getCurlConnection(ilSetting $settings, string $url, ?string $token=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getPreconditions(Setup\Environment $environment)
static _isCurlExtensionLoaded()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
__construct(protected Setup\Config $config)
infoNoConnection(Setup\CLI\IOWrapper $io)
A configuration for the setup.
generateServerInfoFile(string $filename, string $token)