ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ProxyChain.php
Go to the documentation of this file.
1<?php
2
43{
44 protected $chain = array();
45
58 public function __construct(array $chain)
59 {
60 // Ensure that we have an indexed array
61 $this->chain = array_values($chain);
62 }
63
71 public function matches(array $list)
72 {
73 $list = array_values($list); // Ensure that we have an indexed array
74 if ($this->isSizeValid($list)) {
75 $mismatch = false;
76 foreach ($this->chain as $i => $search) {
77 $proxy_url = $list[$i];
78 if (preg_match('/^\/.*\/[ixASUXu]*$/s', $search)) {
79 if (preg_match($search, $proxy_url)) {
81 "Found regexp " . $search . " matching " . $proxy_url
82 );
83 } else {
85 "No regexp match " . $search . " != " . $proxy_url
86 );
87 $mismatch = true;
88 break;
89 }
90 } else {
91 if (strncasecmp($search, $proxy_url, strlen($search)) == 0) {
93 "Found string " . $search . " matching " . $proxy_url
94 );
95 } else {
97 "No match " . $search . " != " . $proxy_url
98 );
99 $mismatch = true;
100 break;
101 }
102 }
103 }
104 if (!$mismatch) {
105 phpCAS::trace("Proxy chain matches");
106 return true;
107 }
108 } else {
109 phpCAS::trace("Proxy chain skipped: size mismatch");
110 }
111 return false;
112 }
113
121 protected function isSizeValid(array $list)
122 {
123 return (sizeof($this->chain) == sizeof($list));
124 }
125}
An exception for terminatinating execution or to throw for unit testing.
A normal proxy-chain definition that lists each level of the chain as either a string or regular expr...
Definition: ProxyChain.php:43
isSizeValid(array $list)
Validate the size of the the list as compared to our chain.
Definition: ProxyChain.php:121
matches(array $list)
Match a list of proxies.
Definition: ProxyChain.php:71
__construct(array $chain)
A chain is an array of strings or regexp strings that will be matched against.
Definition: ProxyChain.php:58
static trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:599
An interface for classes that define a list of allowed proxies in front of the current application.
Definition: Interface.php:42
$i
Definition: metadata.php:24