ILIAS  release_8 Revision v8.24
ProxyConnectableCondition.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
7
8/******************************************************************************
9 *
10 * This file is part of ILIAS, a powerful learning management system.
11 *
12 * ILIAS is licensed with the GPL-3.0, you should have received a copy
13 * of said license along with the source code.
14 *
15 * If this is not the case or you just want to try ILIAS, you'll find
16 * us at:
17 * https://www.ilias.de
18 * https://github.com/ILIAS-eLearning
19 *
20 *****************************************************************************/
22{
23 public function __construct($config)
24 {
26 "Can establish a connection to proxy",
27 function (Setup\Environment $env) use ($config): bool {
28 try {
29 $host = $config->getProxyHost();
30 if (strspn($host, '.0123456789') != strlen($host) && strstr($host, '/') === false) {
31 $host = gethostbyname($host);
32 }
33 $port = $config->getProxyPort() % 65536;
34
35 if (!fsockopen($host, $port, $errno, $errstr, 10)) {
36 throw new Exception("Can`t establish connection to proxy.");
37 }
38 } catch (\Exception $e) {
39 return false;
40 }
41
42 return true;
43 },
44 "Can`t establish connection to proxy."
45 );
46 }
47}
A condition that can't be met by ILIAS itself needs to be met by some external means.
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...