ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ProxyConnectableCondition.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
3 /* Copyright (c) 2020 Daniel Weise <daniel.weise@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 use ILIAS\Setup;
7 
9 {
10  public function __construct($config)
11  {
12  return parent::__construct(
13  "Can establish a connection to proxy",
14  function (Setup\Environment $env) use ($config) : bool {
15  try {
16  $host = $config->getProxyHost();
17  if (strspn($host, '.0123456789') != strlen($host) && strstr($host, '/') === false) {
18  $host = gethostbyname($host);
19  }
20  $port = $config->getProxyPort() % 65536;
21 
22  if (!fsockopen($host, $port, $errno, $errstr, 10)) {
23  throw new Exception("Can`t establish connection to proxy.");
24  }
25  } catch (\Exception $e) {
26  return false;
27  }
28 
29  return true;
30  },
31  "Can`t establish connection to proxy."
32  );
33  }
34 }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
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:11
__construct(Container $dic, ilPlugin $plugin)
A condition that can&#39;t be met by ILIAS itself needs to be met by some external means.