|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* ***************************************************************************** |
|
5
|
|
|
* Contributions to this work were made on behalf of the GÉANT project, a |
|
6
|
|
|
* project that has received funding from the European Union’s Framework |
|
7
|
|
|
* Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus), |
|
8
|
|
|
* Horizon 2020 research and innovation programme under Grant Agreements No. |
|
9
|
|
|
* 691567 (GN4-1) and No. 731122 (GN4-2). |
|
10
|
|
|
* On behalf of the aforementioned projects, GEANT Association is the sole owner |
|
11
|
|
|
* of the copyright in all material which was developed by a member of the GÉANT |
|
12
|
|
|
* project. GÉANT Vereniging (Association) is registered with the Chamber of |
|
13
|
|
|
* Commerce in Amsterdam with registration number 40535155 and operates in the |
|
14
|
|
|
* UK as a branch of GÉANT Vereniging. |
|
15
|
|
|
* |
|
16
|
|
|
* Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. |
|
17
|
|
|
* UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK |
|
18
|
|
|
* |
|
19
|
|
|
* License: see the web/copyright.inc.php file in the file structure or |
|
20
|
|
|
* <base_url>/copyright.php after deploying the software |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* This file executes AJAX searches from diagnostics page. |
|
25
|
|
|
* |
|
26
|
|
|
* |
|
27
|
|
|
* @author Maja Gorecka-Wolniewicz <[email protected]> |
|
28
|
|
|
* |
|
29
|
|
|
* @package Developer |
|
30
|
|
|
*/ |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* |
|
34
|
|
|
* @param string $nonce the nonce that was sent to the page and is to be verified |
|
35
|
|
|
* @param string $optSalt an optional salt value |
|
36
|
|
|
* @return boolean |
|
37
|
|
|
*/ |
|
38
|
|
|
|
|
39
|
|
|
require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php"; |
|
40
|
|
|
|
|
41
|
|
|
// we are referring to $_SESSION later in the file |
|
42
|
|
|
CAT_session_start(); |
|
43
|
|
|
|
|
44
|
|
|
$loggerInstance = new \core\common\Logging(); |
|
45
|
|
|
$returnArray = []; |
|
46
|
|
|
|
|
47
|
|
|
$languageInstance = new \core\common\Language(); |
|
48
|
|
|
$languageInstance->setTextDomain("web_user"); |
|
49
|
|
|
$cat = new \core\CAT(); |
|
50
|
|
|
$realmByUser = filter_input(INPUT_GET, 'realm', FILTER_SANITIZE_STRING); |
|
51
|
|
|
$realmQueryType = filter_input(INPUT_GET, 'type', FILTER_SANITIZE_STRING); |
|
52
|
|
|
$realmCountry = filter_input(INPUT_GET, 'co', FILTER_SANITIZE_STRING); |
|
53
|
|
|
$realmOu = filter_input(INPUT_GET, 'ou', FILTER_SANITIZE_STRING); |
|
54
|
|
|
if (!empty($realmByUser)) { |
|
55
|
|
|
/* select the record matching the realm */ |
|
56
|
|
|
$details = $cat->getExternalDBEntityDetails(0, $realmByUser); |
|
57
|
|
|
if (!empty($details)) { |
|
58
|
|
|
$admins = array(); |
|
59
|
|
|
if (!empty($details['admins'])) { |
|
60
|
|
|
foreach ($details['admins'] as $admin) { |
|
61
|
|
|
$admins[] = $admin['email']; |
|
62
|
|
|
} |
|
63
|
|
|
$details['admins'] = base64_encode(join(',', $admins)); |
|
64
|
|
|
} else { |
|
65
|
|
|
$details['admins'] = ''; |
|
66
|
|
|
} |
|
67
|
|
|
$details['status'] = 1; |
|
68
|
|
|
$returnArray = $details; |
|
69
|
|
|
} |
|
70
|
|
|
} else { |
|
71
|
|
|
if ($realmQueryType) { |
|
72
|
|
|
switch ($realmQueryType) { |
|
73
|
|
|
case "co": |
|
74
|
|
|
/* select countries list */ |
|
75
|
|
|
$details = $cat->getExternalCountriesList(); |
|
76
|
|
|
if (!empty($details)) { |
|
77
|
|
|
$returnArray['status'] = 1; |
|
78
|
|
|
$returnArray['time'] = $details['time']; |
|
79
|
|
|
unset($details['time']); |
|
80
|
|
|
$returnArray['countries'] = $details; |
|
81
|
|
|
} |
|
82
|
|
|
break; |
|
83
|
|
|
case "inst": |
|
84
|
|
|
if ($realmCountry) { |
|
85
|
|
|
$fed = new \core\Federation(strtoupper($realmCountry)); |
|
86
|
|
|
$details = $fed->listExternalEntities(FALSE, \core\Federation::EDUROAM_DB_TYPE_IDP); |
|
87
|
|
|
if (!empty($details)) { |
|
88
|
|
|
$returnArray['status'] = 1; |
|
89
|
|
|
$returnArray['institutions'] = $details; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
break; |
|
93
|
|
|
case "realm": |
|
94
|
|
|
if ($realmOu) { |
|
95
|
|
|
$details = $cat->getExternalDBEntityDetails($realmOu); |
|
96
|
|
|
if (!empty($details)) { |
|
97
|
|
|
$returnArray['status'] = 1; |
|
98
|
|
|
$returnArray['realms'] = explode(',', $details['realmlist']); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
break; |
|
102
|
|
|
case "hotspot": |
|
103
|
|
|
if ($realmCountry) { |
|
104
|
|
|
$fed = new \core\Federation(strtoupper($realmCountry)); |
|
105
|
|
|
$details = $fed->listExternalEntities(FALSE, \core\Federation::EDUROAM_DB_TYPE_SP); |
|
106
|
|
|
if (!empty($details)) { |
|
107
|
|
|
$returnArray['status'] = 1; |
|
108
|
|
|
$returnArray['hotspots'] = $details; |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
break; |
|
112
|
|
|
default: |
|
113
|
|
|
throw new Exception("Unknown realmQueryType"); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
if (empty($returnArray)) { |
|
118
|
|
|
$returnArray['status'] = 0; |
|
119
|
|
|
} |
|
120
|
|
|
$loggerInstance->debug(2, $returnArray); |
|
121
|
|
|
|
|
122
|
|
|
echo(json_encode($returnArray)); |
|
123
|
|
|
|
|
124
|
|
|
|