1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
set_include_path( |
4
|
|
|
'/var/www/html' . PATH_SEPARATOR . |
5
|
|
|
'/var/www/html/vendor/pear/pear-core-minimal/src' . PATH_SEPARATOR . |
6
|
|
|
'/var/www/html/vendor/pear/pear_exception' . PATH_SEPARATOR . |
7
|
|
|
'/var/www/html/vendor/pear/log' . PATH_SEPARATOR . |
8
|
|
|
'/var/www/html/vendor/pear/db' . PATH_SEPARATOR . |
9
|
|
|
'/var/www/html/vendor/pear/net_ldap2' . PATH_SEPARATOR . |
10
|
|
|
'/var/www/html/vendor/cilogon/service-lib/src/Service' . PATH_SEPARATOR . |
11
|
|
|
'.' |
12
|
|
|
); |
13
|
|
|
|
14
|
|
|
require_once 'config.php'; |
15
|
|
|
include_once 'config.secrets.php'; |
16
|
|
|
require_once 'DBService.php'; |
17
|
|
|
require_once 'Util.php'; |
18
|
|
|
require_once 'IdpList.php'; |
19
|
|
|
|
20
|
|
|
use CILogon\Service\IdpList; |
21
|
|
|
|
22
|
|
|
if ($argc >= 2) { |
23
|
|
|
$regbyincommon = null; |
24
|
|
|
$incommonrands = null; |
25
|
|
|
$refedsrands = null; |
26
|
|
|
$sirtfi = null; |
27
|
|
|
$rands = null; |
28
|
|
|
$bronze = null; |
29
|
|
|
$silver = null; |
30
|
|
|
|
31
|
|
|
// Scan command line for attributes to match |
32
|
|
|
for ($v = 1; $v < $argc; $v++) { |
33
|
|
|
$param = strtolower($argv[$v]); |
34
|
|
|
if (preg_match('/^registeredbyincommon=?([01]?)$/', $param, $matches)) { |
35
|
|
|
if ((isset($matches[1])) && ($matches[1] == '0')) { |
36
|
|
|
$regbyincommon = 0; |
37
|
|
|
} else { |
38
|
|
|
$regbyincommon = 1; |
39
|
|
|
} |
40
|
|
|
} elseif (preg_match('/^incommonrands=?([01]?)$/', $param, $matches)) { |
41
|
|
|
if ((isset($matches[1])) && ($matches[1] == '0')) { |
42
|
|
|
$incommonrands = 0; |
43
|
|
|
} else { |
44
|
|
|
$incommonrands = 1; |
45
|
|
|
} |
46
|
|
|
} elseif (preg_match('/^refedsrands=?([01]?)$/', $param, $matches)) { |
47
|
|
|
if ((isset($matches[1])) && ($matches[1] == '0')) { |
48
|
|
|
$refedsrands = 0; |
49
|
|
|
} else { |
50
|
|
|
$refedsrands = 1; |
51
|
|
|
} |
52
|
|
|
} elseif (preg_match('/^sirtfi=?([01]?)$/', $param, $matches)) { |
53
|
|
|
if ((isset($matches[1])) && ($matches[1] == '0')) { |
54
|
|
|
$sirtfi = 0; |
55
|
|
|
} else { |
56
|
|
|
$sirtfi = 1; |
57
|
|
|
} |
58
|
|
|
} elseif (preg_match('/^rands=?([01]?)$/', $param, $matches)) { |
59
|
|
|
if ((isset($matches[1])) && ($matches[1] == '0')) { |
60
|
|
|
$rands = 0; |
61
|
|
|
} else { |
62
|
|
|
$rands = 1; |
63
|
|
|
} |
64
|
|
|
} elseif (preg_match('/^bronze=?([01]?)$/', $param, $matches)) { |
65
|
|
|
if ((isset($matches[1])) && ($matches[1] == '0')) { |
66
|
|
|
$bronze = 0; |
67
|
|
|
} else { |
68
|
|
|
$bronze = 1; |
69
|
|
|
} |
70
|
|
|
} elseif (preg_match('/^silver=?([01]?)$/', $param, $matches)) { |
71
|
|
|
if ((isset($matches[1])) && ($matches[1] == '0')) { |
72
|
|
|
$silver = 0; |
73
|
|
|
} else { |
74
|
|
|
$silver = 1; |
75
|
|
|
} |
76
|
|
|
} else { |
77
|
|
|
echo "ERROR: Unknown query attribute '$param'.\n"; |
78
|
|
|
exit; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
$idplist = new IdpList(); |
83
|
|
|
$allidps = $idplist->getEntityIDs(); |
84
|
|
|
$idps = array(); |
85
|
|
|
|
86
|
|
|
// Loop through all IdPs and try to match command line parameters |
87
|
|
|
foreach ($allidps as $idp) { |
88
|
|
|
if (!is_null($regbyincommon)) { |
89
|
|
|
$param = $idplist->isRegisteredByInCommon($idp); |
90
|
|
|
if ($regbyincommon xor $param) { |
91
|
|
|
continue; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
if (!is_null($incommonrands)) { |
95
|
|
|
$param = $idplist->isInCommonRandS($idp); |
96
|
|
|
if ($incommonrands xor $param) { |
97
|
|
|
continue; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
if (!is_null($refedsrands)) { |
101
|
|
|
$param = $idplist->isREFEDSRandS($idp); |
102
|
|
|
if ($refedsrands xor $param) { |
103
|
|
|
continue; |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
if (!is_null($sirtfi)) { |
107
|
|
|
$param = $idplist->isSIRTFI($idp); |
108
|
|
|
if ($sirtfi xor $param) { |
109
|
|
|
continue; |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
if (!is_null($rands)) { |
113
|
|
|
$param = $idplist->isRandS($idp); |
114
|
|
|
if ($rands xor $param) { |
115
|
|
|
continue; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
if (!is_null($bronze)) { |
119
|
|
|
$param = $idplist->isBronze($idp); |
120
|
|
|
if ($bronze xor $param) { |
121
|
|
|
continue; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
if (!is_null($silver)) { |
125
|
|
|
$param = $idplist->isSilver($idp); |
126
|
|
|
if ($silver xor $param) { |
127
|
|
|
continue; |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
// If we made it this far, add the idp to the list of matched idps. |
131
|
|
|
$idps[] = $idp; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
foreach ($idps as $idp) { |
135
|
|
|
echo $idp . "\t" . $idplist->getOrganizationName($idp) . "\n"; |
136
|
|
|
} |
137
|
|
|
echo count($idps) . " IdPs found matching these conditions.\n"; |
138
|
|
|
} else { |
139
|
|
|
printUsage(); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
function printUsage() |
|
|
|
|
143
|
|
|
{ |
144
|
|
|
echo "Usage: php idpquery.php <RegisteredByInCommon=0|1> <InCommonRandS=0|1>\n"; |
145
|
|
|
echo " <REFEDSRandS=0|1> <SIRTFI=0|1> <RandS=0|1>\n"; |
146
|
|
|
echo " <Bronze=0|1> <Silver=0|1>\n\n"; |
147
|
|
|
echo "This script allows you to query the idplist.xml file for IdPs with attributes\n"; |
148
|
|
|
echo "that satisfy a certain set of conditions. The conditions you specify can be\n"; |
149
|
|
|
echo "either 'must have' (=1) or 'must not have' (=0). These are joined together\n"; |
150
|
|
|
echo "with a logical 'AND'. For example, to get a list of all eduGAIN IdPs that\n"; |
151
|
|
|
echo "are SIRTFI but not REFEDSRandS:\n"; |
152
|
|
|
echo " php idpquery.php RegisteredByInCommon=0 SIRTFI=1 REFEDSRandS=0\n"; |
153
|
|
|
echo "The attributes are case-insensitive. If you neglect to specify =0 or =1,\n"; |
154
|
|
|
echo "=1 is assumed (i.e., 'RandS' is equivalent to 'RandS=1').\n"; |
155
|
|
|
} |
156
|
|
|
|
This check looks for functions that have already been defined in other files.
Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the
@ignore
annotation.See also the PhpDoc documentation for @ignore.