ILIAS  release_7 Revision v7.30-3-g800a261c036
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
7
9{
10 public function __construct($config)
11 {
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}
An exception for terminatinating execution or to throw for unit testing.
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:12
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...