ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ProxyConnectableCondition.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 use ILIAS\Setup;
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 }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
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.
Definition: Environment.php:27
__construct(Container $dic, ilPlugin $plugin)
A condition that can&#39;t be met by ILIAS itself needs to be met by some external means.